| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/common/chrome_paths.h" | 9 #include "content/public/browser/web_contents.h" |
| 10 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "content/public/common/content_paths.h" |
| 11 #include "chrome/test/base/ui_test_utils.h" | |
| 12 #include "content/public/common/content_switches.h" | 11 #include "content/public/common/content_switches.h" |
| 12 #include "content/public/test/browser_test_utils.h" |
| 13 #include "content/shell/shell.h" |
| 14 #include "content/test/content_browser_test.h" |
| 15 #include "content/test/content_browser_test_utils.h" |
| 13 #include "content/test/gpu/gpu_test_config.h" | 16 #include "content/test/gpu/gpu_test_config.h" |
| 14 #include "content/test/gpu/gpu_test_expectations_parser.h" | 17 #include "content/test/gpu/gpu_test_expectations_parser.h" |
| 15 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
| 16 | 19 |
| 17 namespace { | 20 namespace content { |
| 18 | 21 |
| 19 class WebGLConformanceTests : public InProcessBrowserTest { | 22 class WebGLConformanceTests : public ContentBrowserTest { |
| 20 public: | 23 public: |
| 21 WebGLConformanceTests() {} | 24 WebGLConformanceTests() {} |
| 22 | 25 |
| 23 virtual void SetUpCommandLine(CommandLine* command_line) { | 26 virtual void SetUpCommandLine(CommandLine* command_line) { |
| 24 // Allow privileged WebGL extensions. | 27 // Allow privileged WebGL extensions. |
| 25 command_line->AppendSwitch(switches::kEnablePrivilegedWebGLExtensions); | 28 command_line->AppendSwitch(switches::kEnablePrivilegedWebGLExtensions); |
| 26 } | 29 } |
| 27 | 30 |
| 28 virtual void SetUpInProcessBrowserTestFixture() { | 31 virtual void SetUpInProcessBrowserTestFixture() { |
| 29 FilePath webgl_conformance_path; | 32 FilePath webgl_conformance_path; |
| 30 PathService::Get(base::DIR_SOURCE_ROOT, &webgl_conformance_path); | 33 PathService::Get(base::DIR_SOURCE_ROOT, &webgl_conformance_path); |
| 31 webgl_conformance_path = webgl_conformance_path.Append( | 34 webgl_conformance_path = webgl_conformance_path.Append( |
| 32 FILE_PATH_LITERAL("third_party")); | 35 FILE_PATH_LITERAL("third_party")); |
| 33 webgl_conformance_path = webgl_conformance_path.Append( | 36 webgl_conformance_path = webgl_conformance_path.Append( |
| 34 FILE_PATH_LITERAL("webgl_conformance")); | 37 FILE_PATH_LITERAL("webgl_conformance")); |
| 35 ASSERT_TRUE(file_util::DirectoryExists(webgl_conformance_path)) | 38 ASSERT_TRUE(file_util::DirectoryExists(webgl_conformance_path)) |
| 36 << "Missing conformance tests: " << webgl_conformance_path.value(); | 39 << "Missing conformance tests: " << webgl_conformance_path.value(); |
| 37 | 40 |
| 38 PathService::Get(chrome::DIR_TEST_DATA, &test_path_); | 41 PathService::Get(DIR_TEST_DATA, &test_path_); |
| 39 test_path_ = test_path_.Append(FILE_PATH_LITERAL("gpu")); | 42 test_path_ = test_path_.Append(FILE_PATH_LITERAL("gpu")); |
| 40 test_path_ = test_path_.Append(FILE_PATH_LITERAL("webgl_conformance.html")); | 43 test_path_ = test_path_.Append(FILE_PATH_LITERAL("webgl_conformance.html")); |
| 41 | 44 |
| 42 ASSERT_TRUE(bot_config_.LoadCurrentConfig(NULL)) | 45 ASSERT_TRUE(bot_config_.LoadCurrentConfig(NULL)) |
| 43 << "Fail to load bot configuration"; | 46 << "Fail to load bot configuration"; |
| 44 ASSERT_TRUE(bot_config_.IsValid()) | 47 ASSERT_TRUE(bot_config_.IsValid()) |
| 45 << "Invalid bot configuration"; | 48 << "Invalid bot configuration"; |
| 46 | 49 |
| 47 ASSERT_TRUE(test_expectations_.LoadTestExpectations( | 50 ASSERT_TRUE(test_expectations_.LoadTestExpectations( |
| 48 GPUTestExpectationsParser::kWebGLConformanceTest)); | 51 GPUTestExpectationsParser::kWebGLConformanceTest)); |
| 49 } | 52 } |
| 50 | 53 |
| 51 void RunTest(const std::string& url) { | 54 void RunTest(const std::string& url) { |
| 52 std::string test_name = | 55 std::string test_name = |
| 53 testing::UnitTest::GetInstance()->current_test_info()->name(); | 56 testing::UnitTest::GetInstance()->current_test_info()->name(); |
| 54 int32 expectation = | 57 int32 expectation = |
| 55 test_expectations_.GetTestExpectation(test_name, bot_config_); | 58 test_expectations_.GetTestExpectation(test_name, bot_config_); |
| 56 if (expectation != GPUTestExpectationsParser::kGpuTestPass) { | 59 if (expectation != GPUTestExpectationsParser::kGpuTestPass) { |
| 57 LOG(WARNING) << "Test " << test_name << " is bypassed"; | 60 LOG(WARNING) << "Test " << test_name << " is bypassed"; |
| 58 return; | 61 return; |
| 59 } | 62 } |
| 60 | 63 |
| 61 ui_test_utils::DOMMessageQueue message_queue; | 64 DOMMessageQueue message_queue; |
| 62 ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(test_path_)); | 65 NavigateToURL(shell(), net::FilePathToFileURL(test_path_)); |
| 63 ui_test_utils::NavigateToURL( | |
| 64 browser(), GURL("javascript:start('" + url + "');")); | |
| 65 | 66 |
| 66 std::string message; | 67 std::string message; |
| 67 // Wait for message indicating the test has finished running. | 68 NavigateToURL(shell(), GURL("javascript:start('" + url + "');")); |
| 68 ASSERT_TRUE(message_queue.WaitForMessage(&message)); | 69 ASSERT_TRUE(message_queue.WaitForMessage(&message)); |
| 70 |
| 69 EXPECT_STREQ("\"SUCCESS\"", message.c_str()) << message; | 71 EXPECT_STREQ("\"SUCCESS\"", message.c_str()) << message; |
| 70 } | 72 } |
| 71 | 73 |
| 72 private: | 74 private: |
| 73 FilePath test_path_; | 75 FilePath test_path_; |
| 74 GPUTestBotConfig bot_config_; | 76 GPUTestBotConfig bot_config_; |
| 75 GPUTestExpectationsParser test_expectations_; | 77 GPUTestExpectationsParser test_expectations_; |
| 76 }; | 78 }; |
| 77 | 79 |
| 78 #define CONFORMANCE_TEST(name, url) \ | 80 #define CONFORMANCE_TEST(name, url) \ |
| 79 IN_PROC_BROWSER_TEST_F(WebGLConformanceTests, name) { \ | 81 IN_PROC_BROWSER_TEST_F(WebGLConformanceTests, MANUAL_##name) { \ |
| 80 RunTest(url); \ | 82 RunTest(url); \ |
| 81 } | 83 } |
| 82 | 84 |
| 83 // The test declarations are located in webgl_conformance_test_list_autogen.h, | 85 // The test declarations are located in webgl_conformance_test_list_autogen.h, |
| 84 // because the list is automatically generated by a script. | 86 // because the list is automatically generated by a script. |
| 85 // See: generate_webgl_conformance_test_list.py | 87 // See: generate_webgl_conformance_test_list.py |
| 86 #include "webgl_conformance_test_list_autogen.h" | 88 #include "webgl_conformance_test_list_autogen.h" |
| 87 | 89 |
| 88 } // namespace | 90 } // namespace content |
| OLD | NEW |