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