| 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 "base/stl_util.h" |
| 5 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 6 #include "ui/gl/gl_surface_egl.h" | 7 #include "ui/gl/gl_surface_egl.h" |
| 7 | 8 |
| 8 namespace { | 9 namespace { |
| 9 | 10 |
| 10 TEST(EGLInitializationDisplaysTest, DisableD3D11) { | 11 TEST(EGLInitializationDisplaysTest, DisableD3D11) { |
| 11 std::unique_ptr<base::CommandLine> command_line( | 12 std::unique_ptr<base::CommandLine> command_line( |
| 12 new base::CommandLine(base::CommandLine::NO_PROGRAM)); | 13 new base::CommandLine(base::CommandLine::NO_PROGRAM)); |
| 13 | 14 |
| 14 std::vector<gl::DisplayType> displays; | 15 std::vector<gl::DisplayType> displays; |
| 15 | 16 |
| 16 // using --disable-d3d11 with the default --use-angle should never return | 17 // using --disable-d3d11 with the default --use-angle should never return |
| 17 // D3D11. | 18 // D3D11. |
| 18 command_line->AppendSwitch(switches::kDisableD3D11); | 19 command_line->AppendSwitch(switches::kDisableD3D11); |
| 19 GetEGLInitDisplays(true, true, true, command_line.get(), &displays); | 20 GetEGLInitDisplays(true, true, true, command_line.get(), &displays); |
| 20 EXPECT_EQ(std::find(displays.begin(), displays.end(), gl::ANGLE_D3D11), | 21 EXPECT_FALSE(base::ContainsValue(displays, gl::ANGLE_D3D11)); |
| 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, 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_TRUE(base::ContainsValue(displays, gl::ANGLE_D3D11)); |
| 30 displays.end()); | |
| 31 EXPECT_EQ(displays.size(), 1u); | 30 EXPECT_EQ(displays.size(), 1u); |
| 32 | 31 |
| 33 // Specifically requesting D3D11 should not return D3D11 if the extension is | 32 // Specifically requesting D3D11 should not return D3D11 if the extension is |
| 34 // not available | 33 // not available |
| 35 displays.clear(); | 34 displays.clear(); |
| 36 GetEGLInitDisplays(false, true, true, command_line.get(), &displays); | 35 GetEGLInitDisplays(false, true, true, command_line.get(), &displays); |
| 37 EXPECT_EQ(std::find(displays.begin(), displays.end(), gl::ANGLE_D3D11), | 36 EXPECT_FALSE(base::ContainsValue(displays, gl::ANGLE_D3D11)); |
| 38 displays.end()); | |
| 39 } | 37 } |
| 40 | 38 |
| 41 TEST(EGLInitializationDisplaysTest, SwiftShader) { | 39 TEST(EGLInitializationDisplaysTest, SwiftShader) { |
| 42 std::unique_ptr<base::CommandLine> command_line( | 40 std::unique_ptr<base::CommandLine> command_line( |
| 43 new base::CommandLine(base::CommandLine::NO_PROGRAM)); | 41 new base::CommandLine(base::CommandLine::NO_PROGRAM)); |
| 44 | 42 |
| 45 std::vector<gl::DisplayType> displays; | 43 std::vector<gl::DisplayType> displays; |
| 46 | 44 |
| 47 // If swiftshader is requested, only SWIFT_SHADER should be returned | 45 // If swiftshader is requested, only SWIFT_SHADER should be returned |
| 48 command_line->AppendSwitchASCII(switches::kUseGL, | 46 command_line->AppendSwitchASCII(switches::kUseGL, |
| 49 gl::kGLImplementationSwiftShaderForWebGLName); | 47 gl::kGLImplementationSwiftShaderForWebGLName); |
| 50 displays.clear(); | 48 displays.clear(); |
| 51 GetEGLInitDisplays(true, true, true, command_line.get(), &displays); | 49 GetEGLInitDisplays(true, true, true, command_line.get(), &displays); |
| 52 EXPECT_NE(std::find(displays.begin(), displays.end(), gl::SWIFT_SHADER), | 50 EXPECT_TRUE(base::ContainsValue(displays, gl::SWIFT_SHADER)); |
| 53 displays.end()); | |
| 54 EXPECT_EQ(displays.size(), 1u); | 51 EXPECT_EQ(displays.size(), 1u); |
| 55 | 52 |
| 56 // Even if there are other flags, swiftshader should take prescedence | 53 // Even if there are other flags, swiftshader should take prescedence |
| 57 command_line->AppendSwitchASCII(switches::kUseANGLE, | 54 command_line->AppendSwitchASCII(switches::kUseANGLE, |
| 58 gl::kANGLEImplementationD3D11Name); | 55 gl::kANGLEImplementationD3D11Name); |
| 59 displays.clear(); | 56 displays.clear(); |
| 60 GetEGLInitDisplays(true, true, true, command_line.get(), &displays); | 57 GetEGLInitDisplays(true, true, true, command_line.get(), &displays); |
| 61 EXPECT_NE(std::find(displays.begin(), displays.end(), gl::SWIFT_SHADER), | 58 EXPECT_TRUE(base::ContainsValue(displays, gl::SWIFT_SHADER)); |
| 62 displays.end()); | |
| 63 EXPECT_EQ(displays.size(), 1u); | 59 EXPECT_EQ(displays.size(), 1u); |
| 64 } | 60 } |
| 65 | 61 |
| 66 TEST(EGLInitializationDisplaysTest, DefaultRenderers) { | 62 TEST(EGLInitializationDisplaysTest, DefaultRenderers) { |
| 67 std::unique_ptr<base::CommandLine> command_line( | 63 std::unique_ptr<base::CommandLine> command_line( |
| 68 new base::CommandLine(base::CommandLine::NO_PROGRAM)); | 64 new base::CommandLine(base::CommandLine::NO_PROGRAM)); |
| 69 | 65 |
| 70 // Default without --use-angle flag | 66 // Default without --use-angle flag |
| 71 std::vector<gl::DisplayType> default_no_flag_displays; | 67 std::vector<gl::DisplayType> default_no_flag_displays; |
| 72 GetEGLInitDisplays(true, true, true, command_line.get(), | 68 GetEGLInitDisplays(true, true, true, command_line.get(), |
| (...skipping 16 matching lines...) Expand all Loading... |
| 89 std::unique_ptr<base::CommandLine> command_line( | 85 std::unique_ptr<base::CommandLine> command_line( |
| 90 new base::CommandLine(base::CommandLine::NO_PROGRAM)); | 86 new base::CommandLine(base::CommandLine::NO_PROGRAM)); |
| 91 | 87 |
| 92 std::vector<gl::DisplayType> displays; | 88 std::vector<gl::DisplayType> displays; |
| 93 | 89 |
| 94 // OpenGL | 90 // OpenGL |
| 95 command_line->AppendSwitchASCII(switches::kUseANGLE, | 91 command_line->AppendSwitchASCII(switches::kUseANGLE, |
| 96 gl::kANGLEImplementationOpenGLName); | 92 gl::kANGLEImplementationOpenGLName); |
| 97 displays.clear(); | 93 displays.clear(); |
| 98 GetEGLInitDisplays(true, true, true, command_line.get(), &displays); | 94 GetEGLInitDisplays(true, true, true, command_line.get(), &displays); |
| 99 EXPECT_NE(std::find(displays.begin(), displays.end(), gl::ANGLE_OPENGL), | 95 EXPECT_TRUE(base::ContainsValue(displays, gl::ANGLE_OPENGL)); |
| 100 displays.end()); | |
| 101 EXPECT_EQ(displays.size(), 1u); | 96 EXPECT_EQ(displays.size(), 1u); |
| 102 | 97 |
| 103 // OpenGLES | 98 // OpenGLES |
| 104 command_line->AppendSwitchASCII(switches::kUseANGLE, | 99 command_line->AppendSwitchASCII(switches::kUseANGLE, |
| 105 gl::kANGLEImplementationOpenGLESName); | 100 gl::kANGLEImplementationOpenGLESName); |
| 106 displays.clear(); | 101 displays.clear(); |
| 107 GetEGLInitDisplays(true, true, true, command_line.get(), &displays); | 102 GetEGLInitDisplays(true, true, true, command_line.get(), &displays); |
| 108 EXPECT_NE(std::find(displays.begin(), displays.end(), gl::ANGLE_OPENGLES), | 103 EXPECT_TRUE(base::ContainsValue(displays, gl::ANGLE_OPENGLES)); |
| 109 displays.end()); | |
| 110 EXPECT_EQ(displays.size(), 1u); | 104 EXPECT_EQ(displays.size(), 1u); |
| 111 | 105 |
| 112 // Null | 106 // Null |
| 113 command_line->AppendSwitchASCII(switches::kUseANGLE, | 107 command_line->AppendSwitchASCII(switches::kUseANGLE, |
| 114 gl::kANGLEImplementationNullName); | 108 gl::kANGLEImplementationNullName); |
| 115 displays.clear(); | 109 displays.clear(); |
| 116 GetEGLInitDisplays(true, true, true, command_line.get(), &displays); | 110 GetEGLInitDisplays(true, true, true, command_line.get(), &displays); |
| 117 EXPECT_NE(std::find(displays.begin(), displays.end(), gl::ANGLE_NULL), | 111 EXPECT_TRUE(base::ContainsValue(displays, gl::ANGLE_NULL)); |
| 118 displays.end()); | |
| 119 EXPECT_EQ(displays.size(), 1u); | 112 EXPECT_EQ(displays.size(), 1u); |
| 120 } | 113 } |
| 121 | 114 |
| 122 TEST(EGLInitializationDisplaysTest, NoExtensions) { | 115 TEST(EGLInitializationDisplaysTest, NoExtensions) { |
| 123 std::unique_ptr<base::CommandLine> command_line( | 116 std::unique_ptr<base::CommandLine> command_line( |
| 124 new base::CommandLine(base::CommandLine::NO_PROGRAM)); | 117 new base::CommandLine(base::CommandLine::NO_PROGRAM)); |
| 125 | 118 |
| 126 // With no angle platform extensions, only DEFAULT should be available | 119 // With no angle platform extensions, only DEFAULT should be available |
| 127 std::vector<gl::DisplayType> displays; | 120 std::vector<gl::DisplayType> displays; |
| 128 GetEGLInitDisplays(false, false, false, command_line.get(), &displays); | 121 GetEGLInitDisplays(false, false, false, command_line.get(), &displays); |
| 129 EXPECT_NE(std::find(displays.begin(), displays.end(), gl::DEFAULT), | 122 EXPECT_TRUE(base::ContainsValue(displays, gl::DEFAULT)); |
| 130 displays.end()); | |
| 131 EXPECT_EQ(displays.size(), 1u); | 123 EXPECT_EQ(displays.size(), 1u); |
| 132 } | 124 } |
| 133 | 125 |
| 134 } // namespace | 126 } // namespace |
| OLD | NEW |