| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/test/ui/ui_test.h" | 5 #include "chrome/test/ui/ui_test.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 expected_crashes_(0), | 103 expected_crashes_(0), |
| 104 homepage_(L"about:blank"), | 104 homepage_(L"about:blank"), |
| 105 wait_for_initial_loads_(true), | 105 wait_for_initial_loads_(true), |
| 106 dom_automation_enabled_(false), | 106 dom_automation_enabled_(false), |
| 107 process_(0), // NULL on Windows, 0 PID on POSIX. | 107 process_(0), // NULL on Windows, 0 PID on POSIX. |
| 108 show_window_(false), | 108 show_window_(false), |
| 109 clear_profile_(true), | 109 clear_profile_(true), |
| 110 include_testing_id_(true), | 110 include_testing_id_(true), |
| 111 use_existing_browser_(default_use_existing_browser_), | 111 use_existing_browser_(default_use_existing_browser_), |
| 112 enable_file_cookies_(true), | 112 enable_file_cookies_(true), |
| 113 test_start_time_(base::Time::NowFromSystemTime()), |
| 113 command_execution_timeout_ms_(kMaxTestExecutionTime), | 114 command_execution_timeout_ms_(kMaxTestExecutionTime), |
| 114 action_timeout_ms_(kWaitForActionMsec), | 115 action_timeout_ms_(kWaitForActionMsec), |
| 115 action_max_timeout_ms_(kWaitForActionMaxMsec), | 116 action_max_timeout_ms_(kWaitForActionMaxMsec), |
| 116 sleep_timeout_ms_(kWaitForActionMsec) { | 117 sleep_timeout_ms_(kWaitForActionMsec) { |
| 117 PathService::Get(chrome::DIR_APP, &browser_directory_); | 118 PathService::Get(chrome::DIR_APP, &browser_directory_); |
| 118 PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_); | 119 PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_); |
| 119 #if defined(OS_WIN) | |
| 120 GetSystemTimeAsFileTime(&test_start_time_); | |
| 121 #else | |
| 122 // http://code.google.com/p/chromium/issues/detail?id=9833 | |
| 123 #endif | |
| 124 } | 120 } |
| 125 | 121 |
| 126 void UITest::SetUp() { | 122 void UITest::SetUp() { |
| 127 if (!use_existing_browser_) { | 123 if (!use_existing_browser_) { |
| 128 AssertAppNotRunning(L"Please close any other instances " | 124 AssertAppNotRunning(L"Please close any other instances " |
| 129 L"of the app before testing."); | 125 L"of the app before testing."); |
| 130 } | 126 } |
| 131 | 127 |
| 132 // Pass the test case name to chrome.exe on the command line to help with | 128 // Pass the test case name to chrome.exe on the command line to help with |
| 133 // parsing Purify output. | 129 // parsing Purify output. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 158 logging::AssertionList::const_iterator iter = assertions.begin(); | 154 logging::AssertionList::const_iterator iter = assertions.begin(); |
| 159 for (; iter != assertions.end(); ++iter) { | 155 for (; iter != assertions.end(); ++iter) { |
| 160 failures.append(L"\n\n"); | 156 failures.append(L"\n\n"); |
| 161 failures.append(*iter); | 157 failures.append(*iter); |
| 162 } | 158 } |
| 163 } | 159 } |
| 164 EXPECT_EQ(expected_errors_, assertions.size()) << failures; | 160 EXPECT_EQ(expected_errors_, assertions.size()) << failures; |
| 165 | 161 |
| 166 #if defined(OS_WIN) | 162 #if defined(OS_WIN) |
| 167 // Check for crashes during the test | 163 // Check for crashes during the test |
| 168 std::wstring crash_dump_path; | 164 FilePath crash_dump_path; |
| 169 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_path); | 165 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_path); |
| 170 // Each crash creates two dump files, so we divide by two here. | 166 // Each crash creates two dump files, so we divide by two here. |
| 171 int actual_crashes = | 167 int actual_crashes = |
| 172 file_util::CountFilesCreatedAfter(crash_dump_path, test_start_time_) / 2; | 168 file_util::CountFilesCreatedAfter(crash_dump_path, test_start_time_) / 2; |
| 173 std::wstring error_msg = | 169 std::wstring error_msg = |
| 174 L"Encountered an unexpected crash in the program during this test."; | 170 L"Encountered an unexpected crash in the program during this test."; |
| 175 if (expected_crashes_ > 0 && actual_crashes == 0) { | 171 if (expected_crashes_ > 0 && actual_crashes == 0) { |
| 176 error_msg += L" "; | 172 error_msg += L" "; |
| 177 error_msg += kFailedNoCrashService; | 173 error_msg += kFailedNoCrashService; |
| 178 } | 174 } |
| (...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 } | 846 } |
| 851 | 847 |
| 852 bool UITest::EvictFileFromSystemCacheWrapper(const FilePath& path) { | 848 bool UITest::EvictFileFromSystemCacheWrapper(const FilePath& path) { |
| 853 for (int i = 0; i < 10; i++) { | 849 for (int i = 0; i < 10; i++) { |
| 854 if (file_util::EvictFileFromSystemCache(path)) | 850 if (file_util::EvictFileFromSystemCache(path)) |
| 855 return true; | 851 return true; |
| 856 PlatformThread::Sleep(1000); | 852 PlatformThread::Sleep(1000); |
| 857 } | 853 } |
| 858 return false; | 854 return false; |
| 859 } | 855 } |
| OLD | NEW |