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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/process/kill.h" | 13 #include "base/process/kill.h" |
14 #include "base/process/launch.h" | 14 #include "base/process/launch.h" |
15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
16 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
| 17 #include "base/threading/platform_thread.h" |
17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
18 | 19 |
19 #if !defined(OS_MACOSX) | 20 #if !defined(OS_MACOSX) |
20 #include "base/at_exit.h" | 21 #include "base/at_exit.h" |
21 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
22 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
23 #include "base/test/multiprocess_test.h" | 24 #include "base/test/multiprocess_test.h" |
24 #include "base/test/test_timeouts.h" | 25 #include "base/test/test_timeouts.h" |
25 #include "base/threading/thread.h" | 26 #include "base/threading/thread.h" |
26 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 EXPECT_TRUE(CheckServiceProcessReady()); | 221 EXPECT_TRUE(CheckServiceProcessReady()); |
221 return 0; | 222 return 0; |
222 } | 223 } |
223 | 224 |
224 MULTIPROCESS_TEST_MAIN(ServiceProcessStateTestReadyFalse) { | 225 MULTIPROCESS_TEST_MAIN(ServiceProcessStateTestReadyFalse) { |
225 EXPECT_FALSE(CheckServiceProcessReady()); | 226 EXPECT_FALSE(CheckServiceProcessReady()); |
226 return 0; | 227 return 0; |
227 } | 228 } |
228 | 229 |
229 MULTIPROCESS_TEST_MAIN(ServiceProcessStateTestShutdown) { | 230 MULTIPROCESS_TEST_MAIN(ServiceProcessStateTestShutdown) { |
| 231 base::PlatformThread::SetName("ServiceProcessStateTestShutdownMainThread"); |
230 base::MessageLoop message_loop; | 232 base::MessageLoop message_loop; |
231 message_loop.set_thread_name("ServiceProcessStateTestShutdownMainThread"); | |
232 base::Thread io_thread_("ServiceProcessStateTestShutdownIOThread"); | 233 base::Thread io_thread_("ServiceProcessStateTestShutdownIOThread"); |
233 base::Thread::Options options(base::MessageLoop::TYPE_IO, 0); | 234 base::Thread::Options options(base::MessageLoop::TYPE_IO, 0); |
234 EXPECT_TRUE(io_thread_.StartWithOptions(options)); | 235 EXPECT_TRUE(io_thread_.StartWithOptions(options)); |
235 ServiceProcessState state; | 236 ServiceProcessState state; |
236 EXPECT_TRUE(state.Initialize()); | 237 EXPECT_TRUE(state.Initialize()); |
237 EXPECT_TRUE(state.SignalReady( | 238 EXPECT_TRUE(state.SignalReady( |
238 io_thread_.task_runner().get(), | 239 io_thread_.task_runner().get(), |
239 base::Bind(&ShutdownTask, base::MessageLoop::current()))); | 240 base::Bind(&ShutdownTask, base::MessageLoop::current()))); |
240 message_loop.task_runner()->PostDelayedTask( | 241 message_loop.task_runner()->PostDelayedTask( |
241 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 242 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 ScopedAttributesRestorer restorer(bundle_path(), 0777); | 421 ScopedAttributesRestorer restorer(bundle_path(), 0777); |
421 GetIOMessageLoopProxy()->PostTask( | 422 GetIOMessageLoopProxy()->PostTask( |
422 FROM_HERE, | 423 FROM_HERE, |
423 base::Bind(&ChangeAttr, bundle_path(), 0222)); | 424 base::Bind(&ChangeAttr, bundle_path(), 0222)); |
424 Run(); | 425 Run(); |
425 ASSERT_TRUE(mock_launchd()->remove_called()); | 426 ASSERT_TRUE(mock_launchd()->remove_called()); |
426 ASSERT_TRUE(mock_launchd()->delete_called()); | 427 ASSERT_TRUE(mock_launchd()->delete_called()); |
427 } | 428 } |
428 | 429 |
429 #endif // !OS_MACOSX | 430 #endif // !OS_MACOSX |
OLD | NEW |