| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 #include <stdio.h> | 6 #include <stdio.h> |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 14 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
| 15 #include "base/location.h" | 15 #include "base/location.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
| 18 #include "build/build_config.h" // TODO(vtl): Remove this. | |
| 19 #include "mojo/edk/embedder/platform_channel_pair.h" | 18 #include "mojo/edk/embedder/platform_channel_pair.h" |
| 20 #include "mojo/edk/embedder/platform_shared_buffer.h" | 19 #include "mojo/edk/embedder/platform_shared_buffer.h" |
| 21 #include "mojo/edk/embedder/scoped_platform_handle.h" | 20 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 22 #include "mojo/edk/embedder/simple_platform_support.h" | 21 #include "mojo/edk/embedder/simple_platform_support.h" |
| 23 #include "mojo/edk/system/channel.h" | 22 #include "mojo/edk/system/channel.h" |
| 24 #include "mojo/edk/system/channel_endpoint.h" | 23 #include "mojo/edk/system/channel_endpoint.h" |
| 25 #include "mojo/edk/system/channel_endpoint_id.h" | 24 #include "mojo/edk/system/channel_endpoint_id.h" |
| 26 #include "mojo/edk/system/incoming_endpoint.h" | 25 #include "mojo/edk/system/incoming_endpoint.h" |
| 27 #include "mojo/edk/system/message_pipe.h" | 26 #include "mojo/edk/system/message_pipe.h" |
| 28 #include "mojo/edk/system/message_pipe_dispatcher.h" | 27 #include "mojo/edk/system/message_pipe_dispatcher.h" |
| (...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 hss = dispatcher->GetHandleSignalsState(); | 885 hss = dispatcher->GetHandleSignalsState(); |
| 887 EXPECT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfied_signals); | 886 EXPECT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfied_signals); |
| 888 EXPECT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfiable_signals); | 887 EXPECT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfiable_signals); |
| 889 | 888 |
| 890 // Close everything that belongs to us. | 889 // Close everything that belongs to us. |
| 891 mp0->Close(0); | 890 mp0->Close(0); |
| 892 mp1->Close(1); | 891 mp1->Close(1); |
| 893 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); | 892 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); |
| 894 } | 893 } |
| 895 | 894 |
| 896 #if defined(OS_POSIX) | 895 TEST_F(RemoteMessagePipeTest, SharedBufferPassing) { |
| 897 #define MAYBE_SharedBufferPassing SharedBufferPassing | |
| 898 #else | |
| 899 // Not yet implemented (on Windows). | |
| 900 #define MAYBE_SharedBufferPassing DISABLED_SharedBufferPassing | |
| 901 #endif | |
| 902 TEST_F(RemoteMessagePipeTest, MAYBE_SharedBufferPassing) { | |
| 903 static const char kHello[] = "hello"; | 896 static const char kHello[] = "hello"; |
| 904 Waiter waiter; | 897 Waiter waiter; |
| 905 HandleSignalsState hss; | 898 HandleSignalsState hss; |
| 906 uint32_t context = 0; | 899 uint32_t context = 0; |
| 907 | 900 |
| 908 scoped_refptr<ChannelEndpoint> ep0; | 901 scoped_refptr<ChannelEndpoint> ep0; |
| 909 scoped_refptr<MessagePipe> mp0(MessagePipe::CreateLocalProxy(&ep0)); | 902 scoped_refptr<MessagePipe> mp0(MessagePipe::CreateLocalProxy(&ep0)); |
| 910 scoped_refptr<ChannelEndpoint> ep1; | 903 scoped_refptr<ChannelEndpoint> ep1; |
| 911 scoped_refptr<MessagePipe> mp1(MessagePipe::CreateProxyLocal(&ep1)); | 904 scoped_refptr<MessagePipe> mp1(MessagePipe::CreateProxyLocal(&ep1)); |
| 912 BootstrapChannelEndpoints(ep0, ep1); | 905 BootstrapChannelEndpoints(ep0, ep1); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 | 1003 |
| 1011 // Close everything that belongs to us. | 1004 // Close everything that belongs to us. |
| 1012 mp0->Close(0); | 1005 mp0->Close(0); |
| 1013 mp1->Close(1); | 1006 mp1->Close(1); |
| 1014 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); | 1007 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); |
| 1015 | 1008 |
| 1016 // The second mapping should still be good. | 1009 // The second mapping should still be good. |
| 1017 EXPECT_EQ('x', static_cast<char*>(mapping1->GetBase())[1]); | 1010 EXPECT_EQ('x', static_cast<char*>(mapping1->GetBase())[1]); |
| 1018 } | 1011 } |
| 1019 | 1012 |
| 1020 #if defined(OS_POSIX) | 1013 TEST_F(RemoteMessagePipeTest, PlatformHandlePassing) { |
| 1021 #define MAYBE_PlatformHandlePassing PlatformHandlePassing | |
| 1022 #else | |
| 1023 // Not yet implemented (on Windows). | |
| 1024 #define MAYBE_PlatformHandlePassing DISABLED_PlatformHandlePassing | |
| 1025 #endif | |
| 1026 TEST_F(RemoteMessagePipeTest, MAYBE_PlatformHandlePassing) { | |
| 1027 base::ScopedTempDir temp_dir; | 1014 base::ScopedTempDir temp_dir; |
| 1028 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 1015 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 1029 | 1016 |
| 1030 static const char kHello[] = "hello"; | 1017 static const char kHello[] = "hello"; |
| 1031 static const char kWorld[] = "world"; | 1018 static const char kWorld[] = "world"; |
| 1032 Waiter waiter; | 1019 Waiter waiter; |
| 1033 uint32_t context = 0; | 1020 uint32_t context = 0; |
| 1034 HandleSignalsState hss; | 1021 HandleSignalsState hss; |
| 1035 | 1022 |
| 1036 scoped_refptr<ChannelEndpoint> ep0; | 1023 scoped_refptr<ChannelEndpoint> ep0; |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1369 mp0->Close(0); | 1356 mp0->Close(0); |
| 1370 mp1->Close(1); | 1357 mp1->Close(1); |
| 1371 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); | 1358 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); |
| 1372 // Note that |local_mp|'s port 0 belong to |dispatcher|, which was closed. | 1359 // Note that |local_mp|'s port 0 belong to |dispatcher|, which was closed. |
| 1373 local_mp->Close(1); | 1360 local_mp->Close(1); |
| 1374 } | 1361 } |
| 1375 | 1362 |
| 1376 } // namespace | 1363 } // namespace |
| 1377 } // namespace system | 1364 } // namespace system |
| 1378 } // namespace mojo | 1365 } // namespace mojo |
| OLD | NEW |