Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
| 11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
| 12 #include "base/string_util.h" | |
| 12 #include "base/sys_string_conversions.h" | 13 #include "base/sys_string_conversions.h" |
| 13 #include "base/test/test_timeouts.h" | 14 #include "base/test/test_timeouts.h" |
| 14 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/net/url_fixer_upper.h" | 16 #include "chrome/browser/net/url_fixer_upper.h" |
| 16 #include "chrome/common/chrome_constants.h" | 17 #include "chrome/common/chrome_constants.h" |
| 17 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
| 18 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/test/automation/tab_proxy.h" | 20 #include "chrome/test/automation/tab_proxy.h" |
| 20 #include "chrome/test/automation/window_proxy.h" | 21 #include "chrome/test/automation/window_proxy.h" |
| 21 #include "chrome/test/base/chrome_process_util.h" | 22 #include "chrome/test/base/chrome_process_util.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 std::string str = parsed_command_line.GetSwitchValueASCII( | 133 std::string str = parsed_command_line.GetSwitchValueASCII( |
| 133 switches::kPageCyclerIterations); | 134 switches::kPageCyclerIterations); |
| 134 base::StringToInt(str, &num_test_iterations_); | 135 base::StringToInt(str, &num_test_iterations_); |
| 135 } | 136 } |
| 136 | 137 |
| 137 // Expose garbage collection for the page cycler tests. | 138 // Expose garbage collection for the page cycler tests. |
| 138 launch_arguments_.AppendSwitchASCII(switches::kJavaScriptFlags, | 139 launch_arguments_.AppendSwitchASCII(switches::kJavaScriptFlags, |
| 139 "--expose_gc"); | 140 "--expose_gc"); |
| 140 } | 141 } |
| 141 | 142 |
| 143 bool WaitUntilTabURLPathEndWith(TabProxy* tab, | |
|
hans
2011/09/15 12:48:00
nit: it should probably be named "...EndsWith()"
| |
| 144 const std::string& url_path, | |
| 145 int64 timeout_ms) { | |
| 146 base::Time end_time = base::Time::Now() + | |
| 147 base::TimeDelta::FromMilliseconds(timeout_ms); | |
| 148 while ((end_time - base::Time::Now()) > base::TimeDelta()) { | |
| 149 GURL url; | |
| 150 EXPECT_TRUE(tab->GetCurrentURL(&url)); | |
| 151 if (EndsWith(url.path(), url_path, true)) | |
| 152 return true; | |
| 153 base::PlatformThread::Sleep(automation::kSleepTime); | |
|
Paweł Hajdan Jr.
2011/09/15 17:59:34
Polling is _unacceptable_ . Please wait for an eve
cmp
2011/09/15 23:22:52
I don't think it's a big deal, really. If you rea
Johnny(Jianning) Ding
2011/09/16 00:14:10
Thanks Chase! I have sent a patch to make the data
cmp
2011/09/16 00:18:22
Reviewed. :)
Johnny(Jianning) Ding
2011/09/16 00:48:01
Thanks Chase! Just landed that patch. Base on that
Johnny(Jianning) Ding
2011/09/16 00:55:05
Please hold on the review. I need to change the pa
| |
| 154 } | |
| 155 return false; | |
| 156 } | |
| 157 | |
| 142 virtual FilePath GetDataPath(const char* name) { | 158 virtual FilePath GetDataPath(const char* name) { |
| 143 // Make sure the test data is checked out | 159 // Make sure the test data is checked out |
| 144 FilePath test_path; | 160 FilePath test_path; |
| 145 PathService::Get(base::DIR_SOURCE_ROOT, &test_path); | 161 PathService::Get(base::DIR_SOURCE_ROOT, &test_path); |
| 146 test_path = test_path.Append(FILE_PATH_LITERAL("data")); | 162 test_path = test_path.Append(FILE_PATH_LITERAL("data")); |
| 147 test_path = test_path.Append(FILE_PATH_LITERAL("page_cycler")); | 163 test_path = test_path.Append(FILE_PATH_LITERAL("page_cycler")); |
| 148 test_path = test_path.AppendASCII(name); | 164 test_path = test_path.AppendASCII(name); |
| 149 return test_path; | 165 return test_path; |
| 150 } | 166 } |
| 151 | 167 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 190 // Wait for the test to finish. | 206 // Wait for the test to finish. |
| 191 ASSERT_TRUE(WaitUntilCookieValue( | 207 ASSERT_TRUE(WaitUntilCookieValue( |
| 192 tab.get(), test_url, "__pc_done", | 208 tab.get(), test_url, "__pc_done", |
| 193 TestTimeouts::large_test_timeout_ms(), "1")); | 209 TestTimeouts::large_test_timeout_ms(), "1")); |
| 194 | 210 |
| 195 std::string cookie; | 211 std::string cookie; |
| 196 ASSERT_TRUE(tab->GetCookieByName(test_url, "__pc_pages", &cookie)); | 212 ASSERT_TRUE(tab->GetCookieByName(test_url, "__pc_pages", &cookie)); |
| 197 pages->assign(UTF8ToWide(cookie)); | 213 pages->assign(UTF8ToWide(cookie)); |
| 198 ASSERT_FALSE(pages->empty()); | 214 ASSERT_FALSE(pages->empty()); |
| 199 | 215 |
| 216 // Make sure the page is navigated to report.html. Otherwise we may | |
| 217 // check __get_timings successfully in the test page, but fail to run | |
| 218 // __get_timings() in report.html because the test script is not loaded. | |
| 219 ASSERT_TRUE(WaitUntilTabURLPathEndWith(tab.get(), "report.html", | |
| 220 TestTimeouts::action_max_timeout_ms())); | |
| 221 // Wait for the test script to be loaded by checking whether __get_timings | |
| 222 // is ready. | |
| 223 ASSERT_TRUE(WaitUntilJavaScriptCondition(tab, L"", | |
| 224 L"window.domAutomationController.send(" | |
| 225 L"typeof(__get_timings)=='function')", | |
| 226 TestTimeouts::action_max_timeout_ms())); | |
| 227 | |
| 200 // Get the timing cookie value from the DOM automation. | 228 // Get the timing cookie value from the DOM automation. |
| 201 std::wstring wcookie; | 229 std::wstring wcookie; |
| 202 ASSERT_TRUE(tab->ExecuteAndExtractString(L"", | 230 ASSERT_TRUE(tab->ExecuteAndExtractString(L"", |
| 203 L"window.domAutomationController.send(" | 231 L"window.domAutomationController.send(" |
| 204 L"JSON.stringify(__get_timings()));", | 232 L"JSON.stringify(__get_timings()));", |
| 205 &wcookie)); | 233 &wcookie)); |
| 206 cookie = base::SysWideToNativeMB(wcookie); | 234 cookie = base::SysWideToNativeMB(wcookie); |
| 207 | 235 |
| 208 // JSON.stringify() encapsulates the returned string in quotes, strip them. | 236 // JSON.stringify() encapsulates the returned string in quotes, strip them. |
| 209 std::string::size_type start_idx = cookie.find("\""); | 237 std::string::size_type start_idx = cookie.find("\""); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 435 #define PAGE_CYCLER_TESTS(test, name, use_http) \ | 463 #define PAGE_CYCLER_TESTS(test, name, use_http) \ |
| 436 TEST_F(PageCyclerTest, name) { \ | 464 TEST_F(PageCyclerTest, name) { \ |
| 437 RunTest("times", test, use_http); \ | 465 RunTest("times", test, use_http); \ |
| 438 } \ | 466 } \ |
| 439 TEST_F(PageCyclerReferenceTest, name) { \ | 467 TEST_F(PageCyclerReferenceTest, name) { \ |
| 440 RunTest("times", test, use_http); \ | 468 RunTest("times", test, use_http); \ |
| 441 } | 469 } |
| 442 | 470 |
| 443 // This macro simplifies setting up regular and reference build tests | 471 // This macro simplifies setting up regular and reference build tests |
| 444 // for HTML5 database tests. | 472 // for HTML5 database tests. |
| 445 // FLAKY http://crbug.com/67918 | |
| 446 #define PAGE_CYCLER_DATABASE_TESTS(test, name) \ | 473 #define PAGE_CYCLER_DATABASE_TESTS(test, name) \ |
| 447 TEST_F(PageCyclerDatabaseTest, FLAKY_Database##name##File) { \ | 474 TEST_F(PageCyclerDatabaseTest, Database##name##File) { \ |
| 448 RunTest(test, test, false); \ | 475 RunTest(test, test, false); \ |
| 449 } \ | 476 } \ |
| 450 TEST_F(PageCyclerDatabaseReferenceTest, FLAKY_Database##name##File) { \ | 477 TEST_F(PageCyclerDatabaseReferenceTest, Database##name##File) { \ |
| 451 RunTest(test, test, false); \ | 478 RunTest(test, test, false); \ |
| 452 } | 479 } |
| 453 | 480 |
| 454 // This macro simplifies setting up regular and reference build tests | 481 // This macro simplifies setting up regular and reference build tests |
| 455 // for HTML5 Indexed DB tests. | 482 // for HTML5 Indexed DB tests. |
| 456 // FLAKY http://crbug.com/67918 | |
| 457 #define PAGE_CYCLER_IDB_TESTS(test, name) \ | 483 #define PAGE_CYCLER_IDB_TESTS(test, name) \ |
| 458 TEST_F(PageCyclerIndexedDatabaseTest, FLAKY_IndexedDB##name##File) { \ | 484 TEST_F(PageCyclerIndexedDatabaseTest, IndexedDB##name##File) { \ |
| 459 RunTest(test, test, false); \ | 485 RunTest(test, test, false); \ |
| 460 } \ | 486 } \ |
| 461 TEST_F(PageCyclerIndexedDatabaseReferenceTest, IndexedDB##name##File) { \ | 487 TEST_F(PageCyclerIndexedDatabaseReferenceTest, IndexedDB##name##File) { \ |
| 462 RunTest(test, test, false); \ | 488 RunTest(test, test, false); \ |
| 463 } | 489 } |
| 464 | 490 |
| 465 // These are shorthand for File vs. Http tests. | 491 // These are shorthand for File vs. Http tests. |
| 466 #define PAGE_CYCLER_FILE_TESTS(test, name) \ | 492 #define PAGE_CYCLER_FILE_TESTS(test, name) \ |
| 467 PAGE_CYCLER_TESTS(test, name, false) | 493 PAGE_CYCLER_TESTS(test, name, false) |
| 468 #define PAGE_CYCLER_HTTP_TESTS(test, name) \ | 494 #define PAGE_CYCLER_HTTP_TESTS(test, name) \ |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 527 PAGE_CYCLER_DATABASE_TESTS("delete-transactions", | 553 PAGE_CYCLER_DATABASE_TESTS("delete-transactions", |
| 528 DeleteTransactions); | 554 DeleteTransactions); |
| 529 PAGE_CYCLER_DATABASE_TESTS("pseudo-random-transactions", | 555 PAGE_CYCLER_DATABASE_TESTS("pseudo-random-transactions", |
| 530 PseudoRandomTransactions); | 556 PseudoRandomTransactions); |
| 531 #endif | 557 #endif |
| 532 | 558 |
| 533 // Indexed DB tests. | 559 // Indexed DB tests. |
| 534 PAGE_CYCLER_IDB_TESTS("basic_insert", BasicInsert); | 560 PAGE_CYCLER_IDB_TESTS("basic_insert", BasicInsert); |
| 535 | 561 |
| 536 } // namespace | 562 } // namespace |
| OLD | NEW |