OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "mojo/edk/test/multiprocess_test_helper.h" | 5 #include "mojo/edk/test/multiprocess_test_helper.h" |
6 | 6 |
7 #include <functional> | 7 #include <functional> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "mojo/edk/embedder/named_platform_handle.h" | 27 #include "mojo/edk/embedder/named_platform_handle.h" |
28 #include "mojo/edk/embedder/named_platform_handle_utils.h" | 28 #include "mojo/edk/embedder/named_platform_handle_utils.h" |
29 #include "mojo/edk/embedder/pending_process_connection.h" | 29 #include "mojo/edk/embedder/pending_process_connection.h" |
30 #include "mojo/edk/embedder/platform_channel_pair.h" | 30 #include "mojo/edk/embedder/platform_channel_pair.h" |
31 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
32 | 32 |
33 #if defined(OS_WIN) | 33 #if defined(OS_WIN) |
34 #include "base/win/windows_version.h" | 34 #include "base/win/windows_version.h" |
35 #elif defined(OS_MACOSX) && !defined(OS_IOS) | 35 #elif defined(OS_MACOSX) && !defined(OS_IOS) |
36 #include "base/mac/mach_port_broker.h" | 36 #include "base/mac/mach_port_broker.h" |
| 37 #elif defined(OS_ANDROID) |
| 38 // #include "base/android/parcelable_channel.h" |
37 #endif | 39 #endif |
38 | 40 |
39 namespace mojo { | 41 namespace mojo { |
40 namespace edk { | 42 namespace edk { |
41 namespace test { | 43 namespace test { |
42 | 44 |
43 namespace { | 45 namespace { |
44 | 46 |
45 const char kMojoPrimordialPipeToken[] = "mojo-primordial-pipe-token"; | 47 const char kMojoPrimordialPipeToken[] = "mojo-primordial-pipe-token"; |
46 const char kMojoNamedPipeName[] = "mojo-named-pipe-name"; | 48 const char kMojoNamedPipeName[] = "mojo-named-pipe-name"; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 launch_type == LaunchType::NAMED_CHILD) { | 155 launch_type == LaunchType::NAMED_CHILD) { |
154 std::string pipe_token; | 156 std::string pipe_token; |
155 pipe = process.CreateMessagePipe(&pipe_token); | 157 pipe = process.CreateMessagePipe(&pipe_token); |
156 command_line.AppendSwitchASCII(kMojoPrimordialPipeToken, pipe_token); | 158 command_line.AppendSwitchASCII(kMojoPrimordialPipeToken, pipe_token); |
157 } else if (launch_type == LaunchType::PEER || | 159 } else if (launch_type == LaunchType::PEER || |
158 launch_type == LaunchType::NAMED_PEER) { | 160 launch_type == LaunchType::NAMED_PEER) { |
159 peer_token_ = mojo::edk::GenerateRandomToken(); | 161 peer_token_ = mojo::edk::GenerateRandomToken(); |
160 pipe = ConnectToPeerProcess(std::move(server_handle), peer_token_); | 162 pipe = ConnectToPeerProcess(std::move(server_handle), peer_token_); |
161 } | 163 } |
162 | 164 |
163 test_child_ = | 165 base::SpawnChildResult result = |
164 base::SpawnMultiProcessTestChild(test_child_main, command_line, options); | 166 base::SpawnMultiProcessTestChild(test_child_main, command_line, options); |
| 167 test_child_ = std::move(result.process); |
165 if (launch_type == LaunchType::CHILD || launch_type == LaunchType::PEER) | 168 if (launch_type == LaunchType::CHILD || launch_type == LaunchType::PEER) |
166 channel.ChildProcessLaunched(); | 169 channel.ChildProcessLaunched(); |
167 | 170 |
168 if (launch_type == LaunchType::CHILD || | 171 if (launch_type == LaunchType::CHILD || |
169 launch_type == LaunchType::NAMED_CHILD) { | 172 launch_type == LaunchType::NAMED_CHILD) { |
170 DCHECK(server_handle.is_valid()); | 173 DCHECK(server_handle.is_valid()); |
171 process.Connect(test_child_.Handle(), std::move(server_handle), | 174 #if defined(OS_ANDROID) |
| 175 ConnectionParam connection_param(std::move(server_handle), |
| 176 base::android::ParcelableChannelClient( |
| 177 result.parcelable_channel_client), |
| 178 base::android::ParcelableChannelServer( |
| 179 result.parcelable_channel_server)); |
| 180 #else |
| 181 ConnectionParam connection_param(std::move(server_handle)); |
| 182 #endif |
| 183 process.Connect(test_child_.Handle(), std::move(connection_param), |
172 process_error_callback_); | 184 process_error_callback_); |
173 } | 185 } |
174 | 186 |
175 CHECK(test_child_.IsValid()); | 187 CHECK(test_child_.IsValid()); |
176 return pipe; | 188 return pipe; |
177 } | 189 } |
178 | 190 |
179 int MultiprocessTestHelper::WaitForChildShutdown() { | 191 int MultiprocessTestHelper::WaitForChildShutdown() { |
180 CHECK(test_child_.IsValid()); | 192 CHECK(test_child_.IsValid()); |
181 | 193 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 ::testing::Test::HasNonfatalFailure()) ? 1 : 0; | 258 ::testing::Test::HasNonfatalFailure()) ? 1 : 0; |
247 }); | 259 }); |
248 } | 260 } |
249 | 261 |
250 // static | 262 // static |
251 mojo::ScopedMessagePipeHandle MultiprocessTestHelper::primordial_pipe; | 263 mojo::ScopedMessagePipeHandle MultiprocessTestHelper::primordial_pipe; |
252 | 264 |
253 } // namespace test | 265 } // namespace test |
254 } // namespace edk | 266 } // namespace edk |
255 } // namespace mojo | 267 } // namespace mojo |
OLD | NEW |