diff options
34 files changed, 108 insertions, 144 deletions
diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc index d5f1a60..0137200 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(base::TimeDelta action_timeout, +AutomationProxy::AutomationProxy(int action_timeout_ms, bool disconnect_on_failure) : app_launched_(true, false), initial_loads_complete_(true, false), @@ -106,12 +106,13 @@ AutomationProxy::AutomationProxy(base::TimeDelta action_timeout, perform_version_check_(false), disconnect_on_failure_(disconnect_on_failure), channel_disconnected_on_failure_(false), - action_timeout_(action_timeout), + 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(action_timeout.InMilliseconds(), 0); + DCHECK_GE(action_timeout_ms, 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 a829620..21823a5 100644 --- a/chrome/test/automation/automation_proxy.h +++ b/chrome/test/automation/automation_proxy.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 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. @@ -54,7 +54,7 @@ class AutomationMessageSender : public IPC::Sender { // a running instance of the app. class AutomationProxy : public IPC::Listener, public AutomationMessageSender { public: - AutomationProxy(base::TimeDelta action_timeout, bool disconnect_on_failure); + AutomationProxy(int action_timeout_ms, bool disconnect_on_failure); virtual ~AutomationProxy(); // Creates a previously unused channel id. @@ -192,16 +192,15 @@ class AutomationProxy : public IPC::Listener, public AutomationMessageSender { gfx::NativeWindow* external_tab_container, gfx::NativeWindow* tab); - base::TimeDelta action_timeout() const { - return action_timeout_; + int action_timeout_ms() const { + return static_cast<int>(action_timeout_.InMilliseconds()); } // Sets the timeout for subsequent automation calls. - 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; + 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); } // 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 25b3c58..867de74 100644 --- a/chrome/test/automation/browser_proxy.cc +++ b/chrome/test/automation/browser_proxy.cc @@ -200,9 +200,10 @@ bool BrowserProxy::WaitForTabCountToBecome(int count) { } bool BrowserProxy::WaitForTabToBecomeActive(int tab, - base::TimeDelta wait_timeout) { + int wait_timeout) { const TimeTicks start = TimeTicks::Now(); - while (TimeTicks::Now() - start < wait_timeout) { + const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout); + while (TimeTicks::Now() - start < timeout) { base::PlatformThread::Sleep( base::TimeDelta::FromMilliseconds(automation::kSleepTime)); int active_tab; @@ -437,7 +438,7 @@ bool BrowserProxy::SendJSONRequest(const std::string& request, return result; } -bool BrowserProxy::GetInitialLoadTimes(base::TimeDelta timeout, +bool BrowserProxy::GetInitialLoadTimes(int timeout_ms, float* min_start_time, float* max_stop_time, std::vector<float>* stop_times) { @@ -446,8 +447,7 @@ bool BrowserProxy::GetInitialLoadTimes(base::TimeDelta timeout, *max_stop_time = 0; *min_start_time = -1; - if (!SendJSONRequest( - kJSONCommand, timeout.InMilliseconds(), &json_response)) { + if (!SendJSONRequest(kJSONCommand, 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 69f97b27..d764e49 100644 --- a/chrome/test/automation/browser_proxy.h +++ b/chrome/test/automation/browser_proxy.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 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. @@ -106,9 +106,7 @@ 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, - base::TimeDelta wait_timeout) WARN_UNUSED_RESULT; + bool WaitForTabToBecomeActive(int tab, int 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. @@ -182,7 +180,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( - base::TimeDelta timeout, + int timeout_ms, 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 6b3e7c8..5bc4a4c 100644 --- a/chrome/test/automation/dom_automation_browsertest.cc +++ b/chrome/test/automation/dom_automation_browsertest.cc @@ -56,8 +56,7 @@ class DOMAutomationTest : public InProcessBrowserTest { public: DOMAutomationTest() { EnableDOMAutomation(); - JavaScriptExecutionController::set_timeout( - base::TimeDelta::FromSeconds(30)); + JavaScriptExecutionController::set_timeout(30000); } GURL GetTestURL(const char* path) { diff --git a/chrome/test/automation/javascript_execution_controller.h b/chrome/test/automation/javascript_execution_controller.h index f79ef12..90fa6b7 100644 --- a/chrome/test/automation/javascript_execution_controller.h +++ b/chrome/test/automation/javascript_execution_controller.h @@ -71,9 +71,7 @@ class JavaScriptExecutionController // Sets a timeout to be used for all JavaScript methods in which a response // is returned asynchronously. - static void set_timeout(base::TimeDelta timeout) { - timeout_ms_ = timeout.InMilliseconds(); - } + static void set_timeout(int timeout_ms) { timeout_ms_ = timeout_ms; } protected: virtual ~JavaScriptExecutionController(); diff --git a/chrome/test/automation/proxy_launcher.cc b/chrome/test/automation/proxy_launcher.cc index d387aef..c86c8b1 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())); + TestTimeouts::action_max_timeout_ms())); 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())); + TestTimeouts::action_max_timeout_ms())); 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(), &exit_code)); + TestTimeouts::action_max_timeout_ms(), &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(), &exit_code)); + TestTimeouts::action_max_timeout_ms(), &exit_code)); EXPECT_EQ(0, exit_code); // Expect a clean shutdown. browser_quit_time_ = base::TimeTicks::Now() - quit_start; @@ -323,11 +323,9 @@ void ProxyLauncher::AssertAppNotRunning(const std::string& error_message) { ASSERT_TRUE(processes.empty()) << final_error_message; } -bool ProxyLauncher::WaitForBrowserProcessToQuit( - base::TimeDelta timeout, - int* exit_code) { +bool ProxyLauncher::WaitForBrowserProcessToQuit(int timeout, int* exit_code) { #ifdef WAIT_FOR_DEBUGGER_ON_OPEN - timeout = base::TimeDelta::FromSeconds(500); + timeout = 500000; #endif bool success = false; @@ -513,7 +511,7 @@ NamedProxyLauncher::NamedProxyLauncher(const std::string& channel_id, } AutomationProxy* NamedProxyLauncher::CreateAutomationProxy( - base::TimeDelta execution_timeout) { + int execution_timeout) { AutomationProxy* proxy = new AutomationProxy(execution_timeout, disconnect_on_failure_); proxy->InitializeChannel(channel_id_, true); @@ -540,15 +538,14 @@ bool NamedProxyLauncher::InitializeConnection(const LaunchState& state, // Wait for browser to be ready for connections. bool channel_initialized = false; - 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) { + for (int wait_time = 0; + wait_time < TestTimeouts::action_max_timeout_ms(); + wait_time += automation::kSleepTime) { channel_initialized = IPC::Channel::IsNamedServerInitialized(channel_id_); if (channel_initialized) break; - base::PlatformThread::Sleep(sleep_time); + base::PlatformThread::Sleep( + base::TimeDelta::FromMilliseconds(automation::kSleepTime)); } if (!channel_initialized) { LOG(ERROR) << "Failed to wait for testing channel presence."; @@ -583,7 +580,7 @@ AnonymousProxyLauncher::AnonymousProxyLauncher(bool disconnect_on_failure) } AutomationProxy* AnonymousProxyLauncher::CreateAutomationProxy( - base::TimeDelta execution_timeout) { + int 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 763012d..d6886e1 100644 --- a/chrome/test/automation/proxy_launcher.h +++ b/chrome/test/automation/proxy_launcher.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 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. @@ -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(base::TimeDelta timeout, int* exit_code); + bool WaitForBrowserProcessToQuit(int timeout, int* exit_code); AutomationProxy* automation() const; @@ -134,7 +134,7 @@ class ProxyLauncher { protected: // Creates an automation proxy. virtual AutomationProxy* CreateAutomationProxy( - base::TimeDelta execution_timeout) = 0; + int 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,8 +218,7 @@ class NamedProxyLauncher : public ProxyLauncher { NamedProxyLauncher(const std::string& channel_id, bool launch_browser, bool disconnect_on_failure); - virtual AutomationProxy* CreateAutomationProxy( - base::TimeDelta execution_timeout); + virtual AutomationProxy* CreateAutomationProxy(int execution_timeout); virtual bool InitializeConnection( const LaunchState& state, bool wait_for_initial_loads) OVERRIDE WARN_UNUSED_RESULT; @@ -239,8 +238,7 @@ class NamedProxyLauncher : public ProxyLauncher { class AnonymousProxyLauncher : public ProxyLauncher { public: explicit AnonymousProxyLauncher(bool disconnect_on_failure); - virtual AutomationProxy* CreateAutomationProxy( - base::TimeDelta execution_timeout); + virtual AutomationProxy* CreateAutomationProxy(int 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 f3a74d3..006aa6e 100644 --- a/chrome/test/base/ui_test_utils.cc +++ b/chrome/test/base/ui_test_utils.cc @@ -950,7 +950,7 @@ bool TestWebSocketServer::Start(const FilePath& root_directory) { bool wait_success = base::WaitForExitCodeWithTimeout( process_handle, &exit_code, - TestTimeouts::action_max_timeout()); + TestTimeouts::action_max_timeout_ms()); 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 a9c6d59..8565dfd 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, base::TimeDelta::FromMinutes(1))) { + if (!base::WaitForSingleProcess(process, 60 * 1000)) { 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 b145b51..20725c9 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()); + TestTimeouts::large_test_timeout_ms()); } 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 74b6222..945344a 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(), "1"); + TestTimeouts::large_test_timeout_ms(), "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 865bc92..8392a2d 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())); + TestTimeouts::large_test_timeout_ms())); 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())); + TestTimeouts::large_test_timeout_ms())); // 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 0014d17..dee0618 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(), "1"); + TestTimeouts::large_test_timeout_ms(), "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 bc87c97..cc8c915 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(), "1"); + TestTimeouts::large_test_timeout_ms(), "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 65b3621..b662660 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(), "1")); + TestTimeouts::large_test_timeout_ms(), "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(), "1")); + TestTimeouts::action_max_timeout_ms(), "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 09682f6..e57715a 100644 --- a/chrome/test/perf/startup_test.cc +++ b/chrome/test/perf/startup_test.cc @@ -213,7 +213,7 @@ class StartupTest : public UIPerfTest { ASSERT_TRUE(browser_proxy.get()); if (browser_proxy->GetInitialLoadTimes( - TestTimeouts::action_max_timeout(), + TestTimeouts::action_max_timeout_ms(), &min_start, &max_stop, ×) && diff --git a/chrome/test/perf/sunspider_uitest.cc b/chrome/test/perf/sunspider_uitest.cc index 84b9268..8a0961e 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(), "1"); + TestTimeouts::large_test_timeout_ms(), "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 76e2eca..4ae8cb6 100644 --- a/chrome/test/perf/tab_switching_test.cc +++ b/chrome/test/perf/tab_switching_test.cc @@ -97,8 +97,7 @@ 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, base::TimeDelta::FromSeconds(10))); + ASSERT_TRUE(browser_proxy_->WaitForTabToBecomeActive(j, 10000)); } // 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 8374b18..faa2c4f 100644 --- a/chrome/test/perf/url_fetch_test.cc +++ b/chrome/test/perf/url_fetch_test.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 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. @@ -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, - base::TimeDelta wait_js_timeout, + int wait_js_timeout_ms, 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(), + TestTimeouts::large_test_timeout_ms(), wait_cookie_value); ASSERT_TRUE(completed); } else { result->cookie_value = WaitUntilCookieNonEmpty( tab.get(), url, wait_cookie_name, - TestTimeouts::large_test_timeout()); + TestTimeouts::large_test_timeout_ms()); 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); + wait_js_timeout_ms); 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, - base::TimeDelta::FromMilliseconds(js_timeout_ms), + 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 8f3af9f..031c624 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(), "1"); + TestTimeouts::large_test_timeout_ms(), "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 06b922b..5b4e54a 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()); + TestTimeouts::action_max_timeout_ms()); 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 89772bb..bef0daf 100644 --- a/chrome/test/ppapi/ppapi_test.cc +++ b/chrome/test/ppapi/ppapi_test.cc @@ -60,13 +60,14 @@ bool IsAudioOutputAvailable() { PPAPITestBase::TestFinishObserver::TestFinishObserver( RenderViewHost* render_view_host, - base::TimeDelta timeout) + int timeout_s) : finished_(false), waiting_(false), - timeout_(timeout) { + timeout_s_(timeout_s) { registrar_.Add(this, content::NOTIFICATION_DOM_OPERATION_RESPONSE, content::Source<RenderViewHost>(render_view_host)); - timer_.Start(FROM_HERE, timeout, this, &TestFinishObserver::OnTimeout); + timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(timeout_s), + this, &TestFinishObserver::OnTimeout); } bool PPAPITestBase::TestFinishObserver::WaitForFinish() { @@ -90,7 +91,8 @@ void PPAPITestBase::TestFinishObserver::Observe( TrimString(dom_op_details->json, "\"", &response); if (response == "...") { timer_.Stop(); - timer_.Start(FROM_HERE, timeout_, this, &TestFinishObserver::OnTimeout); + timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(timeout_s_), + this, &TestFinishObserver::OnTimeout); } else { result_ = response; finished_ = true; @@ -230,8 +232,7 @@ 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(), - base::TimeDelta::FromMilliseconds(kTimeoutMs)); + chrome::GetActiveWebContents(browser())->GetRenderViewHost(), 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 4c91097..4e53f74 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, - base::TimeDelta timeout); + int timeout_s); bool WaitForFinish(); @@ -61,7 +61,7 @@ class PPAPITestBase : public InProcessBrowserTest { bool finished_; bool waiting_; - base::TimeDelta timeout_; + int timeout_s_; 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 d1a071e..91beeb3 100644 --- a/chrome/test/pyautolib/pyautolib.h +++ b/chrome/test/pyautolib/pyautolib.h @@ -179,20 +179,12 @@ 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 action_max_timeout().InMilliseconds(); - } - - base::TimeDelta large_test_timeout() const { - return TestTimeouts::large_test_timeout(); + return TestTimeouts::action_max_timeout_ms(); } int large_test_timeout_ms() const { - return large_test_timeout().InMilliseconds(); + return TestTimeouts::large_test_timeout_ms(); } protected: diff --git a/chrome/test/reliability/automated_ui_test_base.cc b/chrome/test/reliability/automated_ui_test_base.cc index 3679435..e0eaf57d 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) 2012 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. @@ -219,7 +219,7 @@ bool AutomatedUITestBase::DragActiveTab(bool drag_right) { } if (!browser->WaitForTabToBecomeActive(new_tab_index, - TestTimeouts::action_timeout())) { + TestTimeouts::action_timeout_ms())) { LogWarningMessage("failed_to_reindex_tab"); return false; } diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index 16ca71d..f5eae5a 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -119,7 +119,7 @@ void UITestBase::SetUp() { "of the app before testing."); JavaScriptExecutionController::set_timeout( - TestTimeouts::action_max_timeout()); + TestTimeouts::action_max_timeout_ms()); test_start_time_ = Time::NowFromSystemTime(); SetLaunchSwitches(); @@ -138,22 +138,13 @@ AutomationProxy* UITestBase::automation() const { return launcher_->automation(); } -base::TimeDelta UITestBase::action_timeout() { - return automation()->action_timeout(); -} - int UITestBase::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"; + return automation()->action_timeout_ms(); } void UITestBase::set_action_timeout_ms(int timeout) { - set_action_timeout(base::TimeDelta::FromMilliseconds(timeout)); + automation()->set_action_timeout_ms(timeout); + VLOG(1) << "Automation action timeout set to " << timeout << " ms"; } ProxyLauncher* UITestBase::CreateProxyLauncher() { @@ -423,7 +414,7 @@ bool UITestBase::CloseBrowser(BrowserProxy* browser, if (*application_closed) { int exit_code = -1; EXPECT_TRUE(launcher_->WaitForBrowserProcessToQuit( - TestTimeouts::action_max_timeout(), &exit_code)); + TestTimeouts::action_max_timeout_ms(), &exit_code)); EXPECT_EQ(0, exit_code); // Expect a clean shutown. } @@ -602,7 +593,7 @@ void UITest::WaitForFinish(const std::string &name, const GURL &url, const std::string& test_complete_cookie, const std::string& expected_cookie_value, - const base::TimeDelta wait_time) { + const int 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 @@ -636,9 +627,9 @@ bool UITest::EvictFileFromSystemCacheWrapper(const FilePath& path) { bool UITest::WaitUntilJavaScriptCondition(TabProxy* tab, const std::wstring& frame_xpath, const std::wstring& jscript, - base::TimeDelta timeout) { + int timeout_ms) { const TimeDelta kDelay = TimeDelta::FromMilliseconds(250); - const int kMaxDelays = timeout / kDelay; + const int kMaxDelays = timeout_ms / kDelay.InMilliseconds(); // Wait until the test signals it has completed. for (int i = 0; i < kMaxDelays; ++i) { @@ -661,10 +652,10 @@ bool UITest::WaitUntilJavaScriptCondition(TabProxy* tab, bool UITest::WaitUntilCookieValue(TabProxy* tab, const GURL& url, const char* cookie_name, - base::TimeDelta timeout, + int timeout_ms, const char* expected_value) { const TimeDelta kDelay = TimeDelta::FromMilliseconds(250); - const int kMaxDelays = timeout / kDelay; + const int kMaxDelays = timeout_ms / kDelay.InMilliseconds(); std::string cookie_value; for (int i = 0; i < kMaxDelays; ++i) { @@ -682,9 +673,9 @@ bool UITest::WaitUntilCookieValue(TabProxy* tab, std::string UITest::WaitUntilCookieNonEmpty(TabProxy* tab, const GURL& url, const char* cookie_name, - base::TimeDelta timeout) { + int timeout_ms) { const TimeDelta kDelay = TimeDelta::FromMilliseconds(250); - const int kMaxDelays = timeout / kDelay; + const int kMaxDelays = timeout_ms / kDelay.InMilliseconds(); 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 a8d252e..47a3917 100644 --- a/chrome/test/ui/ui_test.h +++ b/chrome/test/ui/ui_test.h @@ -67,9 +67,7 @@ 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. @@ -379,7 +377,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 base::TimeDelta wait_time); + const int wait_time); // Wrapper around EvictFileFromSystemCache to retry 10 times in case of // error. @@ -399,7 +397,7 @@ class UITest : public UITestBase, public PlatformTest { bool WaitUntilJavaScriptCondition(TabProxy* tab, const std::wstring& frame_xpath, const std::wstring& jscript, - base::TimeDelta timeout); + int timeout_ms); // Polls the tab for the cookie_name cookie and returns once one of the // following conditions hold true: @@ -408,7 +406,7 @@ class UITest : public UITestBase, public PlatformTest { // - The timeout value has been exceeded. bool WaitUntilCookieValue(TabProxy* tab, const GURL& url, const char* cookie_name, - base::TimeDelta timeout, + int timeout_ms, const char* expected_value); // Polls the tab for the cookie_name cookie and returns once one of the @@ -419,7 +417,7 @@ class UITest : public UITestBase, public PlatformTest { std::string WaitUntilCookieNonEmpty(TabProxy* tab, const GURL& url, const char* cookie_name, - base::TimeDelta timeout); + int timeout_ms); // 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 769c572..d709cb1 100644 --- a/chrome/test/webdriver/webdriver_automation.cc +++ b/chrome/test/webdriver/webdriver_automation.cc @@ -286,7 +286,7 @@ class WebDriverAnonymousProxyLauncher : public AnonymousProxyLauncher { virtual ~WebDriverAnonymousProxyLauncher() {} virtual AutomationProxy* CreateAutomationProxy( - base::TimeDelta execution_timeout) OVERRIDE { + int execution_timeout) OVERRIDE { AutomationProxy* proxy = AnonymousProxyLauncher::CreateAutomationProxy(execution_timeout); AddBackwardsCompatFilter(proxy); @@ -302,7 +302,7 @@ class WebDriverNamedProxyLauncher : public NamedProxyLauncher { virtual ~WebDriverNamedProxyLauncher() {} virtual AutomationProxy* CreateAutomationProxy( - base::TimeDelta execution_timeout) OVERRIDE { + int execution_timeout) OVERRIDE { AutomationProxy* proxy = NamedProxyLauncher::CreateAutomationProxy(execution_timeout); // We can only add the filter here if the browser has not already been @@ -436,8 +436,7 @@ void Automation::Init( return; } - launcher_->automation()->set_action_timeout( - base::TimeDelta::FromMilliseconds(base::kNoTimeout)); + launcher_->automation()->set_action_timeout_ms(base::kNoTimeout); logger_.Log(kInfoLogLevel, "Connected to Chrome successfully. Version: " + automation()->server_version()); @@ -477,8 +476,7 @@ void Automation::Terminate() { kill(launcher_->process(), SIGTERM); int exit_code = -1; - if (!launcher_->WaitForBrowserProcessToQuit( - base::TimeDelta::FromSeconds(10), &exit_code)) { + if (!launcher_->WaitForBrowserProcessToQuit(10000, &exit_code)) { TerminateAllChromeProcesses(launcher_->process_id()); } base::CloseProcessHandle(launcher_->process()); diff --git a/chrome_frame/chrome_frame_automation.cc b/chrome_frame/chrome_frame_automation.cc index 12f14cf..9a649c0 100644 --- a/chrome_frame/chrome_frame_automation.cc +++ b/chrome_frame/chrome_frame_automation.cc @@ -134,7 +134,7 @@ class ChromeFrameAutomationProxyImpl::CFMsgDispatcher ChromeFrameAutomationProxyImpl::ChromeFrameAutomationProxyImpl( AutomationProxyCacheEntry* entry, - std::string channel_id, base::TimeDelta launch_timeout) + std::string channel_id, int launch_timeout) : AutomationProxy(launch_timeout, false), proxy_entry_(entry) { TRACE_EVENT_BEGIN_ETW("chromeframe.automationproxy", this, ""); @@ -251,10 +251,8 @@ void AutomationProxyCacheEntry::CreateProxy(ChromeFrameLaunchParams* params, // At same time we must destroy/stop the thread from another thread. std::string channel_id = AutomationProxy::GenerateChannelID(); ChromeFrameAutomationProxyImpl* proxy = - new ChromeFrameAutomationProxyImpl( - this, - channel_id, - base::TimeDelta::FromMilliseconds(params->launch_timeout())); + new ChromeFrameAutomationProxyImpl(this, channel_id, + params->launch_timeout()); // Ensure that the automation proxy actually respects our choice on whether // or not to check the version. diff --git a/chrome_frame/chrome_frame_automation.h b/chrome_frame/chrome_frame_automation.h index 0c778b7..26c9901 100644 --- a/chrome_frame/chrome_frame_automation.h +++ b/chrome_frame/chrome_frame_automation.h @@ -92,7 +92,7 @@ class ChromeFrameAutomationProxyImpl friend class AutomationProxyCacheEntry; ChromeFrameAutomationProxyImpl(AutomationProxyCacheEntry* entry, std::string channel_id, - base::TimeDelta launch_timeout); + int launch_timeout); class CFMsgDispatcher; class TabProxyNotificationMessageFilter; diff --git a/chrome_frame/test/automation_client_mock.cc b/chrome_frame/test/automation_client_mock.cc index 06a5745..bcd63a7 100644 --- a/chrome_frame/test/automation_client_mock.cc +++ b/chrome_frame/test/automation_client_mock.cc @@ -313,9 +313,7 @@ class TestChromeFrameAutomationProxyImpl TestChromeFrameAutomationProxyImpl() // 1 is an unneeded timeout. : ChromeFrameAutomationProxyImpl( - NULL, - AutomationProxy::GenerateChannelID(), - base::TimeDelta::FromMilliseconds(1)) { + NULL, AutomationProxy::GenerateChannelID(), 1) { } MOCK_METHOD3( SendAsAsync, diff --git a/chrome_frame/test/perf/chrome_frame_perftest.cc b/chrome_frame/test/perf/chrome_frame_perftest.cc index a81428f..c1fd280 100644 --- a/chrome_frame/test/perf/chrome_frame_perftest.cc +++ b/chrome_frame/test/perf/chrome_frame_perftest.cc @@ -1498,17 +1498,17 @@ bool RunSingleTestOutOfProc(const std::string& test_name) { if (!base::LaunchProcess(cmd_line, base::LaunchOptions(), &process_handle)) return false; - base::TimeDelta test_terminate_timeout = base::TimeDelta::FromMinutes(1); + int test_terminate_timeout_ms = 60 * 1000; int exit_code = 0; if (!base::WaitForExitCodeWithTimeout(process_handle, &exit_code, - test_terminate_timeout)) { - LOG(ERROR) << "Test timeout (" << test_terminate_timeout.InMilliseconds() - << " ms) exceeded for " << test_name; + test_terminate_timeout_ms)) { + LOG(ERROR) << "Test timeout (" << test_terminate_timeout_ms + << " ms) exceeded for " << test_name; - exit_code = -1; // Set a non-zero exit code to signal a failure. + exit_code = -1; // Set a non-zero exit code to signal a failure. - // Ensure that the process terminates. - base::KillProcess(process_handle, -1, true); + // Ensure that the process terminates. + base::KillProcess(process_handle, -1, true); } base::CloseProcessHandle(process_handle); diff --git a/chrome_frame/test_utils.cc b/chrome_frame/test_utils.cc index ef8a288..2333cc6 100644 --- a/chrome_frame/test_utils.cc +++ b/chrome_frame/test_utils.cc @@ -113,9 +113,8 @@ void ScopedChromeFrameRegistrar::DoRegistration( << registration_command; } else { base::win::ScopedHandle rundll32(process_handle); - if (!base::WaitForExitCodeWithTimeout( - process_handle, &exit_code, - base::TimeDelta::FromMilliseconds(kDllRegistrationTimeoutMs))) { + if (!base::WaitForExitCodeWithTimeout(process_handle, &exit_code, + kDllRegistrationTimeoutMs)) { LOG(ERROR) << "Timeout waiting to register or unregister DLL with " "command: " << registration_command; base::KillProcess(process_handle, 0, false); |