Chromium Code Reviews| Index: mojo/shell/child_process_host_unittest.cc |
| diff --git a/mojo/shell/child_process_host_unittest.cc b/mojo/shell/child_process_host_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..db15808db38de28fa5f756757f19c0c5968d38ee |
| --- /dev/null |
| +++ b/mojo/shell/child_process_host_unittest.cc |
| @@ -0,0 +1,57 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// Note: This file also tests child_process.*. |
| + |
| +#include "mojo/shell/child_process_host.h" |
| + |
| +#include "base/logging.h" |
| +#include "base/macros.h" |
| +#include "base/message_loop/message_loop.h" |
| +#include "mojo/common/message_pump_mojo.h" |
| +#include "mojo/shell/context.h" |
| +#include "mojo/shell/shell_test_base.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +namespace mojo { |
| +namespace shell { |
| +namespace test { |
| +namespace { |
| + |
| +class TestChildProcessHostDelegate |
| + : 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.
|
| + public: |
| + TestChildProcessHostDelegate() {} |
| + virtual ~TestChildProcessHostDelegate() {} |
| + virtual void WillStart() OVERRIDE { |
| + VLOG(2) << "TestChildProcessHostDelegate::WillStart()"; |
| + } |
| + virtual void DidStart(bool success) OVERRIDE { |
| + VLOG(2) << "TestChildProcessHostDelegate::DidStart(" << success << ")"; |
| + base::MessageLoop::current()->QuitWhenIdle(); |
| + } |
| +}; |
| + |
| +typedef ShellTestBase ChildProcessHostTest; |
| + |
| +TEST_F(ChildProcessHostTest, Basic) { |
| + base::MessageLoop message_loop( |
| + scoped_ptr<base::MessagePump>(new mojo::common::MessagePumpMojo())); |
| + |
| + mojo::shell::Context context; |
| + TestChildProcessHostDelegate child_process_host_delegate; |
| + mojo::shell::ChildProcessHost child_process_host( |
| + &context, &child_process_host_delegate, |
| + mojo::shell::ChildProcess::TYPE_TEST); |
| + child_process_host.Start(); |
| + message_loop.Run(); |
| + int exit_code = child_process_host.Join(); |
| + VLOG(2) << "Joined child: exit_code = " << exit_code; |
| + EXPECT_EQ(0, exit_code); |
| +} |
| + |
| +} // namespace |
| +} // namespace test |
| +} // namespace shell |
| +} // namespace mojo |