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

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: Fixed some strange formatting 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_implementation.h"
10 #include "ui/gl/gl_switches.h"
11
12 namespace gfx {
13
14 class EGLApiTest : public testing::Test {
15 public:
16 void SetUp() override {
17 fake_extension_string_ = "";
18
19 driver_.reset(new DriverEGL());
20 api_.reset(new RealEGLApi());
21
22 driver_->fn.eglQueryStringFn = &FakeQueryString;
23 driver_->fn.eglGetCurrentDisplayFn = &FakeGetCurrentDisplay;
24 }
25
26 void TearDown() override {
27 api_.reset(nullptr);
28 driver_.reset(nullptr);
29
30 fake_extension_string_ = "";
31 }
32
33 void InitializeAPI(base::CommandLine* command_line) {
34 api_.reset(new RealEGLApi());
35 if (command_line)
36 api_->InitializeWithCommandLine(driver_.get(), command_line);
37 else
38 api_->Initialize(driver_.get());
39 api_->InitializeWithContext();
40 }
41
42 void SetFakeExtensionString(const char* fake_string) {
43 fake_extension_string_ = fake_string;
44 }
45
46 static const char* GL_BINDING_CALL FakeQueryString(EGLDisplay dpy,
47 EGLint name) {
48 return fake_extension_string_;
49 }
50
51 static EGLDisplay GL_BINDING_CALL FakeGetCurrentDisplay() {
52 return nullptr;
53 }
54
55 const char* GetExtensions() {
56 EGLDisplay display = api_->eglGetCurrentDisplayFn();
57 return api_->eglQueryStringFn(display, EGL_EXTENSIONS);
58 }
59
60 protected:
61 static const char* fake_extension_string_;
62
63 scoped_ptr<DriverEGL> driver_;
64 scoped_ptr<RealEGLApi> api_;
65 };
66
67 const char* EGLApiTest::fake_extension_string_ = "";
68
69 TEST_F(EGLApiTest, DisabledExtensionStringTest) {
70 static const char* kFakeExtensions = "EGL_EXT_1 EGL_EXT_2"
71 " EGL_EXT_3 EGL_EXT_4";
72 static const char* kFakeDisabledExtensions = "EGL_EXT_1,EGL_EXT_2,EGL_FAKE";
73 static const char* kFilteredExtensions = "EGL_EXT_3 EGL_EXT_4";
74
75 SetFakeExtensionString(kFakeExtensions);
76 InitializeAPI(nullptr);
77
78 EXPECT_STREQ(kFakeExtensions, GetExtensions());
79
80 base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
81 command_line.AppendSwitchASCII(switches::kDisableExtensions,
82 kFakeDisabledExtensions);
83 InitializeAPI(&command_line);
84
85 EXPECT_STREQ(kFilteredExtensions, GetExtensions());
86 }
87
88 } // namespace gpu
no sievers 2015/05/28 19:25:10 nit: s/gpu/gfx
David Yen 2015/06/05 23:59:51 Done.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698