OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 // Note: This file also tests child_process.*. |
| 6 |
| 7 #include "mojo/shell/child_process_host.h" |
| 8 |
| 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 "mojo/shell/shell_test_base.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 |
| 17 namespace mojo { |
| 18 namespace shell { |
| 19 namespace test { |
| 20 namespace { |
| 21 |
| 22 class TestChildProcessHostDelegate : public ChildProcessHost::Delegate { |
| 23 public: |
| 24 TestChildProcessHostDelegate() {} |
| 25 virtual ~TestChildProcessHostDelegate() {} |
| 26 virtual void WillStart() OVERRIDE { |
| 27 VLOG(2) << "TestChildProcessHostDelegate::WillStart()"; |
| 28 } |
| 29 virtual void DidStart(bool success) OVERRIDE { |
| 30 VLOG(2) << "TestChildProcessHostDelegate::DidStart(" << success << ")"; |
| 31 base::MessageLoop::current()->QuitWhenIdle(); |
| 32 } |
| 33 }; |
| 34 |
| 35 typedef ShellTestBase ChildProcessHostTest; |
| 36 |
| 37 TEST_F(ChildProcessHostTest, Basic) { |
| 38 base::MessageLoop message_loop( |
| 39 scoped_ptr<base::MessagePump>(new common::MessagePumpMojo())); |
| 40 |
| 41 Context context; |
| 42 TestChildProcessHostDelegate child_process_host_delegate; |
| 43 ChildProcessHost child_process_host(&context, |
| 44 &child_process_host_delegate, |
| 45 ChildProcess::TYPE_TEST); |
| 46 child_process_host.Start(); |
| 47 message_loop.Run(); |
| 48 int exit_code = child_process_host.Join(); |
| 49 VLOG(2) << "Joined child: exit_code = " << exit_code; |
| 50 EXPECT_EQ(0, exit_code); |
| 51 } |
| 52 |
| 53 } // namespace |
| 54 } // namespace test |
| 55 } // namespace shell |
| 56 } // namespace mojo |
OLD | NEW |