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