OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 #include "ui/gl/gl_surface_format.h" | 6 #include "ui/gl/gl_surface_format.h" |
7 | 7 |
8 namespace gl { | 8 namespace gl { |
9 | 9 |
10 TEST(GLSurfaceFormatTest, BasicTest) { | 10 TEST(GLSurfaceFormatTest, BasicTest) { |
11 { | 11 { |
12 // Check default format properties. | 12 // Check default format properties. |
13 GLSurfaceFormat format = GLSurfaceFormat(); | 13 GLSurfaceFormat format = GLSurfaceFormat(); |
14 EXPECT_TRUE(format.IsDefault()); | |
15 EXPECT_EQ(32, format.GetBufferSize()); | 14 EXPECT_EQ(32, format.GetBufferSize()); |
16 EXPECT_FALSE(format.IsSurfaceless()); | |
17 EXPECT_EQ(GLSurfaceFormat::PIXEL_LAYOUT_DONT_CARE, | 15 EXPECT_EQ(GLSurfaceFormat::PIXEL_LAYOUT_DONT_CARE, |
18 format.GetPixelLayout()); | 16 format.GetPixelLayout()); |
19 } | 17 } |
20 | 18 |
21 { | 19 { |
22 // Check rgb565 format as used for low-end Android devices. | 20 // Check rgb565 format as used for low-end Android devices. |
23 GLSurfaceFormat format = GLSurfaceFormat(); | 21 GLSurfaceFormat format = GLSurfaceFormat(); |
24 format.SetRGB565(); | 22 format.SetRGB565(); |
25 EXPECT_FALSE(format.IsDefault()); | |
26 EXPECT_EQ(16, format.GetBufferSize()); | 23 EXPECT_EQ(16, format.GetBufferSize()); |
27 } | 24 } |
28 | 25 |
29 { | 26 { |
30 // Check surfaceless format. | |
31 GLSurfaceFormat format = GLSurfaceFormat(); | |
32 format.SetIsSurfaceless(); | |
33 EXPECT_FALSE(format.IsDefault()); | |
34 EXPECT_TRUE(format.IsSurfaceless()); | |
35 } | |
36 | |
37 { | |
38 // Check custom pixel layout. | 27 // Check custom pixel layout. |
39 GLSurfaceFormat format = GLSurfaceFormat( | 28 GLSurfaceFormat format = GLSurfaceFormat( |
40 GLSurfaceFormat::PIXEL_LAYOUT_RGBA); | 29 GLSurfaceFormat::PIXEL_LAYOUT_RGBA); |
41 EXPECT_FALSE(format.IsDefault()); | |
42 EXPECT_EQ(GLSurfaceFormat::PIXEL_LAYOUT_RGBA, | 30 EXPECT_EQ(GLSurfaceFormat::PIXEL_LAYOUT_RGBA, |
43 format.GetPixelLayout()); | 31 format.GetPixelLayout()); |
44 | 32 |
45 // The custom pixel layout should remain after other modifications. | 33 // The custom pixel layout should remain after other modifications. |
46 format.SetDepthBits(24); | 34 format.SetDepthBits(24); |
47 EXPECT_EQ(GLSurfaceFormat::PIXEL_LAYOUT_RGBA, | 35 EXPECT_EQ(GLSurfaceFormat::PIXEL_LAYOUT_RGBA, |
48 format.GetPixelLayout()); | 36 format.GetPixelLayout()); |
49 EXPECT_EQ(24, format.GetDepthBits()); | 37 EXPECT_EQ(24, format.GetDepthBits()); |
50 } | 38 } |
51 | 39 |
52 { | 40 { |
53 // Check IsCompatible | 41 // Check IsCompatible |
54 GLSurfaceFormat format = GLSurfaceFormat(); | 42 GLSurfaceFormat format = GLSurfaceFormat(); |
55 EXPECT_TRUE(format.IsCompatible(GLSurfaceFormat())); | 43 EXPECT_TRUE(format.IsCompatible(GLSurfaceFormat())); |
56 | 44 |
57 GLSurfaceFormat other = GLSurfaceFormat(); | 45 GLSurfaceFormat other = GLSurfaceFormat(); |
58 other.SetRGB565(); | 46 other.SetRGB565(); |
59 EXPECT_FALSE(format.IsCompatible(other)); | 47 EXPECT_FALSE(format.IsCompatible(other)); |
60 EXPECT_TRUE(other.IsCompatible(other)); | 48 EXPECT_TRUE(other.IsCompatible(other)); |
61 } | 49 } |
62 } | 50 } |
63 | 51 |
64 } | 52 } |
OLD | NEW |