| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // Note: This file also tests child_process.*. | 5 // Note: This file also tests child_process.*. |
| 6 | 6 |
| 7 #include "services/shell/runner/host/child_process_host.h" | 7 #include "services/shell/runner/host/child_process_host.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 #else | 71 #else |
| 72 #define MAYBE_StartJoin StartJoin | 72 #define MAYBE_StartJoin StartJoin |
| 73 #endif // defined(OS_ANDROID) | 73 #endif // defined(OS_ANDROID) |
| 74 // Just tests starting the child process and joining it (without starting an | 74 // Just tests starting the child process and joining it (without starting an |
| 75 // app). | 75 // app). |
| 76 TEST(ChildProcessHostTest, MAYBE_StartJoin) { | 76 TEST(ChildProcessHostTest, MAYBE_StartJoin) { |
| 77 base::FilePath shell_dir; | 77 base::FilePath shell_dir; |
| 78 PathService::Get(base::DIR_MODULE, &shell_dir); | 78 PathService::Get(base::DIR_MODULE, &shell_dir); |
| 79 base::MessageLoop message_loop; | 79 base::MessageLoop message_loop; |
| 80 scoped_refptr<base::SequencedWorkerPool> blocking_pool( | 80 scoped_refptr<base::SequencedWorkerPool> blocking_pool( |
| 81 new base::SequencedWorkerPool(3, "blocking_pool")); | 81 new base::SequencedWorkerPool(3, "blocking_pool", |
| 82 base::TaskPriority::USER_VISIBLE)); |
| 82 | 83 |
| 83 base::Thread io_thread("io_thread"); | 84 base::Thread io_thread("io_thread"); |
| 84 base::Thread::Options options; | 85 base::Thread::Options options; |
| 85 options.message_loop_type = base::MessageLoop::TYPE_IO; | 86 options.message_loop_type = base::MessageLoop::TYPE_IO; |
| 86 io_thread.StartWithOptions(options); | 87 io_thread.StartWithOptions(options); |
| 87 | 88 |
| 88 ProcessDelegate delegate; | 89 ProcessDelegate delegate; |
| 89 mojo::edk::InitIPCSupport(&delegate, io_thread.task_runner()); | 90 mojo::edk::InitIPCSupport(&delegate, io_thread.task_runner()); |
| 90 | 91 |
| 91 NativeRunnerDelegateImpl native_runner_delegate; | 92 NativeRunnerDelegateImpl native_runner_delegate; |
| 92 ChildProcessHost child_process_host(blocking_pool.get(), | 93 ChildProcessHost child_process_host(blocking_pool.get(), |
| 93 &native_runner_delegate, false, | 94 &native_runner_delegate, false, |
| 94 Identity(), base::FilePath()); | 95 Identity(), base::FilePath()); |
| 95 base::RunLoop run_loop; | 96 base::RunLoop run_loop; |
| 96 child_process_host.Start( | 97 child_process_host.Start( |
| 97 Identity(), | 98 Identity(), |
| 98 base::Bind(&ProcessReadyCallbackAdapater, run_loop.QuitClosure()), | 99 base::Bind(&ProcessReadyCallbackAdapater, run_loop.QuitClosure()), |
| 99 base::Bind(&base::DoNothing)); | 100 base::Bind(&base::DoNothing)); |
| 100 run_loop.Run(); | 101 run_loop.Run(); |
| 101 | 102 |
| 102 child_process_host.Join(); | 103 child_process_host.Join(); |
| 103 blocking_pool->Shutdown(); | 104 blocking_pool->Shutdown(); |
| 104 mojo::edk::ShutdownIPCSupport(); | 105 mojo::edk::ShutdownIPCSupport(); |
| 105 EXPECT_EQ(1u, native_runner_delegate.get_and_clear_adjust_count()); | 106 EXPECT_EQ(1u, native_runner_delegate.get_and_clear_adjust_count()); |
| 106 } | 107 } |
| 107 | 108 |
| 108 } // namespace | 109 } // namespace |
| 109 } // namespace shell | 110 } // namespace shell |
| OLD | NEW |