| 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 "mojo/runner/child_process_host.h" | 7 #include "mojo/runner/child_process_host.h" |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/path_service.h" | |
| 13 #include "mojo/message_pump/message_pump_mojo.h" | 12 #include "mojo/message_pump/message_pump_mojo.h" |
| 14 #include "mojo/runner/context.h" | 13 #include "mojo/runner/context.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 15 |
| 17 namespace mojo { | 16 namespace mojo { |
| 18 namespace runner { | 17 namespace runner { |
| 19 namespace { | 18 namespace { |
| 20 | 19 |
| 21 // Subclass just so we can observe |DidStart()|. | 20 // Subclass just so we can observe |DidStart()|. |
| 22 class TestChildProcessHost : public ChildProcessHost { | 21 class TestChildProcessHost : public ChildProcessHost { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 37 | 36 |
| 38 #if defined(OS_ANDROID) | 37 #if defined(OS_ANDROID) |
| 39 // TODO(qsr): Multiprocess shell tests are not supported on android. | 38 // TODO(qsr): Multiprocess shell tests are not supported on android. |
| 40 #define MAYBE_StartJoin DISABLED_StartJoin | 39 #define MAYBE_StartJoin DISABLED_StartJoin |
| 41 #else | 40 #else |
| 42 #define MAYBE_StartJoin StartJoin | 41 #define MAYBE_StartJoin StartJoin |
| 43 #endif // defined(OS_ANDROID) | 42 #endif // defined(OS_ANDROID) |
| 44 // Just tests starting the child process and joining it (without starting an | 43 // Just tests starting the child process and joining it (without starting an |
| 45 // app). | 44 // app). |
| 46 TEST(ChildProcessHostTest, MAYBE_StartJoin) { | 45 TEST(ChildProcessHostTest, MAYBE_StartJoin) { |
| 47 base::FilePath shell_dir; | 46 Context context; |
| 48 PathService::Get(base::DIR_MODULE, &shell_dir); | |
| 49 Context context(shell_dir); | |
| 50 base::MessageLoop message_loop( | 47 base::MessageLoop message_loop( |
| 51 scoped_ptr<base::MessagePump>(new common::MessagePumpMojo())); | 48 scoped_ptr<base::MessagePump>(new common::MessagePumpMojo())); |
| 52 context.Init(); | 49 context.Init(); |
| 53 TestChildProcessHost child_process_host(&context); | 50 TestChildProcessHost child_process_host(&context); |
| 54 child_process_host.Start(); | 51 child_process_host.Start(); |
| 55 message_loop.Run(); | 52 message_loop.Run(); |
| 56 child_process_host.ExitNow(123); | 53 child_process_host.ExitNow(123); |
| 57 int exit_code = child_process_host.Join(); | 54 int exit_code = child_process_host.Join(); |
| 58 VLOG(2) << "Joined child: exit_code = " << exit_code; | 55 VLOG(2) << "Joined child: exit_code = " << exit_code; |
| 59 EXPECT_EQ(123, exit_code); | 56 EXPECT_EQ(123, exit_code); |
| 60 | 57 |
| 61 context.Shutdown(); | 58 context.Shutdown(); |
| 62 } | 59 } |
| 63 | 60 |
| 64 } // namespace | 61 } // namespace |
| 65 } // namespace runner | 62 } // namespace runner |
| 66 } // namespace mojo | 63 } // namespace mojo |
| OLD | NEW |