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