summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gpu_browsertest.cc
diff options
context:
space:
mode:
authorapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-26 02:59:52 +0000
committerapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-26 02:59:52 +0000
commit466645f7eac5bce3e48e9bcf5fa1e004a60ea0d7 (patch)
tree3b33af460b974a98dc04b42a87271924610df99a /chrome/browser/gpu_browsertest.cc
parent2b0caae5cf87e861f12a669ad1ed36950c6bddbd (diff)
downloadchromium_src-466645f7eac5bce3e48e9bcf5fa1e004a60ea0d7.zip
chromium_src-466645f7eac5bce3e48e9bcf5fa1e004a60ea0d7.tar.gz
chromium_src-466645f7eac5bce3e48e9bcf5fa1e004a60ea0d7.tar.bz2
Added browser tests to ensure WebGL and 2D canvas can render to a newly opened window.
Review URL: http://codereview.chromium.org/7470003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94026 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gpu_browsertest.cc')
-rw-r--r--chrome/browser/gpu_browsertest.cc92
1 files changed, 92 insertions, 0 deletions
diff --git a/chrome/browser/gpu_browsertest.cc b/chrome/browser/gpu_browsertest.cc
new file mode 100644
index 0000000..4c86370
--- /dev/null
+++ b/chrome/browser/gpu_browsertest.cc
@@ -0,0 +1,92 @@
+// Copyright (c) 2011 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/path_service.h"
+#include "base/string16.h"
+#include "base/utf_string_conversions.h"
+#include "build/build_config.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/common/chrome_paths.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/test/in_process_browser_test.h"
+#include "chrome/test/test_launcher_utils.h"
+#include "chrome/test/ui_test_utils.h"
+#include "content/browser/tab_contents/tab_contents.h"
+#include "googleurl/src/gurl.h"
+#include "net/base/net_util.h"
+#include "ui/gfx/gl/gl_implementation.h"
+
+class GPUBrowserTest : public InProcessBrowserTest {
+ protected:
+ GPUBrowserTest() {
+ EnableDOMAutomation();
+ }
+
+ virtual void SetUpInProcessBrowserTestFixture() {
+ FilePath test_dir;
+ ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir));
+ gpu_test_dir_ = test_dir.AppendASCII("gpu");
+ }
+
+ virtual void SetUpCommandLine(CommandLine* command_line) {
+ InProcessBrowserTest::SetUpCommandLine(command_line);
+
+ EXPECT_TRUE(test_launcher_utils::OverrideGLImplementation(
+ command_line,
+ gfx::kGLImplementationOSMesaName));
+
+ command_line->AppendSwitch(switches::kDisablePopupBlocking);
+
+#if defined(OS_MACOSX)
+ // Accelerated compositing does not work with OSMesa. AcceleratedSurface
+ // assumes GL contexts are native.
+ command_line->AppendSwitch(switches::kDisableAcceleratedCompositing);
+#endif
+ }
+
+ FilePath gpu_test_dir_;
+};
+
+#if defined(TOOLKIT_VIEWS)
+// Flaky on Windows (dbg): http://crbug.com/72608
+// For ChromeOS: http://crbug.com/76217
+#define MAYBE_BrowserTestCanLaunchWithOSMesa DISABLED_BrowserTestCanLaunchWithOSMesa
+#else
+#define MAYBE_BrowserTestCanLaunchWithOSMesa BrowserTestCanLaunchWithOSMesa
+#endif
+
+IN_PROC_BROWSER_TEST_F(GPUBrowserTest, MAYBE_BrowserTestCanLaunchWithOSMesa) {
+ // Check the webgl test reports success and that the renderer was OSMesa.
+ ui_test_utils::NavigateToURL(
+ browser(),
+ net::FilePathToFileURL(gpu_test_dir_.AppendASCII("webgl.html")));
+
+ EXPECT_EQ(ASCIIToUTF16("SUCCESS: Mesa OffScreen"),
+ browser()->GetSelectedTabContents()->GetTitle());
+}
+
+IN_PROC_BROWSER_TEST_F(GPUBrowserTest, CanOpenPopupAndRenderWithWebGLCanvas) {
+ ui_test_utils::DOMMessageQueue message_queue;
+
+ ui_test_utils::NavigateToURL(
+ browser(),
+ net::FilePathToFileURL(gpu_test_dir_.AppendASCII("webgl_popup.html")));
+
+ std::string result;
+ ASSERT_TRUE(message_queue.WaitForMessage(&result));
+ EXPECT_EQ("\"SUCCESS\"", result);
+}
+
+IN_PROC_BROWSER_TEST_F(GPUBrowserTest, CanOpenPopupAndRenderWith2DCanvas) {
+ ui_test_utils::DOMMessageQueue message_queue;
+
+ ui_test_utils::NavigateToURL(
+ browser(),
+ net::FilePathToFileURL(gpu_test_dir_.AppendASCII("canvas_popup.html")));
+
+ std::string result;
+ ASSERT_TRUE(message_queue.WaitForMessage(&result));
+ EXPECT_EQ("\"SUCCESS\"", result);
+}