diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-19 18:41:18 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-19 18:41:18 +0000 |
commit | c799519cc0806faa5001a9d07badc2cbdf1c97bb (patch) | |
tree | abfad202fe88def23831d092457d244d4ab37a8b /chrome/test/automation | |
parent | d8c6cabdea33f84a488f529bb027491739b2fb6e (diff) | |
download | chromium_src-c799519cc0806faa5001a9d07badc2cbdf1c97bb.zip chromium_src-c799519cc0806faa5001a9d07badc2cbdf1c97bb.tar.gz chromium_src-c799519cc0806faa5001a9d07badc2cbdf1c97bb.tar.bz2 |
GTTF: After timeout, all further automation calls should fail immediately.
If IPC send fails, further automation calls are extremely likely to fail.
Avoid wasting a lot of time on further timeouts by closing the channel
immediately on the first error.
TEST=ui_tests
BUG=51346
Review URL: http://codereview.chromium.org/3131020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56722 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/automation')
-rw-r--r-- | chrome/test/automation/automation_proxy.cc | 28 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy.h | 6 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy_uitest.cc | 2 |
3 files changed, 28 insertions, 8 deletions
diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc index 6cc574b..31e339b 100644 --- a/chrome/test/automation/automation_proxy.cc +++ b/chrome/test/automation/automation_proxy.cc @@ -91,13 +91,15 @@ class AutomationMessageFilter : public IPC::ChannelProxy::MessageFilter { } // anonymous namespace -AutomationProxy::AutomationProxy(int command_execution_timeout_ms) +AutomationProxy::AutomationProxy(int command_execution_timeout_ms, + bool disconnect_on_failure) : app_launched_(true, false), initial_loads_complete_(true, false), new_tab_ui_load_complete_(true, false), shutdown_event_(new base::WaitableEvent(true, false)), app_launch_signaled_(0), perform_version_check_(false), + disconnect_on_failure_(disconnect_on_failure), command_execution_timeout_( TimeDelta::FromMilliseconds(command_execution_timeout_ms)), listener_thread_id_(0) { @@ -113,12 +115,10 @@ AutomationProxy::AutomationProxy(int command_execution_timeout_ms) } AutomationProxy::~AutomationProxy() { - DCHECK(shutdown_event_.get() != NULL); - shutdown_event_->Signal(); // Destruction order is important. Thread has to outlive the channel and // tracker has to outlive the thread since we access the tracker inside // AutomationMessageFilter::OnMessageReceived. - channel_.reset(); + Disconnect(); thread_.reset(); tracker_.reset(); } @@ -379,6 +379,8 @@ bool AutomationProxy::SendProxyConfig(const std::string& new_proxy_config) { } void AutomationProxy::Disconnect() { + DCHECK(shutdown_event_.get() != NULL); + shutdown_event_->Signal(); channel_.reset(); } @@ -389,7 +391,9 @@ void AutomationProxy::OnMessageReceived(const IPC::Message& msg) { } void AutomationProxy::OnChannelError() { - DLOG(ERROR) << "Channel error in AutomationProxy."; + LOG(ERROR) << "Channel error in AutomationProxy."; + if (disconnect_on_failure_) + Disconnect(); } scoped_refptr<WindowProxy> AutomationProxy::GetActiveWindow() { @@ -450,7 +454,19 @@ bool AutomationProxy::Send(IPC::Message* message) { return false; } - return channel_->SendWithTimeout(message, command_execution_timeout_ms()); + bool success = channel_->SendWithTimeout(message, + command_execution_timeout_ms()); + + if (!success && disconnect_on_failure_) { + // Send failed (possibly due to a timeout). Browser is likely in a weird + // state, and further IPC requests are extremely likely to fail (possibly + // timeout, which would make tests slower). Disconnect the channel now + // to avoid the slowness. + LOG(ERROR) << "Disconnecting channel after error!"; + Disconnect(); + } + + return success; } void AutomationProxy::InvalidateHandle(const IPC::Message& message) { diff --git a/chrome/test/automation/automation_proxy.h b/chrome/test/automation/automation_proxy.h index 8b864aa..344c248 100644 --- a/chrome/test/automation/automation_proxy.h +++ b/chrome/test/automation/automation_proxy.h @@ -58,7 +58,7 @@ class AutomationMessageSender : public IPC::Message::Sender { class AutomationProxy : public IPC::Channel::Listener, public AutomationMessageSender { public: - explicit AutomationProxy(int command_execution_timeout_ms); + AutomationProxy(int command_execution_timeout_ms, bool disconnect_on_failure); virtual ~AutomationProxy(); // IPC callback @@ -293,6 +293,10 @@ class AutomationProxy : public IPC::Channel::Listener, // a version resource. bool perform_version_check_; + // If true, the proxy will disconnect the IPC channel on first failure + // to send an IPC message. This helps avoid long timeouts in tests. + bool disconnect_on_failure_; + // Delay to let the browser execute the command. base::TimeDelta command_execution_timeout_; diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc index 4493979..96e43dd 100644 --- a/chrome/test/automation/automation_proxy_uitest.cc +++ b/chrome/test/automation/automation_proxy_uitest.cc @@ -624,7 +624,7 @@ const char simple_data_url[] = "</body></html>"; ExternalTabUITestMockClient::ExternalTabUITestMockClient(int execution_timeout) - : AutomationProxy(execution_timeout), + : AutomationProxy(execution_timeout, false), host_window_style_(WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_VISIBLE), host_window_(NULL) { } |