Chromium Code Reviews| 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 | |
| 23 : public mojo::shell::ChildProcessHost::Delegate { | |
|
sky
2014/06/03 18:20:51
nit: Do you really need mojo_shell:: or mojo:: in
viettrungluu
2014/06/03 19:11:50
Done.
| |
| 24 public: | |
| 25 TestChildProcessHostDelegate() {} | |
| 26 virtual ~TestChildProcessHostDelegate() {} | |
| 27 virtual void WillStart() OVERRIDE { | |
| 28 VLOG(2) << "TestChildProcessHostDelegate::WillStart()"; | |
| 29 } | |
| 30 virtual void DidStart(bool success) OVERRIDE { | |
| 31 VLOG(2) << "TestChildProcessHostDelegate::DidStart(" << success << ")"; | |
| 32 base::MessageLoop::current()->QuitWhenIdle(); | |
| 33 } | |
| 34 }; | |
| 35 | |
| 36 typedef ShellTestBase ChildProcessHostTest; | |
| 37 | |
| 38 TEST_F(ChildProcessHostTest, Basic) { | |
| 39 base::MessageLoop message_loop( | |
| 40 scoped_ptr<base::MessagePump>(new mojo::common::MessagePumpMojo())); | |
| 41 | |
| 42 mojo::shell::Context context; | |
| 43 TestChildProcessHostDelegate child_process_host_delegate; | |
| 44 mojo::shell::ChildProcessHost child_process_host( | |
| 45 &context, &child_process_host_delegate, | |
| 46 mojo::shell::ChildProcess::TYPE_TEST); | |
| 47 child_process_host.Start(); | |
| 48 message_loop.Run(); | |
| 49 int exit_code = child_process_host.Join(); | |
| 50 VLOG(2) << "Joined child: exit_code = " << exit_code; | |
| 51 EXPECT_EQ(0, exit_code); | |
| 52 } | |
| 53 | |
| 54 } // namespace | |
| 55 } // namespace test | |
| 56 } // namespace shell | |
| 57 } // namespace mojo | |
| OLD | NEW |