Add abhijeet.k@samsung.com to AUTHORS list.
[chromium-blink-merge.git] / mojo / shell / app_child_process_host_unittest.cc
blob37624bf31b19d9781806c8a6830b7f14c04d2b40
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 app_child_process.*.
7 #include "mojo/shell/app_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 TestAppChildProcessHost : public AppChildProcessHost {
22 public:
23 explicit TestAppChildProcessHost(Context* context)
24 : AppChildProcessHost(context) {}
25 ~TestAppChildProcessHost() override {}
27 void DidStart(bool success) override {
28 EXPECT_TRUE(success);
29 AppChildProcessHost::DidStart(success);
30 base::MessageLoop::current()->QuitWhenIdle();
33 private:
34 DISALLOW_COPY_AND_ASSIGN(TestAppChildProcessHost);
37 #if defined(OS_ANDROID)
38 // TODO(qsr): Multiprocess shell tests are not supported on android.
39 #define MAYBE_StartJoin DISABLED_StartJoin
40 #else
41 #define MAYBE_StartJoin StartJoin
42 #endif // defined(OS_ANDROID)
43 // Just tests starting the child process and joining it (without starting an
44 // app).
45 TEST(AppChildProcessHostTest, MAYBE_StartJoin) {
46 Context context;
47 base::MessageLoop message_loop(
48 scoped_ptr<base::MessagePump>(new common::MessagePumpMojo()));
49 context.Init();
50 TestAppChildProcessHost app_child_process_host(&context);
51 app_child_process_host.Start();
52 message_loop.Run();
53 app_child_process_host.ExitNow(123);
54 int exit_code = app_child_process_host.Join();
55 VLOG(2) << "Joined child: exit_code = " << exit_code;
56 EXPECT_EQ(123, exit_code);
58 context.Shutdown();
61 } // namespace
62 } // namespace shell
63 } // namespace mojo