OLD | NEW |
---|---|
(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 <vector> | |
6 | |
7 #include "base/command_line.h" | |
8 #include "base/strings/string_split.h" | |
9 #include "base/strings/string_util.h" | |
10 #include "gpu/command_buffer/tests/gl_manager.h" | |
11 #include "testing/gmock/include/gmock/gmock.h" | |
12 #include "ui/gl/gl_gl_api_implementation.h" | |
13 #include "ui/gl/gl_surface.h" | |
14 #include "ui/gl/gl_switches.h" | |
15 | |
16 namespace gpu { | |
17 | |
18 TEST(GLContextTests, DisabledExtensionsTest) { | |
no sievers
2015/04/30 23:49:05
Maybe a better name for this file is gl_api_unitte
David Yen
2015/05/01 21:20:37
done and moved to gfx_unittests
| |
19 static const char* kExtraDisabledExt = "GL_ExtraDisabledExt"; | |
20 | |
21 GLManager gl; | |
22 gl.Initialize(GLManager::Options()); | |
no sievers
2015/04/30 23:49:05
Uh I wouldn't use GLManager here. That's for setti
David Yen
2015/05/01 21:20:37
No longer relevant in the new unit test.
| |
23 gfx::GLContext* gl_context = gl.context(); | |
24 | |
25 const std::string gl_extensions = gl_context->GetExtensions(); | |
26 ASSERT_FALSE(gl_extensions.empty()); | |
27 | |
no sievers
2015/04/30 23:49:05
I think we can do something like this:
const GLu
David Yen
2015/05/01 21:20:37
Done, new unit test is more or less done this way.
| |
28 std::vector<std::string> extensions; | |
29 base::SplitString(gl_extensions, ' ', &extensions); | |
30 ASSERT_LT(3u, gl_extensions.size()); | |
31 | |
32 EXPECT_TRUE(gl_context->HasExtension(extensions[0].c_str())); | |
33 EXPECT_TRUE(gl_context->HasExtension(extensions[1].c_str())); | |
34 EXPECT_TRUE(gl_context->HasExtension(extensions[2].c_str())); | |
35 EXPECT_FALSE(gl_context->HasExtension(kExtraDisabledExt)); | |
36 | |
37 // Disable some extensions along with an extra one that does not exist. | |
38 std::vector<std::string> disabled_extensions; | |
39 disabled_extensions.push_back(extensions[0]); | |
40 disabled_extensions.push_back(extensions[1]); | |
41 disabled_extensions.push_back(kExtraDisabledExt); | |
42 | |
43 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | |
44 command_line.AppendSwitchASCII(switches::kDisableGLExtensions, | |
45 JoinString(disabled_extensions, " ")); | |
46 | |
47 gfx::RealGLApi disabled_extension_api; | |
48 disabled_extension_api.Initialize(&gfx::g_driver_gl, &command_line); | |
49 gfx::ScopedSetGLToRealGLApi scoped_set_api(&disabled_extension_api); | |
50 | |
51 EXPECT_FALSE(gl_context->HasExtension(extensions[0].c_str())); | |
52 EXPECT_FALSE(gl_context->HasExtension(extensions[1].c_str())); | |
53 EXPECT_TRUE(gl_context->HasExtension(extensions[2].c_str())); | |
54 EXPECT_FALSE(gl_context->HasExtension(kExtraDisabledExt)); | |
55 | |
56 gl.Destroy(); | |
57 } | |
58 | |
59 } // namespace gpu | |
60 | |
OLD | NEW |