OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 EXPECT_TRUE(EndsWith(scoped_name, test_str, true)); | 64 EXPECT_TRUE(EndsWith(scoped_name, test_str, true)); |
65 EXPECT_NE(std::string::npos, scoped_name.find(version_info.Version())); | 65 EXPECT_NE(std::string::npos, scoped_name.find(version_info.Version())); |
66 } | 66 } |
67 | 67 |
68 class ServiceProcessStateTest : public base::MultiProcessTest { | 68 class ServiceProcessStateTest : public base::MultiProcessTest { |
69 public: | 69 public: |
70 ServiceProcessStateTest(); | 70 ServiceProcessStateTest(); |
71 virtual ~ServiceProcessStateTest(); | 71 virtual ~ServiceProcessStateTest(); |
72 virtual void SetUp(); | 72 virtual void SetUp(); |
73 base::MessageLoopProxy* IOMessageLoopProxy() { | 73 base::MessageLoopProxy* IOMessageLoopProxy() { |
74 return io_thread_.message_loop_proxy(); | 74 return io_thread_.message_loop_proxy().get(); |
75 } | 75 } |
76 void LaunchAndWait(const std::string& name); | 76 void LaunchAndWait(const std::string& name); |
77 | 77 |
78 private: | 78 private: |
79 // This is used to release the ServiceProcessState singleton after each test. | 79 // This is used to release the ServiceProcessState singleton after each test. |
80 base::ShadowingAtExitManager at_exit_manager_; | 80 base::ShadowingAtExitManager at_exit_manager_; |
81 base::Thread io_thread_; | 81 base::Thread io_thread_; |
82 }; | 82 }; |
83 | 83 |
84 ServiceProcessStateTest::ServiceProcessStateTest() | 84 ServiceProcessStateTest::ServiceProcessStateTest() |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 | 217 |
218 MULTIPROCESS_TEST_MAIN(ServiceProcessStateTestShutdown) { | 218 MULTIPROCESS_TEST_MAIN(ServiceProcessStateTestShutdown) { |
219 base::MessageLoop message_loop; | 219 base::MessageLoop message_loop; |
220 message_loop.set_thread_name("ServiceProcessStateTestShutdownMainThread"); | 220 message_loop.set_thread_name("ServiceProcessStateTestShutdownMainThread"); |
221 base::Thread io_thread_("ServiceProcessStateTestShutdownIOThread"); | 221 base::Thread io_thread_("ServiceProcessStateTestShutdownIOThread"); |
222 base::Thread::Options options(base::MessageLoop::TYPE_IO, 0); | 222 base::Thread::Options options(base::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( | 226 EXPECT_TRUE(state.SignalReady( |
227 io_thread_.message_loop_proxy(), | 227 io_thread_.message_loop_proxy().get(), |
228 base::Bind(&ShutdownTask, base::MessageLoop::current()))); | 228 base::Bind(&ShutdownTask, base::MessageLoop::current()))); |
229 message_loop.PostDelayedTask(FROM_HERE, | 229 message_loop.PostDelayedTask(FROM_HERE, |
230 base::MessageLoop::QuitClosure(), | 230 base::MessageLoop::QuitClosure(), |
231 TestTimeouts::action_max_timeout()); | 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 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 ScopedAttributesRestorer restorer(bundle_path(), 0777); | 409 ScopedAttributesRestorer restorer(bundle_path(), 0777); |
410 GetIOMessageLoopProxy()->PostTask( | 410 GetIOMessageLoopProxy()->PostTask( |
411 FROM_HERE, | 411 FROM_HERE, |
412 base::Bind(&ChangeAttr, bundle_path(), 0222)); | 412 base::Bind(&ChangeAttr, bundle_path(), 0222)); |
413 Run(); | 413 Run(); |
414 ASSERT_TRUE(mock_launchd()->remove_called()); | 414 ASSERT_TRUE(mock_launchd()->remove_called()); |
415 ASSERT_TRUE(mock_launchd()->delete_called()); | 415 ASSERT_TRUE(mock_launchd()->delete_called()); |
416 } | 416 } |
417 | 417 |
418 #endif // !OS_MACOSX | 418 #endif // !OS_MACOSX |
OLD | NEW |