Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: shell/app_child_process_host_unittest.cc

Issue 1040413003: Shell: Remove the test child stuff. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « shell/app_child_process_host.cc ('k') | shell/child_process.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 app_child_process.*.
6 6
7 #include "shell/child_process_host.h" 7 #include "shell/app_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 "mojo/common/message_pump_mojo.h" 12 #include "mojo/common/message_pump_mojo.h"
13 #include "shell/context.h" 13 #include "shell/context.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 namespace mojo { 16 namespace mojo {
17 namespace shell { 17 namespace shell {
18 namespace test {
19 namespace { 18 namespace {
20 19
21 class TestChildProcessHostDelegate : public ChildProcessHost::Delegate { 20 // Subclass just so we can observe |DidStart()|.
21 class TestAppChildProcessHost : public AppChildProcessHost {
22 public: 22 public:
23 TestChildProcessHostDelegate() {} 23 explicit TestAppChildProcessHost(Context* context)
24 ~TestChildProcessHostDelegate() {} 24 : AppChildProcessHost(context) {}
25 void WillStart() override { 25 ~TestAppChildProcessHost() override {}
26 VLOG(2) << "TestChildProcessHostDelegate::WillStart()"; 26
27 }
28 void DidStart(bool success) override { 27 void DidStart(bool success) override {
29 VLOG(2) << "TestChildProcessHostDelegate::DidStart(" << success << ")"; 28 EXPECT_TRUE(success);
29 AppChildProcessHost::DidStart(success);
30 base::MessageLoop::current()->QuitWhenIdle(); 30 base::MessageLoop::current()->QuitWhenIdle();
31 } 31 }
32
33 private:
34 DISALLOW_COPY_AND_ASSIGN(TestAppChildProcessHost);
32 }; 35 };
33 36
34 typedef testing::Test ChildProcessHostTest;
35
36 #if defined(OS_ANDROID) 37 #if defined(OS_ANDROID)
37 // TODO(qsr): Multiprocess shell tests are not supported on android. 38 // TODO(qsr): Multiprocess shell tests are not supported on android.
38 #define MAYBE_Basic DISABLED_Basic 39 #define MAYBE_StartJoin DISABLED_StartJoin
39 #else 40 #else
40 #define MAYBE_Basic Basic 41 #define MAYBE_StartJoin StartJoin
41 #endif // defined(OS_ANDROID) 42 #endif // defined(OS_ANDROID)
42 TEST_F(ChildProcessHostTest, MAYBE_Basic) { 43 // Just tests starting the child process and joining it (without starting an
44 // app).
45 TEST(AppChildProcessHostTest, MAYBE_StartJoin) {
43 Context context; 46 Context context;
44 base::MessageLoop message_loop( 47 base::MessageLoop message_loop(
45 scoped_ptr<base::MessagePump>(new common::MessagePumpMojo())); 48 scoped_ptr<base::MessagePump>(new common::MessagePumpMojo()));
46 context.Init(); 49 context.Init();
47 TestChildProcessHostDelegate child_process_host_delegate; 50 TestAppChildProcessHost app_child_process_host(&context);
48 ChildProcessHost child_process_host(&context, &child_process_host_delegate, 51 app_child_process_host.Start();
49 ChildProcess::TYPE_TEST);
50 child_process_host.Start();
51 message_loop.Run(); 52 message_loop.Run();
52 int exit_code = child_process_host.Join(); 53 app_child_process_host.ExitNow(123);
54 int exit_code = app_child_process_host.Join();
53 VLOG(2) << "Joined child: exit_code = " << exit_code; 55 VLOG(2) << "Joined child: exit_code = " << exit_code;
54 EXPECT_EQ(0, exit_code); 56 EXPECT_EQ(123, exit_code);
55 57
56 context.Shutdown(); 58 context.Shutdown();
57 } 59 }
58 60
59 } // namespace 61 } // namespace
60 } // namespace test
61 } // namespace shell 62 } // namespace shell
62 } // namespace mojo 63 } // namespace mojo
OLDNEW
« no previous file with comments | « shell/app_child_process_host.cc ('k') | shell/child_process.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698