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 <set> | 5 #include <set> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "chrome/test/ui/ui_test.h" | 8 #include "chrome/test/ui/ui_test.h" |
9 | 9 |
10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/platform_thread.h" |
13 #include "base/process_util.h" | 14 #include "base/process_util.h" |
14 #include "base/scoped_ptr.h" | 15 #include "base/scoped_ptr.h" |
15 #include "base/string_util.h" | 16 #include "base/string_util.h" |
16 #include "base/test_file_util.h" | 17 #include "base/test_file_util.h" |
17 #include "base/time.h" | 18 #include "base/time.h" |
18 #include "chrome/app/chrome_dll_resource.h" | 19 #include "chrome/app/chrome_dll_resource.h" |
19 #include "chrome/browser/url_fixer_upper.h" | 20 #include "chrome/browser/url_fixer_upper.h" |
20 #include "chrome/common/chrome_constants.h" | 21 #include "chrome/common/chrome_constants.h" |
21 #include "chrome/common/chrome_paths.h" | 22 #include "chrome/common/chrome_paths.h" |
22 #include "chrome/common/chrome_process_filter.h" | |
23 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
24 #include "chrome/common/debug_flags.h" | 24 #include "chrome/common/debug_flags.h" |
25 #include "chrome/common/logging_chrome.h" | 25 #include "chrome/common/logging_chrome.h" |
26 #include "chrome/common/json_value_serializer.h" | 26 #include "chrome/common/json_value_serializer.h" |
| 27 #include "googleurl/src/gurl.h" |
| 28 #include "net/base/net_util.h" |
| 29 |
| 30 #if defined(OS_WIN) |
| 31 // TODO(port): these just need to be ported. |
| 32 #include "chrome/common/chrome_process_filter.h" |
27 #include "chrome/test/automation/browser_proxy.h" | 33 #include "chrome/test/automation/browser_proxy.h" |
28 #include "chrome/test/automation/tab_proxy.h" | 34 #include "chrome/test/automation/tab_proxy.h" |
29 #include "chrome/test/automation/window_proxy.h" | 35 #include "chrome/test/automation/window_proxy.h" |
30 #include "googleurl/src/gurl.h" | 36 #endif |
31 #include "net/base/net_util.h" | |
32 | 37 |
33 using base::TimeTicks; | 38 using base::TimeTicks; |
34 | 39 |
| 40 // Delay to let browser complete a requested action. |
| 41 const int UITest::kWaitForActionMsec = 2000; |
| 42 const int UITest::kWaitForActionMaxMsec = 10000; |
| 43 // Delay to let the browser complete the test. |
| 44 const int UITest::kMaxTestExecutionTime = 30000; |
| 45 |
35 const wchar_t UITest::kFailedNoCrashService[] = | 46 const wchar_t UITest::kFailedNoCrashService[] = |
36 L"NOTE: This test is expected to fail if crash_service.exe is not " | 47 L"NOTE: This test is expected to fail if crash_service.exe is not " |
37 L"running. Start it manually before running this test (see the build " | 48 L"running. Start it manually before running this test (see the build " |
38 L"output directory)."; | 49 L"output directory)."; |
39 bool UITest::in_process_renderer_ = false; | 50 bool UITest::in_process_renderer_ = false; |
40 bool UITest::in_process_plugins_ = false; | 51 bool UITest::in_process_plugins_ = false; |
41 bool UITest::no_sandbox_ = false; | 52 bool UITest::no_sandbox_ = false; |
42 bool UITest::full_memory_dump_ = false; | 53 bool UITest::full_memory_dump_ = false; |
43 bool UITest::safe_plugins_ = false; | 54 bool UITest::safe_plugins_ = false; |
44 bool UITest::show_error_dialogs_ = true; | 55 bool UITest::show_error_dialogs_ = true; |
(...skipping 21 matching lines...) Expand all Loading... |
66 | 77 |
67 // static | 78 // static |
68 bool UITest::DieFileDie(const std::wstring& file, bool recurse) { | 79 bool UITest::DieFileDie(const std::wstring& file, bool recurse) { |
69 if (!file_util::PathExists(file)) | 80 if (!file_util::PathExists(file)) |
70 return true; | 81 return true; |
71 | 82 |
72 // Sometimes Delete fails, so try a few more times. | 83 // Sometimes Delete fails, so try a few more times. |
73 for (int i = 0; i < 10; ++i) { | 84 for (int i = 0; i < 10; ++i) { |
74 if (file_util::Delete(file, recurse)) | 85 if (file_util::Delete(file, recurse)) |
75 return true; | 86 return true; |
76 Sleep(kWaitForActionMaxMsec / 10); | 87 PlatformThread::Sleep(kWaitForActionMaxMsec / 10); |
77 } | 88 } |
78 return false; | 89 return false; |
79 } | 90 } |
80 | 91 |
81 UITest::UITest() | 92 UITest::UITest() |
82 : testing::Test(), | 93 : testing::Test(), |
83 expected_errors_(0), | 94 expected_errors_(0), |
84 expected_crashes_(0), | 95 expected_crashes_(0), |
| 96 homepage_(L"about:blank"), |
85 wait_for_initial_loads_(true), | 97 wait_for_initial_loads_(true), |
86 homepage_(L"about:blank"), | |
87 dom_automation_enabled_(false), | 98 dom_automation_enabled_(false), |
88 process_(NULL), | 99 process_(0), // NULL on Windows, 0 PID on POSIX. |
89 show_window_(false), | 100 show_window_(false), |
90 clear_profile_(true), | 101 clear_profile_(true), |
91 include_testing_id_(true), | 102 include_testing_id_(true), |
92 use_existing_browser_(default_use_existing_browser_), | 103 use_existing_browser_(default_use_existing_browser_), |
93 command_execution_timeout_ms_(kMaxTestExecutionTime), | 104 command_execution_timeout_ms_(kMaxTestExecutionTime), |
94 action_timeout_ms_(kWaitForActionMsec), | 105 action_timeout_ms_(kWaitForActionMsec), |
95 action_max_timeout_ms_(kWaitForActionMaxMsec) { | 106 action_max_timeout_ms_(kWaitForActionMaxMsec) { |
96 PathService::Get(chrome::DIR_APP, &browser_directory_); | 107 PathService::Get(chrome::DIR_APP, &browser_directory_); |
97 PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_); | 108 PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_); |
| 109 #if defined(OS_WIN) |
98 GetSystemTimeAsFileTime(&test_start_time_); | 110 GetSystemTimeAsFileTime(&test_start_time_); |
| 111 #else |
| 112 NOTIMPLEMENTED(); |
| 113 #endif |
99 } | 114 } |
100 | 115 |
101 void UITest::SetUp() { | 116 void UITest::SetUp() { |
102 if (!use_existing_browser_) { | 117 if (!use_existing_browser_) { |
103 AssertAppNotRunning(L"Please close any other instances " | 118 AssertAppNotRunning(L"Please close any other instances " |
104 L"of the app before testing."); | 119 L"of the app before testing."); |
105 } | 120 } |
106 | 121 |
107 InitializeTimeouts(); | 122 InitializeTimeouts(); |
108 LaunchBrowserAndServer(); | 123 LaunchBrowserAndServer(); |
109 } | 124 } |
110 | 125 |
111 void UITest::TearDown() { | 126 void UITest::TearDown() { |
112 CloseBrowserAndServer(); | 127 CloseBrowserAndServer(); |
113 | 128 |
114 // Make sure that we didn't encounter any assertion failures | 129 // Make sure that we didn't encounter any assertion failures |
115 logging::AssertionList assertions; | 130 logging::AssertionList assertions; |
116 logging::GetFatalAssertions(&assertions); | 131 logging::GetFatalAssertions(&assertions); |
117 | 132 |
118 // If there were errors, get all the error strings for display. | 133 // If there were errors, get all the error strings for display. |
119 std::wstring failures = | 134 std::wstring failures = |
120 L"The following error(s) occurred in the application during this test:"; | 135 L"The following error(s) occurred in the application during this test:"; |
121 if (static_cast<int>(assertions.size()) > expected_errors_) { | 136 if (assertions.size() > expected_errors_) { |
122 logging::AssertionList::const_iterator iter = assertions.begin(); | 137 logging::AssertionList::const_iterator iter = assertions.begin(); |
123 for (; iter != assertions.end(); ++iter) { | 138 for (; iter != assertions.end(); ++iter) { |
124 failures.append(L"\n\n"); | 139 failures.append(L"\n\n"); |
125 failures.append(*iter); | 140 failures.append(*iter); |
126 } | 141 } |
127 } | 142 } |
128 EXPECT_EQ(expected_errors_, assertions.size()) << failures; | 143 EXPECT_EQ(expected_errors_, assertions.size()) << failures; |
129 | 144 |
| 145 #if defined(OS_WIN) |
130 // Check for crashes during the test | 146 // Check for crashes during the test |
131 std::wstring crash_dump_path; | 147 std::wstring crash_dump_path; |
132 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_path); | 148 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_path); |
133 // Each crash creates two dump files, so we divide by two here. | 149 // Each crash creates two dump files, so we divide by two here. |
134 int actual_crashes = | 150 int actual_crashes = |
135 file_util::CountFilesCreatedAfter(crash_dump_path, test_start_time_) / 2; | 151 file_util::CountFilesCreatedAfter(crash_dump_path, test_start_time_) / 2; |
136 std::wstring error_msg = | 152 std::wstring error_msg = |
137 L"Encountered an unexpected crash in the program during this test."; | 153 L"Encountered an unexpected crash in the program during this test."; |
138 if (expected_crashes_ > 0 && actual_crashes == 0) { | 154 if (expected_crashes_ > 0 && actual_crashes == 0) { |
139 error_msg += L" "; | 155 error_msg += L" "; |
140 error_msg += kFailedNoCrashService; | 156 error_msg += kFailedNoCrashService; |
141 } | 157 } |
142 EXPECT_EQ(expected_crashes_, actual_crashes) << error_msg; | 158 EXPECT_EQ(expected_crashes_, actual_crashes) << error_msg; |
| 159 #else |
| 160 // TODO(port): we don't catch crashes, nor have CountFilesCreatedAfter. |
| 161 NOTIMPLEMENTED(); |
| 162 #endif |
143 } | 163 } |
144 | 164 |
145 // Pick up the various test time out values from the command line. | 165 // Pick up the various test time out values from the command line. |
146 void UITest::InitializeTimeouts() { | 166 void UITest::InitializeTimeouts() { |
147 if (CommandLine().HasSwitch(kUiTestTimeout)) { | 167 if (CommandLine().HasSwitch(kUiTestTimeout)) { |
148 std::wstring timeout_str = CommandLine().GetSwitchValue(kUiTestTimeout); | 168 std::wstring timeout_str = CommandLine().GetSwitchValue(kUiTestTimeout); |
149 int timeout = StringToInt(timeout_str); | 169 int timeout = StringToInt(timeout_str); |
150 command_execution_timeout_ms_ = std::max(kMaxTestExecutionTime, timeout); | 170 command_execution_timeout_ms_ = std::max(kMaxTestExecutionTime, timeout); |
151 } | 171 } |
152 | 172 |
153 if (CommandLine().HasSwitch(kUiTestActionTimeout)) { | 173 if (CommandLine().HasSwitch(kUiTestActionTimeout)) { |
154 std::wstring act_str = CommandLine().GetSwitchValue(kUiTestActionTimeout); | 174 std::wstring act_str = CommandLine().GetSwitchValue(kUiTestActionTimeout); |
155 int act_timeout = StringToInt(act_str); | 175 int act_timeout = StringToInt(act_str); |
156 action_timeout_ms_ = std::max(kWaitForActionMsec, act_timeout); | 176 action_timeout_ms_ = std::max(kWaitForActionMsec, act_timeout); |
157 } | 177 } |
158 | 178 |
159 if (CommandLine().HasSwitch(kUiTestActionMaxTimeout)) { | 179 if (CommandLine().HasSwitch(kUiTestActionMaxTimeout)) { |
160 std::wstring action_max_str = | 180 std::wstring action_max_str = |
161 CommandLine().GetSwitchValue(kUiTestActionMaxTimeout); | 181 CommandLine().GetSwitchValue(kUiTestActionMaxTimeout); |
162 int max_timeout = StringToInt(action_max_str); | 182 int max_timeout = StringToInt(action_max_str); |
163 action_max_timeout_ms_ = std::max(kWaitForActionMaxMsec, max_timeout); | 183 action_max_timeout_ms_ = std::max(kWaitForActionMaxMsec, max_timeout); |
164 } | 184 } |
165 } | 185 } |
166 | 186 |
167 void UITest::LaunchBrowserAndServer() { | 187 void UITest::LaunchBrowserAndServer() { |
| 188 #if defined(OS_WIN) |
168 // Set up IPC testing interface server. | 189 // Set up IPC testing interface server. |
169 server_.reset(new AutomationProxy(command_execution_timeout_ms_)); | 190 server_.reset(new AutomationProxy(command_execution_timeout_ms_)); |
170 | 191 |
171 LaunchBrowser(launch_arguments_, clear_profile_); | 192 LaunchBrowser(launch_arguments_, clear_profile_); |
172 if (wait_for_initial_loads_) | 193 if (wait_for_initial_loads_) |
173 ASSERT_TRUE(server_->WaitForInitialLoads()); | 194 ASSERT_TRUE(server_->WaitForInitialLoads()); |
174 else | 195 else |
175 Sleep(2000); | 196 Sleep(2000); |
176 | 197 |
177 automation()->SetFilteredInet(true); | 198 automation()->SetFilteredInet(true); |
| 199 #else |
| 200 // TODO(port): depends on AutomationProxy. |
| 201 NOTIMPLEMENTED(); |
| 202 #endif |
178 } | 203 } |
179 | 204 |
180 void UITest::CloseBrowserAndServer() { | 205 void UITest::CloseBrowserAndServer() { |
181 QuitBrowser(); | 206 QuitBrowser(); |
182 CleanupAppProcesses(); | 207 CleanupAppProcesses(); |
183 | 208 |
| 209 #if defined(OS_WIN) |
184 // Shut down IPC testing interface. | 210 // Shut down IPC testing interface. |
185 server_.reset(); | 211 server_.reset(); |
| 212 #else |
| 213 // TODO(port): depends on AutomationProxy. |
| 214 NOTIMPLEMENTED(); |
| 215 #endif |
186 } | 216 } |
187 | 217 |
188 void UITest::LaunchBrowser(const std::wstring& arguments, bool clear_profile) { | 218 void UITest::LaunchBrowser(const std::wstring& arguments, bool clear_profile) { |
189 std::wstring command_line(browser_directory_); | 219 std::wstring command_line(browser_directory_); |
190 file_util::AppendToPath(&command_line, | 220 file_util::AppendToPath(&command_line, |
191 chrome::kBrowserProcessExecutableName); | 221 chrome::kBrowserProcessExecutableName); |
192 | 222 |
193 // Add any explict command line flags passed to the process. | 223 // Add any explict command line flags passed to the process. |
194 std::wstring extra_chrome_flags = | 224 std::wstring extra_chrome_flags = |
195 CommandLine().GetSwitchValue(kExtraChromeFlagsSwitch); | 225 CommandLine().GetSwitchValue(kExtraChromeFlagsSwitch); |
196 if (!extra_chrome_flags.empty()) | 226 if (!extra_chrome_flags.empty()) |
197 command_line.append(L" " + extra_chrome_flags); | 227 command_line.append(L" " + extra_chrome_flags); |
198 | 228 |
199 // We need cookies on file:// for things like the page cycler. | 229 // We need cookies on file:// for things like the page cycler. |
200 CommandLine::AppendSwitch(&command_line, switches::kEnableFileCookies); | 230 CommandLine::AppendSwitch(&command_line, switches::kEnableFileCookies); |
201 | 231 |
202 if (dom_automation_enabled_) | 232 if (dom_automation_enabled_) |
203 CommandLine::AppendSwitch(&command_line, | 233 CommandLine::AppendSwitch(&command_line, |
204 switches::kDomAutomationController); | 234 switches::kDomAutomationController); |
205 | 235 |
| 236 #if defined(OS_WIN) |
206 if (include_testing_id_) { | 237 if (include_testing_id_) { |
207 if (use_existing_browser_) { | 238 if (use_existing_browser_) { |
208 // TODO(erikkay): The new switch depends on a browser instance already | 239 // TODO(erikkay): The new switch depends on a browser instance already |
209 // running, it won't open a new browser window if it's not. We could fix | 240 // running, it won't open a new browser window if it's not. We could fix |
210 // this by passing an url (e.g. about:blank) on the command line, but | 241 // this by passing an url (e.g. about:blank) on the command line, but |
211 // I decided to keep using the old switch in the existing use case to | 242 // I decided to keep using the old switch in the existing use case to |
212 // minimize changes in behavior. | 243 // minimize changes in behavior. |
213 CommandLine::AppendSwitchWithValue(&command_line, | 244 CommandLine::AppendSwitchWithValue(&command_line, |
214 switches::kAutomationClientChannelID, | 245 switches::kAutomationClientChannelID, |
215 server_->channel_id()); | 246 server_->channel_id()); |
216 } else { | 247 } else { |
217 CommandLine::AppendSwitchWithValue(&command_line, | 248 CommandLine::AppendSwitchWithValue(&command_line, |
218 switches::kTestingChannelID, | 249 switches::kTestingChannelID, |
219 server_->channel_id()); | 250 server_->channel_id()); |
220 } | 251 } |
221 } | 252 } |
| 253 #else |
| 254 // TODO(port): depends on AutomationProxy. |
| 255 NOTIMPLEMENTED(); |
| 256 #endif |
222 | 257 |
223 if (!show_error_dialogs_) | 258 if (!show_error_dialogs_) |
224 CommandLine::AppendSwitch(&command_line, switches::kNoErrorDialogs); | 259 CommandLine::AppendSwitch(&command_line, switches::kNoErrorDialogs); |
225 if (in_process_renderer_) | 260 if (in_process_renderer_) |
226 CommandLine::AppendSwitch(&command_line, switches::kSingleProcess); | 261 CommandLine::AppendSwitch(&command_line, switches::kSingleProcess); |
227 if (in_process_plugins_) | 262 if (in_process_plugins_) |
228 CommandLine::AppendSwitch(&command_line, switches::kInProcessPlugins); | 263 CommandLine::AppendSwitch(&command_line, switches::kInProcessPlugins); |
229 if (no_sandbox_) | 264 if (no_sandbox_) |
230 CommandLine::AppendSwitch(&command_line, switches::kNoSandbox); | 265 CommandLine::AppendSwitch(&command_line, switches::kNoSandbox); |
231 if (full_memory_dump_) | 266 if (full_memory_dump_) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 // Clear user data directory to make sure test environment is consistent | 305 // Clear user data directory to make sure test environment is consistent |
271 // We balk on really short (absolute) user_data_dir directory names, because | 306 // We balk on really short (absolute) user_data_dir directory names, because |
272 // we're worried that they'd accidentally be root or something. | 307 // we're worried that they'd accidentally be root or something. |
273 ASSERT_LT(10, static_cast<int>(user_data_dir_.size())) << | 308 ASSERT_LT(10, static_cast<int>(user_data_dir_.size())) << |
274 "The user data directory name passed into this test was too " | 309 "The user data directory name passed into this test was too " |
275 "short to delete safely. Please check the user-data-dir " | 310 "short to delete safely. Please check the user-data-dir " |
276 "argument and try again."; | 311 "argument and try again."; |
277 if (clear_profile) | 312 if (clear_profile) |
278 ASSERT_TRUE(DieFileDie(user_data_dir_, true)); | 313 ASSERT_TRUE(DieFileDie(user_data_dir_, true)); |
279 | 314 |
| 315 #if defined(OS_WIN) |
280 if (!template_user_data_.empty()) { | 316 if (!template_user_data_.empty()) { |
281 // Recursively copy the template directory to the user_data_dir. | 317 // Recursively copy the template directory to the user_data_dir. |
282 ASSERT_TRUE(file_util::CopyRecursiveDirNoCache(template_user_data_, | 318 ASSERT_TRUE(file_util::CopyRecursiveDirNoCache(template_user_data_, |
283 user_data_dir_)); | 319 user_data_dir_)); |
284 } | 320 } |
285 | 321 |
286 browser_launch_time_ = TimeTicks::Now(); | 322 browser_launch_time_ = TimeTicks::Now(); |
287 | 323 |
288 bool started = base::LaunchApp(command_line, | 324 bool started = base::LaunchApp(command_line, |
289 false, // Don't wait for process object | 325 false, // Don't wait for process object |
290 // (doesn't work for us) | 326 // (doesn't work for us) |
291 !show_window_, | 327 !show_window_, |
292 &process_); | 328 &process_); |
293 ASSERT_EQ(started, true); | 329 ASSERT_EQ(started, true); |
294 | 330 |
295 if (use_existing_browser_) { | 331 if (use_existing_browser_) { |
296 DWORD pid = 0; | 332 DWORD pid = 0; |
297 HWND hwnd = FindWindowEx(HWND_MESSAGE, NULL, chrome::kMessageWindowClass, | 333 HWND hwnd = FindWindowEx(HWND_MESSAGE, NULL, chrome::kMessageWindowClass, |
298 user_data_dir_.c_str()); | 334 user_data_dir_.c_str()); |
299 GetWindowThreadProcessId(hwnd, &pid); | 335 GetWindowThreadProcessId(hwnd, &pid); |
300 // This mode doesn't work if we wound up launching a new browser ourselves. | 336 // This mode doesn't work if we wound up launching a new browser ourselves. |
301 ASSERT_NE(pid, base::GetProcId(process_)); | 337 ASSERT_NE(pid, base::GetProcId(process_)); |
302 CloseHandle(process_); | 338 CloseHandle(process_); |
303 process_ = OpenProcess(SYNCHRONIZE, false, pid); | 339 process_ = OpenProcess(SYNCHRONIZE, false, pid); |
304 } | 340 } |
| 341 #else |
| 342 // TODO(port): above code is very Windows-specific; we need to |
| 343 // figure out and abstract out how we'll handle finding any existing |
| 344 // running process, etc. on other platforms. |
| 345 NOTIMPLEMENTED(); |
| 346 #endif |
305 } | 347 } |
306 | 348 |
307 void UITest::QuitBrowser() { | 349 void UITest::QuitBrowser() { |
| 350 #if defined(OS_WIN) |
308 typedef std::vector<BrowserProxy*> BrowserVector; | 351 typedef std::vector<BrowserProxy*> BrowserVector; |
309 | 352 |
310 // There's nothing to do here if the browser is not running. | 353 // There's nothing to do here if the browser is not running. |
311 if (IsBrowserRunning()) { | 354 if (IsBrowserRunning()) { |
312 automation()->SetFilteredInet(false); | 355 automation()->SetFilteredInet(false); |
313 BrowserVector browsers; | 356 BrowserVector browsers; |
314 | 357 |
315 // Build up a list of HWNDs; we do this as a separate step so that closing | 358 // Build up a list of HWNDs; we do this as a separate step so that closing |
316 // the windows doesn't mess up the iteration. | 359 // the windows doesn't mess up the iteration. |
317 int window_count = 0; | 360 int window_count = 0; |
(...skipping 25 matching lines...) Expand all Loading... |
343 if (WAIT_TIMEOUT == WaitForSingleObject(process_, timeout)) { | 386 if (WAIT_TIMEOUT == WaitForSingleObject(process_, timeout)) { |
344 // We need to force the browser to quit because it didn't quit fast | 387 // We need to force the browser to quit because it didn't quit fast |
345 // enough. Take no chance and kill every chrome processes. | 388 // enough. Take no chance and kill every chrome processes. |
346 CleanupAppProcesses(); | 389 CleanupAppProcesses(); |
347 } | 390 } |
348 } | 391 } |
349 | 392 |
350 // Don't forget to close the handle | 393 // Don't forget to close the handle |
351 CloseHandle(process_); | 394 CloseHandle(process_); |
352 process_ = NULL; | 395 process_ = NULL; |
| 396 #else |
| 397 // TODO(port): depends on AutomationProxy. |
| 398 NOTIMPLEMENTED(); |
| 399 #endif // OS_WIN |
353 } | 400 } |
354 | 401 |
355 void UITest::AssertAppNotRunning(const std::wstring& error_message) { | 402 void UITest::AssertAppNotRunning(const std::wstring& error_message) { |
| 403 #if defined(OS_WIN) |
356 ASSERT_EQ(0, GetBrowserProcessCount()) << error_message; | 404 ASSERT_EQ(0, GetBrowserProcessCount()) << error_message; |
| 405 #else |
| 406 // TODO(port): depends on AutomationProxy. |
| 407 NOTIMPLEMENTED(); |
| 408 #endif |
357 } | 409 } |
358 | 410 |
359 void UITest::CleanupAppProcesses() { | 411 void UITest::CleanupAppProcesses() { |
| 412 #if defined(OS_WIN) |
360 BrowserProcessFilter filter(L""); | 413 BrowserProcessFilter filter(L""); |
361 | 414 |
362 // Make sure that no instances of the browser remain. | 415 // Make sure that no instances of the browser remain. |
363 const int kExitTimeoutMs = 5000; | 416 const int kExitTimeoutMs = 5000; |
364 const int kExitCode = 1; | 417 const int kExitCode = 1; |
365 base::CleanupProcesses( | 418 base::CleanupProcesses( |
366 chrome::kBrowserProcessExecutableName, kExitTimeoutMs, kExitCode, | 419 chrome::kBrowserProcessExecutableName, kExitTimeoutMs, kExitCode, |
367 &filter); | 420 &filter); |
368 | 421 |
369 // Suppress spammy failures that seem to be occurring when running | 422 // Suppress spammy failures that seem to be occurring when running |
370 // the UI tests in single-process mode. | 423 // the UI tests in single-process mode. |
371 // TODO(jhughes): figure out why this is necessary at all, and fix it | 424 // TODO(jhughes): figure out why this is necessary at all, and fix it |
372 if (!in_process_renderer_) { | 425 if (!in_process_renderer_) { |
373 AssertAppNotRunning(L"Unable to quit all browser processes."); | 426 AssertAppNotRunning(L"Unable to quit all browser processes."); |
374 } | 427 } |
| 428 #else |
| 429 // TODO(port): depends on BrowserProcessFilter. |
| 430 NOTIMPLEMENTED(); |
| 431 #endif |
375 } | 432 } |
376 | 433 |
| 434 // TODO(port): this #if effectively cuts out half of this file on |
| 435 // non-Windows platforms, and is a temporary hack to get things |
| 436 // building. |
| 437 #if defined(OS_WIN) |
377 TabProxy* UITest::GetActiveTab() { | 438 TabProxy* UITest::GetActiveTab() { |
378 scoped_ptr<BrowserProxy> window_proxy(automation()->GetBrowserWindow(0)); | 439 scoped_ptr<BrowserProxy> window_proxy(automation()->GetBrowserWindow(0)); |
379 if (!window_proxy.get()) | 440 if (!window_proxy.get()) |
380 return NULL; | 441 return NULL; |
381 | 442 |
382 int active_tab_index = -1; | 443 int active_tab_index = -1; |
383 EXPECT_TRUE(window_proxy->GetActiveTabIndex(&active_tab_index)); | 444 EXPECT_TRUE(window_proxy->GetActiveTabIndex(&active_tab_index)); |
384 if (active_tab_index == -1) | 445 if (active_tab_index == -1) |
385 return NULL; | 446 return NULL; |
386 | 447 |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 const std::wstring& units, | 773 const std::wstring& units, |
713 bool important) { | 774 bool important) { |
714 // <*>RESULT <graph_name>: <trace_name>= <value> <units> | 775 // <*>RESULT <graph_name>: <trace_name>= <value> <units> |
715 // <*>RESULT <graph_name>: <trace_name>= {<mean>, <std deviation>} <units> | 776 // <*>RESULT <graph_name>: <trace_name>= {<mean>, <std deviation>} <units> |
716 // <*>RESULT <graph_name>: <trace_name>= [<value>,value,value,...,] <units> | 777 // <*>RESULT <graph_name>: <trace_name>= [<value>,value,value,...,] <units> |
717 wprintf(L"%lsRESULT %ls%ls: %ls= %ls%ls%ls %ls\n", | 778 wprintf(L"%lsRESULT %ls%ls: %ls= %ls%ls%ls %ls\n", |
718 important ? L"*" : L"", measurement.c_str(), modifier.c_str(), | 779 important ? L"*" : L"", measurement.c_str(), modifier.c_str(), |
719 trace.c_str(), prefix.c_str(), values.c_str(), suffix.c_str(), | 780 trace.c_str(), prefix.c_str(), values.c_str(), suffix.c_str(), |
720 units.c_str()); | 781 units.c_str()); |
721 } | 782 } |
| 783 |
| 784 #endif // OS_WIN |
OLD | NEW |