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

Side by Side Diff: chrome/test/automation/proxy_launcher.cc

Issue 7523060: Let pyauto create an attached webdriver instance to manipulate web pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/automation/proxy_launcher.h" 5 #include "chrome/test/automation/proxy_launcher.h"
6 6
7 #include "base/environment.h" 7 #include "base/environment.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 } 498 }
499 499
500 base::TimeDelta ProxyLauncher::browser_quit_time() const { 500 base::TimeDelta ProxyLauncher::browser_quit_time() const {
501 return browser_quit_time_; 501 return browser_quit_time_;
502 } 502 }
503 503
504 // NamedProxyLauncher functions 504 // NamedProxyLauncher functions
505 505
506 NamedProxyLauncher::NamedProxyLauncher(const std::string& channel_id, 506 NamedProxyLauncher::NamedProxyLauncher(const std::string& channel_id,
507 bool launch_browser, 507 bool launch_browser,
508 bool wait_for_server_channel,
508 bool disconnect_on_failure) 509 bool disconnect_on_failure)
509 : channel_id_(channel_id), 510 : channel_id_(channel_id),
510 launch_browser_(launch_browser), 511 launch_browser_(launch_browser),
512 wait_for_server_channel_(wait_for_server_channel),
511 disconnect_on_failure_(disconnect_on_failure) { 513 disconnect_on_failure_(disconnect_on_failure) {
512 } 514 }
513 515
514 AutomationProxy* NamedProxyLauncher::CreateAutomationProxy( 516 AutomationProxy* NamedProxyLauncher::CreateAutomationProxy(
515 int execution_timeout) { 517 int execution_timeout) {
516 AutomationProxy* proxy = new AutomationProxy(execution_timeout, 518 AutomationProxy* proxy = new AutomationProxy(execution_timeout,
517 disconnect_on_failure_); 519 disconnect_on_failure_);
518 proxy->InitializeChannel(channel_id_, true); 520 proxy->InitializeChannel(channel_id_, true);
519 return proxy; 521 return proxy;
520 } 522 }
(...skipping 14 matching lines...) Expand all
535 LOG(ERROR) << "Failed to delete " << testing_channel_path.value(); 537 LOG(ERROR) << "Failed to delete " << testing_channel_path.value();
536 return false; 538 return false;
537 } 539 }
538 540
539 if (!LaunchBrowser(state)) { 541 if (!LaunchBrowser(state)) {
540 LOG(ERROR) << "Failed to LaunchBrowser"; 542 LOG(ERROR) << "Failed to LaunchBrowser";
541 return false; 543 return false;
542 } 544 }
543 } 545 }
544 546
545 // Wait for browser to be ready for connections. 547 if (wait_for_server_channel_) {
546 bool testing_channel_exists = false; 548 // Wait for browser to be ready for connections.
547 for (int wait_time = 0; 549 bool testing_channel_exists = false;
548 wait_time < TestTimeouts::action_max_timeout_ms(); 550 for (int wait_time = 0;
549 wait_time += automation::kSleepTime) { 551 wait_time < TestTimeouts::action_max_timeout_ms();
550 testing_channel_exists = file_util::PathExists(testing_channel_path); 552 wait_time += automation::kSleepTime) {
551 if (testing_channel_exists) 553 testing_channel_exists = file_util::PathExists(testing_channel_path);
552 break; 554 if (testing_channel_exists)
553 base::PlatformThread::Sleep(automation::kSleepTime); 555 break;
554 } 556 base::PlatformThread::Sleep(automation::kSleepTime);
555 if (!testing_channel_exists) { 557 }
556 LOG(ERROR) << "Failed to wait for testing channel presence."; 558 if (!testing_channel_exists) {
557 return false; 559 LOG(ERROR) << "Failed to wait for testing channel presence.";
560 return false;
561 }
558 } 562 }
559 563
560 if (!ConnectToRunningBrowser(wait_for_initial_loads)) { 564 if (!ConnectToRunningBrowser(wait_for_initial_loads)) {
561 LOG(ERROR) << "Failed to ConnectToRunningBrowser"; 565 LOG(ERROR) << "Failed to ConnectToRunningBrowser";
562 return false; 566 return false;
563 } 567 }
564 568
565 return true; 569 return true;
566 } 570 }
567 571
(...skipping 30 matching lines...) Expand all
598 return LaunchBrowserAndServer(state, wait_for_initial_loads); 602 return LaunchBrowserAndServer(state, wait_for_initial_loads);
599 } 603 }
600 604
601 void AnonymousProxyLauncher::TerminateConnection() { 605 void AnonymousProxyLauncher::TerminateConnection() {
602 CloseBrowserAndServer(); 606 CloseBrowserAndServer();
603 } 607 }
604 608
605 std::string AnonymousProxyLauncher::PrefixedChannelID() const { 609 std::string AnonymousProxyLauncher::PrefixedChannelID() const {
606 return channel_id_; 610 return channel_id_;
607 } 611 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698