Index: ui/gl/gl_api_unittest.cc |
diff --git a/ui/gl/gl_api_unittest.cc b/ui/gl/gl_api_unittest.cc |
index 6f274b467347a3b49bec37f2f4bb2ff05ce35ecd..f0185c670e1a19033f002d59e0549c56d78af197 100644 |
--- a/ui/gl/gl_api_unittest.cc |
+++ b/ui/gl/gl_api_unittest.cc |
@@ -13,29 +13,11 @@ |
#include "ui/gl/gl_gl_api_implementation.h" |
#include "ui/gl/gl_implementation.h" |
#include "ui/gl/gl_switches.h" |
+#include "ui/gl/gl_version_info.h" |
#include "ui/gl/gpu_timing.h" |
namespace gl { |
-class GLContextFake : public GLContext { |
- public: |
- bool Initialize(GLSurface* compatible_surface, |
- const GLContextAttribs& attribs) override { |
- return true; |
- } |
- 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<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 { |
@@ -44,9 +26,6 @@ class GLApiTest : public testing::Test { |
num_fake_extension_strings_ = 0; |
fake_extension_strings_ = nullptr; |
- DCHECK(!g_current_gl_context_tls); |
- g_current_gl_context_tls = new base::ThreadLocalPointer<GLApi>; |
- |
SetGLGetProcAddressProc( |
static_cast<GLGetProcAddressProc>(&FakeGLGetProcAddress)); |
} |
@@ -58,8 +37,7 @@ class GLApiTest : public testing::Test { |
void TearDown() override { |
api_.reset(nullptr); |
- delete g_current_gl_context_tls; |
- g_current_gl_context_tls = nullptr; |
+ driver_.reset(nullptr); |
SetGLImplementation(kGLImplementationNone); |
fake_extension_string_ = ""; |
@@ -69,21 +47,23 @@ class GLApiTest : public testing::Test { |
} |
void InitializeAPI(base::CommandLine* command_line) { |
- api_.reset(new RealGLApi()); |
- g_current_gl_context_tls->Set(api_.get()); |
- |
- g_driver_gl.ClearBindings(); |
- g_driver_gl.fn.glGetStringFn = &FakeGetString; |
- g_driver_gl.fn.glGetStringiFn = &FakeGetStringi; |
- g_driver_gl.fn.glGetIntegervFn = &FakeGetIntegervFn; |
+ driver_.reset(new DriverGL()); |
+ driver_->fn.glGetStringFn = &FakeGetString; |
+ driver_->fn.glGetStringiFn = &FakeGetStringi; |
+ driver_->fn.glGetIntegervFn = &FakeGetIntegervFn; |
- fake_context_ = new GLContextFake(); |
+ api_.reset(new RealGLApi()); |
if (command_line) |
- api_->InitializeWithCommandLine(&g_driver_gl, command_line); |
+ api_->InitializeWithCommandLine(driver_.get(), command_line); |
else |
- api_->Initialize(&g_driver_gl); |
+ api_->Initialize(driver_.get()); |
+ |
api_->InitializeFilteredExtensions(); |
- g_driver_gl.InitializeCustomDynamicBindings(fake_context_.get()); |
+ std::unique_ptr<GLVersionInfo> version = |
+ GetVersionInfoFromContext(api_.get()); |
+ driver_->InitializeDynamicBindings( |
+ version.get(), GetGLExtensionsFromCurrentContext(api_.get())); |
+ api_->set_version(std::move(version)); |
} |
void SetFakeExtensionString(const char* fake_string) { |
@@ -138,7 +118,6 @@ class GLApiTest : public testing::Test { |
static uint32_t num_fake_extension_strings_; |
static const char** fake_extension_strings_; |
- scoped_refptr<GLContext> fake_context_; |
std::unique_ptr<DriverGL> driver_; |
std::unique_ptr<RealGLApi> api_; |
}; |
@@ -176,14 +155,14 @@ TEST_F(GLApiTest, DisabledExtensionBitTest) { |
SetFakeExtensionStrings(kFakeExtensions, arraysize(kFakeExtensions)); |
InitializeAPI(nullptr); |
- EXPECT_TRUE(g_driver_gl.ext.b_GL_ARB_timer_query); |
+ EXPECT_TRUE(driver_->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); |
+ EXPECT_FALSE(driver_->ext.b_GL_ARB_timer_query); |
} |
TEST_F(GLApiTest, DisabledExtensionStringIndexTest) { |