| Index: chrome/test/ui/ui_test.cc
|
| ===================================================================
|
| --- chrome/test/ui/ui_test.cc (revision 65589)
|
| +++ chrome/test/ui/ui_test.cc (working copy)
|
| @@ -30,6 +30,7 @@
|
| #include "base/utf_string_conversions.h"
|
| #include "chrome/app/chrome_command_ids.h"
|
| #include "chrome/browser/net/url_fixer_upper.h"
|
| +#include "chrome/common/automation_constants.h"
|
| #include "chrome/common/chrome_constants.h"
|
| #include "chrome/common/chrome_paths.h"
|
| #include "chrome/common/chrome_switches.h"
|
| @@ -41,6 +42,7 @@
|
| #include "chrome/test/automation/automation_proxy.h"
|
| #include "chrome/test/automation/browser_proxy.h"
|
| #include "chrome/test/automation/javascript_execution_controller.h"
|
| +#include "chrome/test/automation/proxy_launcher.h"
|
| #include "chrome/test/automation/tab_proxy.h"
|
| #include "chrome/test/automation/window_proxy.h"
|
| #include "chrome/test/chrome_process_util.h"
|
| @@ -138,7 +140,9 @@
|
| JavaScriptExecutionController::set_timeout(
|
| TestTimeouts::action_max_timeout_ms());
|
| test_start_time_ = Time::NowFromSystemTime();
|
| - LaunchBrowserAndServer();
|
| +
|
| + launcher_.reset(CreateProxyLauncher());
|
| + launcher_->InitializeConnection(this);
|
| }
|
|
|
| void UITestBase::TearDown() {
|
| @@ -173,24 +177,35 @@
|
|
|
| // TODO(phajdan.jr): get rid of set_command_execution_timeout_ms.
|
| void UITestBase::set_command_execution_timeout_ms(int timeout) {
|
| - server_->set_command_execution_timeout_ms(timeout);
|
| + automation_proxy_->set_command_execution_timeout_ms(timeout);
|
| VLOG(1) << "Automation command execution timeout set to " << timeout << " ms";
|
| }
|
|
|
| -AutomationProxy* UITestBase::CreateAutomationProxy(int execution_timeout) {
|
| - return new AutomationProxy(execution_timeout, false);
|
| +ProxyLauncher* UITestBase::CreateProxyLauncher() {
|
| + return new AnonymousProxyLauncher(false);
|
| }
|
|
|
| void UITestBase::LaunchBrowserAndServer() {
|
| - // Set up IPC testing interface server.
|
| - server_.reset(CreateAutomationProxy(
|
| - TestTimeouts::command_execution_timeout_ms()));
|
| + // Set up IPC testing interface as a server.
|
| + automation_proxy_.reset(launcher_->CreateAutomationProxy(
|
| + TestTimeouts::command_execution_timeout_ms()));
|
|
|
| LaunchBrowser(launch_arguments_, clear_profile_);
|
| - ASSERT_EQ(AUTOMATION_SUCCESS, server_->WaitForAppLaunch())
|
| + WaitForBrowserLaunch();
|
| +}
|
| +
|
| +void UITestBase::ConnectToRunningBrowser() {
|
| + // Set up IPC testing interface as a client.
|
| + automation_proxy_.reset(launcher_->CreateAutomationProxy(
|
| + TestTimeouts::command_execution_timeout_ms()));
|
| + WaitForBrowserLaunch();
|
| +}
|
| +
|
| +void UITestBase::WaitForBrowserLaunch() {
|
| + ASSERT_EQ(AUTOMATION_SUCCESS, automation_proxy_->WaitForAppLaunch())
|
| << "Error while awaiting automation ping from browser process";
|
| if (wait_for_initial_loads_)
|
| - ASSERT_TRUE(server_->WaitForInitialLoads());
|
| + ASSERT_TRUE(automation_proxy_->WaitForInitialLoads());
|
| else
|
| PlatformThread::Sleep(sleep_timeout_ms());
|
|
|
| @@ -208,7 +223,7 @@
|
| AssertAppNotRunning(StringPrintf(
|
| L"Unable to quit all browser processes. Original PID %d", process_id_));
|
|
|
| - server_.reset(); // Shut down IPC testing interface.
|
| + automation_proxy_.reset(); // Shut down IPC testing interface.
|
| }
|
|
|
| void UITestBase::LaunchBrowser(const CommandLine& arguments,
|
| @@ -565,7 +580,7 @@
|
| }
|
|
|
| void UITestBase::CloseBrowserAsync(BrowserProxy* browser) const {
|
| - ASSERT_TRUE(server_->Send(
|
| + ASSERT_TRUE(automation_proxy_->Send(
|
| new AutomationMsg_CloseBrowserRequestAsync(0, browser->handle())));
|
| }
|
|
|
| @@ -577,7 +592,7 @@
|
|
|
| bool result = true;
|
|
|
| - bool succeeded = server_->Send(new AutomationMsg_CloseBrowser(
|
| + bool succeeded = automation_proxy_->Send(new AutomationMsg_CloseBrowser(
|
| 0, browser->handle(), &result, application_closed));
|
|
|
| if (!succeeded)
|
| @@ -695,10 +710,9 @@
|
| if (dom_automation_enabled_)
|
| command_line.AppendSwitch(switches::kDomAutomationController);
|
|
|
| - if (include_testing_id_) {
|
| + if (include_testing_id_)
|
| command_line.AppendSwitchASCII(switches::kTestingChannelID,
|
| - server_->channel_id());
|
| - }
|
| + launcher_->PrefixedChannelID());
|
|
|
| if (!show_error_dialogs_ &&
|
| !CommandLine::ForCurrentProcess()->HasSwitch(
|
| @@ -775,10 +789,11 @@
|
| << browser_wrapper;
|
| }
|
|
|
| - bool started = base::LaunchApp(command_line.argv(),
|
| - server_->fds_to_map(),
|
| - wait,
|
| - process);
|
| + base::file_handle_mapping_vector fds;
|
| + if (automation_proxy_.get())
|
| + fds = automation_proxy_->fds_to_map();
|
| +
|
| + bool started = base::LaunchApp(command_line.argv(), fds, wait, process);
|
| #endif
|
|
|
| return started;
|
| @@ -845,11 +860,11 @@
|
| PlatformTest::TearDown();
|
| }
|
|
|
| -AutomationProxy* UITest::CreateAutomationProxy(int execution_timeout) {
|
| +ProxyLauncher* UITest::CreateProxyLauncher() {
|
| // Make the AutomationProxy disconnect the channel on the first error,
|
| // so that we avoid spending a lot of time in timeouts. The browser is likely
|
| // hosed if we hit those errors.
|
| - return new AutomationProxy(execution_timeout, true);
|
| + return new AnonymousProxyLauncher(true);
|
| }
|
|
|
| static CommandLine* CreatePythonCommandLine() {
|
| @@ -1175,4 +1190,3 @@
|
| ADD_FAILURE() << "Timeout reached in " << __FUNCTION__;
|
| return false;
|
| }
|
| -
|
|
|