Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ui / gl / test / egl_initialization_displays_unittest.cc
blobbeb7586ae8dcd7db5ff2f59e8c0ebcd06e205308
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.
5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "ui/gl/gl_surface_egl.h"
8 namespace {
10 TEST(EGLInitializationDisplaysTest, DisableD3D11) {
11 scoped_ptr<base::CommandLine> command_line(
12 new base::CommandLine(base::CommandLine::NO_PROGRAM));
14 std::vector<gfx::DisplayType> displays;
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());
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);
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());
41 TEST(EGLInitializationDisplaysTest, SwiftShader) {
42 scoped_ptr<base::CommandLine> command_line(
43 new base::CommandLine(base::CommandLine::NO_PROGRAM));
45 std::vector<gfx::DisplayType> displays;
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);
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);
66 TEST(EGLInitializationDisplaysTest, DefaultRenderers) {
67 scoped_ptr<base::CommandLine> command_line(
68 new base::CommandLine(base::CommandLine::NO_PROGRAM));
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());
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());
83 // Make sure the same results are returned
84 EXPECT_EQ(default_no_flag_displays, default_with_flag_displays);
87 TEST(EGLInitializationDisplaysTest, NonDefaultRenderers) {
88 scoped_ptr<base::CommandLine> command_line(
89 new base::CommandLine(base::CommandLine::NO_PROGRAM));
91 std::vector<gfx::DisplayType> displays;
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);
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);
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);
121 TEST(EGLInitializationDisplaysTest, NoExtensions) {
122 scoped_ptr<base::CommandLine> command_line(
123 new base::CommandLine(base::CommandLine::NO_PROGRAM));
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);
133 } // namespace