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

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

Issue 10787010: Switch to TimeDelta interfaces in chrome automation test infrastructure. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase onto master. 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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 proxy->channel()->set_outgoing_message_filter(filter); 293 proxy->channel()->set_outgoing_message_filter(filter);
294 } 294 }
295 295
296 class WebDriverAnonymousProxyLauncher : public AnonymousProxyLauncher { 296 class WebDriverAnonymousProxyLauncher : public AnonymousProxyLauncher {
297 public: 297 public:
298 WebDriverAnonymousProxyLauncher() 298 WebDriverAnonymousProxyLauncher()
299 : AnonymousProxyLauncher(false) {} 299 : AnonymousProxyLauncher(false) {}
300 virtual ~WebDriverAnonymousProxyLauncher() {} 300 virtual ~WebDriverAnonymousProxyLauncher() {}
301 301
302 virtual AutomationProxy* CreateAutomationProxy( 302 virtual AutomationProxy* CreateAutomationProxy(
303 int execution_timeout) OVERRIDE { 303 base::TimeDelta execution_timeout) OVERRIDE {
304 AutomationProxy* proxy = 304 AutomationProxy* proxy =
305 AnonymousProxyLauncher::CreateAutomationProxy(execution_timeout); 305 AnonymousProxyLauncher::CreateAutomationProxy(execution_timeout);
306 AddBackwardsCompatFilter(proxy); 306 AddBackwardsCompatFilter(proxy);
307 return proxy; 307 return proxy;
308 } 308 }
309 }; 309 };
310 310
311 class WebDriverNamedProxyLauncher : public NamedProxyLauncher { 311 class WebDriverNamedProxyLauncher : public NamedProxyLauncher {
312 public: 312 public:
313 WebDriverNamedProxyLauncher(const std::string& channel_id, 313 WebDriverNamedProxyLauncher(const std::string& channel_id,
314 bool launch_browser) 314 bool launch_browser)
315 : NamedProxyLauncher(channel_id, launch_browser, false) {} 315 : NamedProxyLauncher(channel_id, launch_browser, false) {}
316 virtual ~WebDriverNamedProxyLauncher() {} 316 virtual ~WebDriverNamedProxyLauncher() {}
317 317
318 virtual AutomationProxy* CreateAutomationProxy( 318 virtual AutomationProxy* CreateAutomationProxy(
319 int execution_timeout) OVERRIDE { 319 base::TimeDelta execution_timeout) OVERRIDE {
320 AutomationProxy* proxy = 320 AutomationProxy* proxy =
321 NamedProxyLauncher::CreateAutomationProxy(execution_timeout); 321 NamedProxyLauncher::CreateAutomationProxy(execution_timeout);
322 // We can only add the filter here if the browser has not already been 322 // We can only add the filter here if the browser has not already been
323 // started. Otherwise the filter is not guaranteed to receive the 323 // started. Otherwise the filter is not guaranteed to receive the
324 // first message. The only occasion where we don't launch the browser is 324 // first message. The only occasion where we don't launch the browser is
325 // in PyAuto, in which case the backwards compat filter isn't needed 325 // in PyAuto, in which case the backwards compat filter isn't needed
326 // anyways because ChromeDriver and Chrome are at the same version there. 326 // anyways because ChromeDriver and Chrome are at the same version there.
327 if (launch_browser_) 327 if (launch_browser_)
328 AddBackwardsCompatFilter(proxy); 328 AddBackwardsCompatFilter(proxy);
329 return proxy; 329 return proxy;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 }; 443 };
444 if (!launcher_->InitializeConnection(launch_props, true)) { 444 if (!launcher_->InitializeConnection(launch_props, true)) {
445 logger_.Log(kSevereLogLevel, "Failed to initialize connection"); 445 logger_.Log(kSevereLogLevel, "Failed to initialize connection");
446 *error = new Error( 446 *error = new Error(
447 kUnknownError, 447 kUnknownError,
448 "Unable to either launch or connect to Chrome. Please check that " 448 "Unable to either launch or connect to Chrome. Please check that "
449 "ChromeDriver is up-to-date. " + chrome_details); 449 "ChromeDriver is up-to-date. " + chrome_details);
450 return; 450 return;
451 } 451 }
452 452
453 launcher_->automation()->set_action_timeout_ms(base::kNoTimeout); 453 launcher_->automation()->set_action_timeout(
454 base::TimeDelta::FromMilliseconds(base::kNoTimeout));
454 logger_.Log(kInfoLogLevel, "Connected to Chrome successfully. Version: " + 455 logger_.Log(kInfoLogLevel, "Connected to Chrome successfully. Version: " +
455 automation()->server_version()); 456 automation()->server_version());
456 457
457 *error = DetermineBuildNumber(); 458 *error = DetermineBuildNumber();
458 if (*error) 459 if (*error)
459 return; 460 return;
460 *build_no = build_no_; 461 *build_no = build_no_;
461 462
462 // Check the version of Chrome is compatible with this ChromeDriver. 463 // Check the version of Chrome is compatible with this ChromeDriver.
463 chrome_details += ", version (" + automation()->server_version() + ")"; 464 chrome_details += ", version (" + automation()->server_version() + ")";
(...skipping 22 matching lines...) Expand all
486 // if all else fails, kill it hard. 487 // if all else fails, kill it hard.
487 Error* error = NULL; 488 Error* error = NULL;
488 AcceptOrDismissAppModalDialog(true /* accept */, &error); 489 AcceptOrDismissAppModalDialog(true /* accept */, &error);
489 scoped_ptr<Error> scoped_error(error); 490 scoped_ptr<Error> scoped_error(error);
490 491
491 kill(launcher_->process(), SIGTERM); 492 kill(launcher_->process(), SIGTERM);
492 #else 493 #else
493 automation()->Disconnect(); 494 automation()->Disconnect();
494 #endif 495 #endif
495 int exit_code = -1; 496 int exit_code = -1;
496 if (!launcher_->WaitForBrowserProcessToQuit(10000, &exit_code)) { 497 if (!launcher_->WaitForBrowserProcessToQuit(
498 base::TimeDelta::FromSeconds(10), &exit_code)) {
497 logger_.Log(kWarningLogLevel, "Chrome still running, terminating..."); 499 logger_.Log(kWarningLogLevel, "Chrome still running, terminating...");
498 TerminateAllChromeProcesses(launcher_->process_id()); 500 TerminateAllChromeProcesses(launcher_->process_id());
499 } 501 }
500 base::CloseProcessHandle(launcher_->process()); 502 base::CloseProcessHandle(launcher_->process());
501 logger_.Log(kInfoLogLevel, "Chrome shutdown"); 503 logger_.Log(kInfoLogLevel, "Chrome shutdown");
502 } 504 }
503 } 505 }
504 506
505 void Automation::ExecuteScript(const WebViewId& view_id, 507 void Automation::ExecuteScript(const WebViewId& view_id,
506 const FramePath& frame_path, 508 const FramePath& frame_path,
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 } 1192 }
1191 1193
1192 Error* Automation::CheckMaximizeSupported() { 1194 Error* Automation::CheckMaximizeSupported() {
1193 const char* message = 1195 const char* message =
1194 "Maximize automation interface is not supported for this version of " 1196 "Maximize automation interface is not supported for this version of "
1195 "Chrome."; 1197 "Chrome.";
1196 return CheckVersion(1160, message); 1198 return CheckVersion(1160, message);
1197 } 1199 }
1198 1200
1199 } // namespace webdriver 1201 } // 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