~ubuntu-branches/ubuntu/vivid/mir/vivid

« back to all changes in this revision

Viewing changes to tests/unit-tests/graphics/test_pixel_format_utils.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2014-02-04 14:49:07 UTC
  • mto: This revision was merged to the branch mainline in revision 61.
  • Revision ID: package-import@ubuntu.com-20140204144907-o3ruhix0ey26lchl
Tags: upstream-0.1.4+14.04.20140204
Import upstream version 0.1.4+14.04.20140204

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2014 Canonical Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU General Public License version 3,
 
6
 * as published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com>
 
17
 */
 
18
 
 
19
#include "mir_toolkit/common.h"
 
20
#include "mir/graphics/pixel_format_utils.h"
 
21
#include <gmock/gmock.h>
 
22
#include <gtest/gtest.h>
 
23
 
 
24
using namespace mir::graphics;
 
25
TEST(MirPixelFormatUtils, contains_alpha)
 
26
{
 
27
    EXPECT_FALSE(contains_alpha(mir_pixel_format_xbgr_8888));
 
28
    EXPECT_FALSE(contains_alpha(mir_pixel_format_bgr_888));
 
29
    EXPECT_FALSE(contains_alpha(mir_pixel_format_xrgb_8888));
 
30
    EXPECT_FALSE(contains_alpha(mir_pixel_format_xbgr_8888));
 
31
    EXPECT_TRUE(contains_alpha(mir_pixel_format_argb_8888));
 
32
    EXPECT_TRUE(contains_alpha(mir_pixel_format_abgr_8888));
 
33
    EXPECT_FALSE(contains_alpha(mir_pixel_format_invalid));
 
34
    EXPECT_FALSE(contains_alpha(mir_pixel_formats));
 
35
}
 
36
 
 
37
TEST(MirPixelFormatUtils, red_channel_depths)
 
38
{
 
39
    EXPECT_EQ(8, red_channel_depth(mir_pixel_format_xbgr_8888));
 
40
    EXPECT_EQ(8, red_channel_depth(mir_pixel_format_bgr_888));
 
41
    EXPECT_EQ(8, red_channel_depth(mir_pixel_format_xrgb_8888));
 
42
    EXPECT_EQ(8, red_channel_depth(mir_pixel_format_xbgr_8888));
 
43
    EXPECT_EQ(8, red_channel_depth(mir_pixel_format_argb_8888));
 
44
    EXPECT_EQ(8, red_channel_depth(mir_pixel_format_abgr_8888));
 
45
    EXPECT_EQ(0, red_channel_depth(mir_pixel_format_invalid));
 
46
    EXPECT_EQ(0, red_channel_depth(mir_pixel_formats));
 
47
}
 
48
 
 
49
TEST(MirPixelFormatUtils, blue_channel_depths)
 
50
{
 
51
    EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_xbgr_8888));
 
52
    EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_bgr_888));
 
53
    EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_xrgb_8888));
 
54
    EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_xbgr_8888));
 
55
    EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_argb_8888));
 
56
    EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_abgr_8888));
 
57
    EXPECT_EQ(0, blue_channel_depth(mir_pixel_format_invalid));
 
58
    EXPECT_EQ(0, blue_channel_depth(mir_pixel_formats));
 
59
}
 
60
 
 
61
TEST(MirPixelFormatUtils, green_channel_depths)
 
62
{
 
63
    EXPECT_EQ(8, green_channel_depth(mir_pixel_format_xbgr_8888));
 
64
    EXPECT_EQ(8, green_channel_depth(mir_pixel_format_bgr_888));
 
65
    EXPECT_EQ(8, green_channel_depth(mir_pixel_format_xrgb_8888));
 
66
    EXPECT_EQ(8, green_channel_depth(mir_pixel_format_xbgr_8888));
 
67
    EXPECT_EQ(8, green_channel_depth(mir_pixel_format_argb_8888));
 
68
    EXPECT_EQ(8, green_channel_depth(mir_pixel_format_abgr_8888));
 
69
    EXPECT_EQ(0, green_channel_depth(mir_pixel_format_invalid));
 
70
    EXPECT_EQ(0, green_channel_depth(mir_pixel_formats));
 
71
}
 
72
 
 
73
 
 
74
TEST(MirPixelFormatUtils, alpha_channel_depths)
 
75
{
 
76
    EXPECT_EQ(0, alpha_channel_depth(mir_pixel_format_xbgr_8888));
 
77
    EXPECT_EQ(0, alpha_channel_depth(mir_pixel_format_bgr_888));
 
78
    EXPECT_EQ(0, alpha_channel_depth(mir_pixel_format_xrgb_8888));
 
79
    EXPECT_EQ(0, alpha_channel_depth(mir_pixel_format_xbgr_8888));
 
80
    EXPECT_EQ(8, alpha_channel_depth(mir_pixel_format_argb_8888));
 
81
    EXPECT_EQ(8, alpha_channel_depth(mir_pixel_format_abgr_8888));
 
82
    EXPECT_EQ(0, alpha_channel_depth(mir_pixel_format_invalid));
 
83
    EXPECT_EQ(0, alpha_channel_depth(mir_pixel_formats));
 
84
}
 
85
 
 
86
TEST(MirPixelFormatUtils, valid_mir_pixel_format)
 
87
{
 
88
    EXPECT_TRUE(valid_pixel_format(mir_pixel_format_xbgr_8888));
 
89
    EXPECT_TRUE(valid_pixel_format(mir_pixel_format_bgr_888));
 
90
    EXPECT_TRUE(valid_pixel_format(mir_pixel_format_xrgb_8888));
 
91
    EXPECT_TRUE(valid_pixel_format(mir_pixel_format_xbgr_8888));
 
92
    EXPECT_TRUE(valid_pixel_format(mir_pixel_format_argb_8888));
 
93
    EXPECT_TRUE(valid_pixel_format(mir_pixel_format_abgr_8888));
 
94
    EXPECT_FALSE(valid_pixel_format(mir_pixel_format_invalid));
 
95
    EXPECT_FALSE(valid_pixel_format(mir_pixel_formats));
 
96
}