Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: ui/gl/test/egl_initialization_displays_unittest.cc

Issue 2415663008: Expose Null ANGLE backend (Closed)
Patch Set: Fix/Add test Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gl/gl_switches.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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<gl::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, true, command_line.get(), &displays);
20 EXPECT_EQ(std::find(displays.begin(), displays.end(), gl::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 gl::kANGLEImplementationD3D11Name); 26 gl::kANGLEImplementationD3D11Name);
27 displays.clear(); 27 displays.clear();
28 GetEGLInitDisplays(true, true, command_line.get(), &displays); 28 GetEGLInitDisplays(true, true, true, command_line.get(), &displays);
29 EXPECT_NE(std::find(displays.begin(), displays.end(), gl::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, true, command_line.get(), &displays);
37 EXPECT_EQ(std::find(displays.begin(), displays.end(), gl::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<gl::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 gl::kGLImplementationSwiftShaderName); 49 gl::kGLImplementationSwiftShaderName);
50 displays.clear(); 50 displays.clear();
51 GetEGLInitDisplays(true, true, command_line.get(), &displays); 51 GetEGLInitDisplays(true, true, true, command_line.get(), &displays);
52 EXPECT_NE(std::find(displays.begin(), displays.end(), gl::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 gl::kANGLEImplementationD3D11Name); 58 gl::kANGLEImplementationD3D11Name);
59 displays.clear(); 59 displays.clear();
60 GetEGLInitDisplays(true, true, command_line.get(), &displays); 60 GetEGLInitDisplays(true, true, true, command_line.get(), &displays);
61 EXPECT_NE(std::find(displays.begin(), displays.end(), gl::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<gl::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, true, command_line.get(),
73 &default_no_flag_displays);
73 EXPECT_FALSE(default_no_flag_displays.empty()); 74 EXPECT_FALSE(default_no_flag_displays.empty());
74 75
75 // Default with --use-angle flag 76 // Default with --use-angle flag
76 command_line->AppendSwitchASCII(switches::kUseANGLE, 77 command_line->AppendSwitchASCII(switches::kUseANGLE,
77 gl::kANGLEImplementationDefaultName); 78 gl::kANGLEImplementationDefaultName);
78 std::vector<gl::DisplayType> default_with_flag_displays; 79 std::vector<gl::DisplayType> default_with_flag_displays;
79 GetEGLInitDisplays(true, true, command_line.get(), 80 GetEGLInitDisplays(true, true, true, command_line.get(),
80 &default_with_flag_displays); 81 &default_with_flag_displays);
81 EXPECT_FALSE(default_with_flag_displays.empty()); 82 EXPECT_FALSE(default_with_flag_displays.empty());
82 83
83 // Make sure the same results are returned 84 // Make sure the same results are returned
84 EXPECT_EQ(default_no_flag_displays, default_with_flag_displays); 85 EXPECT_EQ(default_no_flag_displays, default_with_flag_displays);
85 } 86 }
86 87
87 TEST(EGLInitializationDisplaysTest, NonDefaultRenderers) { 88 TEST(EGLInitializationDisplaysTest, NonDefaultRenderers) {
88 std::unique_ptr<base::CommandLine> command_line( 89 std::unique_ptr<base::CommandLine> command_line(
89 new base::CommandLine(base::CommandLine::NO_PROGRAM)); 90 new base::CommandLine(base::CommandLine::NO_PROGRAM));
90 91
91 std::vector<gl::DisplayType> displays; 92 std::vector<gl::DisplayType> displays;
92 93
93 // OpenGL 94 // OpenGL
94 command_line->AppendSwitchASCII(switches::kUseANGLE, 95 command_line->AppendSwitchASCII(switches::kUseANGLE,
95 gl::kANGLEImplementationOpenGLName); 96 gl::kANGLEImplementationOpenGLName);
96 displays.clear(); 97 displays.clear();
97 GetEGLInitDisplays(true, true, command_line.get(), &displays); 98 GetEGLInitDisplays(true, true, true, command_line.get(), &displays);
98 EXPECT_NE(std::find(displays.begin(), displays.end(), gl::ANGLE_OPENGL), 99 EXPECT_NE(std::find(displays.begin(), displays.end(), gl::ANGLE_OPENGL),
99 displays.end()); 100 displays.end());
100 EXPECT_EQ(displays.size(), 1u); 101 EXPECT_EQ(displays.size(), 1u);
101 102
102 // OpenGLES 103 // OpenGLES
103 command_line->AppendSwitchASCII(switches::kUseANGLE, 104 command_line->AppendSwitchASCII(switches::kUseANGLE,
104 gl::kANGLEImplementationOpenGLESName); 105 gl::kANGLEImplementationOpenGLESName);
105 displays.clear(); 106 displays.clear();
106 GetEGLInitDisplays(true, true, command_line.get(), &displays); 107 GetEGLInitDisplays(true, true, true, command_line.get(), &displays);
107 EXPECT_NE(std::find(displays.begin(), displays.end(), gl::ANGLE_OPENGLES), 108 EXPECT_NE(std::find(displays.begin(), displays.end(), gl::ANGLE_OPENGLES),
108 displays.end()); 109 displays.end());
109 EXPECT_EQ(displays.size(), 1u); 110 EXPECT_EQ(displays.size(), 1u);
111
112 // Null
113 command_line->AppendSwitchASCII(switches::kUseANGLE,
114 gl::kANGLEImplementationNullName);
115 displays.clear();
116 GetEGLInitDisplays(true, true, true, command_line.get(), &displays);
117 EXPECT_NE(std::find(displays.begin(), displays.end(), gl::ANGLE_NULL),
118 displays.end());
119 EXPECT_EQ(displays.size(), 1u);
110 } 120 }
111 121
112 TEST(EGLInitializationDisplaysTest, NoExtensions) { 122 TEST(EGLInitializationDisplaysTest, NoExtensions) {
113 std::unique_ptr<base::CommandLine> command_line( 123 std::unique_ptr<base::CommandLine> command_line(
114 new base::CommandLine(base::CommandLine::NO_PROGRAM)); 124 new base::CommandLine(base::CommandLine::NO_PROGRAM));
115 125
116 // With no angle platform extensions, only DEFAULT should be available 126 // With no angle platform extensions, only DEFAULT should be available
117 std::vector<gl::DisplayType> displays; 127 std::vector<gl::DisplayType> displays;
118 GetEGLInitDisplays(false, false, command_line.get(), &displays); 128 GetEGLInitDisplays(false, false, false, command_line.get(), &displays);
119 EXPECT_NE(std::find(displays.begin(), displays.end(), gl::DEFAULT), 129 EXPECT_NE(std::find(displays.begin(), displays.end(), gl::DEFAULT),
120 displays.end()); 130 displays.end());
121 EXPECT_EQ(displays.size(), 1u); 131 EXPECT_EQ(displays.size(), 1u);
122 } 132 }
123 133
124 } // namespace 134 } // namespace
OLDNEW
« no previous file with comments | « ui/gl/gl_switches.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698