| 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_egl_api_implementation.h" | 9 #include "ui/gl/gl_egl_api_implementation.h" |
| 10 #include "ui/gl/gl_surface_egl.h" | 10 #include "ui/gl/gl_surface_egl.h" |
| 11 #include "ui/gl/gl_switches.h" | 11 #include "ui/gl/gl_switches.h" |
| 12 | 12 |
| 13 namespace gl { | 13 namespace gl { |
| 14 | 14 |
| 15 class EGLApiTest : public testing::Test { | 15 class EGLApiTest : public testing::Test { |
| 16 public: | 16 public: |
| 17 void SetUp() override { | 17 void SetUp() override { |
| 18 fake_client_extension_string_ = ""; | 18 fake_client_extension_string_ = ""; |
| 19 fake_extension_string_ = ""; | 19 fake_extension_string_ = ""; |
| 20 | 20 |
| 21 // TODO(dyen): Add a way to bind mock drivers for testing. | 21 // TODO(dyen): Add a way to bind mock drivers for testing. |
| 22 g_driver_egl.ClearBindings(); | 22 g_driver_egl.ClearBindings(); |
| 23 g_driver_egl.fn.eglInitializeFn = &FakeInitialize; | 23 g_driver_egl.fn.eglInitializeFn = &FakeInitialize; |
| 24 g_driver_egl.fn.eglQueryStringFn = &FakeQueryString; | 24 g_driver_egl.fn.eglQueryStringFn = &FakeQueryString; |
| 25 g_driver_egl.fn.eglGetCurrentDisplayFn = &FakeGetCurrentDisplay; | 25 g_driver_egl.fn.eglGetCurrentDisplayFn = &FakeGetCurrentDisplay; |
| 26 g_driver_egl.fn.eglGetDisplayFn = &FakeGetDisplay; | 26 g_driver_egl.fn.eglGetDisplayFn = &FakeGetDisplay; |
| 27 g_driver_egl.fn.eglGetErrorFn = &FakeGetError; | 27 g_driver_egl.fn.eglGetErrorFn = &FakeGetError; |
| 28 g_driver_egl.fn.eglGetProcAddressFn = &FakeGetProcAddress; |
| 28 } | 29 } |
| 29 | 30 |
| 30 void TearDown() override { | 31 void TearDown() override { |
| 31 g_current_egl_context = nullptr; | 32 g_current_egl_context = nullptr; |
| 32 api_.reset(nullptr); | 33 api_.reset(nullptr); |
| 33 g_driver_egl.ClearBindings(); | 34 g_driver_egl.ClearBindings(); |
| 34 | 35 |
| 35 fake_client_extension_string_ = ""; | 36 fake_client_extension_string_ = ""; |
| 36 fake_extension_string_ = ""; | 37 fake_extension_string_ = ""; |
| 37 } | 38 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 76 |
| 76 static EGLDisplay GL_BINDING_CALL FakeGetDisplay( | 77 static EGLDisplay GL_BINDING_CALL FakeGetDisplay( |
| 77 EGLNativeDisplayType native_display) { | 78 EGLNativeDisplayType native_display) { |
| 78 return reinterpret_cast<EGLDisplay>(0x1); | 79 return reinterpret_cast<EGLDisplay>(0x1); |
| 79 } | 80 } |
| 80 | 81 |
| 81 static EGLint GL_BINDING_CALL FakeGetError() { | 82 static EGLint GL_BINDING_CALL FakeGetError() { |
| 82 return EGL_SUCCESS; | 83 return EGL_SUCCESS; |
| 83 } | 84 } |
| 84 | 85 |
| 86 static __eglMustCastToProperFunctionPointerType GL_BINDING_CALL |
| 87 FakeGetProcAddress(const char* procname) { |
| 88 return nullptr; |
| 89 } |
| 90 |
| 85 std::pair<const char*, const char*> GetExtensions() { | 91 std::pair<const char*, const char*> GetExtensions() { |
| 86 return std::make_pair( | 92 return std::make_pair( |
| 87 api_->eglQueryStringFn(EGL_NO_DISPLAY, EGL_EXTENSIONS), | 93 api_->eglQueryStringFn(EGL_NO_DISPLAY, EGL_EXTENSIONS), |
| 88 api_->eglQueryStringFn(api_->eglGetCurrentDisplayFn(), EGL_EXTENSIONS)); | 94 api_->eglQueryStringFn(api_->eglGetCurrentDisplayFn(), EGL_EXTENSIONS)); |
| 89 } | 95 } |
| 90 | 96 |
| 91 protected: | 97 protected: |
| 92 static const char* fake_extension_string_; | 98 static const char* fake_extension_string_; |
| 93 static const char* fake_client_extension_string_; | 99 static const char* fake_client_extension_string_; |
| 94 | 100 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 141 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 136 command_line.AppendSwitchASCII(switches::kDisableGLExtensions, | 142 command_line.AppendSwitchASCII(switches::kDisableGLExtensions, |
| 137 kFakeDisabledExtensions); | 143 kFakeDisabledExtensions); |
| 138 InitializeAPI(&command_line); | 144 InitializeAPI(&command_line); |
| 139 | 145 |
| 140 EXPECT_STREQ(kFilteredClientExtensions, GetExtensions().first); | 146 EXPECT_STREQ(kFilteredClientExtensions, GetExtensions().first); |
| 141 EXPECT_STREQ(kFilteredExtensions, GetExtensions().second); | 147 EXPECT_STREQ(kFilteredExtensions, GetExtensions().second); |
| 142 } | 148 } |
| 143 | 149 |
| 144 } // namespace gl | 150 } // namespace gl |
| OLD | NEW |