summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authortedvessenes@gmail.com <tedvessenes@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-20 19:41:56 +0000
committertedvessenes@gmail.com <tedvessenes@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-20 19:41:56 +0000
commita0b900be2e35012f904a15ed278f31124c4b955e (patch)
tree5218149018d4d4db6640d8d6f05ac23edef3bd60 /chrome/test
parent1e9db21babb70b7d861ad65a09d96ced486ab513 (diff)
downloadchromium_src-a0b900be2e35012f904a15ed278f31124c4b955e.zip
chromium_src-a0b900be2e35012f904a15ed278f31124c4b955e.tar.gz
chromium_src-a0b900be2e35012f904a15ed278f31124c4b955e.tar.bz2
Switch to TimeDelta interfaces in chrome automation test infrastructure.
This is a resubmit of a previously reverted commit: https://chromiumcodereview.appspot.com/10736064/ BUG=108171 Review URL: https://chromiumcodereview.appspot.com/10787010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147700 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/automation/automation_proxy.cc7
-rw-r--r--chrome/test/automation/automation_proxy.h17
-rw-r--r--chrome/test/automation/browser_proxy.cc10
-rw-r--r--chrome/test/automation/browser_proxy.h8
-rw-r--r--chrome/test/automation/dom_automation_browsertest.cc3
-rw-r--r--chrome/test/automation/javascript_execution_controller.h5
-rw-r--r--chrome/test/automation/proxy_launcher.cc29
-rw-r--r--chrome/test/automation/proxy_launcher.h12
-rw-r--r--chrome/test/base/ui_test_utils.cc2
-rw-r--r--chrome/test/mini_installer_test/installer_test_util.cc2
-rw-r--r--chrome/test/perf/dom_checker_uitest.cc2
-rw-r--r--chrome/test/perf/dromaeo_benchmark_uitest.cc2
-rw-r--r--chrome/test/perf/frame_rate/frame_rate_tests.cc4
-rw-r--r--chrome/test/perf/indexeddb_uitest.cc2
-rw-r--r--chrome/test/perf/kraken_benchmark_uitest.cc2
-rw-r--r--chrome/test/perf/page_cycler_test.cc4
-rw-r--r--chrome/test/perf/startup_test.cc2
-rw-r--r--chrome/test/perf/sunspider_uitest.cc2
-rw-r--r--chrome/test/perf/tab_switching_test.cc3
-rw-r--r--chrome/test/perf/url_fetch_test.cc12
-rw-r--r--chrome/test/perf/v8_benchmark_uitest.cc2
-rw-r--r--chrome/test/ppapi/ppapi_browsertest.cc2
-rw-r--r--chrome/test/ppapi/ppapi_test.cc13
-rw-r--r--chrome/test/ppapi/ppapi_test.h4
-rw-r--r--chrome/test/pyautolib/pyautolib.h12
-rw-r--r--chrome/test/reliability/automated_ui_test_base.cc4
-rw-r--r--chrome/test/ui/ui_test.cc33
-rw-r--r--chrome/test/ui/ui_test.h10
-rw-r--r--chrome/test/webdriver/webdriver_automation.cc10
29 files changed, 126 insertions, 94 deletions
diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc
index 0137200..d5f1a60 100644
--- a/chrome/test/automation/automation_proxy.cc
+++ b/chrome/test/automation/automation_proxy.cc
@@ -97,7 +97,7 @@ class AutomationMessageFilter : public IPC::ChannelProxy::MessageFilter {
} // anonymous namespace
-AutomationProxy::AutomationProxy(int action_timeout_ms,
+AutomationProxy::AutomationProxy(base::TimeDelta action_timeout,
bool disconnect_on_failure)
: app_launched_(true, false),
initial_loads_complete_(true, false),
@@ -106,13 +106,12 @@ AutomationProxy::AutomationProxy(int action_timeout_ms,
perform_version_check_(false),
disconnect_on_failure_(disconnect_on_failure),
channel_disconnected_on_failure_(false),
- action_timeout_(
- TimeDelta::FromMilliseconds(action_timeout_ms)),
+ action_timeout_(action_timeout),
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(action_timeout_ms, 0);
+ DCHECK_GE(action_timeout.InMilliseconds(), 0);
listener_thread_id_ = base::PlatformThread::CurrentId();
InitializeHandleTracker();
InitializeThread();
diff --git a/chrome/test/automation/automation_proxy.h b/chrome/test/automation/automation_proxy.h
index 21823a5..a829620 100644
--- a/chrome/test/automation/automation_proxy.h
+++ b/chrome/test/automation/automation_proxy.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -54,7 +54,7 @@ class AutomationMessageSender : public IPC::Sender {
// a running instance of the app.
class AutomationProxy : public IPC::Listener, public AutomationMessageSender {
public:
- AutomationProxy(int action_timeout_ms, bool disconnect_on_failure);
+ AutomationProxy(base::TimeDelta action_timeout, bool disconnect_on_failure);
virtual ~AutomationProxy();
// Creates a previously unused channel id.
@@ -192,15 +192,16 @@ class AutomationProxy : public IPC::Listener, public AutomationMessageSender {
gfx::NativeWindow* external_tab_container,
gfx::NativeWindow* tab);
- int action_timeout_ms() const {
- return static_cast<int>(action_timeout_.InMilliseconds());
+ base::TimeDelta action_timeout() const {
+ return action_timeout_;
}
// Sets the timeout for subsequent automation calls.
- 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";
- action_timeout_ = base::TimeDelta::FromMilliseconds(timeout_ms);
+ void set_action_timeout(base::TimeDelta timeout) {
+ DCHECK(timeout <= base::TimeDelta::FromMinutes(10))
+ << "10+ min of automation timeout "
+ "can make the test hang and be killed by buildbot";
+ action_timeout_ = timeout;
}
// Returns the server version of the server connected. You may only call this
diff --git a/chrome/test/automation/browser_proxy.cc b/chrome/test/automation/browser_proxy.cc
index 867de74..25b3c58 100644
--- a/chrome/test/automation/browser_proxy.cc
+++ b/chrome/test/automation/browser_proxy.cc
@@ -200,10 +200,9 @@ bool BrowserProxy::WaitForTabCountToBecome(int count) {
}
bool BrowserProxy::WaitForTabToBecomeActive(int tab,
- int wait_timeout) {
+ base::TimeDelta wait_timeout) {
const TimeTicks start = TimeTicks::Now();
- const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout);
- while (TimeTicks::Now() - start < timeout) {
+ while (TimeTicks::Now() - start < wait_timeout) {
base::PlatformThread::Sleep(
base::TimeDelta::FromMilliseconds(automation::kSleepTime));
int active_tab;
@@ -438,7 +437,7 @@ bool BrowserProxy::SendJSONRequest(const std::string& request,
return result;
}
-bool BrowserProxy::GetInitialLoadTimes(int timeout_ms,
+bool BrowserProxy::GetInitialLoadTimes(base::TimeDelta timeout,
float* min_start_time,
float* max_stop_time,
std::vector<float>* stop_times) {
@@ -447,7 +446,8 @@ bool BrowserProxy::GetInitialLoadTimes(int timeout_ms,
*max_stop_time = 0;
*min_start_time = -1;
- if (!SendJSONRequest(kJSONCommand, timeout_ms, &json_response)) {
+ if (!SendJSONRequest(
+ kJSONCommand, timeout.InMilliseconds(), &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 d764e49..69f97b27 100644
--- a/chrome/test/automation/browser_proxy.h
+++ b/chrome/test/automation/browser_proxy.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -106,7 +106,9 @@ class BrowserProxy : public AutomationResourceProxy {
// Block the thread until the specified tab is the active tab.
// |wait_timeout| is the timeout, in milliseconds, for waiting.
// Returns false if the tab does not become active.
- bool WaitForTabToBecomeActive(int tab, int wait_timeout) WARN_UNUSED_RESULT;
+ bool WaitForTabToBecomeActive(
+ int tab,
+ base::TimeDelta wait_timeout) WARN_UNUSED_RESULT;
// Opens the FindInPage box. Note: If you just want to search within a tab
// you don't need to call this function, just use FindInPage(...) directly.
@@ -180,7 +182,7 @@ class BrowserProxy : public AutomationResourceProxy {
// the delay that WaitForInitialLoads waits for), and a list of all
// finished timestamps into |stop_times|. Returns true on success.
bool GetInitialLoadTimes(
- int timeout_ms,
+ base::TimeDelta timeout,
float* min_start_time,
float* max_stop_time,
std::vector<float>* stop_times);
diff --git a/chrome/test/automation/dom_automation_browsertest.cc b/chrome/test/automation/dom_automation_browsertest.cc
index cb149e4..2467f7a 100644
--- a/chrome/test/automation/dom_automation_browsertest.cc
+++ b/chrome/test/automation/dom_automation_browsertest.cc
@@ -55,7 +55,8 @@ void EnsureAttributeEventuallyMatches(
class DOMAutomationTest : public InProcessBrowserTest {
public:
DOMAutomationTest() {
- JavaScriptExecutionController::set_timeout(30000);
+ JavaScriptExecutionController::set_timeout(
+ base::TimeDelta::FromSeconds(30));
}
GURL GetTestURL(const char* path) {
diff --git a/chrome/test/automation/javascript_execution_controller.h b/chrome/test/automation/javascript_execution_controller.h
index 90fa6b7..db78db9 100644
--- a/chrome/test/automation/javascript_execution_controller.h
+++ b/chrome/test/automation/javascript_execution_controller.h
@@ -10,6 +10,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
+#include "base/time.h"
#include "base/values.h"
#include "chrome/test/automation/javascript_message_utils.h"
@@ -71,7 +72,9 @@ class JavaScriptExecutionController
// Sets a timeout to be used for all JavaScript methods in which a response
// is returned asynchronously.
- static void set_timeout(int timeout_ms) { timeout_ms_ = timeout_ms; }
+ static void set_timeout(base::TimeDelta timeout) {
+ timeout_ms_ = timeout.InMilliseconds();
+ }
protected:
virtual ~JavaScriptExecutionController();
diff --git a/chrome/test/automation/proxy_launcher.cc b/chrome/test/automation/proxy_launcher.cc
index c86c8b1..d387aef 100644
--- a/chrome/test/automation/proxy_launcher.cc
+++ b/chrome/test/automation/proxy_launcher.cc
@@ -130,7 +130,7 @@ bool ProxyLauncher::LaunchBrowserAndServer(const LaunchState& state,
bool wait_for_initial_loads) {
// Set up IPC testing interface as a server.
automation_proxy_.reset(CreateAutomationProxy(
- TestTimeouts::action_max_timeout_ms()));
+ TestTimeouts::action_max_timeout()));
if (!LaunchBrowser(state))
return false;
@@ -144,7 +144,7 @@ bool ProxyLauncher::LaunchBrowserAndServer(const LaunchState& state,
bool ProxyLauncher::ConnectToRunningBrowser(bool wait_for_initial_loads) {
// Set up IPC testing interface as a client.
automation_proxy_.reset(CreateAutomationProxy(
- TestTimeouts::action_max_timeout_ms()));
+ TestTimeouts::action_max_timeout()));
return WaitForBrowserLaunch(wait_for_initial_loads);
}
@@ -271,7 +271,7 @@ void ProxyLauncher::QuitBrowser() {
// been closed.
int exit_code = -1;
EXPECT_TRUE(WaitForBrowserProcessToQuit(
- TestTimeouts::action_max_timeout_ms(), &exit_code));
+ TestTimeouts::action_max_timeout(), &exit_code));
EXPECT_EQ(0, exit_code); // Expect a clean shutdown.
browser_quit_time_ = base::TimeTicks::Now() - quit_start;
@@ -302,7 +302,7 @@ void ProxyLauncher::TerminateBrowser() {
int exit_code = -1;
EXPECT_TRUE(WaitForBrowserProcessToQuit(
- TestTimeouts::action_max_timeout_ms(), &exit_code));
+ TestTimeouts::action_max_timeout(), &exit_code));
EXPECT_EQ(0, exit_code); // Expect a clean shutdown.
browser_quit_time_ = base::TimeTicks::Now() - quit_start;
@@ -323,9 +323,11 @@ void ProxyLauncher::AssertAppNotRunning(const std::string& error_message) {
ASSERT_TRUE(processes.empty()) << final_error_message;
}
-bool ProxyLauncher::WaitForBrowserProcessToQuit(int timeout, int* exit_code) {
+bool ProxyLauncher::WaitForBrowserProcessToQuit(
+ base::TimeDelta timeout,
+ int* exit_code) {
#ifdef WAIT_FOR_DEBUGGER_ON_OPEN
- timeout = 500000;
+ timeout = base::TimeDelta::FromSeconds(500);
#endif
bool success = false;
@@ -511,7 +513,7 @@ NamedProxyLauncher::NamedProxyLauncher(const std::string& channel_id,
}
AutomationProxy* NamedProxyLauncher::CreateAutomationProxy(
- int execution_timeout) {
+ base::TimeDelta execution_timeout) {
AutomationProxy* proxy = new AutomationProxy(execution_timeout,
disconnect_on_failure_);
proxy->InitializeChannel(channel_id_, true);
@@ -538,14 +540,15 @@ bool NamedProxyLauncher::InitializeConnection(const LaunchState& state,
// Wait for browser to be ready for connections.
bool channel_initialized = false;
- for (int wait_time = 0;
- wait_time < TestTimeouts::action_max_timeout_ms();
- wait_time += automation::kSleepTime) {
+ base::TimeDelta sleep_time = base::TimeDelta::FromMilliseconds(
+ automation::kSleepTime);
+ for (base::TimeDelta wait_time = base::TimeDelta();
+ wait_time < TestTimeouts::action_max_timeout();
+ wait_time += sleep_time) {
channel_initialized = IPC::Channel::IsNamedServerInitialized(channel_id_);
if (channel_initialized)
break;
- base::PlatformThread::Sleep(
- base::TimeDelta::FromMilliseconds(automation::kSleepTime));
+ base::PlatformThread::Sleep(sleep_time);
}
if (!channel_initialized) {
LOG(ERROR) << "Failed to wait for testing channel presence.";
@@ -580,7 +583,7 @@ AnonymousProxyLauncher::AnonymousProxyLauncher(bool disconnect_on_failure)
}
AutomationProxy* AnonymousProxyLauncher::CreateAutomationProxy(
- int execution_timeout) {
+ base::TimeDelta execution_timeout) {
AutomationProxy* proxy = new AutomationProxy(execution_timeout,
disconnect_on_failure_);
proxy->InitializeChannel(channel_id_, false);
diff --git a/chrome/test/automation/proxy_launcher.h b/chrome/test/automation/proxy_launcher.h
index d6886e1..763012d 100644
--- a/chrome/test/automation/proxy_launcher.h
+++ b/chrome/test/automation/proxy_launcher.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -105,7 +105,7 @@ class ProxyLauncher {
// Wait for the browser process to shut down on its own (i.e. as a result of
// some action that your test has taken). If it has exited within |timeout|,
// puts the exit code in |exit_code| and returns true.
- bool WaitForBrowserProcessToQuit(int timeout, int* exit_code);
+ bool WaitForBrowserProcessToQuit(base::TimeDelta timeout, int* exit_code);
AutomationProxy* automation() const;
@@ -134,7 +134,7 @@ class ProxyLauncher {
protected:
// Creates an automation proxy.
virtual AutomationProxy* CreateAutomationProxy(
- int execution_timeout) = 0;
+ base::TimeDelta execution_timeout) = 0;
// Returns the automation proxy's channel with any prefixes prepended,
// for passing as a command line parameter over to the browser.
@@ -218,7 +218,8 @@ class NamedProxyLauncher : public ProxyLauncher {
NamedProxyLauncher(const std::string& channel_id,
bool launch_browser, bool disconnect_on_failure);
- virtual AutomationProxy* CreateAutomationProxy(int execution_timeout);
+ virtual AutomationProxy* CreateAutomationProxy(
+ base::TimeDelta execution_timeout);
virtual bool InitializeConnection(
const LaunchState& state,
bool wait_for_initial_loads) OVERRIDE WARN_UNUSED_RESULT;
@@ -238,7 +239,8 @@ class NamedProxyLauncher : public ProxyLauncher {
class AnonymousProxyLauncher : public ProxyLauncher {
public:
explicit AnonymousProxyLauncher(bool disconnect_on_failure);
- virtual AutomationProxy* CreateAutomationProxy(int execution_timeout);
+ virtual AutomationProxy* CreateAutomationProxy(
+ base::TimeDelta execution_timeout);
virtual bool InitializeConnection(
const LaunchState& state,
bool wait_for_initial_loads) OVERRIDE WARN_UNUSED_RESULT;
diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc
index e1fbf90..c75b269 100644
--- a/chrome/test/base/ui_test_utils.cc
+++ b/chrome/test/base/ui_test_utils.cc
@@ -894,7 +894,7 @@ bool TestWebSocketServer::Start(const FilePath& root_directory) {
bool wait_success = base::WaitForExitCodeWithTimeout(
process_handle,
&exit_code,
- TestTimeouts::action_max_timeout_ms());
+ TestTimeouts::action_max_timeout());
base::CloseProcessHandle(process_handle);
if (!wait_success || exit_code != 0) {
diff --git a/chrome/test/mini_installer_test/installer_test_util.cc b/chrome/test/mini_installer_test/installer_test_util.cc
index 8565dfd..a9c6d59 100644
--- a/chrome/test/mini_installer_test/installer_test_util.cc
+++ b/chrome/test/mini_installer_test/installer_test_util.cc
@@ -291,7 +291,7 @@ bool RunAndWaitForCommandToFinish(CommandLine command) {
<< command.GetCommandLineString();
return false;
}
- if (!base::WaitForSingleProcess(process, 60 * 1000)) {
+ if (!base::WaitForSingleProcess(process, base::TimeDelta::FromMinutes(1))) {
LOG(ERROR) << "Launched process did not complete.";
return false;
}
diff --git a/chrome/test/perf/dom_checker_uitest.cc b/chrome/test/perf/dom_checker_uitest.cc
index 20725c9..b145b51 100644
--- a/chrome/test/perf/dom_checker_uitest.cc
+++ b/chrome/test/perf/dom_checker_uitest.cc
@@ -145,7 +145,7 @@ class DomCheckerTest : public UITest {
bool WaitUntilTestCompletes(TabProxy* tab) {
return WaitUntilJavaScriptCondition(tab, L"",
L"window.domAutomationController.send(automation.IsDone());",
- TestTimeouts::large_test_timeout_ms());
+ TestTimeouts::large_test_timeout());
}
bool GetTestCount(TabProxy* tab, int* test_count) {
diff --git a/chrome/test/perf/dromaeo_benchmark_uitest.cc b/chrome/test/perf/dromaeo_benchmark_uitest.cc
index 945344a..74b6222 100644
--- a/chrome/test/perf/dromaeo_benchmark_uitest.cc
+++ b/chrome/test/perf/dromaeo_benchmark_uitest.cc
@@ -60,7 +60,7 @@ class DromaeoTest : public UIPerfTest {
bool WaitUntilTestCompletes(TabProxy* tab, const GURL& test_url) {
return WaitUntilCookieValue(tab, test_url, "__done",
- TestTimeouts::large_test_timeout_ms(), "1");
+ TestTimeouts::large_test_timeout(), "1");
}
bool GetScore(TabProxy* tab, std::string* score) {
diff --git a/chrome/test/perf/frame_rate/frame_rate_tests.cc b/chrome/test/perf/frame_rate/frame_rate_tests.cc
index 8392a2d..865bc92 100644
--- a/chrome/test/perf/frame_rate/frame_rate_tests.cc
+++ b/chrome/test/perf/frame_rate/frame_rate_tests.cc
@@ -191,7 +191,7 @@ class FrameRateTest
// that flag kHasRedirect is enabled for the current test.
ASSERT_TRUE(WaitUntilJavaScriptCondition(
tab, L"", L"window.domAutomationController.send(__initialized);",
- TestTimeouts::large_test_timeout_ms()));
+ TestTimeouts::large_test_timeout()));
if (HasFlag(kForceGpuComposited)) {
ASSERT_TRUE(tab->NavigateToURLAsync(
@@ -204,7 +204,7 @@ class FrameRateTest
// Block until the tests completes.
ASSERT_TRUE(WaitUntilJavaScriptCondition(
tab, L"", L"window.domAutomationController.send(!__running_all);",
- TestTimeouts::large_test_timeout_ms()));
+ TestTimeouts::large_test_timeout()));
// TODO(jbates): remove this check when ref builds are updated.
if (!HasFlag(kUseReferenceBuild)) {
diff --git a/chrome/test/perf/indexeddb_uitest.cc b/chrome/test/perf/indexeddb_uitest.cc
index dee0618..0014d17 100644
--- a/chrome/test/perf/indexeddb_uitest.cc
+++ b/chrome/test/perf/indexeddb_uitest.cc
@@ -58,7 +58,7 @@ class IndexedDBTest : public UIPerfTest {
bool WaitUntilTestCompletes(TabProxy* tab, const GURL& test_url) {
return WaitUntilCookieValue(tab, test_url, "__done",
- TestTimeouts::large_test_timeout_ms(), "1");
+ TestTimeouts::large_test_timeout(), "1");
}
bool GetResults(TabProxy* tab, ResultsMap* results) {
diff --git a/chrome/test/perf/kraken_benchmark_uitest.cc b/chrome/test/perf/kraken_benchmark_uitest.cc
index cc8c915..bc87c97 100644
--- a/chrome/test/perf/kraken_benchmark_uitest.cc
+++ b/chrome/test/perf/kraken_benchmark_uitest.cc
@@ -56,7 +56,7 @@ class KrakenBenchmarkTest : public UIPerfTest {
private:
bool WaitUntilTestCompletes(TabProxy* tab, const GURL& test_url) {
return WaitUntilCookieValue(tab, test_url, "__done",
- TestTimeouts::large_test_timeout_ms(), "1");
+ TestTimeouts::large_test_timeout(), "1");
}
bool GetResults(TabProxy* tab, ResultsMap* results) {
diff --git a/chrome/test/perf/page_cycler_test.cc b/chrome/test/perf/page_cycler_test.cc
index b662660..65b3621 100644
--- a/chrome/test/perf/page_cycler_test.cc
+++ b/chrome/test/perf/page_cycler_test.cc
@@ -201,7 +201,7 @@ class PageCyclerTest : public UIPerfTest {
// Wait for the test to finish.
ASSERT_TRUE(WaitUntilCookieValue(
tab.get(), test_url, "__pc_done",
- TestTimeouts::large_test_timeout_ms(), "1"));
+ TestTimeouts::large_test_timeout(), "1"));
std::string cookie;
ASSERT_TRUE(tab->GetCookieByName(test_url, "__pc_pages", &cookie));
@@ -211,7 +211,7 @@ class PageCyclerTest : public UIPerfTest {
// Wait for the report.html to be loaded.
ASSERT_TRUE(WaitUntilCookieValue(
tab.get(), test_url, "__navigated_to_report",
- TestTimeouts::action_max_timeout_ms(), "1"));
+ TestTimeouts::action_max_timeout(), "1"));
// Get the timing cookie value from the DOM automation.
std::wstring wcookie;
diff --git a/chrome/test/perf/startup_test.cc b/chrome/test/perf/startup_test.cc
index 4001aeb..a7e8166 100644
--- a/chrome/test/perf/startup_test.cc
+++ b/chrome/test/perf/startup_test.cc
@@ -216,7 +216,7 @@ class StartupTest : public UIPerfTest {
ASSERT_TRUE(browser_proxy.get());
if (browser_proxy->GetInitialLoadTimes(
- TestTimeouts::action_max_timeout_ms(),
+ TestTimeouts::action_max_timeout(),
&min_start,
&max_stop,
&times) &&
diff --git a/chrome/test/perf/sunspider_uitest.cc b/chrome/test/perf/sunspider_uitest.cc
index 8a0961e..84b9268 100644
--- a/chrome/test/perf/sunspider_uitest.cc
+++ b/chrome/test/perf/sunspider_uitest.cc
@@ -62,7 +62,7 @@ class SunSpiderTest : public UIPerfTest {
bool WaitUntilTestCompletes(TabProxy* tab, const GURL& test_url) {
return WaitUntilCookieValue(tab, test_url, "__done",
- TestTimeouts::large_test_timeout_ms(), "1");
+ TestTimeouts::large_test_timeout(), "1");
}
bool GetTotal(TabProxy* tab, std::string* total) {
diff --git a/chrome/test/perf/tab_switching_test.cc b/chrome/test/perf/tab_switching_test.cc
index 4ae8cb6..76e2eca 100644
--- a/chrome/test/perf/tab_switching_test.cc
+++ b/chrome/test/perf/tab_switching_test.cc
@@ -97,7 +97,8 @@ class TabSwitchingUITest : public UIPerfTest {
ASSERT_TRUE(browser_proxy_->GetTabCount(&final_tab_count));
for (int j = initial_tab_count; j < final_tab_count; ++j) {
ASSERT_TRUE(browser_proxy_->ActivateTab(j));
- ASSERT_TRUE(browser_proxy_->WaitForTabToBecomeActive(j, 10000));
+ ASSERT_TRUE(browser_proxy_->WaitForTabToBecomeActive(
+ j, base::TimeDelta::FromSeconds(10)));
}
// Close the browser to force a dump of log.
diff --git a/chrome/test/perf/url_fetch_test.cc b/chrome/test/perf/url_fetch_test.cc
index faa2c4f..8374b18 100644
--- a/chrome/test/perf/url_fetch_test.cc
+++ b/chrome/test/perf/url_fetch_test.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -45,7 +45,7 @@ class UrlFetchTest : public UIPerfTest {
const char* var_to_fetch,
const std::string& wait_js_expr,
const std::string& wait_js_frame_xpath,
- int wait_js_timeout_ms,
+ base::TimeDelta wait_js_timeout,
UrlFetchTestResult* result) {
scoped_refptr<TabProxy> tab(GetActiveTab());
ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(url));
@@ -54,13 +54,13 @@ class UrlFetchTest : public UIPerfTest {
if (wait_cookie_value) {
bool completed = WaitUntilCookieValue(
tab.get(), url, wait_cookie_name,
- TestTimeouts::large_test_timeout_ms(),
+ TestTimeouts::large_test_timeout(),
wait_cookie_value);
ASSERT_TRUE(completed);
} else {
result->cookie_value = WaitUntilCookieNonEmpty(
tab.get(), url, wait_cookie_name,
- TestTimeouts::large_test_timeout_ms());
+ TestTimeouts::large_test_timeout());
ASSERT_TRUE(result->cookie_value.length());
}
} else if (!wait_js_expr.empty()) {
@@ -68,7 +68,7 @@ class UrlFetchTest : public UIPerfTest {
tab.get(),
UTF8ToWide(wait_js_frame_xpath),
UTF8ToWide(wait_js_expr),
- wait_js_timeout_ms);
+ wait_js_timeout);
ASSERT_TRUE(completed);
}
if (var_to_fetch) {
@@ -161,7 +161,7 @@ TEST_F(UrlFetchTest, UrlFetch) {
jsvar.length() > 0 ? jsvar.c_str() : NULL,
js_expr,
js_frame_xpath,
- js_timeout_ms,
+ base::TimeDelta::FromMilliseconds(js_timeout_ms),
&result);
// Write out the cookie if requested
diff --git a/chrome/test/perf/v8_benchmark_uitest.cc b/chrome/test/perf/v8_benchmark_uitest.cc
index 031c624..8f3af9f 100644
--- a/chrome/test/perf/v8_benchmark_uitest.cc
+++ b/chrome/test/perf/v8_benchmark_uitest.cc
@@ -63,7 +63,7 @@ class V8BenchmarkTest : public UIPerfTest {
bool WaitUntilTestCompletes(TabProxy* tab, const GURL& test_url) {
return WaitUntilCookieValue(tab, test_url, "__done",
- TestTimeouts::large_test_timeout_ms(), "1");
+ TestTimeouts::large_test_timeout(), "1");
}
bool GetScore(TabProxy* tab, std::string* score) {
diff --git a/chrome/test/ppapi/ppapi_browsertest.cc b/chrome/test/ppapi/ppapi_browsertest.cc
index 5b4e54a..06b922b 100644
--- a/chrome/test/ppapi/ppapi_browsertest.cc
+++ b/chrome/test/ppapi/ppapi_browsertest.cc
@@ -725,7 +725,7 @@ IN_PROC_BROWSER_TEST_F(OutOfProcessPPAPITest, View_PageHideShow) {
// The plugin will be loaded in the foreground tab and will send us a message.
TestFinishObserver observer(
chrome::GetActiveWebContents(browser())->GetRenderViewHost(),
- TestTimeouts::action_max_timeout_ms());
+ TestTimeouts::action_max_timeout());
GURL url = GetTestFileUrl("View_PageHideShow");
ui_test_utils::NavigateToURL(browser(), url);
diff --git a/chrome/test/ppapi/ppapi_test.cc b/chrome/test/ppapi/ppapi_test.cc
index 0f49080..056b6ad 100644
--- a/chrome/test/ppapi/ppapi_test.cc
+++ b/chrome/test/ppapi/ppapi_test.cc
@@ -60,14 +60,13 @@ bool IsAudioOutputAvailable() {
PPAPITestBase::TestFinishObserver::TestFinishObserver(
RenderViewHost* render_view_host,
- int timeout_s)
+ base::TimeDelta timeout)
: finished_(false),
waiting_(false),
- timeout_s_(timeout_s) {
+ timeout_(timeout) {
registrar_.Add(this, content::NOTIFICATION_DOM_OPERATION_RESPONSE,
content::Source<RenderViewHost>(render_view_host));
- timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(timeout_s),
- this, &TestFinishObserver::OnTimeout);
+ timer_.Start(FROM_HERE, timeout, this, &TestFinishObserver::OnTimeout);
}
bool PPAPITestBase::TestFinishObserver::WaitForFinish() {
@@ -91,8 +90,7 @@ void PPAPITestBase::TestFinishObserver::Observe(
TrimString(dom_op_details->json, "\"", &response);
if (response == "...") {
timer_.Stop();
- timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(timeout_s_),
- this, &TestFinishObserver::OnTimeout);
+ timer_.Start(FROM_HERE, timeout_, this, &TestFinishObserver::OnTimeout);
} else {
result_ = response;
finished_ = true;
@@ -231,7 +229,8 @@ void PPAPITestBase::RunTestURL(const GURL& test_url) {
// any other value indicates completion (in this case it will start with
// "PASS" or "FAIL"). This keeps us from timing out on waits for long tests.
TestFinishObserver observer(
- chrome::GetActiveWebContents(browser())->GetRenderViewHost(), kTimeoutMs);
+ chrome::GetActiveWebContents(browser())->GetRenderViewHost(),
+ base::TimeDelta::FromMilliseconds(kTimeoutMs));
ui_test_utils::NavigateToURL(browser(), test_url);
diff --git a/chrome/test/ppapi/ppapi_test.h b/chrome/test/ppapi/ppapi_test.h
index 4e53f74..4c91097 100644
--- a/chrome/test/ppapi/ppapi_test.h
+++ b/chrome/test/ppapi/ppapi_test.h
@@ -44,7 +44,7 @@ class PPAPITestBase : public InProcessBrowserTest {
class TestFinishObserver : public content::NotificationObserver {
public:
TestFinishObserver(content::RenderViewHost* render_view_host,
- int timeout_s);
+ base::TimeDelta timeout);
bool WaitForFinish();
@@ -61,7 +61,7 @@ class PPAPITestBase : public InProcessBrowserTest {
bool finished_;
bool waiting_;
- int timeout_s_;
+ base::TimeDelta timeout_;
std::string result_;
content::NotificationRegistrar registrar_;
base::RepeatingTimer<TestFinishObserver> timer_;
diff --git a/chrome/test/pyautolib/pyautolib.h b/chrome/test/pyautolib/pyautolib.h
index 3de0596..4ac0571 100644
--- a/chrome/test/pyautolib/pyautolib.h
+++ b/chrome/test/pyautolib/pyautolib.h
@@ -167,12 +167,20 @@ class PyUITestBase : public UITestBase {
std::string GetCookie(const GURL& cookie_url, int window_index = 0,
int tab_index = 0);
+ base::TimeDelta action_max_timeout() const {
+ return TestTimeouts::action_max_timeout();
+ }
+
int action_max_timeout_ms() const {
- return TestTimeouts::action_max_timeout_ms();
+ return action_max_timeout().InMilliseconds();
+ }
+
+ base::TimeDelta large_test_timeout() const {
+ return TestTimeouts::large_test_timeout();
}
int large_test_timeout_ms() const {
- return TestTimeouts::large_test_timeout_ms();
+ return large_test_timeout().InMilliseconds();
}
protected:
diff --git a/chrome/test/reliability/automated_ui_test_base.cc b/chrome/test/reliability/automated_ui_test_base.cc
index e0eaf57d..3679435 100644
--- a/chrome/test/reliability/automated_ui_test_base.cc
+++ b/chrome/test/reliability/automated_ui_test_base.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -219,7 +219,7 @@ bool AutomatedUITestBase::DragActiveTab(bool drag_right) {
}
if (!browser->WaitForTabToBecomeActive(new_tab_index,
- TestTimeouts::action_timeout_ms())) {
+ TestTimeouts::action_timeout())) {
LogWarningMessage("failed_to_reindex_tab");
return false;
}
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc
index be708ea..dabb5f0 100644
--- a/chrome/test/ui/ui_test.cc
+++ b/chrome/test/ui/ui_test.cc
@@ -120,7 +120,7 @@ void UITestBase::SetUp() {
"of the app before testing.");
JavaScriptExecutionController::set_timeout(
- TestTimeouts::action_max_timeout_ms());
+ TestTimeouts::action_max_timeout());
test_start_time_ = Time::NowFromSystemTime();
SetLaunchSwitches();
@@ -139,13 +139,22 @@ AutomationProxy* UITestBase::automation() const {
return launcher_->automation();
}
+base::TimeDelta UITestBase::action_timeout() {
+ return automation()->action_timeout();
+}
+
int UITestBase::action_timeout_ms() {
- return automation()->action_timeout_ms();
+ return action_timeout().InMilliseconds();
+}
+
+void UITestBase::set_action_timeout(base::TimeDelta timeout) {
+ automation()->set_action_timeout(timeout);
+ VLOG(1) << "Automation action timeout set to "
+ << timeout.InMilliseconds() << " ms";
}
void UITestBase::set_action_timeout_ms(int timeout) {
- automation()->set_action_timeout_ms(timeout);
- VLOG(1) << "Automation action timeout set to " << timeout << " ms";
+ set_action_timeout(base::TimeDelta::FromMilliseconds(timeout));
}
ProxyLauncher* UITestBase::CreateProxyLauncher() {
@@ -415,7 +424,7 @@ bool UITestBase::CloseBrowser(BrowserProxy* browser,
if (*application_closed) {
int exit_code = -1;
EXPECT_TRUE(launcher_->WaitForBrowserProcessToQuit(
- TestTimeouts::action_max_timeout_ms(), &exit_code));
+ TestTimeouts::action_max_timeout(), &exit_code));
EXPECT_EQ(0, exit_code); // Expect a clean shutown.
}
@@ -594,7 +603,7 @@ void UITest::WaitForFinish(const std::string &name,
const GURL &url,
const std::string& test_complete_cookie,
const std::string& expected_cookie_value,
- const int wait_time) {
+ const base::TimeDelta wait_time) {
// The webpage being tested has javascript which sets a cookie
// which signals completion of the test. The cookie name is
// a concatenation of the test name and the test id. This allows
@@ -628,9 +637,9 @@ bool UITest::EvictFileFromSystemCacheWrapper(const FilePath& path) {
bool UITest::WaitUntilJavaScriptCondition(TabProxy* tab,
const std::wstring& frame_xpath,
const std::wstring& jscript,
- int timeout_ms) {
+ base::TimeDelta timeout) {
const TimeDelta kDelay = TimeDelta::FromMilliseconds(250);
- const int kMaxDelays = timeout_ms / kDelay.InMilliseconds();
+ const int kMaxDelays = timeout / kDelay;
// Wait until the test signals it has completed.
for (int i = 0; i < kMaxDelays; ++i) {
@@ -653,10 +662,10 @@ bool UITest::WaitUntilJavaScriptCondition(TabProxy* tab,
bool UITest::WaitUntilCookieValue(TabProxy* tab,
const GURL& url,
const char* cookie_name,
- int timeout_ms,
+ base::TimeDelta timeout,
const char* expected_value) {
const TimeDelta kDelay = TimeDelta::FromMilliseconds(250);
- const int kMaxDelays = timeout_ms / kDelay.InMilliseconds();
+ const int kMaxDelays = timeout / kDelay;
std::string cookie_value;
for (int i = 0; i < kMaxDelays; ++i) {
@@ -674,9 +683,9 @@ bool UITest::WaitUntilCookieValue(TabProxy* tab,
std::string UITest::WaitUntilCookieNonEmpty(TabProxy* tab,
const GURL& url,
const char* cookie_name,
- int timeout_ms) {
+ base::TimeDelta timeout) {
const TimeDelta kDelay = TimeDelta::FromMilliseconds(250);
- const int kMaxDelays = timeout_ms / kDelay.InMilliseconds();
+ const int kMaxDelays = timeout / kDelay;
for (int i = 0; i < kMaxDelays; ++i) {
std::string cookie_value;
diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h
index 47a3917..a8d252e 100644
--- a/chrome/test/ui/ui_test.h
+++ b/chrome/test/ui/ui_test.h
@@ -67,7 +67,9 @@ class UITestBase {
void ConnectToRunningBrowser();
// Only for pyauto.
+ base::TimeDelta action_timeout();
int action_timeout_ms();
+ void set_action_timeout(base::TimeDelta timeout);
void set_action_timeout_ms(int timeout);
// Overridable so that derived classes can provide their own ProxyLauncher.
@@ -377,7 +379,7 @@ class UITest : public UITestBase, public PlatformTest {
const std::string &id, const GURL &url,
const std::string& test_complete_cookie,
const std::string& expected_cookie_value,
- const int wait_time);
+ const base::TimeDelta wait_time);
// Wrapper around EvictFileFromSystemCache to retry 10 times in case of
// error.
@@ -397,7 +399,7 @@ class UITest : public UITestBase, public PlatformTest {
bool WaitUntilJavaScriptCondition(TabProxy* tab,
const std::wstring& frame_xpath,
const std::wstring& jscript,
- int timeout_ms);
+ base::TimeDelta timeout);
// Polls the tab for the cookie_name cookie and returns once one of the
// following conditions hold true:
@@ -406,7 +408,7 @@ class UITest : public UITestBase, public PlatformTest {
// - The timeout value has been exceeded.
bool WaitUntilCookieValue(TabProxy* tab, const GURL& url,
const char* cookie_name,
- int timeout_ms,
+ base::TimeDelta timeout,
const char* expected_value);
// Polls the tab for the cookie_name cookie and returns once one of the
@@ -417,7 +419,7 @@ class UITest : public UITestBase, public PlatformTest {
std::string WaitUntilCookieNonEmpty(TabProxy* tab,
const GURL& url,
const char* cookie_name,
- int timeout_ms);
+ base::TimeDelta timeout);
// Waits until the Find window has become fully visible (if |wait_for_open| is
// true) or fully hidden (if |wait_for_open| is false). This function can time
diff --git a/chrome/test/webdriver/webdriver_automation.cc b/chrome/test/webdriver/webdriver_automation.cc
index 13f5880..5eeb1cb 100644
--- a/chrome/test/webdriver/webdriver_automation.cc
+++ b/chrome/test/webdriver/webdriver_automation.cc
@@ -300,7 +300,7 @@ class WebDriverAnonymousProxyLauncher : public AnonymousProxyLauncher {
virtual ~WebDriverAnonymousProxyLauncher() {}
virtual AutomationProxy* CreateAutomationProxy(
- int execution_timeout) OVERRIDE {
+ base::TimeDelta execution_timeout) OVERRIDE {
AutomationProxy* proxy =
AnonymousProxyLauncher::CreateAutomationProxy(execution_timeout);
AddBackwardsCompatFilter(proxy);
@@ -316,7 +316,7 @@ class WebDriverNamedProxyLauncher : public NamedProxyLauncher {
virtual ~WebDriverNamedProxyLauncher() {}
virtual AutomationProxy* CreateAutomationProxy(
- int execution_timeout) OVERRIDE {
+ base::TimeDelta execution_timeout) OVERRIDE {
AutomationProxy* proxy =
NamedProxyLauncher::CreateAutomationProxy(execution_timeout);
// We can only add the filter here if the browser has not already been
@@ -450,7 +450,8 @@ void Automation::Init(
return;
}
- launcher_->automation()->set_action_timeout_ms(base::kNoTimeout);
+ launcher_->automation()->set_action_timeout(
+ base::TimeDelta::FromMilliseconds(base::kNoTimeout));
logger_.Log(kInfoLogLevel, "Connected to Chrome successfully. Version: " +
automation()->server_version());
@@ -493,7 +494,8 @@ void Automation::Terminate() {
automation()->Disconnect();
#endif
int exit_code = -1;
- if (!launcher_->WaitForBrowserProcessToQuit(10000, &exit_code)) {
+ if (!launcher_->WaitForBrowserProcessToQuit(
+ base::TimeDelta::FromSeconds(10), &exit_code)) {
logger_.Log(kWarningLogLevel, "Chrome still running, terminating...");
TerminateAllChromeProcesses(launcher_->process_id());
}