| 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 "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
| 10 #include "content/public/common/content_paths.h" | 10 #include "content/public/common/content_paths.h" |
| 11 #include "content/public/common/content_switches.h" | 11 #include "content/public/common/content_switches.h" |
| 12 #include "content/public/test/browser_test_utils.h" | 12 #include "content/public/test/browser_test_utils.h" |
| 13 #include "content/shell/shell.h" | 13 #include "content/shell/shell.h" |
| 14 #include "content/test/content_browser_test.h" | 14 #include "content/test/content_browser_test.h" |
| 15 #include "content/test/content_browser_test_utils.h" | 15 #include "content/test/content_browser_test_utils.h" |
| 16 #include "content/test/gpu/gpu_test_config.h" | 16 #include "gpu/config/gpu_test_config.h" |
| 17 #include "content/test/gpu/gpu_test_expectations_parser.h" | 17 #include "gpu/config/gpu_test_expectations_parser.h" |
| 18 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
| 19 | 19 |
| 20 namespace content { | 20 namespace content { |
| 21 | 21 |
| 22 class WebGLConformanceTest : public ContentBrowserTest { | 22 class WebGLConformanceTest : public ContentBrowserTest { |
| 23 public: | 23 public: |
| 24 WebGLConformanceTest() {} | 24 WebGLConformanceTest() {} |
| 25 | 25 |
| 26 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 26 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 27 // Allow privileged WebGL extensions. | 27 // Allow privileged WebGL extensions. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 45 | 45 |
| 46 PathService::Get(DIR_TEST_DATA, &test_path_); | 46 PathService::Get(DIR_TEST_DATA, &test_path_); |
| 47 test_path_ = test_path_.Append(FILE_PATH_LITERAL("gpu")); | 47 test_path_ = test_path_.Append(FILE_PATH_LITERAL("gpu")); |
| 48 test_path_ = test_path_.Append(FILE_PATH_LITERAL("webgl_conformance.html")); | 48 test_path_ = test_path_.Append(FILE_PATH_LITERAL("webgl_conformance.html")); |
| 49 | 49 |
| 50 ASSERT_TRUE(bot_config_.LoadCurrentConfig(NULL)) | 50 ASSERT_TRUE(bot_config_.LoadCurrentConfig(NULL)) |
| 51 << "Fail to load bot configuration"; | 51 << "Fail to load bot configuration"; |
| 52 ASSERT_TRUE(bot_config_.IsValid()) | 52 ASSERT_TRUE(bot_config_.IsValid()) |
| 53 << "Invalid bot configuration"; | 53 << "Invalid bot configuration"; |
| 54 | 54 |
| 55 ASSERT_TRUE(test_expectations_.LoadTestExpectations( | 55 base::FilePath path; |
| 56 GPUTestExpectationsParser::kWebGLConformanceTest)); | 56 ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &path)); |
| 57 path = path.Append(FILE_PATH_LITERAL("gpu")) |
| 58 .Append(FILE_PATH_LITERAL("webgl_conformance_test_expectations.txt")); |
| 59 ASSERT_TRUE(file_util::PathExists(path)); |
| 60 ASSERT_TRUE(test_expectations_.LoadTestExpectations(path)); |
| 57 } | 61 } |
| 58 | 62 |
| 59 void RunTest(std::string url, std::string test_name) { | 63 void RunTest(std::string url, std::string test_name) { |
| 60 int32 expectation = | 64 int32 expectation = |
| 61 test_expectations_.GetTestExpectation(test_name, bot_config_); | 65 test_expectations_.GetTestExpectation(test_name, bot_config_); |
| 62 if (expectation != GPUTestExpectationsParser::kGpuTestPass) { | 66 if (expectation != gpu::GPUTestExpectationsParser::kGpuTestPass) { |
| 63 LOG(WARNING) << "Test " << test_name << " is bypassed"; | 67 LOG(WARNING) << "Test " << test_name << " is bypassed"; |
| 64 return; | 68 return; |
| 65 } | 69 } |
| 66 | 70 |
| 67 DOMMessageQueue message_queue; | 71 DOMMessageQueue message_queue; |
| 68 NavigateToURL(shell(), net::FilePathToFileURL(test_path_)); | 72 NavigateToURL(shell(), net::FilePathToFileURL(test_path_)); |
| 69 | 73 |
| 70 std::string message; | 74 std::string message; |
| 71 NavigateToURL(shell(), GURL("javascript:start('" + url + "');")); | 75 NavigateToURL(shell(), GURL("javascript:start('" + url + "');")); |
| 72 ASSERT_TRUE(message_queue.WaitForMessage(&message)); | 76 ASSERT_TRUE(message_queue.WaitForMessage(&message)); |
| 73 | 77 |
| 74 EXPECT_STREQ("\"SUCCESS\"", message.c_str()) << message; | 78 EXPECT_STREQ("\"SUCCESS\"", message.c_str()) << message; |
| 75 } | 79 } |
| 76 | 80 |
| 77 private: | 81 private: |
| 78 base::FilePath test_path_; | 82 base::FilePath test_path_; |
| 79 GPUTestBotConfig bot_config_; | 83 gpu::GPUTestBotConfig bot_config_; |
| 80 GPUTestExpectationsParser test_expectations_; | 84 gpu::GPUTestExpectationsParser test_expectations_; |
| 81 }; | 85 }; |
| 82 | 86 |
| 83 #define CONFORMANCE_TEST(name, url) \ | 87 #define CONFORMANCE_TEST(name, url) \ |
| 84 IN_PROC_BROWSER_TEST_F(WebGLConformanceTest, MANUAL_##name) { \ | 88 IN_PROC_BROWSER_TEST_F(WebGLConformanceTest, MANUAL_##name) { \ |
| 85 RunTest(url, #name); \ | 89 RunTest(url, #name); \ |
| 86 } | 90 } |
| 87 | 91 |
| 88 // The test declarations are located in webgl_conformance_test_list_autogen.h, | 92 // The test declarations are located in webgl_conformance_test_list_autogen.h, |
| 89 // because the list is automatically generated by a script. | 93 // because the list is automatically generated by a script. |
| 90 // See: generate_webgl_conformance_test_list.py | 94 // See: generate_webgl_conformance_test_list.py |
| 91 #include "webgl_conformance_test_list_autogen.h" | 95 #include "webgl_conformance_test_list_autogen.h" |
| 92 | 96 |
| 93 } // namespace content | 97 } // namespace content |
| OLD | NEW |