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

Side by Side Diff: services/shell/runner/host/child_process_host_unittest.cc

Issue 1882423004: Move shell service to toplevel shell namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 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 <utility> 10 #include <utility>
10 11
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "base/callback.h" 13 #include "base/callback.h"
13 #include "base/command_line.h" 14 #include "base/command_line.h"
14 #include "base/logging.h" 15 #include "base/logging.h"
15 #include "base/macros.h" 16 #include "base/macros.h"
16 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
17 #include "base/path_service.h" 18 #include "base/path_service.h"
18 #include "base/run_loop.h" 19 #include "base/run_loop.h"
19 #include "base/threading/thread.h" 20 #include "base/threading/thread.h"
20 #include "mojo/edk/embedder/embedder.h" 21 #include "mojo/edk/embedder/embedder.h"
21 #include "mojo/edk/embedder/process_delegate.h" 22 #include "mojo/edk/embedder/process_delegate.h"
22 #include "mojo/message_pump/message_pump_mojo.h" 23 #include "mojo/message_pump/message_pump_mojo.h"
23 #include "services/shell/native_runner_delegate.h" 24 #include "services/shell/native_runner_delegate.h"
24 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
25 26
26 namespace mojo {
27 namespace shell { 27 namespace shell {
28 namespace { 28 namespace {
29 29
30 void ProcessReadyCallbackAdapater(const base::Closure& callback, 30 void ProcessReadyCallbackAdapater(const base::Closure& callback,
31 base::ProcessId process_id) { 31 base::ProcessId process_id) {
32 callback.Run(); 32 callback.Run();
33 } 33 }
34 34
35 class ProcessDelegate : public edk::ProcessDelegate { 35 class ProcessDelegate : public mojo::edk::ProcessDelegate {
36 public: 36 public:
37 ProcessDelegate() {} 37 ProcessDelegate() {}
38 ~ProcessDelegate() override {} 38 ~ProcessDelegate() override {}
39 39
40 private: 40 private:
41 void OnShutdownComplete() override {} 41 void OnShutdownComplete() override {}
42 DISALLOW_COPY_AND_ASSIGN(ProcessDelegate); 42 DISALLOW_COPY_AND_ASSIGN(ProcessDelegate);
43 }; 43 };
44 44
45 class NativeRunnerDelegateImpl : public NativeRunnerDelegate { 45 class NativeRunnerDelegateImpl : public NativeRunnerDelegate {
(...skipping 25 matching lines...) Expand all
71 #define MAYBE_StartJoin DISABLED_StartJoin 71 #define MAYBE_StartJoin DISABLED_StartJoin
72 #else 72 #else
73 #define MAYBE_StartJoin StartJoin 73 #define MAYBE_StartJoin StartJoin
74 #endif // defined(OS_ANDROID) 74 #endif // defined(OS_ANDROID)
75 // Just tests starting the child process and joining it (without starting an 75 // Just tests starting the child process and joining it (without starting an
76 // app). 76 // app).
77 TEST(ChildProcessHostTest, MAYBE_StartJoin) { 77 TEST(ChildProcessHostTest, MAYBE_StartJoin) {
78 base::FilePath shell_dir; 78 base::FilePath shell_dir;
79 PathService::Get(base::DIR_MODULE, &shell_dir); 79 PathService::Get(base::DIR_MODULE, &shell_dir);
80 base::MessageLoop message_loop( 80 base::MessageLoop message_loop(
81 scoped_ptr<base::MessagePump>(new common::MessagePumpMojo())); 81 std::unique_ptr<base::MessagePump>(new mojo::common::MessagePumpMojo()));
82 scoped_refptr<base::SequencedWorkerPool> blocking_pool( 82 scoped_refptr<base::SequencedWorkerPool> blocking_pool(
83 new base::SequencedWorkerPool(3, "blocking_pool")); 83 new base::SequencedWorkerPool(3, "blocking_pool"));
84 84
85 base::Thread io_thread("io_thread"); 85 base::Thread io_thread("io_thread");
86 base::Thread::Options options; 86 base::Thread::Options options;
87 options.message_loop_type = base::MessageLoop::TYPE_IO; 87 options.message_loop_type = base::MessageLoop::TYPE_IO;
88 io_thread.StartWithOptions(options); 88 io_thread.StartWithOptions(options);
89 89
90 ProcessDelegate delegate; 90 ProcessDelegate delegate;
91 edk::InitIPCSupport(&delegate, io_thread.task_runner()); 91 mojo::edk::InitIPCSupport(&delegate, io_thread.task_runner());
92 92
93 NativeRunnerDelegateImpl native_runner_delegate; 93 NativeRunnerDelegateImpl native_runner_delegate;
94 ChildProcessHost child_process_host(blocking_pool.get(), 94 ChildProcessHost child_process_host(blocking_pool.get(),
95 &native_runner_delegate, false, 95 &native_runner_delegate, false,
96 Identity(), base::FilePath()); 96 Identity(), base::FilePath());
97 base::RunLoop run_loop; 97 base::RunLoop run_loop;
98 child_process_host.Start( 98 child_process_host.Start(
99 Identity(), 99 Identity(),
100 base::Bind(&ProcessReadyCallbackAdapater, run_loop.QuitClosure()), 100 base::Bind(&ProcessReadyCallbackAdapater, run_loop.QuitClosure()),
101 base::Bind(&base::DoNothing)); 101 base::Bind(&base::DoNothing));
102 run_loop.Run(); 102 run_loop.Run();
103 103
104 child_process_host.Join(); 104 child_process_host.Join();
105 blocking_pool->Shutdown(); 105 blocking_pool->Shutdown();
106 edk::ShutdownIPCSupport(); 106 mojo::edk::ShutdownIPCSupport();
107 EXPECT_EQ(1u, native_runner_delegate.get_and_clear_adjust_count()); 107 EXPECT_EQ(1u, native_runner_delegate.get_and_clear_adjust_count());
108 } 108 }
109 109
110 } // namespace 110 } // namespace
111 } // namespace shell 111 } // namespace shell
112 } // namespace mojo
OLDNEW
« no previous file with comments | « services/shell/runner/host/child_process_host.cc ('k') | services/shell/runner/host/host_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698