OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/file_path.h" | 5 #include "base/file_path.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/platform_thread.h" | 8 #include "base/platform_thread.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "chrome/browser/worker_host/worker_service.h" | 10 #include "chrome/browser/worker_host/worker_service.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 std::string* expected_result_value); | 48 std::string* expected_result_value); |
49 | 49 |
50 bool initialized_for_layout_test_; | 50 bool initialized_for_layout_test_; |
51 int test_count_; | 51 int test_count_; |
52 FilePath temp_test_dir_; | 52 FilePath temp_test_dir_; |
53 FilePath layout_test_dir_; | 53 FilePath layout_test_dir_; |
54 FilePath test_case_dir_; | 54 FilePath test_case_dir_; |
55 FilePath new_http_root_dir_; | 55 FilePath new_http_root_dir_; |
56 FilePath new_layout_test_dir_; | 56 FilePath new_layout_test_dir_; |
57 FilePath rebase_result_dir_; | 57 FilePath rebase_result_dir_; |
58 FilePath rebase_result_win_dir_; | |
58 std::string layout_test_controller_; | 59 std::string layout_test_controller_; |
59 }; | 60 }; |
60 | 61 |
61 WorkerTest::WorkerTest() | 62 WorkerTest::WorkerTest() |
62 : UITest(), initialized_for_layout_test_(false), test_count_(0) { | 63 : UITest(), initialized_for_layout_test_(false), test_count_(0) { |
63 } | 64 } |
64 | 65 |
65 WorkerTest::~WorkerTest() { | 66 WorkerTest::~WorkerTest() { |
66 // The deletion might fail because HTTP server process might not been | 67 // The deletion might fail because HTTP server process might not been |
67 // completely shut down yet and is still holding certain handle to it. | 68 // completely shut down yet and is still holding certain handle to it. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 // This is because our build machines do not have WebKit layout tests added. | 111 // This is because our build machines do not have WebKit layout tests added. |
111 layout_test_dir_ = src_dir.AppendASCII("chrome"); | 112 layout_test_dir_ = src_dir.AppendASCII("chrome"); |
112 layout_test_dir_ = layout_test_dir_.AppendASCII("test"); | 113 layout_test_dir_ = layout_test_dir_.AppendASCII("test"); |
113 layout_test_dir_ = layout_test_dir_.AppendASCII("data"); | 114 layout_test_dir_ = layout_test_dir_.AppendASCII("data"); |
114 layout_test_dir_ = layout_test_dir_.AppendASCII("workers"); | 115 layout_test_dir_ = layout_test_dir_.AppendASCII("workers"); |
115 layout_test_dir_ = layout_test_dir_.Append(test_parent_dir); | 116 layout_test_dir_ = layout_test_dir_.Append(test_parent_dir); |
116 layout_test_dir_ = layout_test_dir_.Append(test_case_dir); | 117 layout_test_dir_ = layout_test_dir_.Append(test_case_dir); |
117 | 118 |
118 // If not found, try to use the original copy of WebKit layout tests for | 119 // If not found, try to use the original copy of WebKit layout tests for |
119 // workers. For testing only in local machine only. | 120 // workers. For testing only in local machine only. |
120 // webkit/data/layout_tests/LayoutTests/.../workers | 121 // third_party/LayoutTests/.../workers |
121 if (!file_util::DirectoryExists(layout_test_dir_)) { | 122 if (!file_util::DirectoryExists(layout_test_dir_)) { |
122 layout_test_dir_ = src_dir.AppendASCII("webkit"); | 123 layout_test_dir_ = src_dir.AppendASCII("third_party"); |
123 layout_test_dir_ = layout_test_dir_.AppendASCII("data"); | |
124 layout_test_dir_ = layout_test_dir_.AppendASCII("layout_tests"); | |
125 layout_test_dir_ = layout_test_dir_.Append(test_parent_dir); | 124 layout_test_dir_ = layout_test_dir_.Append(test_parent_dir); |
126 layout_test_dir_ = layout_test_dir_.Append(test_case_dir); | 125 layout_test_dir_ = layout_test_dir_.Append(test_case_dir); |
127 ASSERT_TRUE(file_util::DirectoryExists(layout_test_dir_)); | 126 ASSERT_TRUE(file_util::DirectoryExists(layout_test_dir_)); |
128 } | 127 } |
129 | 128 |
130 // Gets the file path to rebased expected result directory for workers. | 129 // Gets the file path to rebased expected result directory for workers for |
130 // current platform. | |
131 // webkit/data/layout_tests/platform/chromium_***/LayoutTests/.../workers | 131 // webkit/data/layout_tests/platform/chromium_***/LayoutTests/.../workers |
132 rebase_result_dir_ = src_dir.AppendASCII("webkit"); | 132 rebase_result_dir_ = src_dir.AppendASCII("webkit"); |
133 rebase_result_dir_ = rebase_result_dir_.AppendASCII("data"); | 133 rebase_result_dir_ = rebase_result_dir_.AppendASCII("data"); |
134 rebase_result_dir_ = rebase_result_dir_.AppendASCII("layout_tests"); | 134 rebase_result_dir_ = rebase_result_dir_.AppendASCII("layout_tests"); |
135 rebase_result_dir_ = rebase_result_dir_.AppendASCII("platform"); | 135 rebase_result_dir_ = rebase_result_dir_.AppendASCII("platform"); |
136 rebase_result_dir_ = rebase_result_dir_.AppendASCII(kPlatformName); | 136 rebase_result_dir_ = rebase_result_dir_.AppendASCII(kPlatformName); |
137 rebase_result_dir_ = rebase_result_dir_.Append(test_parent_dir); | 137 rebase_result_dir_ = rebase_result_dir_.Append(test_parent_dir); |
138 rebase_result_dir_ = rebase_result_dir_.Append(test_case_dir); | 138 rebase_result_dir_ = rebase_result_dir_.Append(test_case_dir); |
139 | 139 |
140 // Gets the file path to rebased expected result directory for workers under | |
141 // win32 platform. This is used by other non-win32 platform to use the same | |
142 // rebased expected results. | |
143 #if !defined(OS_WIN) | |
144 rebase_result_win_dir_ = src_dir.AppendASCII("webkit"); | |
145 rebase_result_win_dir_ = rebase_result_win_dir_.AppendASCII("data"); | |
146 rebase_result_win_dir_ = rebase_result_win_dir_.AppendASCII("layout_tests"); | |
147 rebase_result_win_dir_ = rebase_result_win_dir_.AppendASCII("platform"); | |
148 rebase_result_win_dir_ = rebase_result_win_dir_.AppendASCII("chromium-win"); | |
149 rebase_result_win_dir_ = rebase_result_win_dir_.Append(test_parent_dir); | |
150 rebase_result_win_dir_ = rebase_result_win_dir_.Append(test_case_dir); | |
151 #endif | |
152 | |
140 // Creates the temporary directory. | 153 // Creates the temporary directory. |
141 ASSERT_TRUE(file_util::CreateNewTempDirectory( | 154 ASSERT_TRUE(file_util::CreateNewTempDirectory( |
142 FILE_PATH_LITERAL("chrome_worker_test_"), &temp_test_dir_)); | 155 FILE_PATH_LITERAL("chrome_worker_test_"), &temp_test_dir_)); |
143 | 156 |
144 // Creates the new layout test subdirectory under the temp directory. | 157 // Creates the new layout test subdirectory under the temp directory. |
145 // Note that we have to mimic the same layout test directory structure, | 158 // Note that we have to mimic the same layout test directory structure, |
146 // like .../LayoutTests/fast/workers/.... Otherwise those layout tests | 159 // like .../LayoutTests/fast/workers/.... Otherwise those layout tests |
147 // dealing with location property, like worker-location.html, could fail. | 160 // dealing with location property, like worker-location.html, could fail. |
148 new_layout_test_dir_ = temp_test_dir_; | 161 new_layout_test_dir_ = temp_test_dir_; |
149 new_layout_test_dir_ = new_layout_test_dir_.Append(test_parent_dir); | 162 new_layout_test_dir_ = new_layout_test_dir_.Append(test_parent_dir); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
237 UnescapeRule::NORMAL | UnescapeRule::SPACES | | 250 UnescapeRule::NORMAL | UnescapeRule::SPACES | |
238 UnescapeRule::URL_SPECIAL_CHARS | UnescapeRule::CONTROL_CHARS); | 251 UnescapeRule::URL_SPECIAL_CHARS | UnescapeRule::CONTROL_CHARS); |
239 value += "\n"; | 252 value += "\n"; |
240 ReplaceSubstringsAfterOffset(&value, 0, "\r", ""); | 253 ReplaceSubstringsAfterOffset(&value, 0, "\r", ""); |
241 | 254 |
242 // Reads the expected result. First try to read from rebase directory. | 255 // Reads the expected result. First try to read from rebase directory. |
243 // If failed, read from original directory. | 256 // If failed, read from original directory. |
244 std::string expected_result_value; | 257 std::string expected_result_value; |
245 if (!ReadExpectedResult(rebase_result_dir_, | 258 if (!ReadExpectedResult(rebase_result_dir_, |
246 test_case_file_name, | 259 test_case_file_name, |
247 &expected_result_value)) | 260 &expected_result_value)) { |
248 ReadExpectedResult(layout_test_dir_, | 261 if (rebase_result_win_dir_.empty() || |
249 test_case_file_name, | 262 !ReadExpectedResult(rebase_result_win_dir_, |
250 &expected_result_value); | 263 test_case_file_name, |
264 &expected_result_value)) | |
levin
2009/07/28 00:59:05
indent off.
| |
265 ReadExpectedResult(layout_test_dir_, | |
266 test_case_file_name, | |
267 &expected_result_value); | |
268 } | |
251 ASSERT_TRUE(!expected_result_value.empty()); | 269 ASSERT_TRUE(!expected_result_value.empty()); |
252 | 270 |
253 // Normalizes the expected result. | 271 // Normalizes the expected result. |
254 ReplaceSubstringsAfterOffset(&expected_result_value, 0, "\r", ""); | 272 ReplaceSubstringsAfterOffset(&expected_result_value, 0, "\r", ""); |
255 | 273 |
256 // Compares the results. | 274 // Compares the results. |
257 EXPECT_STREQ(expected_result_value.c_str(), value.c_str()); | 275 EXPECT_STREQ(expected_result_value.c_str(), value.c_str()); |
258 } | 276 } |
259 | 277 |
260 bool WorkerTest::ReadExpectedResult(const FilePath& result_dir_path, | 278 bool WorkerTest::ReadExpectedResult(const FilePath& result_dir_path, |
(...skipping 15 matching lines...) Expand all Loading... | |
276 | 294 |
277 TEST_F(WorkerTest, MultipleWorkers) { | 295 TEST_F(WorkerTest, MultipleWorkers) { |
278 RunTest(L"multi_worker.html"); | 296 RunTest(L"multi_worker.html"); |
279 } | 297 } |
280 | 298 |
281 TEST_F(WorkerTest, WorkerFastLayoutTests) { | 299 TEST_F(WorkerTest, WorkerFastLayoutTests) { |
282 static const char* kLayoutTestFiles[] = { | 300 static const char* kLayoutTestFiles[] = { |
283 "stress-js-execution.html", | 301 "stress-js-execution.html", |
284 "use-machine-stack.html", | 302 "use-machine-stack.html", |
285 "worker-close.html", | 303 "worker-close.html", |
286 //"worker-constructor.html", | 304 "worker-constructor.html", |
287 "worker-context-gc.html", | 305 "worker-context-gc.html", |
288 "worker-event-listener.html", | 306 "worker-event-listener.html", |
289 "worker-gc.html", | 307 "worker-gc.html", |
290 "worker-location.html", | 308 "worker-location.html", |
291 "worker-navigator.html", | 309 "worker-navigator.html", |
292 "worker-replace-global-constructor.html", | 310 "worker-replace-global-constructor.html", |
293 "worker-replace-self.html", | 311 "worker-replace-self.html", |
312 "worker-script-error.html", | |
294 "worker-terminate.html", | 313 "worker-terminate.html", |
295 "worker-timeout.html" | 314 "worker-timeout.html" |
296 }; | 315 }; |
297 | 316 |
298 FilePath fast_test_dir; | 317 FilePath fast_test_dir; |
299 fast_test_dir = fast_test_dir.AppendASCII("LayoutTests"); | 318 fast_test_dir = fast_test_dir.AppendASCII("LayoutTests"); |
300 fast_test_dir = fast_test_dir.AppendASCII("fast"); | 319 fast_test_dir = fast_test_dir.AppendASCII("fast"); |
301 | 320 |
302 FilePath worker_test_dir; | 321 FilePath worker_test_dir; |
303 worker_test_dir = worker_test_dir.AppendASCII("workers"); | 322 worker_test_dir = worker_test_dir.AppendASCII("workers"); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
386 EXPECT_EQ(total_workers + 1 + (UITest::in_process_renderer() ? 0 : tab_count), | 405 EXPECT_EQ(total_workers + 1 + (UITest::in_process_renderer() ? 0 : tab_count), |
387 UITest::GetBrowserProcessCount()); | 406 UITest::GetBrowserProcessCount()); |
388 | 407 |
389 // Now close the first tab and check that the queued workers were started. | 408 // Now close the first tab and check that the queued workers were started. |
390 tab->Close(true); | 409 tab->Close(true); |
391 tab->NavigateToURL(GetTestUrl(L"google", L"google.html")); | 410 tab->NavigateToURL(GetTestUrl(L"google", L"google.html")); |
392 | 411 |
393 EXPECT_EQ(total_workers + 1 + (UITest::in_process_renderer() ? 0 : tab_count), | 412 EXPECT_EQ(total_workers + 1 + (UITest::in_process_renderer() ? 0 : tab_count), |
394 UITest::GetBrowserProcessCount()); | 413 UITest::GetBrowserProcessCount()); |
395 } | 414 } |
OLD | NEW |