Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: chrome/test/webdriver/webdriver_automation.cc

Issue 10736064: Switch to TimeDelta interfaces in chrome automation test infrastructure. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/test/ui/ui_test.cc ('k') | chrome_frame/chrome_frame_automation.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/webdriver/webdriver_automation.h" 5 #include "chrome/test/webdriver/webdriver_automation.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #endif 9 #endif
10 10
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 proxy->channel()->set_outgoing_message_filter(filter); 279 proxy->channel()->set_outgoing_message_filter(filter);
280 } 280 }
281 281
282 class WebDriverAnonymousProxyLauncher : public AnonymousProxyLauncher { 282 class WebDriverAnonymousProxyLauncher : public AnonymousProxyLauncher {
283 public: 283 public:
284 WebDriverAnonymousProxyLauncher() 284 WebDriverAnonymousProxyLauncher()
285 : AnonymousProxyLauncher(false) {} 285 : AnonymousProxyLauncher(false) {}
286 virtual ~WebDriverAnonymousProxyLauncher() {} 286 virtual ~WebDriverAnonymousProxyLauncher() {}
287 287
288 virtual AutomationProxy* CreateAutomationProxy( 288 virtual AutomationProxy* CreateAutomationProxy(
289 int execution_timeout) OVERRIDE { 289 base::TimeDelta execution_timeout) OVERRIDE {
290 AutomationProxy* proxy = 290 AutomationProxy* proxy =
291 AnonymousProxyLauncher::CreateAutomationProxy(execution_timeout); 291 AnonymousProxyLauncher::CreateAutomationProxy(execution_timeout);
292 AddBackwardsCompatFilter(proxy); 292 AddBackwardsCompatFilter(proxy);
293 return proxy; 293 return proxy;
294 } 294 }
295 }; 295 };
296 296
297 class WebDriverNamedProxyLauncher : public NamedProxyLauncher { 297 class WebDriverNamedProxyLauncher : public NamedProxyLauncher {
298 public: 298 public:
299 WebDriverNamedProxyLauncher(const std::string& channel_id, 299 WebDriverNamedProxyLauncher(const std::string& channel_id,
300 bool launch_browser) 300 bool launch_browser)
301 : NamedProxyLauncher(channel_id, launch_browser, false) {} 301 : NamedProxyLauncher(channel_id, launch_browser, false) {}
302 virtual ~WebDriverNamedProxyLauncher() {} 302 virtual ~WebDriverNamedProxyLauncher() {}
303 303
304 virtual AutomationProxy* CreateAutomationProxy( 304 virtual AutomationProxy* CreateAutomationProxy(
305 int execution_timeout) OVERRIDE { 305 base::TimeDelta execution_timeout) OVERRIDE {
306 AutomationProxy* proxy = 306 AutomationProxy* proxy =
307 NamedProxyLauncher::CreateAutomationProxy(execution_timeout); 307 NamedProxyLauncher::CreateAutomationProxy(execution_timeout);
308 // We can only add the filter here if the browser has not already been 308 // We can only add the filter here if the browser has not already been
309 // started. Otherwise the filter is not guaranteed to receive the 309 // started. Otherwise the filter is not guaranteed to receive the
310 // first message. The only occasion where we don't launch the browser is 310 // first message. The only occasion where we don't launch the browser is
311 // in PyAuto, in which case the backwards compat filter isn't needed 311 // in PyAuto, in which case the backwards compat filter isn't needed
312 // anyways because ChromeDriver and Chrome are at the same version there. 312 // anyways because ChromeDriver and Chrome are at the same version there.
313 if (launch_browser_) 313 if (launch_browser_)
314 AddBackwardsCompatFilter(proxy); 314 AddBackwardsCompatFilter(proxy);
315 return proxy; 315 return proxy;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 }; 429 };
430 if (!launcher_->InitializeConnection(launch_props, true)) { 430 if (!launcher_->InitializeConnection(launch_props, true)) {
431 logger_.Log(kSevereLogLevel, "Failed to initialize connection"); 431 logger_.Log(kSevereLogLevel, "Failed to initialize connection");
432 *error = new Error( 432 *error = new Error(
433 kUnknownError, 433 kUnknownError,
434 "Unable to either launch or connect to Chrome. Please check that " 434 "Unable to either launch or connect to Chrome. Please check that "
435 "ChromeDriver is up-to-date. " + chrome_details); 435 "ChromeDriver is up-to-date. " + chrome_details);
436 return; 436 return;
437 } 437 }
438 438
439 launcher_->automation()->set_action_timeout_ms(base::kNoTimeout); 439 launcher_->automation()->set_action_timeout(
440 base::TimeDelta::FromMilliseconds(base::kNoTimeout));
440 logger_.Log(kInfoLogLevel, "Connected to Chrome successfully. Version: " + 441 logger_.Log(kInfoLogLevel, "Connected to Chrome successfully. Version: " +
441 automation()->server_version()); 442 automation()->server_version());
442 443
443 *error = DetermineBuildNumber(); 444 *error = DetermineBuildNumber();
444 if (*error) 445 if (*error)
445 return; 446 return;
446 *build_no = build_no_; 447 *build_no = build_no_;
447 448
448 // Check the version of Chrome is compatible with this ChromeDriver. 449 // Check the version of Chrome is compatible with this ChromeDriver.
449 chrome_details += ", version (" + automation()->server_version() + ")"; 450 chrome_details += ", version (" + automation()->server_version() + ")";
(...skipping 19 matching lines...) Expand all
469 // There's currently no way to shutdown gracefully with mac chrome. 470 // There's currently no way to shutdown gracefully with mac chrome.
470 // An alert could be open or (open before shutdown is started) and stop 471 // An alert could be open or (open before shutdown is started) and stop
471 // the whole process. Close any current dialog, try to kill gently, and 472 // the whole process. Close any current dialog, try to kill gently, and
472 // if all else fails, kill it hard. 473 // if all else fails, kill it hard.
473 Error* error = NULL; 474 Error* error = NULL;
474 AcceptOrDismissAppModalDialog(true /* accept */, &error); 475 AcceptOrDismissAppModalDialog(true /* accept */, &error);
475 scoped_ptr<Error> scoped_error(error); 476 scoped_ptr<Error> scoped_error(error);
476 477
477 kill(launcher_->process(), SIGTERM); 478 kill(launcher_->process(), SIGTERM);
478 int exit_code = -1; 479 int exit_code = -1;
479 if (!launcher_->WaitForBrowserProcessToQuit(10000, &exit_code)) { 480 if (!launcher_->WaitForBrowserProcessToQuit(
481 base::TimeDelta::FromSeconds(10), &exit_code)) {
480 TerminateAllChromeProcesses(launcher_->process_id()); 482 TerminateAllChromeProcesses(launcher_->process_id());
481 } 483 }
482 base::CloseProcessHandle(launcher_->process()); 484 base::CloseProcessHandle(launcher_->process());
483 #else 485 #else
484 launcher_->TerminateBrowser(); 486 launcher_->TerminateBrowser();
485 #endif 487 #endif
486 } 488 }
487 } 489 }
488 490
489 void Automation::ExecuteScript(const WebViewId& view_id, 491 void Automation::ExecuteScript(const WebViewId& view_id,
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 } 1176 }
1175 1177
1176 Error* Automation::CheckMaximizeSupported() { 1178 Error* Automation::CheckMaximizeSupported() {
1177 const char* message = 1179 const char* message =
1178 "Maximize automation interface is not supported for this version of " 1180 "Maximize automation interface is not supported for this version of "
1179 "Chrome."; 1181 "Chrome.";
1180 return CheckVersion(1160, message); 1182 return CheckVersion(1160, message);
1181 } 1183 }
1182 1184
1183 } // namespace webdriver 1185 } // namespace webdriver
OLDNEW
« no previous file with comments | « chrome/test/ui/ui_test.cc ('k') | chrome_frame/chrome_frame_automation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698