OLD | NEW |
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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
522 void NamedProxyLauncher::InitializeConnection(const LaunchState& state, | 522 bool NamedProxyLauncher::InitializeConnection(const LaunchState& state, |
523 bool wait_for_initial_loads) { | 523 bool wait_for_initial_loads) { |
524 if (launch_browser_) { | 524 if (launch_browser_) { |
525 #if defined(OS_POSIX) | 525 #if defined(OS_POSIX) |
526 // Because we are waiting on the existence of the testing file below, | 526 // Because we are waiting on the existence of the testing file below, |
527 // make sure there isn't one already there before browser launch. | 527 // make sure there isn't one already there before browser launch. |
528 EXPECT_TRUE(file_util::Delete(FilePath(channel_id_), false)); | 528 if (!file_util::Delete(FilePath(channel_id_), false)) { |
| 529 LOG(ERROR) << "Failed to delete " << channel_id_; |
| 530 return false; |
| 531 } |
529 #endif | 532 #endif |
530 | 533 |
531 // Set up IPC testing interface as a client. | 534 if (!LaunchBrowser(state)) { |
532 ASSERT_TRUE(LaunchBrowser(state)); | 535 LOG(ERROR) << "Failed to LaunchBrowser"; |
| 536 return false; |
| 537 } |
533 } | 538 } |
534 | 539 |
535 // Wait for browser to be ready for connections. | 540 // Wait for browser to be ready for connections. |
536 bool channel_initialized = false; | 541 bool channel_initialized = false; |
537 for (int wait_time = 0; | 542 for (int wait_time = 0; |
538 wait_time < TestTimeouts::action_max_timeout_ms(); | 543 wait_time < TestTimeouts::action_max_timeout_ms(); |
539 wait_time += automation::kSleepTime) { | 544 wait_time += automation::kSleepTime) { |
540 channel_initialized = IPC::Channel::IsNamedServerInitialized(channel_id_); | 545 channel_initialized = IPC::Channel::IsNamedServerInitialized(channel_id_); |
541 if (channel_initialized) | 546 if (channel_initialized) |
542 break; | 547 break; |
543 base::PlatformThread::Sleep(automation::kSleepTime); | 548 base::PlatformThread::Sleep(automation::kSleepTime); |
544 } | 549 } |
545 EXPECT_TRUE(channel_initialized); | 550 if (!channel_initialized) { |
| 551 LOG(ERROR) << "Failed to wait for testing channel presence."; |
| 552 return false; |
| 553 } |
546 | 554 |
547 ASSERT_TRUE(ConnectToRunningBrowser(wait_for_initial_loads)); | 555 if (!ConnectToRunningBrowser(wait_for_initial_loads)) { |
| 556 LOG(ERROR) << "Failed to ConnectToRunningBrowser"; |
| 557 return false; |
| 558 } |
| 559 return true; |
548 } | 560 } |
549 | 561 |
550 void NamedProxyLauncher::TerminateConnection() { | 562 void NamedProxyLauncher::TerminateConnection() { |
551 if (launch_browser_) | 563 if (launch_browser_) |
552 CloseBrowserAndServer(); | 564 CloseBrowserAndServer(); |
553 else | 565 else |
554 DisconnectFromRunningBrowser(); | 566 DisconnectFromRunningBrowser(); |
555 } | 567 } |
556 | 568 |
557 std::string NamedProxyLauncher::PrefixedChannelID() const { | 569 std::string NamedProxyLauncher::PrefixedChannelID() const { |
(...skipping 10 matching lines...) Expand all Loading... |
568 } | 580 } |
569 | 581 |
570 AutomationProxy* AnonymousProxyLauncher::CreateAutomationProxy( | 582 AutomationProxy* AnonymousProxyLauncher::CreateAutomationProxy( |
571 int execution_timeout) { | 583 int execution_timeout) { |
572 AutomationProxy* proxy = new AutomationProxy(execution_timeout, | 584 AutomationProxy* proxy = new AutomationProxy(execution_timeout, |
573 disconnect_on_failure_); | 585 disconnect_on_failure_); |
574 proxy->InitializeChannel(channel_id_, false); | 586 proxy->InitializeChannel(channel_id_, false); |
575 return proxy; | 587 return proxy; |
576 } | 588 } |
577 | 589 |
578 void AnonymousProxyLauncher::InitializeConnection(const LaunchState& state, | 590 bool AnonymousProxyLauncher::InitializeConnection(const LaunchState& state, |
579 bool wait_for_initial_loads) { | 591 bool wait_for_initial_loads) { |
580 ASSERT_TRUE(LaunchBrowserAndServer(state, wait_for_initial_loads)); | 592 return LaunchBrowserAndServer(state, wait_for_initial_loads); |
581 } | 593 } |
582 | 594 |
583 void AnonymousProxyLauncher::TerminateConnection() { | 595 void AnonymousProxyLauncher::TerminateConnection() { |
584 CloseBrowserAndServer(); | 596 CloseBrowserAndServer(); |
585 } | 597 } |
586 | 598 |
587 std::string AnonymousProxyLauncher::PrefixedChannelID() const { | 599 std::string AnonymousProxyLauncher::PrefixedChannelID() const { |
588 return channel_id_; | 600 return channel_id_; |
589 } | 601 } |
OLD | NEW |