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

Unified 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, 7 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 side-by-side diff with in-line comments
Download patch
Index: ui/gl/egl_api_unittest.cc
diff --git a/ui/gl/egl_api_unittest.cc b/ui/gl/egl_api_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e5576ae0cf34410a39cc50dbeeee4663f5cf07c8
--- /dev/null
+++ b/ui/gl/egl_api_unittest.cc
@@ -0,0 +1,88 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/command_line.h"
+#include "base/memory/scoped_ptr.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gl/gl_egl_api_implementation.h"
+#include "ui/gl/gl_implementation.h"
+#include "ui/gl/gl_switches.h"
+
+namespace gfx {
+
+class EGLApiTest : public testing::Test {
+ public:
+ void SetUp() override {
+ fake_extension_string_ = "";
+
+ driver_.reset(new DriverEGL());
+ api_.reset(new RealEGLApi());
+
+ driver_->fn.eglQueryStringFn = &FakeQueryString;
+ driver_->fn.eglGetCurrentDisplayFn = &FakeGetCurrentDisplay;
+ }
+
+ void TearDown() override {
+ api_.reset(nullptr);
+ driver_.reset(nullptr);
+
+ fake_extension_string_ = "";
+ }
+
+ void InitializeAPI(base::CommandLine* command_line) {
+ api_.reset(new RealEGLApi());
+ if (command_line)
+ api_->InitializeWithCommandLine(driver_.get(), command_line);
+ else
+ api_->Initialize(driver_.get());
+ api_->InitializeWithContext();
+ }
+
+ void SetFakeExtensionString(const char* fake_string) {
+ fake_extension_string_ = fake_string;
+ }
+
+ static const char* GL_BINDING_CALL FakeQueryString(EGLDisplay dpy,
+ EGLint name) {
+ return fake_extension_string_;
+ }
+
+ static EGLDisplay GL_BINDING_CALL FakeGetCurrentDisplay() {
+ return nullptr;
+ }
+
+ const char* GetExtensions() {
+ EGLDisplay display = api_->eglGetCurrentDisplayFn();
+ return api_->eglQueryStringFn(display, EGL_EXTENSIONS);
+ }
+
+ protected:
+ static const char* fake_extension_string_;
+
+ scoped_ptr<DriverEGL> driver_;
+ scoped_ptr<RealEGLApi> api_;
+};
+
+const char* EGLApiTest::fake_extension_string_ = "";
+
+TEST_F(EGLApiTest, DisabledExtensionStringTest) {
+ static const char* kFakeExtensions = "EGL_EXT_1 EGL_EXT_2"
+ " EGL_EXT_3 EGL_EXT_4";
+ static const char* kFakeDisabledExtensions = "EGL_EXT_1,EGL_EXT_2,EGL_FAKE";
+ static const char* kFilteredExtensions = "EGL_EXT_3 EGL_EXT_4";
+
+ SetFakeExtensionString(kFakeExtensions);
+ InitializeAPI(nullptr);
+
+ EXPECT_STREQ(kFakeExtensions, GetExtensions());
+
+ base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
+ command_line.AppendSwitchASCII(switches::kDisableExtensions,
+ kFakeDisabledExtensions);
+ InitializeAPI(&command_line);
+
+ EXPECT_STREQ(kFilteredExtensions, GetExtensions());
+}
+
+} // namespace gpu
no sievers 2015/05/28 19:25:10 nit: s/gpu/gfx
David Yen 2015/06/05 23:59:51 Done.

Powered by Google App Engine
This is Rietveld 408576698