OLD | NEW |
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 #include "mojo/edk/embedder/embedder.h" | 5 #include "mojo/edk/embedder/embedder.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/base_paths.h" | 13 #include "base/base_paths.h" |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/files/file.h" | 16 #include "base/files/file.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/memory/shared_memory.h" | 19 #include "base/memory/shared_memory.h" |
20 #include "base/message_loop/message_loop.h" | 20 #include "base/message_loop/message_loop.h" |
21 #include "base/path_service.h" | 21 #include "base/path_service.h" |
22 #include "base/process/process_handle.h" | 22 #include "base/process/process_handle.h" |
23 #include "base/run_loop.h" | 23 #include "base/run_loop.h" |
24 #include "base/synchronization/waitable_event.h" | 24 #include "base/synchronization/waitable_event.h" |
25 #include "base/test/test_timeouts.h" | 25 #include "base/test/test_timeouts.h" |
| 26 #include "mojo/edk/embedder/embedder.h" |
26 #include "mojo/edk/embedder/named_platform_handle.h" | 27 #include "mojo/edk/embedder/named_platform_handle.h" |
27 #include "mojo/edk/embedder/named_platform_handle_utils.h" | 28 #include "mojo/edk/embedder/named_platform_handle_utils.h" |
28 #include "mojo/edk/embedder/platform_channel_pair.h" | 29 #include "mojo/edk/embedder/platform_channel_pair.h" |
29 #include "mojo/edk/embedder/test_embedder.h" | 30 #include "mojo/edk/embedder/test_embedder.h" |
30 #include "mojo/edk/system/test_utils.h" | 31 #include "mojo/edk/system/test_utils.h" |
31 #include "mojo/edk/test/mojo_test_base.h" | 32 #include "mojo/edk/test/mojo_test_base.h" |
32 #include "mojo/edk/test/scoped_ipc_support.h" | |
33 #include "mojo/public/c/system/core.h" | 33 #include "mojo/public/c/system/core.h" |
34 #include "mojo/public/cpp/system/handle.h" | 34 #include "mojo/public/cpp/system/handle.h" |
35 #include "mojo/public/cpp/system/message_pipe.h" | 35 #include "mojo/public/cpp/system/message_pipe.h" |
36 #include "testing/gtest/include/gtest/gtest.h" | 36 #include "testing/gtest/include/gtest/gtest.h" |
37 | 37 |
38 namespace mojo { | 38 namespace mojo { |
39 namespace edk { | 39 namespace edk { |
40 namespace { | 40 namespace { |
41 | 41 |
42 const MojoHandleSignals kSignalReadadableWritable = | 42 const MojoHandleSignals kSignalReadadableWritable = |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 EXPECT_EQ(MOJO_RESULT_OK, | 588 EXPECT_EQ(MOJO_RESULT_OK, |
589 Wait(server_pipe.get(), MOJO_HANDLE_SIGNAL_PEER_CLOSED, | 589 Wait(server_pipe.get(), MOJO_HANDLE_SIGNAL_PEER_CLOSED, |
590 MOJO_DEADLINE_INDEFINITE, nullptr)); | 590 MOJO_DEADLINE_INDEFINITE, nullptr)); |
591 base::MessageLoop message_loop; | 591 base::MessageLoop message_loop; |
592 base::RunLoop run_loop; | 592 base::RunLoop run_loop; |
593 ScopedPlatformHandle client_handle; | 593 ScopedPlatformHandle client_handle; |
594 // Closing the channel involves posting a task to the IO thread to do the | 594 // Closing the channel involves posting a task to the IO thread to do the |
595 // work. By the time the local message pipe has been observerd as closed, | 595 // work. By the time the local message pipe has been observerd as closed, |
596 // that task will have been posted. Therefore, a task to create the client | 596 // that task will have been posted. Therefore, a task to create the client |
597 // connection should be handled after the channel is closed. | 597 // connection should be handled after the channel is closed. |
598 test::GetIoTaskRunner()->PostTaskAndReply( | 598 GetIOTaskRunner()->PostTaskAndReply( |
599 FROM_HERE, | 599 FROM_HERE, |
600 base::Bind(&CreateClientHandleOnIoThread, named_handle, &client_handle), | 600 base::Bind(&CreateClientHandleOnIoThread, named_handle, &client_handle), |
601 run_loop.QuitClosure()); | 601 run_loop.QuitClosure()); |
602 run_loop.Run(); | 602 run_loop.Run(); |
603 EXPECT_FALSE(client_handle.is_valid()); | 603 EXPECT_FALSE(client_handle.is_valid()); |
604 } | 604 } |
605 | 605 |
606 #if !defined(OS_IOS) | 606 #if !defined(OS_IOS) |
607 | 607 |
608 TEST_F(EmbedderTest, ClosePipeToConnectedPeer) { | 608 TEST_F(EmbedderTest, ClosePipeToConnectedPeer) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 client_mp) { | 653 client_mp) { |
654 ASSERT_EQ(MOJO_RESULT_OK, MojoWait(client_mp, MOJO_HANDLE_SIGNAL_PEER_CLOSED, | 654 ASSERT_EQ(MOJO_RESULT_OK, MojoWait(client_mp, MOJO_HANDLE_SIGNAL_PEER_CLOSED, |
655 MOJO_DEADLINE_INDEFINITE, nullptr)); | 655 MOJO_DEADLINE_INDEFINITE, nullptr)); |
656 } | 656 } |
657 | 657 |
658 #endif // !defined(OS_IOS) | 658 #endif // !defined(OS_IOS) |
659 | 659 |
660 } // namespace | 660 } // namespace |
661 } // namespace edk | 661 } // namespace edk |
662 } // namespace mojo | 662 } // namespace mojo |
OLD | NEW |