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

Side by Side Diff: shell/app_child_process_host_unittest.cc

Issue 1047333002: For the out-of-process NativeRunner, make sure that Start()'s callback always gets called. (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/application_manager/native_runner.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 app_child_process.*. 5 // Note: This file also tests app_child_process.*.
6 6
7 #include "shell/app_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 "mojo/public/c/system/types.h"
14 #include "mojo/public/cpp/system/message_pipe.h"
13 #include "shell/context.h" 15 #include "shell/context.h"
14 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
15 17
16 namespace mojo { 18 namespace mojo {
17 namespace shell { 19 namespace shell {
18 namespace { 20 namespace {
19 21
20 // Subclass just so we can observe |DidStart()|. 22 // Subclass just so we can observe |DidStart()|.
21 class TestAppChildProcessHost : public AppChildProcessHost { 23 class TestAppChildProcessHost : public AppChildProcessHost {
22 public: 24 public:
(...skipping 19 matching lines...) Expand all
42 #endif // defined(OS_ANDROID) 44 #endif // defined(OS_ANDROID)
43 // Just tests starting the child process and joining it (without starting an 45 // Just tests starting the child process and joining it (without starting an
44 // app). 46 // app).
45 TEST(AppChildProcessHostTest, MAYBE_StartJoin) { 47 TEST(AppChildProcessHostTest, MAYBE_StartJoin) {
46 Context context; 48 Context context;
47 base::MessageLoop message_loop( 49 base::MessageLoop message_loop(
48 scoped_ptr<base::MessagePump>(new common::MessagePumpMojo())); 50 scoped_ptr<base::MessagePump>(new common::MessagePumpMojo()));
49 context.Init(); 51 context.Init();
50 TestAppChildProcessHost app_child_process_host(&context); 52 TestAppChildProcessHost app_child_process_host(&context);
51 app_child_process_host.Start(); 53 app_child_process_host.Start();
52 message_loop.Run(); 54 message_loop.Run(); // This should run until |DidStart()|.
53 app_child_process_host.ExitNow(123); 55 app_child_process_host.ExitNow(123);
54 int exit_code = app_child_process_host.Join(); 56 int exit_code = app_child_process_host.Join();
55 VLOG(2) << "Joined child: exit_code = " << exit_code; 57 VLOG(2) << "Joined child: exit_code = " << exit_code;
56 EXPECT_EQ(123, exit_code); 58 EXPECT_EQ(123, exit_code);
59
60 context.Shutdown();
61 }
62
63 #if defined(OS_ANDROID)
64 // TODO(qsr): Multiprocess shell tests are not supported on android.
65 #define MAYBE_ConnectionError DISABLED_ConnectionError
66 #else
67 #define MAYBE_ConnectionError ConnectionError
68 #endif // defined(OS_ANDROID)
69 // Tests that even on connection error, the callback to |StartApp()| will get
70 // called.
71 TEST(AppChildProcessHostTest, MAYBE_ConnectionError) {
72 Context context;
73 base::MessageLoop message_loop(
74 scoped_ptr<base::MessagePump>(new common::MessagePumpMojo()));
75 context.Init();
76 TestAppChildProcessHost app_child_process_host(&context);
77 app_child_process_host.Start();
78 message_loop.Run(); // This should run until |DidStart()|.
79 // Send |ExitNow()| first, so that the |StartApp()| below won't actually be
80 // processed, and we'll just get a connection error.
81 app_child_process_host.ExitNow(123);
82 MessagePipe mp;
83 InterfaceRequest<Application> application_request;
84 application_request.Bind(mp.handle0.Pass());
85 // This won't actually be called, but the callback should be run.
86 MojoResult result = MOJO_RESULT_INTERNAL;
87 app_child_process_host.StartApp(
88 "/does_not_exist/cbvgyuio", false, application_request.Pass(),
89 [&result](int32_t r) {
90 result = r;
91 base::MessageLoop::current()->QuitWhenIdle();
92 });
93 message_loop.Run();
94 EXPECT_EQ(MOJO_RESULT_UNKNOWN, result);
95 int exit_code = app_child_process_host.Join();
96 VLOG(2) << "Joined child: exit_code = " << exit_code;
97 EXPECT_EQ(123, exit_code);
57 98
58 context.Shutdown(); 99 context.Shutdown();
59 } 100 }
60 101
61 } // namespace 102 } // namespace
62 } // namespace shell 103 } // namespace shell
63 } // namespace mojo 104 } // namespace mojo
OLDNEW
« no previous file with comments | « shell/app_child_process_host.cc ('k') | shell/application_manager/native_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698