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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "build/build_config.h" | 24 #include "build/build_config.h" |
25 #include "mojo/edk/embedder/platform_channel_pair.h" | 25 #include "mojo/edk/embedder/platform_channel_pair.h" |
26 #include "mojo/edk/embedder/scoped_platform_handle.h" | 26 #include "mojo/edk/embedder/scoped_platform_handle.h" |
27 #include "mojo/edk/system/handle_signals_state.h" | 27 #include "mojo/edk/system/handle_signals_state.h" |
28 #include "mojo/edk/system/test_utils.h" | 28 #include "mojo/edk/system/test_utils.h" |
29 #include "mojo/edk/test/mojo_test_base.h" | 29 #include "mojo/edk/test/mojo_test_base.h" |
30 #include "mojo/edk/test/test_utils.h" | 30 #include "mojo/edk/test/test_utils.h" |
31 #include "mojo/public/c/system/buffer.h" | 31 #include "mojo/public/c/system/buffer.h" |
32 #include "mojo/public/c/system/functions.h" | 32 #include "mojo/public/c/system/functions.h" |
33 #include "mojo/public/c/system/types.h" | 33 #include "mojo/public/c/system/types.h" |
34 #include "mojo/public/cpp/system/watcher.h" | 34 #include "mojo/public/cpp/system/simple_watcher.h" |
35 #include "testing/gtest/include/gtest/gtest.h" | 35 #include "testing/gtest/include/gtest/gtest.h" |
36 | 36 |
37 | 37 |
38 namespace mojo { | 38 namespace mojo { |
39 namespace edk { | 39 namespace edk { |
40 namespace { | 40 namespace { |
41 | 41 |
42 class MultiprocessMessagePipeTest : public test::MojoTestBase { | 42 class MultiprocessMessagePipeTest : public test::MojoTestBase { |
43 protected: | 43 protected: |
44 // Convenience class for tests which will control command-driven children. | 44 // Convenience class for tests which will control command-driven children. |
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 // mechanisms when it races with handle transfer. | 1264 // mechanisms when it races with handle transfer. |
1265 MojoHandle handles[4]; | 1265 MojoHandle handles[4]; |
1266 EXPECT_EQ("o_O", ReadMessageWithHandles(parent, handles, 4)); | 1266 EXPECT_EQ("o_O", ReadMessageWithHandles(parent, handles, 4)); |
1267 | 1267 |
1268 // Wait on handle 0 using MojoWait. | 1268 // Wait on handle 0 using MojoWait. |
1269 EXPECT_EQ(MOJO_RESULT_OK, MojoWait(handles[0], MOJO_HANDLE_SIGNAL_PEER_CLOSED, | 1269 EXPECT_EQ(MOJO_RESULT_OK, MojoWait(handles[0], MOJO_HANDLE_SIGNAL_PEER_CLOSED, |
1270 MOJO_DEADLINE_INDEFINITE, nullptr)); | 1270 MOJO_DEADLINE_INDEFINITE, nullptr)); |
1271 | 1271 |
1272 base::MessageLoop message_loop; | 1272 base::MessageLoop message_loop; |
1273 | 1273 |
1274 // Wait on handle 1 using a Watcher. | 1274 // Wait on handle 1 using a SimpleWatcher. |
1275 { | 1275 { |
1276 base::RunLoop run_loop; | 1276 base::RunLoop run_loop; |
1277 Watcher watcher(FROM_HERE); | 1277 SimpleWatcher watcher(FROM_HERE, SimpleWatcher::ArmingPolicy::AUTOMATIC); |
1278 watcher.Start(Handle(handles[1]), MOJO_HANDLE_SIGNAL_PEER_CLOSED, | 1278 watcher.Watch(Handle(handles[1]), MOJO_HANDLE_SIGNAL_PEER_CLOSED, |
1279 base::Bind([] (base::RunLoop* loop, MojoResult result) { | 1279 base::Bind( |
1280 EXPECT_EQ(MOJO_RESULT_OK, result); | 1280 [](base::RunLoop* loop, MojoResult result) { |
1281 loop->Quit(); | 1281 EXPECT_EQ(MOJO_RESULT_OK, result); |
1282 }, &run_loop)); | 1282 loop->Quit(); |
| 1283 }, |
| 1284 &run_loop)); |
1283 run_loop.Run(); | 1285 run_loop.Run(); |
1284 } | 1286 } |
1285 | 1287 |
1286 // Wait on handle 2 by polling with MojoReadMessage. | 1288 // Wait on handle 2 by polling with MojoReadMessage. |
1287 MojoResult result; | 1289 MojoResult result; |
1288 do { | 1290 do { |
1289 result = MojoReadMessage(handles[2], nullptr, nullptr, nullptr, nullptr, | 1291 result = MojoReadMessage(handles[2], nullptr, nullptr, nullptr, nullptr, |
1290 MOJO_READ_MESSAGE_FLAG_NONE); | 1292 MOJO_READ_MESSAGE_FLAG_NONE); |
1291 } while (result == MOJO_RESULT_SHOULD_WAIT); | 1293 } while (result == MOJO_RESULT_SHOULD_WAIT); |
1292 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, result); | 1294 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, result); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1383 INSTANTIATE_TEST_CASE_P( | 1385 INSTANTIATE_TEST_CASE_P( |
1384 , | 1386 , |
1385 MultiprocessMessagePipeTestWithPeerSupport, | 1387 MultiprocessMessagePipeTestWithPeerSupport, |
1386 testing::Values(test::MojoTestBase::LaunchType::CHILD, | 1388 testing::Values(test::MojoTestBase::LaunchType::CHILD, |
1387 test::MojoTestBase::LaunchType::PEER, | 1389 test::MojoTestBase::LaunchType::PEER, |
1388 test::MojoTestBase::LaunchType::NAMED_CHILD, | 1390 test::MojoTestBase::LaunchType::NAMED_CHILD, |
1389 test::MojoTestBase::LaunchType::NAMED_PEER)); | 1391 test::MojoTestBase::LaunchType::NAMED_PEER)); |
1390 } // namespace | 1392 } // namespace |
1391 } // namespace edk | 1393 } // namespace edk |
1392 } // namespace mojo | 1394 } // namespace mojo |
OLD | NEW |