Commit 8270c6fe authored by tedvessenes@gmail.com's avatar tedvessenes@gmail.com

Switch to TimeDelta interfaces of TestTimeouts in chrome and ui code reviewable by ben.

R=ben@chromium.org
BUG=108171


Review URL: https://chromiumcodereview.appspot.com/10704115

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145729 0039d316-1c4b-4281-b951-d872f2087c98
parent 9a39267a
......@@ -35,12 +35,12 @@ namespace {
// base::Bind to run the StartChrome methods in many threads.
class ChromeStarter : public base::RefCountedThreadSafe<ChromeStarter> {
public:
ChromeStarter(int timeout_ms, const FilePath& user_data_dir)
ChromeStarter(base::TimeDelta timeout, const FilePath& user_data_dir)
: ready_event_(false /* manual */, false /* signaled */),
done_event_(false /* manual */, false /* signaled */),
process_handle_(base::kNullProcessHandle),
process_terminated_(false),
timeout_ms_(timeout_ms),
timeout_(timeout),
user_data_dir_(user_data_dir) {
}
......@@ -101,7 +101,7 @@ class ChromeStarter : public base::RefCountedThreadSafe<ChromeStarter> {
// one process. The test below will take care of killing that process
// to unstuck us once it confirms there is only one.
process_terminated_ = base::WaitForSingleProcess(process_handle_,
timeout_ms_);
timeout_);
// Let the test know we are done.
done_event_.Signal();
}
......@@ -120,7 +120,7 @@ class ChromeStarter : public base::RefCountedThreadSafe<ChromeStarter> {
base::CloseProcessHandle(process_handle_);
}
int timeout_ms_;
base::TimeDelta timeout_;
FilePath user_data_dir_;
DISALLOW_COPY_AND_ASSIGN(ChromeStarter);
......@@ -144,7 +144,7 @@ class ProcessSingletonTest : public InProcessBrowserTest {
chrome_starter_threads_[i].reset(new base::Thread("ChromeStarter"));
ASSERT_TRUE(chrome_starter_threads_[i]->Start());
chrome_starters_[i] = new ChromeStarter(
TestTimeouts::action_max_timeout_ms(), temp_profile_dir_.path());
TestTimeouts::action_max_timeout(), temp_profile_dir_.path());
}
}
......
......@@ -104,7 +104,7 @@ class ProcessSingletonLinuxTest : public testing::Test {
ProcessSingleton::NotifyResult NotifyOtherProcess(
bool override_kill,
int timeout_ms) {
base::TimeDelta timeout) {
scoped_ptr<ProcessSingleton> process_singleton(CreateProcessSingleton());
CommandLine command_line(CommandLine::ForCurrentProcess()->GetProgram());
command_line.AppendArg("about:blank");
......@@ -116,18 +116,18 @@ class ProcessSingletonLinuxTest : public testing::Test {
}
return process_singleton->NotifyOtherProcessWithTimeout(
command_line, timeout_ms / 1000, true);
command_line, timeout.InSeconds(), true);
}
// A helper method to call ProcessSingleton::NotifyOtherProcessOrCreate().
ProcessSingleton::NotifyResult NotifyOtherProcessOrCreate(
const std::string& url,
int timeout_ms) {
base::TimeDelta timeout) {
scoped_ptr<ProcessSingleton> process_singleton(CreateProcessSingleton());
CommandLine command_line(CommandLine::ForCurrentProcess()->GetProgram());
command_line.AppendArg(url);
return process_singleton->NotifyOtherProcessWithTimeoutOrCreate(
command_line, base::Bind(&NotificationCallback), timeout_ms / 1000);
command_line, base::Bind(&NotificationCallback), timeout.InSeconds());
}
void CheckNotified() {
......@@ -241,7 +241,7 @@ TEST_F(ProcessSingletonLinuxTest, CheckSocketFile) {
TEST_F(ProcessSingletonLinuxTest, NotifyOtherProcessSuccess) {
CreateProcessSingletonOnThread();
EXPECT_EQ(ProcessSingleton::PROCESS_NOTIFIED,
NotifyOtherProcess(true, TestTimeouts::action_timeout_ms()));
NotifyOtherProcess(true, TestTimeouts::action_timeout()));
CheckNotified();
}
......@@ -251,7 +251,7 @@ TEST_F(ProcessSingletonLinuxTest, NotifyOtherProcessFailure) {
BlockWorkerThread();
EXPECT_EQ(ProcessSingleton::PROCESS_NONE,
NotifyOtherProcess(true, TestTimeouts::action_timeout_ms()));
NotifyOtherProcess(true, TestTimeouts::action_timeout()));
ASSERT_EQ(1, kill_callbacks_);
UnblockWorkerThread();
......@@ -274,7 +274,7 @@ TEST_F(ProcessSingletonLinuxTest, NotifyOtherProcessNoSuicide) {
EXPECT_EQ(0, unlink(socket_path_.value().c_str()));
EXPECT_EQ(ProcessSingleton::PROCESS_NONE,
NotifyOtherProcess(false, TestTimeouts::action_timeout_ms()));
NotifyOtherProcess(false, TestTimeouts::action_timeout()));
// If we've gotten to this point without killing ourself, the test succeeded.
}
......@@ -286,7 +286,7 @@ TEST_F(ProcessSingletonLinuxTest, NotifyOtherProcessHostChanged) {
EXPECT_EQ(0, symlink("FAKEFOOHOST-1234", lock_path_.value().c_str()));
EXPECT_EQ(ProcessSingleton::PROCESS_NOTIFIED,
NotifyOtherProcess(false, TestTimeouts::action_timeout_ms()));
NotifyOtherProcess(false, TestTimeouts::action_timeout()));
CheckNotified();
}
......@@ -301,7 +301,7 @@ TEST_F(ProcessSingletonLinuxTest, NotifyOtherProcessDifferingHost) {
EXPECT_EQ(0, symlink("FAKEFOOHOST-1234", lock_path_.value().c_str()));
EXPECT_EQ(ProcessSingleton::PROFILE_IN_USE,
NotifyOtherProcess(false, TestTimeouts::action_timeout_ms()));
NotifyOtherProcess(false, TestTimeouts::action_timeout()));
ASSERT_EQ(0, unlink(lock_path_.value().c_str()));
......@@ -320,7 +320,7 @@ TEST_F(ProcessSingletonLinuxTest, NotifyOtherProcessOrCreate_DifferingHost) {
std::string url("about:blank");
EXPECT_EQ(ProcessSingleton::PROFILE_IN_USE,
NotifyOtherProcessOrCreate(url, TestTimeouts::action_timeout_ms()));
NotifyOtherProcessOrCreate(url, TestTimeouts::action_timeout()));
ASSERT_EQ(0, unlink(lock_path_.value().c_str()));
......@@ -371,6 +371,6 @@ TEST_F(ProcessSingletonLinuxTest, NotifyOtherProcessOrCreate_BadCookie) {
std::string url("about:blank");
EXPECT_EQ(ProcessSingleton::PROFILE_IN_USE,
NotifyOtherProcessOrCreate(url, TestTimeouts::action_timeout_ms()));
NotifyOtherProcessOrCreate(url, TestTimeouts::action_timeout()));
}
......@@ -66,7 +66,7 @@ class ServiceProcessControlBrowserTest
void WaitForShutdown() {
EXPECT_TRUE(base::WaitForSingleProcess(
service_process_handle_,
TestTimeouts::action_max_timeout_ms()));
TestTimeouts::action_max_timeout()));
}
void ProcessControlLaunched() {
......
......@@ -194,7 +194,7 @@ TEST_F(ServiceProcessStateTest, MAYBE_ForceShutdown) {
ASSERT_TRUE(ForceServiceProcessShutdown(version, pid));
int exit_code = 0;
ASSERT_TRUE(base::WaitForExitCodeWithTimeout(handle,
&exit_code, TestTimeouts::action_max_timeout_ms()));
&exit_code, TestTimeouts::action_max_timeout()));
base::CloseProcessHandle(handle);
ASSERT_EQ(exit_code, 0);
}
......
// 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.
......@@ -107,7 +107,7 @@ void CocoaTest::TearDown() {
// Cover delayed actions by spinning the loop at least once after
// this timeout.
const NSTimeInterval kCloseTimeoutSeconds =
TestTimeouts::action_timeout_ms() / 1000.0;
TestTimeouts::action_timeout().InSecondsF();
// Cover chains of delayed actions by spinning the loop at least
// this many times.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment