| 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "ui/gl/gl_implementation.h" | 9 #include "ui/gl/gl_implementation.h" |
| 10 #include "ui/gl/gl_surface_wgl.h" | 10 #include "ui/gl/gl_surface_wgl.h" |
| 11 #include "ui/gl/gl_wgl_api_implementation.h" | 11 #include "ui/gl/gl_wgl_api_implementation.h" |
| 12 | 12 |
| 13 typedef std::pair<std::string, std::string> stringpair; | 13 typedef std::pair<std::string, std::string> stringpair; |
| 14 | 14 |
| 15 namespace gl { | 15 namespace gl { |
| 16 | 16 |
| 17 class WGLApiTest : public testing::Test { | 17 class WGLApiTest : public testing::Test { |
| 18 public: | 18 public: |
| 19 void SetUp() override { | 19 void SetUp() override { |
| 20 GLSurfaceWGL::InitializeOneOffForTesting(); | 20 GLSurfaceWGL::InitializeOneOffForTesting(); |
| 21 fake_arb_extension_string_ = ""; | 21 fake_arb_extension_string_ = ""; |
| 22 fake_ext_extension_string_ = ""; | 22 fake_ext_extension_string_ = ""; |
| 23 | 23 |
| 24 g_driver_wgl.ClearBindings(); | 24 g_driver_wgl.ClearBindings(); |
| 25 g_driver_wgl.fn.wglGetExtensionsStringARBFn = &FakeGetExtensionsStringARB; | 25 g_driver_wgl.fn.wglGetExtensionsStringARBFn = &FakeGetExtensionsStringARB; |
| 26 g_driver_wgl.fn.wglGetExtensionsStringEXTFn = &FakeGetExtensionsStringEXT; | 26 g_driver_wgl.fn.wglGetExtensionsStringEXTFn = &FakeGetExtensionsStringEXT; |
| 27 SetGLImplementation(kGLImplementationDesktopGL); | 27 SetGLImplementation(kGLImplementationDesktopGL); |
| 28 SetGLGetProcAddressProc( | 28 SetGLGetProcAddressProc(&FakeGLGetProcAddress); |
| 29 static_cast<GLGetProcAddressProc>(&FakeGLGetProcAddress)); | |
| 30 } | 29 } |
| 31 | 30 |
| 32 void TearDown() override { | 31 void TearDown() override { |
| 33 g_current_wgl_context = nullptr; | 32 g_current_wgl_context = nullptr; |
| 34 api_.reset(nullptr); | 33 api_.reset(nullptr); |
| 35 g_driver_wgl.ClearBindings(); | 34 g_driver_wgl.ClearBindings(); |
| 36 | 35 |
| 37 fake_ext_extension_string_ = ""; | 36 fake_ext_extension_string_ = ""; |
| 38 fake_arb_extension_string_ = ""; | 37 fake_arb_extension_string_ = ""; |
| 39 } | 38 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 58 | 57 |
| 59 stringpair GetExtensions() { | 58 stringpair GetExtensions() { |
| 60 auto stringify = [](const char* str) -> std::string { | 59 auto stringify = [](const char* str) -> std::string { |
| 61 return str ? str : ""; | 60 return str ? str : ""; |
| 62 }; | 61 }; |
| 63 return stringpair( | 62 return stringpair( |
| 64 stringify(wglGetExtensionsStringARB(NULL)), | 63 stringify(wglGetExtensionsStringARB(NULL)), |
| 65 stringify(wglGetExtensionsStringEXT())); | 64 stringify(wglGetExtensionsStringEXT())); |
| 66 } | 65 } |
| 67 | 66 |
| 68 static void* GL_BINDING_CALL FakeGLGetProcAddress(const char *proc) { | 67 static GLFunctionPointerType WINAPI FakeGLGetProcAddress(const char* proc) { |
| 69 return NULL; | 68 return NULL; |
| 70 } | 69 } |
| 71 | 70 |
| 72 static const char* GL_BINDING_CALL FakeGetExtensionsStringARB(HDC dc) { | 71 static const char* GL_BINDING_CALL FakeGetExtensionsStringARB(HDC dc) { |
| 73 return fake_arb_extension_string_; | 72 return fake_arb_extension_string_; |
| 74 } | 73 } |
| 75 | 74 |
| 76 static const char* GL_BINDING_CALL FakeGetExtensionsStringEXT() { | 75 static const char* GL_BINDING_CALL FakeGetExtensionsStringEXT() { |
| 77 return fake_ext_extension_string_; | 76 return fake_ext_extension_string_; |
| 78 } | 77 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 InitializeAPI(nullptr); | 144 InitializeAPI(nullptr); |
| 146 EXPECT_EQ(stringpair(kFakeExtensions, kFakeExtensions), | 145 EXPECT_EQ(stringpair(kFakeExtensions, kFakeExtensions), |
| 147 GetExtensions()); | 146 GetExtensions()); |
| 148 | 147 |
| 149 InitializeAPI(&command_line); | 148 InitializeAPI(&command_line); |
| 150 EXPECT_EQ(stringpair(kFilteredExtensions, kFilteredExtensions), | 149 EXPECT_EQ(stringpair(kFilteredExtensions, kFilteredExtensions), |
| 151 GetExtensions()); | 150 GetExtensions()); |
| 152 } | 151 } |
| 153 | 152 |
| 154 } // namespace gl | 153 } // namespace gl |
| OLD | NEW |