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

Unified Diff: gpu/command_buffer/tests/gl_context_unittest.cc

Issue 1110923003: Added switch to disable specified GL extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Accidentally removed necessary class declaration Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/BUILD.gn ('k') | gpu/gpu.gyp » ('j') | ui/gl/gl_gl_api_implementation.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/tests/gl_context_unittest.cc
diff --git a/gpu/command_buffer/tests/gl_context_unittest.cc b/gpu/command_buffer/tests/gl_context_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9aa0b7db9b1d92cf12dac0c9b4fefd45dd6d4cb1
--- /dev/null
+++ b/gpu/command_buffer/tests/gl_context_unittest.cc
@@ -0,0 +1,60 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <vector>
+
+#include "base/command_line.h"
+#include "base/strings/string_split.h"
+#include "base/strings/string_util.h"
+#include "gpu/command_buffer/tests/gl_manager.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "ui/gl/gl_gl_api_implementation.h"
+#include "ui/gl/gl_surface.h"
+#include "ui/gl/gl_switches.h"
+
+namespace gpu {
+
+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
+ static const char* kExtraDisabledExt = "GL_ExtraDisabledExt";
+
+ GLManager gl;
+ 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.
+ gfx::GLContext* gl_context = gl.context();
+
+ const std::string gl_extensions = gl_context->GetExtensions();
+ ASSERT_FALSE(gl_extensions.empty());
+
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.
+ std::vector<std::string> extensions;
+ base::SplitString(gl_extensions, ' ', &extensions);
+ ASSERT_LT(3u, gl_extensions.size());
+
+ EXPECT_TRUE(gl_context->HasExtension(extensions[0].c_str()));
+ EXPECT_TRUE(gl_context->HasExtension(extensions[1].c_str()));
+ EXPECT_TRUE(gl_context->HasExtension(extensions[2].c_str()));
+ EXPECT_FALSE(gl_context->HasExtension(kExtraDisabledExt));
+
+ // Disable some extensions along with an extra one that does not exist.
+ std::vector<std::string> disabled_extensions;
+ disabled_extensions.push_back(extensions[0]);
+ disabled_extensions.push_back(extensions[1]);
+ disabled_extensions.push_back(kExtraDisabledExt);
+
+ base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
+ command_line.AppendSwitchASCII(switches::kDisableGLExtensions,
+ JoinString(disabled_extensions, " "));
+
+ gfx::RealGLApi disabled_extension_api;
+ disabled_extension_api.Initialize(&gfx::g_driver_gl, &command_line);
+ gfx::ScopedSetGLToRealGLApi scoped_set_api(&disabled_extension_api);
+
+ EXPECT_FALSE(gl_context->HasExtension(extensions[0].c_str()));
+ EXPECT_FALSE(gl_context->HasExtension(extensions[1].c_str()));
+ EXPECT_TRUE(gl_context->HasExtension(extensions[2].c_str()));
+ EXPECT_FALSE(gl_context->HasExtension(kExtraDisabledExt));
+
+ gl.Destroy();
+}
+
+} // namespace gpu
+
« no previous file with comments | « gpu/BUILD.gn ('k') | gpu/gpu.gyp » ('j') | ui/gl/gl_gl_api_implementation.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698