| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #if defined(OS_POSIX) | 7 #if defined(OS_POSIX) |
| 8 #include <signal.h> | 8 #include <signal.h> |
| 9 #include <sys/types.h> | 9 #include <sys/types.h> |
| 10 #endif | 10 #endif |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 } | 265 } |
| 266 | 266 |
| 267 AutomationProxy* UITestBase::CreateAutomationProxy(int execution_timeout) { | 267 AutomationProxy* UITestBase::CreateAutomationProxy(int execution_timeout) { |
| 268 return new AutomationProxy(execution_timeout, false); | 268 return new AutomationProxy(execution_timeout, false); |
| 269 } | 269 } |
| 270 | 270 |
| 271 void UITestBase::LaunchBrowserAndServer() { | 271 void UITestBase::LaunchBrowserAndServer() { |
| 272 // Set up IPC testing interface server. | 272 // Set up IPC testing interface server. |
| 273 server_.reset(CreateAutomationProxy(command_execution_timeout_ms_)); | 273 server_.reset(CreateAutomationProxy(command_execution_timeout_ms_)); |
| 274 | 274 |
| 275 const int kTries = 3; | 275 LaunchBrowser(launch_arguments_, clear_profile_); |
| 276 for (int i = 0; i < kTries; i++) { | 276 server_->WaitForAppLaunch(); |
| 277 if (i > 0) { | 277 if (wait_for_initial_loads_) |
| 278 LOG(ERROR) << "Launching browser again, retry #" << i; | 278 ASSERT_TRUE(server_->WaitForInitialLoads()); |
| 279 } | 279 else |
| 280 PlatformThread::Sleep(sleep_timeout_ms()); |
| 280 | 281 |
| 281 LaunchBrowser(launch_arguments_, clear_profile_); | 282 EXPECT_TRUE(automation()->SetFilteredInet(ShouldFilterInet())); |
| 282 AutomationLaunchResult launch_result = server_->WaitForAppLaunch(); | |
| 283 if (launch_result == AUTOMATION_SUCCESS) { | |
| 284 bool initial_loads_result = false; | |
| 285 if (wait_for_initial_loads_) { | |
| 286 initial_loads_result = server_->WaitForInitialLoads(); | |
| 287 } else { | |
| 288 PlatformThread::Sleep(sleep_timeout_ms()); | |
| 289 initial_loads_result = true; | |
| 290 } | |
| 291 | |
| 292 if (initial_loads_result) { | |
| 293 if (automation()->SetFilteredInet(ShouldFilterInet())) { | |
| 294 return; | |
| 295 } else { | |
| 296 LOG(ERROR) << "SetFilteredInet failed"; | |
| 297 } | |
| 298 } else { | |
| 299 LOG(ERROR) << "WaitForInitialLoadsFailed"; | |
| 300 } | |
| 301 } else { | |
| 302 LOG(ERROR) << "WaitForAppLaunch failed: " << launch_result; | |
| 303 } | |
| 304 | |
| 305 // The browser is likely hosed or already down at this point. Do not wait | |
| 306 // for it, just kill anything that is still running, preparing a clean | |
| 307 // environment for the next retry. | |
| 308 CleanupAppProcesses(); | |
| 309 } | |
| 310 | |
| 311 FAIL() << "Failed to launch browser"; | |
| 312 } | 283 } |
| 313 | 284 |
| 314 void UITestBase::CloseBrowserAndServer() { | 285 void UITestBase::CloseBrowserAndServer() { |
| 315 QuitBrowser(); | 286 QuitBrowser(); |
| 316 CleanupAppProcesses(); | 287 CleanupAppProcesses(); |
| 317 | 288 |
| 318 // Suppress spammy failures that seem to be occurring when running | 289 // Suppress spammy failures that seem to be occurring when running |
| 319 // the UI tests in single-process mode. | 290 // the UI tests in single-process mode. |
| 320 // TODO(jhughes): figure out why this is necessary at all, and fix it | 291 // TODO(jhughes): figure out why this is necessary at all, and fix it |
| 321 if (!in_process_renderer_) | 292 if (!in_process_renderer_) |
| (...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1252 UITestBase::TearDown(); | 1223 UITestBase::TearDown(); |
| 1253 PlatformTest::TearDown(); | 1224 PlatformTest::TearDown(); |
| 1254 } | 1225 } |
| 1255 | 1226 |
| 1256 AutomationProxy* UITest::CreateAutomationProxy(int execution_timeout) { | 1227 AutomationProxy* UITest::CreateAutomationProxy(int execution_timeout) { |
| 1257 // Make the AutomationProxy disconnect the channel on the first error, | 1228 // Make the AutomationProxy disconnect the channel on the first error, |
| 1258 // so that we avoid spending a lot of time in timeouts. The browser is likely | 1229 // so that we avoid spending a lot of time in timeouts. The browser is likely |
| 1259 // hosed if we hit those errors. | 1230 // hosed if we hit those errors. |
| 1260 return new AutomationProxy(execution_timeout, true); | 1231 return new AutomationProxy(execution_timeout, true); |
| 1261 } | 1232 } |
| OLD | NEW |