summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/test/test_switches.cc3
-rw-r--r--base/test/test_switches.h3
-rw-r--r--base/test/test_timeouts.cc9
-rw-r--r--base/test/test_timeouts.h9
-rw-r--r--chrome/chrome.gyp1
-rw-r--r--chrome/test/automation/automation_json_requests.cc7
-rw-r--r--chrome/test/automation/automation_json_requests.h1
-rw-r--r--chrome/test/automation/automation_proxy.cc25
-rw-r--r--chrome/test/automation/automation_proxy.h17
-rw-r--r--chrome/test/automation/browser_proxy.cc11
-rw-r--r--chrome/test/automation/browser_proxy.h3
-rw-r--r--chrome/test/automation/proxy_launcher.cc6
-rw-r--r--chrome/test/functional/downloads.py13
-rw-r--r--chrome/test/functional/test_utils.py4
-rw-r--r--chrome/test/interactive_ui/fast_shutdown_interactive_uitest.cc3
-rw-r--r--chrome/test/pyautolib/pyauto.py42
-rw-r--r--chrome/test/pyautolib/pyautolib.cc7
-rw-r--r--chrome/test/pyautolib/pyautolib.h8
-rw-r--r--chrome/test/pyautolib/pyautolib.i20
-rw-r--r--chrome/test/ui/ui_test.cc12
-rw-r--r--chrome/test/ui/ui_test.h4
-rw-r--r--chrome_frame/test/automation_client_mock.h4
22 files changed, 120 insertions, 92 deletions
diff --git a/base/test/test_switches.cc b/base/test/test_switches.cc
index 991f4f3..d4491ee 100644
--- a/base/test/test_switches.cc
+++ b/base/test/test_switches.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -13,6 +13,5 @@ const char switches::kTestLargeTimeout[] = "test-large-timeout";
const char switches::kTestTinyTimeout[] = "test-tiny-timeout";
const char switches::kUiTestActionTimeout[] = "ui-test-action-timeout";
const char switches::kUiTestActionMaxTimeout[] = "ui-test-action-max-timeout";
-const char switches::kUiTestCommandExecutionTimeout[] = "ui-test-timeout";
const char switches::kUiTestTerminateTimeout[] = "ui-test-terminate-timeout";
const char switches::kUiTestTimeout[] = "test-timeout";
diff --git a/base/test/test_switches.h b/base/test/test_switches.h
index 44ebd23..81891cb6 100644
--- a/base/test/test_switches.h
+++ b/base/test/test_switches.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -14,7 +14,6 @@ extern const char kTestLargeTimeout[];
extern const char kTestTinyTimeout[];
extern const char kUiTestActionTimeout[];
extern const char kUiTestActionMaxTimeout[];
-extern const char kUiTestCommandExecutionTimeout[];
extern const char kUiTestTerminateTimeout[];
extern const char kUiTestTimeout[];
diff --git a/base/test/test_timeouts.cc b/base/test/test_timeouts.cc
index 20cd8a9..1d86b2c 100644
--- a/base/test/test_timeouts.cc
+++ b/base/test/test_timeouts.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -44,14 +44,11 @@ bool TestTimeouts::initialized_ = false;
// static
int TestTimeouts::tiny_timeout_ms_ = 100;
int TestTimeouts::action_timeout_ms_ = 2000;
-int TestTimeouts::action_max_timeout_ms_ = 20000;
+int TestTimeouts::action_max_timeout_ms_ = 25000;
int TestTimeouts::large_test_timeout_ms_ = 3 * 60 * 1000;
int TestTimeouts::huge_test_timeout_ms_ = 10 * 60 * 1000;
// static
-int TestTimeouts::command_execution_timeout_ms_ = 25000;
-
-// static
int TestTimeouts::wait_for_terminate_timeout_ms_ = 15000;
// static
@@ -83,8 +80,6 @@ void TestTimeouts::Initialize() {
CHECK(action_max_timeout_ms_ <= large_test_timeout_ms_);
CHECK(large_test_timeout_ms_ <= huge_test_timeout_ms_);
- InitializeTimeout(switches::kUiTestCommandExecutionTimeout,
- &command_execution_timeout_ms_);
InitializeTimeout(switches::kUiTestTerminateTimeout,
&wait_for_terminate_timeout_ms_);
diff --git a/base/test/test_timeouts.h b/base/test/test_timeouts.h
index f4cb1ff..64df11a 100644
--- a/base/test/test_timeouts.h
+++ b/base/test/test_timeouts.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -35,12 +35,6 @@ class TestTimeouts {
// Do not use multiple times in a single test.
static int huge_test_timeout_ms() { return huge_test_timeout_ms_; }
- // Timeout to use for AutomationProxy. Do not use in other places.
- // TODO(phajdan.jr): Remove command_execution_timeout_ms.
- static int command_execution_timeout_ms() {
- return command_execution_timeout_ms_;
- }
-
// Timeout to wait for a process to terminate.
static int wait_for_terminate_timeout_ms() {
return wait_for_terminate_timeout_ms_;
@@ -60,7 +54,6 @@ class TestTimeouts {
static int action_max_timeout_ms_;
static int large_test_timeout_ms_;
static int huge_test_timeout_ms_;
- static int command_execution_timeout_ms_;
static int wait_for_terminate_timeout_ms_;
static int live_operation_timeout_ms_;
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index c3ddf93..fd178e5 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -1409,6 +1409,7 @@
'msvs_guid': '1556EF78-C7E6-43C8-951F-F6B43AC0DD12',
'dependencies': [
'theme_resources',
+ '../base/base.gyp:test_support_base',
'../skia/skia.gyp:skia',
'../testing/gtest.gyp:gtest',
],
diff --git a/chrome/test/automation/automation_json_requests.cc b/chrome/test/automation/automation_json_requests.cc
index 8d7853d..0879f8d 100644
--- a/chrome/test/automation/automation_json_requests.cc
+++ b/chrome/test/automation/automation_json_requests.cc
@@ -9,6 +9,7 @@
#include "base/values.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
+#include "base/test/test_timeouts.h"
#include "chrome/common/automation_messages.h"
#include "chrome/common/json_value_serializer.h"
#include "chrome/test/automation/automation_proxy.h"
@@ -21,7 +22,8 @@ bool SendAutomationJSONRequest(AutomationMessageSender* sender,
std::string request, reply;
base::JSONWriter::Write(&request_dict, false, &request);
bool success = false;
- if (!SendAutomationJSONRequest(sender, request, &reply, &success))
+ if (!SendAutomationJSONRequest(sender, request,
+ TestTimeouts::action_max_timeout_ms(), &reply, &success))
return false;
scoped_ptr<Value> value(base::JSONReader::Read(reply, true));
if (!value.get() || !value->IsType(Value::TYPE_DICTIONARY)) {
@@ -58,10 +60,11 @@ WebKeyEvent::WebKeyEvent(automation::KeyEventTypes type,
bool SendAutomationJSONRequest(AutomationMessageSender* sender,
const std::string& request,
+ int timeout_ms,
std::string* reply,
bool* success) {
return sender->Send(new AutomationMsg_SendJSONRequest(
- -1, request, reply, success));
+ -1, request, reply, success), timeout_ms);
}
bool SendGetIndicesFromTabIdJSONRequest(
diff --git a/chrome/test/automation/automation_json_requests.h b/chrome/test/automation/automation_json_requests.h
index a08442e..4a74682 100644
--- a/chrome/test/automation/automation_json_requests.h
+++ b/chrome/test/automation/automation_json_requests.h
@@ -40,6 +40,7 @@ struct WebKeyEvent {
// completed successfully by the automation provider.
bool SendAutomationJSONRequest(AutomationMessageSender* sender,
const std::string& request,
+ int timeout_ms,
std::string* reply,
bool* success) WARN_UNUSED_RESULT;
diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc
index 637dc52..f6edd40 100644
--- a/chrome/test/automation/automation_proxy.cc
+++ b/chrome/test/automation/automation_proxy.cc
@@ -90,7 +90,7 @@ class AutomationMessageFilter : public IPC::ChannelProxy::MessageFilter {
} // anonymous namespace
-AutomationProxy::AutomationProxy(int command_execution_timeout_ms,
+AutomationProxy::AutomationProxy(int action_timeout_ms,
bool disconnect_on_failure)
: app_launched_(true, false),
initial_loads_complete_(true, false),
@@ -99,13 +99,13 @@ AutomationProxy::AutomationProxy(int command_execution_timeout_ms,
app_launch_signaled_(0),
perform_version_check_(false),
disconnect_on_failure_(disconnect_on_failure),
- command_execution_timeout_(
- TimeDelta::FromMilliseconds(command_execution_timeout_ms)),
+ action_timeout_(
+ TimeDelta::FromMilliseconds(action_timeout_ms)),
listener_thread_id_(0) {
// base::WaitableEvent::TimedWait() will choke if we give it a negative value.
// Zero also seems unreasonable, since we need to wait for IPC, but at
// least it is legal... ;-)
- DCHECK_GE(command_execution_timeout_ms, 0);
+ DCHECK_GE(action_timeout_ms, 0);
listener_thread_id_ = base::PlatformThread::CurrentId();
InitializeHandleTracker();
InitializeThread();
@@ -169,7 +169,7 @@ void AutomationProxy::InitializeHandleTracker() {
AutomationLaunchResult AutomationProxy::WaitForAppLaunch() {
AutomationLaunchResult result = AUTOMATION_SUCCESS;
- if (app_launched_.TimedWait(command_execution_timeout_)) {
+ if (app_launched_.TimedWait(action_timeout_)) {
if (perform_version_check_) {
// Obtain our own version number and compare it to what the automation
// provider sent.
@@ -209,11 +209,11 @@ bool AutomationProxy::WaitForProcessLauncherThreadToGoIdle() {
}
bool AutomationProxy::WaitForInitialLoads() {
- return initial_loads_complete_.TimedWait(command_execution_timeout_);
+ return initial_loads_complete_.TimedWait(action_timeout_);
}
bool AutomationProxy::WaitForInitialNewTabUILoad(int* load_time) {
- if (new_tab_ui_load_complete_.TimedWait(command_execution_timeout_)) {
+ if (new_tab_ui_load_complete_.TimedWait(action_timeout_)) {
*load_time = new_tab_ui_load_time_;
new_tab_ui_load_complete_.Reset();
return true;
@@ -443,14 +443,18 @@ base::file_handle_mapping_vector AutomationProxy::fds_to_map() const {
#endif // defined(OS_POSIX)
bool AutomationProxy::Send(IPC::Message* message) {
+ return Send(message,
+ static_cast<int>(action_timeout_.InMilliseconds()));
+}
+
+bool AutomationProxy::Send(IPC::Message* message, int timeout_ms) {
if (!channel_.get()) {
LOG(ERROR) << "Automation channel has been closed; dropping message!";
delete message;
return false;
}
- bool success = channel_->SendWithTimeout(message,
- command_execution_timeout_ms());
+ bool success = channel_->SendWithTimeout(message, timeout_ms);
if (!success && disconnect_on_failure_) {
// Send failed (possibly due to a timeout). Browser is likely in a weird
@@ -549,9 +553,10 @@ bool AutomationProxy::ResetToDefaultTheme() {
}
bool AutomationProxy::SendJSONRequest(const std::string& request,
+ int timeout_ms,
std::string* response) {
bool result = false;
- if (!SendAutomationJSONRequest(this, request, response, &result))
+ if (!SendAutomationJSONRequest(this, request, timeout_ms, response, &result))
return false;
return result;
}
diff --git a/chrome/test/automation/automation_proxy.h b/chrome/test/automation/automation_proxy.h
index d98a9fb..e273e4b 100644
--- a/chrome/test/automation/automation_proxy.h
+++ b/chrome/test/automation/automation_proxy.h
@@ -49,6 +49,7 @@ class AutomationMessageSender : public IPC::Message::Sender {
// and the proxy provider might be still working on the previous
// request.
virtual bool Send(IPC::Message* message) = 0;
+ virtual bool Send(IPC::Message* message, int timeout_ms) = 0;
};
// This is the interface that external processes can use to interact with
@@ -56,7 +57,7 @@ class AutomationMessageSender : public IPC::Message::Sender {
class AutomationProxy : public IPC::Channel::Listener,
public AutomationMessageSender {
public:
- AutomationProxy(int command_execution_timeout_ms, bool disconnect_on_failure);
+ AutomationProxy(int action_timeout_ms, bool disconnect_on_failure);
virtual ~AutomationProxy();
// Creates a previously unused channel id.
@@ -80,7 +81,7 @@ class AutomationProxy : public IPC::Channel::Listener,
// Waits for the app to launch and the automation provider to say hello
// (the app isn't fully done loading by this point).
// Returns SUCCESS if the launch is successful.
- // Returns TIMEOUT if there was no response by command_execution_timeout_
+ // Returns TIMEOUT if there was no response by action_timeout_
// Returns VERSION_MISMATCH if the automation protocol version of the
// automation provider does not match and if perform_version_check_ is set
// to true. Note that perform_version_check_ defaults to false, call
@@ -211,6 +212,7 @@ class AutomationProxy : public IPC::Channel::Listener,
// Generic pattern for sending automation requests.
bool SendJSONRequest(const std::string& request,
+ int timeout_ms,
std::string* response) WARN_UNUSED_RESULT;
#if defined(OS_CHROMEOS)
@@ -226,6 +228,7 @@ class AutomationProxy : public IPC::Channel::Listener,
// AutomationMessageSender implementation.
virtual bool Send(IPC::Message* message) WARN_UNUSED_RESULT;
+ virtual bool Send(IPC::Message* message, int timeout_ms) WARN_UNUSED_RESULT;
// Wrapper over AutomationHandleTracker::InvalidateHandle. Receives the
// message from AutomationProxy, unpacks the messages and routes that call to
@@ -240,15 +243,15 @@ class AutomationProxy : public IPC::Channel::Listener,
gfx::NativeWindow* external_tab_container,
gfx::NativeWindow* tab);
- int command_execution_timeout_ms() const {
- return static_cast<int>(command_execution_timeout_.InMilliseconds());
+ int action_timeout_ms() const {
+ return static_cast<int>(action_timeout_.InMilliseconds());
}
// Sets the timeout for subsequent automation calls.
- void set_command_execution_timeout_ms(int timeout_ms) {
+ void set_action_timeout_ms(int timeout_ms) {
DCHECK(timeout_ms <= 10 * 60 * 1000 ) << "10+ min of automation timeout "
"can make the test hang and be killed by buildbot";
- command_execution_timeout_ = base::TimeDelta::FromMilliseconds(timeout_ms);
+ action_timeout_ = base::TimeDelta::FromMilliseconds(timeout_ms);
}
// Returns the server version of the server connected. You may only call this
@@ -303,7 +306,7 @@ class AutomationProxy : public IPC::Channel::Listener,
bool disconnect_on_failure_;
// Delay to let the browser execute the command.
- base::TimeDelta command_execution_timeout_;
+ base::TimeDelta action_timeout_;
base::PlatformThreadId listener_thread_id_;
diff --git a/chrome/test/automation/browser_proxy.cc b/chrome/test/automation/browser_proxy.cc
index 1016223..1db1dd2 100644
--- a/chrome/test/automation/browser_proxy.cc
+++ b/chrome/test/automation/browser_proxy.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,6 +8,7 @@
#include "base/json/json_reader.h"
#include "base/logging.h"
+#include "base/test/test_timeouts.h"
#include "base/threading/platform_thread.h"
#include "base/time.h"
#include "chrome/common/automation_constants.h"
@@ -576,6 +577,7 @@ bool BrowserProxy::WaitForPopupMenuToOpen() {
}
bool BrowserProxy::SendJSONRequest(const std::string& request,
+ int timeout_ms,
std::string* response) {
if (!is_valid())
return false;
@@ -584,7 +586,8 @@ bool BrowserProxy::SendJSONRequest(const std::string& request,
if (!sender_->Send(new AutomationMsg_SendJSONRequest(handle_,
request,
response,
- &result)))
+ &result),
+ timeout_ms))
return false;
return result;
}
@@ -597,7 +600,9 @@ bool BrowserProxy::GetInitialLoadTimes(float* min_start_time,
*max_stop_time = 0;
*min_start_time = -1;
- if (!SendJSONRequest(kJSONCommand, &json_response)) {
+ if (!SendJSONRequest(kJSONCommand,
+ TestTimeouts::action_max_timeout_ms(),
+ &json_response)) {
// Older browser versions do not support GetInitialLoadTimes.
// Fail gracefully and do not record them in this case.
return false;
diff --git a/chrome/test/automation/browser_proxy.h b/chrome/test/automation/browser_proxy.h
index 7d77949..9e82fa4 100644
--- a/chrome/test/automation/browser_proxy.h
+++ b/chrome/test/automation/browser_proxy.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -223,6 +223,7 @@ class BrowserProxy : public AutomationResourceProxy {
// Generic pattern for sending automation requests.
bool SendJSONRequest(const std::string& request,
+ int timeout_ms,
std::string* response) WARN_UNUSED_RESULT;
// Gets the load times for all tabs started from the command line.
diff --git a/chrome/test/automation/proxy_launcher.cc b/chrome/test/automation/proxy_launcher.cc
index 4f65e07..a96fd50 100644
--- a/chrome/test/automation/proxy_launcher.cc
+++ b/chrome/test/automation/proxy_launcher.cc
@@ -133,7 +133,7 @@ void ProxyLauncher::LaunchBrowserAndServer(const LaunchState& state,
bool wait_for_initial_loads) {
// Set up IPC testing interface as a server.
automation_proxy_.reset(CreateAutomationProxy(
- TestTimeouts::command_execution_timeout_ms()));
+ TestTimeouts::action_max_timeout_ms()));
LaunchBrowser(state);
WaitForBrowserLaunch(wait_for_initial_loads);
@@ -142,7 +142,7 @@ void ProxyLauncher::LaunchBrowserAndServer(const LaunchState& state,
void ProxyLauncher::ConnectToRunningBrowser(bool wait_for_initial_loads) {
// Set up IPC testing interface as a client.
automation_proxy_.reset(CreateAutomationProxy(
- TestTimeouts::command_execution_timeout_ms()));
+ TestTimeouts::action_max_timeout_ms()));
WaitForBrowserLaunch(wait_for_initial_loads);
}
@@ -542,7 +542,7 @@ void NamedProxyLauncher::InitializeConnection(const LaunchState& state,
// Wait for browser to be ready for connections.
bool testing_channel_exists = false;
for (int wait_time = 0;
- wait_time < TestTimeouts::command_execution_timeout_ms();
+ wait_time < TestTimeouts::action_max_timeout_ms();
wait_time += automation::kSleepTime) {
testing_channel_exists = file_util::PathExists(testing_channel_path);
if (testing_channel_exists)
diff --git a/chrome/test/functional/downloads.py b/chrome/test/functional/downloads.py
index 1827dc2..4e8720f 100644
--- a/chrome/test/functional/downloads.py
+++ b/chrome/test/functional/downloads.py
@@ -1,5 +1,5 @@
#!/usr/bin/python
-# Copyright (c) 2010 The Chromium Authors. All rights reserved.
+# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -215,10 +215,7 @@ class DownloadsTest(pyauto.PyUITest):
self._ClearLocalDownloadState(downloaded_pkg)
self.DownloadAndWaitForStart(file_url)
self._DeleteAfterShutdown(downloaded_pkg)
- # Waiting for big file to download might exceed automation timeout.
- # Temporarily increase the automation timeout.
- test_utils.CallFunctionWithNewTimeout(self, 4 * 60 * 1000, # 4 min.
- self.WaitForAllDownloadsToComplete)
+ self.WaitForAllDownloadsToComplete(timeout=self.large_test_timeout_ms());
# Verify that the file was correctly downloaded
self.assertTrue(os.path.exists(downloaded_pkg),
'Downloaded file %s missing.' % downloaded_pkg)
@@ -359,11 +356,7 @@ class DownloadsTest(pyauto.PyUITest):
resume_dict = self.PerformActionOnDownload(self._GetDownloadId(),
'toggle_pause')
self.assertFalse(resume_dict['is_paused'])
-
- # Waiting for big file to download might exceed automation timeout.
- # Temporarily increase the automation timeout.
- test_utils.CallFunctionWithNewTimeout(self, 2 * 60 * 1000, # 2 min.
- self.WaitForAllDownloadsToComplete)
+ self.WaitForAllDownloadsToComplete(timeout=self.large_test_timeout_ms());
# Verify that the file was correctly downloaded after pause and resume.
self.assertTrue(os.path.exists(downloaded_pkg),
diff --git a/chrome/test/functional/test_utils.py b/chrome/test/functional/test_utils.py
index 2f4ce60..a30d2f2 100644
--- a/chrome/test/functional/test_utils.py
+++ b/chrome/test/functional/test_utils.py
@@ -1,6 +1,6 @@
#!/usr/bin/python
-# Copyright (c) 2010 The Chromium Authors. All rights reserved.
+# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -224,7 +224,7 @@ def CallFunctionWithNewTimeout(self, new_timeout, function):
This method resets the timeout before returning.
"""
- timeout_changer = pyauto.PyUITest.CmdExecutionTimeoutChanger(
+ timeout_changer = pyauto.PyUITest.ActionTimeoutChanger(
self, new_timeout)
logging.info('Automation execution timeout has been changed to %d. '
'If the timeout is large the test might appear to hang.'
diff --git a/chrome/test/interactive_ui/fast_shutdown_interactive_uitest.cc b/chrome/test/interactive_ui/fast_shutdown_interactive_uitest.cc
index a783f3c..e240d13 100644
--- a/chrome/test/interactive_ui/fast_shutdown_interactive_uitest.cc
+++ b/chrome/test/interactive_ui/fast_shutdown_interactive_uitest.cc
@@ -1,8 +1,9 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/file_path.h"
+#include "base/test/test_timeouts.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/ui/view_ids.h"
#include "chrome/test/automation/automation_proxy.h"
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py
index e0313fb4..f728896 100644
--- a/chrome/test/pyautolib/pyauto.py
+++ b/chrome/test/pyautolib/pyauto.py
@@ -444,12 +444,13 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
time.sleep(retry_sleep)
return False
- class CmdExecutionTimeoutChanger(object):
- """Facilitate temporary changes to command_execution_timeout_ms.
+
+ class ActionTimeoutChanger(object):
+ """Facilitate temporary changes to action_timeout_ms.
Automatically resets to original timeout when object is destroyed.
"""
- _saved_timeout = -1 # Saved value for command_execution_timeout_ms
+ _saved_timeout = -1 # Saved value for action_timeout_ms
def __init__(self, ui_test, new_timeout):
"""Initialize.
@@ -458,18 +459,18 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
ui_test: a PyUITest object
new_timeout: new timeout to use (in milli secs)
"""
- self._saved_timeout = ui_test.command_execution_timeout_ms()
+ self._saved_timeout = ui_test.action_timeout_ms()
if new_timeout != self._saved_timeout:
- ui_test.set_command_execution_timeout_ms(new_timeout)
+ ui_test.set_action_timeout_ms(new_timeout)
self._ui_test = ui_test
def __del__(self):
"""Reset command_execution_timeout_ms to original value."""
- if self._ui_test.command_execution_timeout_ms() != self._saved_timeout:
- self._ui_test.set_command_execution_timeout_ms(self._saved_timeout)
+ if self._ui_test.action_timeout_ms() != self._saved_timeout:
+ self._ui_test.set_action_timeout_ms(self._saved_timeout)
- def _GetResultFromJSONRequest(self, cmd_dict, windex=0):
+ def _GetResultFromJSONRequest(self, cmd_dict, windex=0, timeout=-1):
"""Issue call over the JSON automation channel and fetch output.
This method packages the given dictionary into a json string, sends it
@@ -487,13 +488,17 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
Use -ve windex if the automation command does not apply to a
browser window. example: chromeos login
+ timeout: request timeout (in milliseconds)
+
Returns:
a dictionary for the output returned by the automation channel.
Raises:
pyauto_errors.JSONInterfaceError if the automation call returns an error.
"""
- result = self._SendJSONRequest(windex, json.dumps(cmd_dict))
+ if timeout == -1: # Default
+ timeout = self.action_max_timeout_ms()
+ result = self._SendJSONRequest(windex, json.dumps(cmd_dict), timeout)
if len(result) == 0:
raise JSONInterfaceError('Automation call received no response.')
ret_dict = json.loads(result)
@@ -519,7 +524,8 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
"""
return download_info.DownloadInfo(
self._SendJSONRequest(
- windex, json.dumps({'command': 'GetDownloadsInfo'})))
+ windex, json.dumps({'command': 'GetDownloadsInfo'}),
+ self.action_max_timeout_ms()))
def GetOmniboxInfo(self, windex=0):
"""Return info about Omnibox.
@@ -546,7 +552,8 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
"""
return omnibox_info.OmniboxInfo(
self._SendJSONRequest(windex,
- json.dumps({'command': 'GetOmniboxInfo'})))
+ json.dumps({'command': 'GetOmniboxInfo'}),
+ self.action_max_timeout_ms()))
def SetOmniboxText(self, text, windex=0):
"""Enter text into the omnibox. This shifts focus to the omnibox.
@@ -748,7 +755,8 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
an instance of prefs_info.PrefsInfo
"""
return prefs_info.PrefsInfo(
- self._SendJSONRequest(0, json.dumps({'command': 'GetPrefsInfo'})))
+ self._SendJSONRequest(0, json.dumps({'command': 'GetPrefsInfo'}),
+ self.action_max_timeout_ms()))
def SetPrefs(self, path, value):
"""Set preference for the given path.
@@ -806,14 +814,14 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
cmd_dict['type'] = 3 # kKeyUpType
self._GetResultFromJSONRequest(cmd_dict)
- def WaitForAllDownloadsToComplete(self, windex=0):
+ def WaitForAllDownloadsToComplete(self, windex=0, timeout=-1):
"""Wait for all downloads to complete.
Note: This method does not work for dangerous downloads. Use
WaitForGivenDownloadsToComplete (below) instead.
"""
cmd_dict = {'command': 'WaitForAllDownloadsToComplete'}
- self._GetResultFromJSONRequest(cmd_dict, windex=windex)
+ self._GetResultFromJSONRequest(cmd_dict, windex=windex, timeout=timeout)
def WaitForDownloadToComplete(self, download_path, timeout=-1):
"""Wait for the given downloads to complete.
@@ -1108,7 +1116,8 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
'search_text': search_text,
}
return history_info.HistoryInfo(
- self._SendJSONRequest(0, json.dumps(cmd_dict)))
+ self._SendJSONRequest(0, json.dumps(cmd_dict),
+ self.action_max_timeout_ms()))
def GetTranslateInfo(self, tab_index=0, window_index=0):
"""Returns info about translate for the given page.
@@ -1464,7 +1473,8 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
an instance of plugins_info.PluginsInfo
"""
return plugins_info.PluginsInfo(
- self._SendJSONRequest(0, json.dumps({'command': 'GetPluginsInfo'})))
+ self._SendJSONRequest(0, json.dumps({'command': 'GetPluginsInfo'}),
+ self.action_max_timeout_ms()))
def EnablePlugin(self, path):
"""Enable the plugin at the given path.
diff --git a/chrome/test/pyautolib/pyautolib.cc b/chrome/test/pyautolib/pyautolib.cc
index 667c597..0a6c484 100644
--- a/chrome/test/pyautolib/pyautolib.cc
+++ b/chrome/test/pyautolib/pyautolib.cc
@@ -323,16 +323,17 @@ scoped_refptr<BrowserProxy> PyUITestBase::GetBrowserWindow(int window_index) {
}
std::string PyUITestBase::_SendJSONRequest(int window_index,
- const std::string& request) {
+ const std::string& request,
+ int timeout) {
std::string response;
if (window_index < 0) { // Do not need to target a browser window.
- EXPECT_TRUE(automation()->SendJSONRequest(request, &response));
+ EXPECT_TRUE(automation()->SendJSONRequest(request, timeout, &response));
} else {
scoped_refptr<BrowserProxy> browser_proxy =
automation()->GetBrowserWindow(window_index);
EXPECT_TRUE(browser_proxy.get());
if (browser_proxy.get()) {
- EXPECT_TRUE(browser_proxy->SendJSONRequest(request, &response));
+ EXPECT_TRUE(browser_proxy->SendJSONRequest(request, timeout, &response));
}
}
return response;
diff --git a/chrome/test/pyautolib/pyautolib.h b/chrome/test/pyautolib/pyautolib.h
index 5e5c22d..fc90687 100644
--- a/chrome/test/pyautolib/pyautolib.h
+++ b/chrome/test/pyautolib/pyautolib.h
@@ -168,7 +168,9 @@ class PyUITestBase : public UITestBase {
// automation proxy additions. Returns response as JSON dict.
// Use -ve window_index for automation calls not targetted at a browser
// window. Example: Login call for chromeos.
- std::string _SendJSONRequest(int window_index, const std::string& request);
+ std::string _SendJSONRequest(int window_index,
+ const std::string& request,
+ int timeout);
// Execute javascript in a given tab, and return the response. This is
// a low-level method intended for use mostly by GetDOMValue(). Note that
@@ -203,8 +205,8 @@ class PyUITestBase : public UITestBase {
return TestTimeouts::action_max_timeout_ms();
}
- int command_execution_timeout_ms() const {
- return TestTimeouts::command_execution_timeout_ms();
+ int large_test_timeout_ms() const {
+ return TestTimeouts::large_test_timeout_ms();
}
private:
diff --git a/chrome/test/pyautolib/pyautolib.i b/chrome/test/pyautolib/pyautolib.i
index a35660d..72671f1 100644
--- a/chrome/test/pyautolib/pyautolib.i
+++ b/chrome/test/pyautolib/pyautolib.i
@@ -195,13 +195,18 @@ class PyUITestBase {
int action_max_timeout_ms() const;
%feature("docstring", "Get the timeout (in milli secs) for an automation "
- "call") command_execution_timeout_ms;
- int command_execution_timeout_ms() const;
+ "call") action_timeout_ms;
+ int action_timeout_ms();
+
%feature("docstring", "Set the timeout (in milli secs) for an automation "
"call. This is an internal method. Do not use this directly. "
- "Use CmdExecutionTimeoutChanger instead")
- set_command_execution_timeout_ms;
- void set_command_execution_timeout_ms(int timeout);
+ "Use ActionTimeoutChanger instead")
+ set_action_timeout_ms;
+ void set_action_timeout_ms(int timeout);
+
+ %feature("docstring", "Timeout (in milli secs) for large tests.")
+ large_test_timeout_ms;
+ int large_test_timeout_ms() const;
%feature("docstring", "Launches the browser and IPC testing server.")
LaunchBrowserAndServer;
@@ -371,9 +376,12 @@ class PyUITestBase {
// Meta-method
%feature("docstring", "Send a sync JSON request to Chrome. "
"Returns a JSON dict as a response. "
+ "Given timeout in milliseconds."
"Internal method.")
_SendJSONRequest;
- std::string _SendJSONRequest(int window_index, const std::string& request);
+ std::string _SendJSONRequest(int window_index,
+ const std::string& request,
+ int timeout);
%feature("docstring", "Execute a string of javascript in the specified "
"(window, tab, frame) and return a string.") ExecuteJavascript;
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc
index 95378d7..102f639 100644
--- a/chrome/test/ui/ui_test.cc
+++ b/chrome/test/ui/ui_test.cc
@@ -25,6 +25,7 @@
#include "base/string_number_conversions.h"
#include "base/string_split.h"
#include "base/test/test_file_util.h"
+#include "base/test/test_timeouts.h"
#include "base/threading/platform_thread.h"
#include "base/time.h"
#include "base/utf_string_conversions.h"
@@ -159,10 +160,13 @@ void UITestBase::TearDown() {
EXPECT_EQ(expected_crashes_, actual_crashes) << error_msg;
}
-// TODO(phajdan.jr): get rid of set_command_execution_timeout_ms.
-void UITestBase::set_command_execution_timeout_ms(int timeout) {
- automation()->set_command_execution_timeout_ms(timeout);
- VLOG(1) << "Automation command execution timeout set to " << timeout << " ms";
+int UITestBase::action_timeout_ms() {
+ return automation()->action_timeout_ms();
+}
+
+void UITestBase::set_action_timeout_ms(int timeout) {
+ automation()->set_action_timeout_ms(timeout);
+ VLOG(1) << "Automation action timeout set to " << timeout << " ms";
}
ProxyLauncher* UITestBase::CreateProxyLauncher() {
diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h
index 5ec4039..62b101d 100644
--- a/chrome/test/ui/ui_test.h
+++ b/chrome/test/ui/ui_test.h
@@ -24,7 +24,6 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
#include "base/process.h"
-#include "base/test/test_timeouts.h"
#include "base/time.h"
#include "build/build_config.h"
// TODO(evanm): we should be able to just forward-declare
@@ -62,7 +61,8 @@ class UITestBase {
void ConnectToRunningBrowser();
// Only for pyauto.
- void set_command_execution_timeout_ms(int timeout);
+ int action_timeout_ms();
+ void set_action_timeout_ms(int timeout);
// Overridable so that derived classes can provide their own ProxyLauncher.
virtual ProxyLauncher* CreateProxyLauncher();
diff --git a/chrome_frame/test/automation_client_mock.h b/chrome_frame/test/automation_client_mock.h
index 6f736a0..d6e8112 100644
--- a/chrome_frame/test/automation_client_mock.h
+++ b/chrome_frame/test/automation_client_mock.h
@@ -105,6 +105,10 @@ struct MockAutomationMessageSender : public AutomationMessageSender {
return proxy_->Send(msg);
}
+ virtual bool Send(IPC::Message* msg, int timeout_ms) {
+ return proxy_->Send(msg);
+ }
+
void ForwardTo(StrictMock<MockAutomationProxy> *p) {
proxy_ = p;
}