OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_egl.h" | 6 #include "ui/gl/gl_surface_egl.h" |
7 | 7 |
8 namespace { | 8 namespace { |
9 | 9 |
10 TEST(EGLInitializationDisplaysTest, DisableD3D11) { | 10 TEST(EGLInitializationDisplaysTest, DisableD3D11) { |
11 std::unique_ptr<base::CommandLine> command_line( | 11 std::unique_ptr<base::CommandLine> command_line( |
12 new base::CommandLine(base::CommandLine::NO_PROGRAM)); | 12 new base::CommandLine(base::CommandLine::NO_PROGRAM)); |
13 | 13 |
14 std::vector<gfx::DisplayType> displays; | 14 std::vector<gl::DisplayType> displays; |
15 | 15 |
16 // using --disable-d3d11 with the default --use-angle should never return | 16 // using --disable-d3d11 with the default --use-angle should never return |
17 // D3D11. | 17 // D3D11. |
18 command_line->AppendSwitch(switches::kDisableD3D11); | 18 command_line->AppendSwitch(switches::kDisableD3D11); |
19 GetEGLInitDisplays(true, true, command_line.get(), &displays); | 19 GetEGLInitDisplays(true, true, command_line.get(), &displays); |
20 EXPECT_EQ(std::find(displays.begin(), displays.end(), gfx::ANGLE_D3D11), | 20 EXPECT_EQ(std::find(displays.begin(), displays.end(), gl::ANGLE_D3D11), |
21 displays.end()); | 21 displays.end()); |
22 | 22 |
23 // Specifically requesting D3D11 should always return it if the extension is | 23 // Specifically requesting D3D11 should always return it if the extension is |
24 // available | 24 // available |
25 command_line->AppendSwitchASCII(switches::kUseANGLE, | 25 command_line->AppendSwitchASCII(switches::kUseANGLE, |
26 gfx::kANGLEImplementationD3D11Name); | 26 gl::kANGLEImplementationD3D11Name); |
27 displays.clear(); | 27 displays.clear(); |
28 GetEGLInitDisplays(true, true, command_line.get(), &displays); | 28 GetEGLInitDisplays(true, true, command_line.get(), &displays); |
29 EXPECT_NE(std::find(displays.begin(), displays.end(), gfx::ANGLE_D3D11), | 29 EXPECT_NE(std::find(displays.begin(), displays.end(), gl::ANGLE_D3D11), |
30 displays.end()); | 30 displays.end()); |
31 EXPECT_EQ(displays.size(), 1u); | 31 EXPECT_EQ(displays.size(), 1u); |
32 | 32 |
33 // Specifically requesting D3D11 should not return D3D11 if the extension is | 33 // Specifically requesting D3D11 should not return D3D11 if the extension is |
34 // not available | 34 // not available |
35 displays.clear(); | 35 displays.clear(); |
36 GetEGLInitDisplays(false, true, command_line.get(), &displays); | 36 GetEGLInitDisplays(false, true, command_line.get(), &displays); |
37 EXPECT_EQ(std::find(displays.begin(), displays.end(), gfx::ANGLE_D3D11), | 37 EXPECT_EQ(std::find(displays.begin(), displays.end(), gl::ANGLE_D3D11), |
38 displays.end()); | 38 displays.end()); |
39 } | 39 } |
40 | 40 |
41 TEST(EGLInitializationDisplaysTest, SwiftShader) { | 41 TEST(EGLInitializationDisplaysTest, SwiftShader) { |
42 std::unique_ptr<base::CommandLine> command_line( | 42 std::unique_ptr<base::CommandLine> command_line( |
43 new base::CommandLine(base::CommandLine::NO_PROGRAM)); | 43 new base::CommandLine(base::CommandLine::NO_PROGRAM)); |
44 | 44 |
45 std::vector<gfx::DisplayType> displays; | 45 std::vector<gl::DisplayType> displays; |
46 | 46 |
47 // If swiftshader is requested, only SWIFT_SHADER should be returned | 47 // If swiftshader is requested, only SWIFT_SHADER should be returned |
48 command_line->AppendSwitchASCII(switches::kUseGL, | 48 command_line->AppendSwitchASCII(switches::kUseGL, |
49 gfx::kGLImplementationSwiftShaderName); | 49 gl::kGLImplementationSwiftShaderName); |
50 displays.clear(); | 50 displays.clear(); |
51 GetEGLInitDisplays(true, true, command_line.get(), &displays); | 51 GetEGLInitDisplays(true, true, command_line.get(), &displays); |
52 EXPECT_NE(std::find(displays.begin(), displays.end(), gfx::SWIFT_SHADER), | 52 EXPECT_NE(std::find(displays.begin(), displays.end(), gl::SWIFT_SHADER), |
53 displays.end()); | 53 displays.end()); |
54 EXPECT_EQ(displays.size(), 1u); | 54 EXPECT_EQ(displays.size(), 1u); |
55 | 55 |
56 // Even if there are other flags, swiftshader should take prescedence | 56 // Even if there are other flags, swiftshader should take prescedence |
57 command_line->AppendSwitchASCII(switches::kUseANGLE, | 57 command_line->AppendSwitchASCII(switches::kUseANGLE, |
58 gfx::kANGLEImplementationD3D11Name); | 58 gl::kANGLEImplementationD3D11Name); |
59 displays.clear(); | 59 displays.clear(); |
60 GetEGLInitDisplays(true, true, command_line.get(), &displays); | 60 GetEGLInitDisplays(true, true, command_line.get(), &displays); |
61 EXPECT_NE(std::find(displays.begin(), displays.end(), gfx::SWIFT_SHADER), | 61 EXPECT_NE(std::find(displays.begin(), displays.end(), gl::SWIFT_SHADER), |
62 displays.end()); | 62 displays.end()); |
63 EXPECT_EQ(displays.size(), 1u); | 63 EXPECT_EQ(displays.size(), 1u); |
64 } | 64 } |
65 | 65 |
66 TEST(EGLInitializationDisplaysTest, DefaultRenderers) { | 66 TEST(EGLInitializationDisplaysTest, DefaultRenderers) { |
67 std::unique_ptr<base::CommandLine> command_line( | 67 std::unique_ptr<base::CommandLine> command_line( |
68 new base::CommandLine(base::CommandLine::NO_PROGRAM)); | 68 new base::CommandLine(base::CommandLine::NO_PROGRAM)); |
69 | 69 |
70 // Default without --use-angle flag | 70 // Default without --use-angle flag |
71 std::vector<gfx::DisplayType> default_no_flag_displays; | 71 std::vector<gl::DisplayType> default_no_flag_displays; |
72 GetEGLInitDisplays(true, true, command_line.get(), &default_no_flag_displays); | 72 GetEGLInitDisplays(true, true, command_line.get(), &default_no_flag_displays); |
73 EXPECT_FALSE(default_no_flag_displays.empty()); | 73 EXPECT_FALSE(default_no_flag_displays.empty()); |
74 | 74 |
75 // Default with --use-angle flag | 75 // Default with --use-angle flag |
76 command_line->AppendSwitchASCII(switches::kUseANGLE, | 76 command_line->AppendSwitchASCII(switches::kUseANGLE, |
77 gfx::kANGLEImplementationDefaultName); | 77 gl::kANGLEImplementationDefaultName); |
78 std::vector<gfx::DisplayType> default_with_flag_displays; | 78 std::vector<gl::DisplayType> default_with_flag_displays; |
79 GetEGLInitDisplays(true, true, command_line.get(), | 79 GetEGLInitDisplays(true, true, command_line.get(), |
80 &default_with_flag_displays); | 80 &default_with_flag_displays); |
81 EXPECT_FALSE(default_with_flag_displays.empty()); | 81 EXPECT_FALSE(default_with_flag_displays.empty()); |
82 | 82 |
83 // Make sure the same results are returned | 83 // Make sure the same results are returned |
84 EXPECT_EQ(default_no_flag_displays, default_with_flag_displays); | 84 EXPECT_EQ(default_no_flag_displays, default_with_flag_displays); |
85 } | 85 } |
86 | 86 |
87 TEST(EGLInitializationDisplaysTest, NonDefaultRenderers) { | 87 TEST(EGLInitializationDisplaysTest, NonDefaultRenderers) { |
88 std::unique_ptr<base::CommandLine> command_line( | 88 std::unique_ptr<base::CommandLine> command_line( |
89 new base::CommandLine(base::CommandLine::NO_PROGRAM)); | 89 new base::CommandLine(base::CommandLine::NO_PROGRAM)); |
90 | 90 |
91 std::vector<gfx::DisplayType> displays; | 91 std::vector<gl::DisplayType> displays; |
92 | 92 |
93 // OpenGL | 93 // OpenGL |
94 command_line->AppendSwitchASCII(switches::kUseANGLE, | 94 command_line->AppendSwitchASCII(switches::kUseANGLE, |
95 gfx::kANGLEImplementationOpenGLName); | 95 gl::kANGLEImplementationOpenGLName); |
96 displays.clear(); | 96 displays.clear(); |
97 GetEGLInitDisplays(true, true, command_line.get(), &displays); | 97 GetEGLInitDisplays(true, true, command_line.get(), &displays); |
98 EXPECT_NE(std::find(displays.begin(), displays.end(), gfx::ANGLE_OPENGL), | 98 EXPECT_NE(std::find(displays.begin(), displays.end(), gl::ANGLE_OPENGL), |
99 displays.end()); | 99 displays.end()); |
100 EXPECT_EQ(displays.size(), 1u); | 100 EXPECT_EQ(displays.size(), 1u); |
101 | 101 |
102 // OpenGLES | 102 // OpenGLES |
103 command_line->AppendSwitchASCII(switches::kUseANGLE, | 103 command_line->AppendSwitchASCII(switches::kUseANGLE, |
104 gfx::kANGLEImplementationOpenGLESName); | 104 gl::kANGLEImplementationOpenGLESName); |
105 displays.clear(); | 105 displays.clear(); |
106 GetEGLInitDisplays(true, true, command_line.get(), &displays); | 106 GetEGLInitDisplays(true, true, command_line.get(), &displays); |
107 EXPECT_NE(std::find(displays.begin(), displays.end(), gfx::ANGLE_OPENGLES), | 107 EXPECT_NE(std::find(displays.begin(), displays.end(), gl::ANGLE_OPENGLES), |
108 displays.end()); | 108 displays.end()); |
109 EXPECT_EQ(displays.size(), 1u); | 109 EXPECT_EQ(displays.size(), 1u); |
110 } | 110 } |
111 | 111 |
112 TEST(EGLInitializationDisplaysTest, NoExtensions) { | 112 TEST(EGLInitializationDisplaysTest, NoExtensions) { |
113 std::unique_ptr<base::CommandLine> command_line( | 113 std::unique_ptr<base::CommandLine> command_line( |
114 new base::CommandLine(base::CommandLine::NO_PROGRAM)); | 114 new base::CommandLine(base::CommandLine::NO_PROGRAM)); |
115 | 115 |
116 // With no angle platform extensions, only DEFAULT should be available | 116 // With no angle platform extensions, only DEFAULT should be available |
117 std::vector<gfx::DisplayType> displays; | 117 std::vector<gl::DisplayType> displays; |
118 GetEGLInitDisplays(false, false, command_line.get(), &displays); | 118 GetEGLInitDisplays(false, false, command_line.get(), &displays); |
119 EXPECT_NE(std::find(displays.begin(), displays.end(), gfx::DEFAULT), | 119 EXPECT_NE(std::find(displays.begin(), displays.end(), gl::DEFAULT), |
120 displays.end()); | 120 displays.end()); |
121 EXPECT_EQ(displays.size(), 1u); | 121 EXPECT_EQ(displays.size(), 1u); |
122 } | 122 } |
123 | 123 |
124 } // namespace | 124 } // namespace |
OLD | NEW |