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

Unified Diff: ui/gl/gl_api_unittest.cc

Issue 1253433002: Fix GL extension filtering so that extension bits are set correctly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up context tls Created 5 years, 5 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 | « no previous file | ui/gl/gl_gl_api_implementation.h » ('j') | ui/gl/gl_gl_api_implementation.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_api_unittest.cc
diff --git a/ui/gl/gl_api_unittest.cc b/ui/gl/gl_api_unittest.cc
index 9b15bec443e97ea48fdb27f19ac16f14d52df41e..40f8f58da6b8e885ea5d19ed37a157818831413a 100644
--- a/ui/gl/gl_api_unittest.cc
+++ b/ui/gl/gl_api_unittest.cc
@@ -5,12 +5,34 @@
#include "base/command_line.h"
#include "base/memory/scoped_ptr.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gl/gl_context.h"
#include "ui/gl/gl_gl_api_implementation.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_switches.h"
+#include "ui/gl/gpu_timing.h"
namespace gfx {
+class GLContextFake : public GLContext {
+ public:
+ bool Initialize(GLSurface* compatible_surface,
+ GpuPreference gpu_preference) override {
+ return true;
+ }
+ void Destroy() override {}
+ bool MakeCurrent(GLSurface* surface) override { return true; }
+ void ReleaseCurrent(GLSurface* surface) override {}
+ bool IsCurrent(GLSurface* surface) override { return true; }
+ void* GetHandle() override { return NULL; }
+ scoped_refptr<gfx::GPUTimingClient> CreateGPUTimingClient() override {
+ return NULL;
+ }
+ void OnSetSwapInterval(int interval) override {}
+ GLContextFake() : GLContext(NULL) {}
+ protected:
+ ~GLContextFake() override {}
+};
+
class GLApiTest : public testing::Test {
public:
void SetUp() override {
@@ -18,17 +40,25 @@ class GLApiTest : public testing::Test {
num_fake_extension_strings_ = 0;
fake_extension_strings_ = nullptr;
- driver_.reset(new DriverGL());
+ g_current_gl_context_tls = new base::ThreadLocalPointer<GLApi>;
api_.reset(new RealGLApi());
- driver_->fn.glGetStringFn = &FakeGetString;
- driver_->fn.glGetStringiFn = &FakeGetStringi;
- driver_->fn.glGetIntegervFn = &FakeGetIntegervFn;
+ g_driver_gl.ClearBindings();
+ g_driver_gl.fn.glGetStringFn = &FakeGetString;
+ g_driver_gl.fn.glGetStringiFn = &FakeGetStringi;
+ g_driver_gl.fn.glGetIntegervFn = &FakeGetIntegervFn;
+
+ SetGLGetProcAddressProc(
+ static_cast<GLGetProcAddressProc>(&FakeGLGetProcAddress));
+ }
+
+ static void* GL_BINDING_CALL FakeGLGetProcAddress(const char *proc) {
+ return reinterpret_cast<void*>(0x1);
}
void TearDown() override {
api_.reset(nullptr);
- driver_.reset(nullptr);
+ delete g_current_gl_context_tls;
SetGLImplementation(kGLImplementationNone);
fake_extension_string_ = "";
@@ -38,10 +68,15 @@ class GLApiTest : public testing::Test {
void InitializeAPI(base::CommandLine* command_line) {
api_.reset(new RealGLApi());
+ g_current_gl_context_tls->Set(api_.get());
+
+ fake_context_ = new GLContextFake();
if (command_line)
- api_->InitializeWithCommandLine(driver_.get(), command_line);
+ api_->InitializeWithCommandLine(&g_driver_gl, command_line);
else
- api_->Initialize(driver_.get());
+ api_->Initialize(&g_driver_gl);
+ api_->InitializeFilteredExtensions();
no sievers 2015/07/23 23:45:57 Doesn't InitializeWithContext() call this?
Tobias Sargeant 2015/07/24 09:29:14 Not any more. It's safe to remove InitializeWithCo
+ g_driver_gl.InitializeCustomDynamicBindings(fake_context_.get());
api_->InitializeWithContext();
}
@@ -92,6 +127,7 @@ class GLApiTest : public testing::Test {
static uint32_t num_fake_extension_strings_;
static const char** fake_extension_strings_;
+ scoped_refptr<GLContext> fake_context_;
scoped_ptr<DriverGL> driver_;
scoped_ptr<RealGLApi> api_;
};
@@ -119,6 +155,25 @@ TEST_F(GLApiTest, DisabledExtensionStringTest) {
EXPECT_STREQ(kFilteredExtensions, GetExtensions());
}
+TEST_F(GLApiTest, DisabledExtensionBitTest) {
+ static const char* kFakeExtensions[] = {
+ "GL_ARB_timer_query"
+ };
+ static const char* kFakeDisabledExtensions = "GL_ARB_timer_query";
+
+ SetFakeExtensionStrings(kFakeExtensions, arraysize(kFakeExtensions));
+ InitializeAPI(nullptr);
+
+ EXPECT_TRUE(g_driver_gl.ext.b_GL_ARB_timer_query);
+
+ base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
+ command_line.AppendSwitchASCII(switches::kDisableGLExtensions,
+ kFakeDisabledExtensions);
+ InitializeAPI(&command_line);
+
+ EXPECT_FALSE(g_driver_gl.ext.b_GL_ARB_timer_query);
+}
+
TEST_F(GLApiTest, DisabledExtensionStringIndexTest) {
static const char* kFakeExtensions[] = {
"GL_EXT_1",
« no previous file with comments | « no previous file | ui/gl/gl_gl_api_implementation.h » ('j') | ui/gl/gl_gl_api_implementation.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698