Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / mojo / shell / child_process_host_unittest.cc
blob8e8f16d899b9526d8355865c484cb3f1c34e9740
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
3 // found in the LICENSE file.
5 // Note: This file also tests child_process.*.
7 #include "mojo/shell/child_process_host.h"
9 #include "base/logging.h"
10 #include "base/macros.h"
11 #include "base/message_loop/message_loop.h"
12 #include "mojo/common/message_pump_mojo.h"
13 #include "mojo/shell/context.h"
14 #include "testing/gtest/include/gtest/gtest.h"
16 namespace mojo {
17 namespace shell {
18 namespace {
20 // Subclass just so we can observe |DidStart()|.
21 class TestChildProcessHost : public ChildProcessHost {
22 public:
23 explicit TestChildProcessHost(Context* context) : ChildProcessHost(context) {}
24 ~TestChildProcessHost() override {}
26 void DidStart(bool success) override {
27 EXPECT_TRUE(success);
28 ChildProcessHost::DidStart(success);
29 base::MessageLoop::current()->QuitWhenIdle();
32 private:
33 DISALLOW_COPY_AND_ASSIGN(TestChildProcessHost);
36 #if defined(OS_ANDROID)
37 // TODO(qsr): Multiprocess shell tests are not supported on android.
38 #define MAYBE_StartJoin DISABLED_StartJoin
39 #else
40 #define MAYBE_StartJoin StartJoin
41 #endif // defined(OS_ANDROID)
42 // Just tests starting the child process and joining it (without starting an
43 // app).
44 TEST(ChildProcessHostTest, MAYBE_StartJoin) {
45 Context context;
46 base::MessageLoop message_loop(
47 scoped_ptr<base::MessagePump>(new common::MessagePumpMojo()));
48 context.Init();
49 TestChildProcessHost child_process_host(&context);
50 child_process_host.Start();
51 message_loop.Run();
52 child_process_host.ExitNow(123);
53 int exit_code = child_process_host.Join();
54 VLOG(2) << "Joined child: exit_code = " << exit_code;
55 EXPECT_EQ(123, exit_code);
57 context.Shutdown();
60 } // namespace
61 } // namespace shell
62 } // namespace mojo