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