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

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

Issue 1123343004: Add a --use-angle flag for selecting the ANGLE renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move dependency on gl.gyp into conditional. Created 5 years, 7 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_tests.gyp ('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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "ui/gl/gl_surface_egl.h"
7
8 namespace {
9
10 TEST(EGLInitializationDisplaysTest, DisableD3D11) {
11 scoped_ptr<base::CommandLine> command_line(
12 new base::CommandLine(base::CommandLine::NO_PROGRAM));
13
14 std::vector<gfx::DisplayType> displays;
15
16 // using --disable-d3d11 with the default --use-angle should never return
17 // D3D11.
18 command_line->AppendSwitch(switches::kDisableD3D11);
19 GetEGLInitDisplays(true, true, command_line.get(), &displays);
20 EXPECT_EQ(std::find(displays.begin(), displays.end(), gfx::ANGLE_D3D11),
21 displays.end());
22
23 // Specifically requesting D3D11 should always return it if the extension is
24 // available
25 command_line->AppendSwitchASCII(switches::kUseANGLE,
26 gfx::kANGLEImplementationD3D11Name);
27 displays.clear();
28 GetEGLInitDisplays(true, true, command_line.get(), &displays);
29 EXPECT_NE(std::find(displays.begin(), displays.end(), gfx::ANGLE_D3D11),
30 displays.end());
31 EXPECT_EQ(displays.size(), 1u);
32
33 // Specifically requesting D3D11 should not return D3D11 if the extension is
34 // not available
35 displays.clear();
36 GetEGLInitDisplays(false, true, command_line.get(), &displays);
37 EXPECT_EQ(std::find(displays.begin(), displays.end(), gfx::ANGLE_D3D11),
38 displays.end());
39 }
40
41 TEST(EGLInitializationDisplaysTest, SwiftShader) {
42 scoped_ptr<base::CommandLine> command_line(
43 new base::CommandLine(base::CommandLine::NO_PROGRAM));
44
45 std::vector<gfx::DisplayType> displays;
46
47 // If swiftshader is requested, only SWIFT_SHADER should be returned
48 command_line->AppendSwitchASCII(switches::kUseGL,
49 gfx::kGLImplementationSwiftShaderName);
50 displays.clear();
51 GetEGLInitDisplays(true, true, command_line.get(), &displays);
52 EXPECT_NE(std::find(displays.begin(), displays.end(), gfx::SWIFT_SHADER),
53 displays.end());
54 EXPECT_EQ(displays.size(), 1u);
55
56 // Even if there are other flags, swiftshader should take prescedence
57 command_line->AppendSwitchASCII(switches::kUseANGLE,
58 gfx::kANGLEImplementationD3D11Name);
59 displays.clear();
60 GetEGLInitDisplays(true, true, command_line.get(), &displays);
61 EXPECT_NE(std::find(displays.begin(), displays.end(), gfx::SWIFT_SHADER),
62 displays.end());
63 EXPECT_EQ(displays.size(), 1u);
64 }
65
66 TEST(EGLInitializationDisplaysTest, DefaultRenderers) {
67 scoped_ptr<base::CommandLine> command_line(
68 new base::CommandLine(base::CommandLine::NO_PROGRAM));
69
70 // Default without --use-angle flag
71 std::vector<gfx::DisplayType> default_no_flag_displays;
72 GetEGLInitDisplays(true, true, command_line.get(), &default_no_flag_displays);
73 EXPECT_FALSE(default_no_flag_displays.empty());
74
75 // Default with --use-angle flag
76 command_line->AppendSwitchASCII(switches::kUseANGLE,
77 gfx::kANGLEImplementationDefaultName);
78 std::vector<gfx::DisplayType> default_with_flag_displays;
79 GetEGLInitDisplays(true, true, command_line.get(),
80 &default_with_flag_displays);
81 EXPECT_FALSE(default_with_flag_displays.empty());
82
83 // Make sure the same results are returned
84 EXPECT_EQ(default_no_flag_displays, default_with_flag_displays);
85 }
86
87 TEST(EGLInitializationDisplaysTest, NonDefaultRenderers) {
88 scoped_ptr<base::CommandLine> command_line(
89 new base::CommandLine(base::CommandLine::NO_PROGRAM));
90
91 std::vector<gfx::DisplayType> displays;
92
93 // WARP
94 command_line->AppendSwitchASCII(switches::kUseANGLE,
95 gfx::kANGLEImplementationWARPName);
96 displays.clear();
97 GetEGLInitDisplays(true, true, command_line.get(), &displays);
98 EXPECT_NE(std::find(displays.begin(), displays.end(), gfx::ANGLE_WARP),
99 displays.end());
100 EXPECT_EQ(displays.size(), 1u);
101
102 // OpenGL
103 command_line->AppendSwitchASCII(switches::kUseANGLE,
104 gfx::kANGLEImplementationOpenGLName);
105 displays.clear();
106 GetEGLInitDisplays(true, true, command_line.get(), &displays);
107 EXPECT_NE(std::find(displays.begin(), displays.end(), gfx::ANGLE_OPENGL),
108 displays.end());
109 EXPECT_EQ(displays.size(), 1u);
110
111 // OpenGLES
112 command_line->AppendSwitchASCII(switches::kUseANGLE,
113 gfx::kANGLEImplementationOpenGLESName);
114 displays.clear();
115 GetEGLInitDisplays(true, true, command_line.get(), &displays);
116 EXPECT_NE(std::find(displays.begin(), displays.end(), gfx::ANGLE_OPENGLES),
117 displays.end());
118 EXPECT_EQ(displays.size(), 1u);
119 }
120
121 TEST(EGLInitializationDisplaysTest, NoExtensions) {
122 scoped_ptr<base::CommandLine> command_line(
123 new base::CommandLine(base::CommandLine::NO_PROGRAM));
124
125 // With no angle platform extensions, only DEFAULT should be available
126 std::vector<gfx::DisplayType> displays;
127 GetEGLInitDisplays(false, false, command_line.get(), &displays);
128 EXPECT_NE(std::find(displays.begin(), displays.end(), gfx::DEFAULT),
129 displays.end());
130 EXPECT_EQ(displays.size(), 1u);
131 }
132
133 } // namespace
OLDNEW
« no previous file with comments | « ui/gl/gl_tests.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698