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

Side by Side Diff: ui/gl/egl_api_unittest.cc

Issue 2491993002: ui/gl: Initialize the ANGLE Platform on all configurations (Closed)
Patch Set: Rebase on top of the renaming of ClearGLBindings Created 4 years 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 unified diff | Download patch
« no previous file with comments | « ui/gl/BUILD.gn ('k') | ui/gl/gl_surface_egl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « ui/gl/BUILD.gn ('k') | ui/gl/gl_surface_egl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698