diff options
Diffstat (limited to 'chrome/test')
-rw-r--r-- | chrome/test/data/gpu/webgl_conformance.html | 50 | ||||
-rw-r--r-- | chrome/test/gpu/webgl_conformance_tests.cc | 75 |
2 files changed, 70 insertions, 55 deletions
diff --git a/chrome/test/data/gpu/webgl_conformance.html b/chrome/test/data/gpu/webgl_conformance.html index a173db8..ca067e7 100644 --- a/chrome/test/data/gpu/webgl_conformance.html +++ b/chrome/test/data/gpu/webgl_conformance.html @@ -5,10 +5,15 @@ </script> <script> var BASE_URL = "../../../../third_party/webgl_conformance/"; -var gl = null; +var running; +var result; var message; function start(start_url) { + running = true; + result = true; + message = ""; + // Report function called by each conformance test. function report(type, msg, success) { var reportType = WebGLTestHarnessModule.TestHarness.reportType; @@ -17,26 +22,21 @@ function start(start_url) { // Accept every page loaded. return true; case reportType.TEST_RESULT: - if (!success) - message = "FAILURE: " + msg; - else - message = "SUCCESS"; + if (!success) { + // If any test fails, the result is false. + result = false; + message += msg + "\n"; + } break; case reportType.FINISH_PAGE: - if (!success) - message = "TIMEOUT (" + window.webglTestHarness.timeoutDelay + " ms)"; - case reportType.FINISHED_ALL_TESTS: - if (message.substr(0, 7) != "SUCCESS") { - var ext = gl.getExtension("WEBGL_debug_renderer_info"); - if (ext) { - message += "\nGL_VENDOR: " + - gl.getParameter(ext.UNMASKED_VENDOR_WEBGL) + "\n"; - message += "GL_RENDERER: " + - gl.getParameter(ext.UNMASKED_RENDERER_WEBGL); - } + if (!success) { + // Result is false if a timeout occurs. + result = false; + message += "Timeout (" + window.webglTestHarness.timeoutDelay + + " ms)\n"; } - domAutomationController.setAutomationId(1); - domAutomationController.send(message); + case reportType.FINISHED_ALL_TESTS: + running = false; break; } } @@ -57,16 +57,16 @@ function start(start_url) { return context; } - message = ""; - // Assert the WebGL context exists. - gl = create3DContext(); - if (!gl) { - message = "FAILURE: unable to fetch WebGL context"; - domAutomationController.setAutomationId(1); - domAutomationController.send(message); + var context = create3DContext(); + if (!context) { + message += "Unable to fetch WebGL rendering context for Canvas.\n"; + running = false; + result = false; return; } + message += "WebGL VENDOR: " + context.getParameter(context.VENDOR) + "\n"; + message += "WebGL RENDERER: " + context.getParameter(context.RENDERER) + "\n"; var iframe = document.getElementById("testframe"); var testHarness = new WebGLTestHarnessModule.TestHarness( diff --git a/chrome/test/gpu/webgl_conformance_tests.cc b/chrome/test/gpu/webgl_conformance_tests.cc index b8ca609..2c171cb 100644 --- a/chrome/test/gpu/webgl_conformance_tests.cc +++ b/chrome/test/gpu/webgl_conformance_tests.cc @@ -2,31 +2,33 @@ // 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/file_util.h" #include "base/path_service.h" -#include "chrome/browser/ui/browser.h" +#include "base/test/test_timeouts.h" +#include "base/utf_string_conversions.h" #include "chrome/common/chrome_paths.h" -#include "chrome/test/base/in_process_browser_test.h" -#include "chrome/test/base/ui_test_utils.h" +#include "chrome/test/automation/tab_proxy.h" +#include "chrome/test/ui/javascript_test_util.h" +#include "chrome/test/ui/ui_test.h" #include "content/public/common/content_switches.h" #include "net/base/net_util.h" namespace { -class WebGLConformanceTests : public InProcessBrowserTest { +class WebGLConformanceTests : public UITest { public: - WebGLConformanceTests() {} - - virtual void SetUpCommandLine(CommandLine* command_line) { - // This enables DOM automation for tab contents. - EnableDOMAutomation(); + WebGLConformanceTests() { + show_window_ = true; + dom_automation_enabled_ = true; + } - // Allow privileged WebGL extensions. - command_line->AppendSwitch(switches::kEnablePrivilegedWebGLExtensions); + void SetUp() { + // Ensure that a GPU bot is never blacklisted. + launch_arguments_.AppendSwitch(switches::kIgnoreGpuBlacklist); + UITest::SetUp(); } - virtual void SetUpInProcessBrowserTestFixture() { + void RunTest(const std::string& url) { FilePath webgl_conformance_path; PathService::Get(base::DIR_SOURCE_ROOT, &webgl_conformance_path); webgl_conformance_path = webgl_conformance_path.Append( @@ -36,29 +38,42 @@ class WebGLConformanceTests : public InProcessBrowserTest { ASSERT_TRUE(file_util::DirectoryExists(webgl_conformance_path)) << "Missing conformance tests: " << webgl_conformance_path.value(); - PathService::Get(chrome::DIR_TEST_DATA, &test_path_); - test_path_ = test_path_.Append(FILE_PATH_LITERAL("gpu")); - test_path_ = test_path_.Append(FILE_PATH_LITERAL("webgl_conformance.html")); - } + FilePath test_path; + PathService::Get(chrome::DIR_TEST_DATA, &test_path); + test_path = test_path.Append(FILE_PATH_LITERAL("gpu")); + test_path = test_path.Append(FILE_PATH_LITERAL("webgl_conformance.html")); - void RunTest(const std::string& url) { - ui_test_utils::DOMMessageQueue message_queue; - ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(test_path_)); - ui_test_utils::NavigateToURL( - browser(), GURL("javascript:start('" + url + "');")); + scoped_refptr<TabProxy> tab(GetActiveTab()); + ASSERT_TRUE(tab.get()); - std::string message; - // Wait for message indicating the test has finished running. - ASSERT_TRUE(message_queue.WaitForMessage(&message)); - EXPECT_STREQ("\"SUCCESS\"", message.c_str()) << message; - } + ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, + tab->NavigateToURL(net::FilePathToFileURL(test_path))); + + ASSERT_TRUE(tab->NavigateToURLAsync( + GURL("javascript:start('" + url + "');"))); + + // Block until the test completes. + ASSERT_TRUE(WaitUntilJavaScriptCondition( + tab, L"", L"window.domAutomationController.send(!running);", + TestTimeouts::large_test_timeout_ms())); - private: - FilePath test_path_; + // Read out the test result. + std::wstring result, message; + ASSERT_TRUE(tab->ExecuteAndExtractString( + L"", + L"window.domAutomationController.send(JSON.stringify(result));", + &result)); + ASSERT_TRUE(tab->ExecuteAndExtractString( + L"", + L"window.domAutomationController.send(message);", + &message)); + + EXPECT_EQ(WideToUTF8(result),"true") << WideToUTF8(message); + } }; #define CONFORMANCE_TEST(name, url) \ -IN_PROC_BROWSER_TEST_F(WebGLConformanceTests, name) { \ +TEST_F(WebGLConformanceTests, name) { \ RunTest(url); \ } |