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

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

Issue 1151093006: Added disabling EGL extensions support with --disable-extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Setup global egl driver since we are using global functions to initialize the extension string Created 5 years, 6 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/command_line.h"
6 #include "base/memory/scoped_ptr.h"
7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/gl/gl_egl_api_implementation.h"
9 #include "ui/gl/gl_switches.h"
10
11 namespace gfx {
12
13 class EGLApiTest : public testing::Test {
14 public:
15 void SetUp() override {
16 fake_extension_string_ = "";
17
18 g_driver_egl.ClearBindings();
no sievers 2015/06/08 22:26:35 Can you add a TODO (and maybe file a bug) so that
David Yen 2015/06/09 20:43:15 Done.
19 g_driver_egl.fn.eglInitializeFn = &FakeInitialize;
20 g_driver_egl.fn.eglQueryStringFn = &FakeQueryString;
21 g_driver_egl.fn.eglGetCurrentDisplayFn = &FakeGetCurrentDisplay;
22 g_driver_egl.fn.eglGetDisplayFn = &FakeGetDisplay;
23 g_driver_egl.fn.eglGetErrorFn = &FakeGetError;
24 }
25
26 void TearDown() override {
27 g_current_egl_context = nullptr;
28 api_.reset(nullptr);
29 g_driver_egl.ClearBindings();
30
31 fake_extension_string_ = "";
32 }
33
34 void InitializeAPI(base::CommandLine* command_line) {
35 api_.reset(new RealEGLApi());
36 g_current_egl_context = api_.get();
37 if (command_line)
38 api_->InitializeWithCommandLine(&g_driver_egl, command_line);
39 else
40 api_->Initialize(&g_driver_egl);
41 api_->InitializeFilteredExtensions();
42 }
43
44 void SetFakeExtensionString(const char* fake_string) {
45 fake_extension_string_ = fake_string;
46 }
47
48 static EGLBoolean GL_BINDING_CALL FakeInitialize(EGLDisplay display,
49 EGLint * major,
50 EGLint * minor) {
51 return EGL_TRUE;
52 }
53
54 static const char* GL_BINDING_CALL FakeQueryString(EGLDisplay dpy,
55 EGLint name) {
56 return fake_extension_string_;
57 }
58
59 static EGLDisplay GL_BINDING_CALL FakeGetCurrentDisplay() {
60 return nullptr;
61 }
62
63 static EGLDisplay GL_BINDING_CALL FakeGetDisplay(
64 EGLNativeDisplayType native_display) {
65 return EGL_NO_DISPLAY;
66 }
67
68 static EGLint GL_BINDING_CALL FakeGetError() {
69 return EGL_SUCCESS;
70 }
71
72 const char* GetExtensions() {
73 EGLDisplay display = api_->eglGetCurrentDisplayFn();
74 return api_->eglQueryStringFn(display, EGL_EXTENSIONS);
75 }
76
77 protected:
78 static const char* fake_extension_string_;
79
80 scoped_ptr<RealEGLApi> api_;
81 };
82
83 const char* EGLApiTest::fake_extension_string_ = "";
84
85 TEST_F(EGLApiTest, DisabledExtensionStringTest) {
86 static const char* kFakeExtensions = "EGL_EXT_1 EGL_EXT_2"
87 " EGL_EXT_3 EGL_EXT_4";
88 static const char* kFakeDisabledExtensions = "EGL_EXT_1,EGL_EXT_2,EGL_FAKE";
89 static const char* kFilteredExtensions = "EGL_EXT_3 EGL_EXT_4";
90
91 SetFakeExtensionString(kFakeExtensions);
92 InitializeAPI(nullptr);
93
94 EXPECT_STREQ(kFakeExtensions, GetExtensions());
95
96 base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
97 command_line.AppendSwitchASCII(switches::kDisableGLExtensions,
98 kFakeDisabledExtensions);
99 InitializeAPI(&command_line);
100
101 EXPECT_STREQ(kFilteredExtensions, GetExtensions());
102 }
103
104 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/BUILD.gn ('k') | ui/gl/gl_api_unittest.cc » ('j') | ui/gl/gl_bindings.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698