Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: chrome/common/service_process_util_unittest.cc

Issue 9185026: Convert use of int ms to TimeDelta in files owned by brettw. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove static class initializations. Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/service_process_util.h" 5 #include "chrome/common/service_process_util.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 ASSERT_TRUE(state.Initialize()); 178 ASSERT_TRUE(state.Initialize());
179 ASSERT_TRUE(GetServiceProcessData(&version, &pid)); 179 ASSERT_TRUE(GetServiceProcessData(&version, &pid));
180 ASSERT_EQ(base::GetCurrentProcId(), pid); 180 ASSERT_EQ(base::GetCurrentProcId(), pid);
181 } 181 }
182 182
183 TEST_F(ServiceProcessStateTest, MAYBE_ForceShutdown) { 183 TEST_F(ServiceProcessStateTest, MAYBE_ForceShutdown) {
184 base::ProcessHandle handle = SpawnChild("ServiceProcessStateTestShutdown", 184 base::ProcessHandle handle = SpawnChild("ServiceProcessStateTestShutdown",
185 true); 185 true);
186 ASSERT_TRUE(handle); 186 ASSERT_TRUE(handle);
187 for (int i = 0; !CheckServiceProcessReady() && i < 10; ++i) { 187 for (int i = 0; !CheckServiceProcessReady() && i < 10; ++i) {
188 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout_ms()); 188 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout());
189 } 189 }
190 ASSERT_TRUE(CheckServiceProcessReady()); 190 ASSERT_TRUE(CheckServiceProcessReady());
191 std::string version; 191 std::string version;
192 base::ProcessId pid; 192 base::ProcessId pid;
193 ASSERT_TRUE(GetServiceProcessData(&version, &pid)); 193 ASSERT_TRUE(GetServiceProcessData(&version, &pid));
194 ASSERT_TRUE(ForceServiceProcessShutdown(version, pid)); 194 ASSERT_TRUE(ForceServiceProcessShutdown(version, pid));
195 int exit_code = 0; 195 int exit_code = 0;
196 ASSERT_TRUE(base::WaitForExitCodeWithTimeout(handle, 196 ASSERT_TRUE(base::WaitForExitCodeWithTimeout(handle,
197 &exit_code, TestTimeouts::action_max_timeout_ms())); 197 &exit_code, TestTimeouts::action_max_timeout_ms()));
198 base::CloseProcessHandle(handle); 198 base::CloseProcessHandle(handle);
(...skipping 22 matching lines...) Expand all
221 base::Thread io_thread_("ServiceProcessStateTestShutdownIOThread"); 221 base::Thread io_thread_("ServiceProcessStateTestShutdownIOThread");
222 base::Thread::Options options(MessageLoop::TYPE_IO, 0); 222 base::Thread::Options options(MessageLoop::TYPE_IO, 0);
223 EXPECT_TRUE(io_thread_.StartWithOptions(options)); 223 EXPECT_TRUE(io_thread_.StartWithOptions(options));
224 ServiceProcessState state; 224 ServiceProcessState state;
225 EXPECT_TRUE(state.Initialize()); 225 EXPECT_TRUE(state.Initialize());
226 EXPECT_TRUE(state.SignalReady(io_thread_.message_loop_proxy(), 226 EXPECT_TRUE(state.SignalReady(io_thread_.message_loop_proxy(),
227 base::Bind(&ShutdownTask, 227 base::Bind(&ShutdownTask,
228 MessageLoop::current()))); 228 MessageLoop::current())));
229 message_loop.PostDelayedTask(FROM_HERE, 229 message_loop.PostDelayedTask(FROM_HERE,
230 MessageLoop::QuitClosure(), 230 MessageLoop::QuitClosure(),
231 TestTimeouts::action_max_timeout_ms()); 231 TestTimeouts::action_max_timeout());
232 EXPECT_FALSE(g_good_shutdown); 232 EXPECT_FALSE(g_good_shutdown);
233 message_loop.Run(); 233 message_loop.Run();
234 EXPECT_TRUE(g_good_shutdown); 234 EXPECT_TRUE(g_good_shutdown);
235 return 0; 235 return 0;
236 } 236 }
237 237
238 #else // !OS_MACOSX 238 #else // !OS_MACOSX
239 239
240 #include <CoreFoundation/CoreFoundation.h> 240 #include <CoreFoundation/CoreFoundation.h>
241 241
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 &executable_path_)); 376 &executable_path_));
377 mock_launchd_.reset(new MockLaunchd(executable_path_, &loop_)); 377 mock_launchd_.reset(new MockLaunchd(executable_path_, &loop_));
378 scoped_launchd_instance_.reset( 378 scoped_launchd_instance_.reset(
379 new Launchd::ScopedInstance(mock_launchd_.get())); 379 new Launchd::ScopedInstance(mock_launchd_.get()));
380 ASSERT_TRUE(service_process_state_.Initialize()); 380 ASSERT_TRUE(service_process_state_.Initialize());
381 ASSERT_TRUE(service_process_state_.SignalReady( 381 ASSERT_TRUE(service_process_state_.SignalReady(
382 io_thread_.message_loop_proxy(), 382 io_thread_.message_loop_proxy(),
383 base::Closure())); 383 base::Closure()));
384 loop_.PostDelayedTask(FROM_HERE, 384 loop_.PostDelayedTask(FROM_HERE,
385 MessageLoop::QuitClosure(), 385 MessageLoop::QuitClosure(),
386 TestTimeouts::action_max_timeout_ms()); 386 TestTimeouts::action_max_timeout());
387 } 387 }
388 388
389 bool MakeABundle(const FilePath& dst, 389 bool MakeABundle(const FilePath& dst,
390 const std::string& name, 390 const std::string& name,
391 FilePath* bundle_root, 391 FilePath* bundle_root,
392 FilePath* executable) { 392 FilePath* executable) {
393 *bundle_root = dst.Append(name + std::string(".app")); 393 *bundle_root = dst.Append(name + std::string(".app"));
394 FilePath contents = bundle_root->AppendASCII("Contents"); 394 FilePath contents = bundle_root->AppendASCII("Contents");
395 FilePath mac_os = contents.AppendASCII("MacOS"); 395 FilePath mac_os = contents.AppendASCII("MacOS");
396 *executable = mac_os.Append(name); 396 *executable = mac_os.Append(name);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 ScopedAttributesRestorer restorer(bundle_path(), 0777); 575 ScopedAttributesRestorer restorer(bundle_path(), 0777);
576 GetIOMessageLoopProxy()->PostTask( 576 GetIOMessageLoopProxy()->PostTask(
577 FROM_HERE, 577 FROM_HERE,
578 base::Bind(&ChangeAttr, bundle_path(), 0222)); 578 base::Bind(&ChangeAttr, bundle_path(), 0222));
579 Run(); 579 Run();
580 ASSERT_TRUE(mock_launchd()->remove_called()); 580 ASSERT_TRUE(mock_launchd()->remove_called());
581 ASSERT_TRUE(mock_launchd()->delete_called()); 581 ASSERT_TRUE(mock_launchd()->delete_called());
582 } 582 }
583 583
584 #endif // !OS_MACOSX 584 #endif // !OS_MACOSX
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698