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

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: move bools into struct 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 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 return browser_launch_time_; 497 return browser_launch_time_;
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 const InitParams& params)
508 bool disconnect_on_failure)
509 : channel_id_(channel_id), 508 : channel_id_(channel_id),
510 launch_browser_(launch_browser), 509 launch_browser_(params.launch_browser),
511 disconnect_on_failure_(disconnect_on_failure) { 510 disconnect_on_failure_(params.disconnect_on_failure),
511 wait_for_server_channel_(params.wait_for_server_channel) {
512 } 512 }
513 513
514 AutomationProxy* NamedProxyLauncher::CreateAutomationProxy( 514 AutomationProxy* NamedProxyLauncher::CreateAutomationProxy(
515 int execution_timeout) { 515 int execution_timeout) {
516 AutomationProxy* proxy = new AutomationProxy(execution_timeout, 516 AutomationProxy* proxy = new AutomationProxy(execution_timeout,
517 disconnect_on_failure_); 517 disconnect_on_failure_);
518 proxy->InitializeChannel(channel_id_, true); 518 proxy->InitializeChannel(channel_id_, true);
519 return proxy; 519 return proxy;
520 } 520 }
521 521
(...skipping 13 matching lines...) Expand all
535 LOG(ERROR) << "Failed to delete " << testing_channel_path.value(); 535 LOG(ERROR) << "Failed to delete " << testing_channel_path.value();
536 return false; 536 return false;
537 } 537 }
538 538
539 if (!LaunchBrowser(state)) { 539 if (!LaunchBrowser(state)) {
540 LOG(ERROR) << "Failed to LaunchBrowser"; 540 LOG(ERROR) << "Failed to LaunchBrowser";
541 return false; 541 return false;
542 } 542 }
543 } 543 }
544 544
545 // Wait for browser to be ready for connections. 545 if (wait_for_server_channel_) {
546 bool testing_channel_exists = false; 546 // Wait for browser to be ready for connections.
547 for (int wait_time = 0; 547 bool testing_channel_exists = false;
548 wait_time < TestTimeouts::action_max_timeout_ms(); 548 for (int wait_time = 0;
549 wait_time += automation::kSleepTime) { 549 wait_time < TestTimeouts::action_max_timeout_ms();
550 testing_channel_exists = file_util::PathExists(testing_channel_path); 550 wait_time += automation::kSleepTime) {
551 if (testing_channel_exists) 551 testing_channel_exists = file_util::PathExists(testing_channel_path);
552 break; 552 if (testing_channel_exists)
553 base::PlatformThread::Sleep(automation::kSleepTime); 553 break;
554 } 554 base::PlatformThread::Sleep(automation::kSleepTime);
555 if (!testing_channel_exists) { 555 }
556 LOG(ERROR) << "Failed to wait for testing channel presence."; 556 if (!testing_channel_exists) {
557 return false; 557 LOG(ERROR) << "Failed to wait for testing channel presence.";
558 return false;
559 }
558 } 560 }
559 561
560 if (!ConnectToRunningBrowser(wait_for_initial_loads)) { 562 if (!ConnectToRunningBrowser(wait_for_initial_loads)) {
561 LOG(ERROR) << "Failed to ConnectToRunningBrowser"; 563 LOG(ERROR) << "Failed to ConnectToRunningBrowser";
562 return false; 564 return false;
563 } 565 }
564 566
565 return true; 567 return true;
566 } 568 }
567 569
(...skipping 30 matching lines...) Expand all
598 return LaunchBrowserAndServer(state, wait_for_initial_loads); 600 return LaunchBrowserAndServer(state, wait_for_initial_loads);
599 } 601 }
600 602
601 void AnonymousProxyLauncher::TerminateConnection() { 603 void AnonymousProxyLauncher::TerminateConnection() {
602 CloseBrowserAndServer(); 604 CloseBrowserAndServer();
603 } 605 }
604 606
605 std::string AnonymousProxyLauncher::PrefixedChannelID() const { 607 std::string AnonymousProxyLauncher::PrefixedChannelID() const {
606 return channel_id_; 608 return channel_id_;
607 } 609 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698