summaryrefslogtreecommitdiffstats
path: root/mojo/edk/system/multiprocess_message_pipe_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'mojo/edk/system/multiprocess_message_pipe_unittest.cc')
-rw-r--r--mojo/edk/system/multiprocess_message_pipe_unittest.cc39
1 files changed, 39 insertions, 0 deletions
diff --git a/mojo/edk/system/multiprocess_message_pipe_unittest.cc b/mojo/edk/system/multiprocess_message_pipe_unittest.cc
index 00c2ab5..ece85a1 100644
--- a/mojo/edk/system/multiprocess_message_pipe_unittest.cc
+++ b/mojo/edk/system/multiprocess_message_pipe_unittest.cc
@@ -19,6 +19,7 @@
#include "base/logging.h"
#include "base/strings/string_split.h"
#include "build/build_config.h"
+#include "mojo/edk/embedder/platform_channel_pair.h"
#include "mojo/edk/embedder/scoped_platform_handle.h"
#include "mojo/edk/system/handle_signals_state.h"
#include "mojo/edk/system/test_utils.h"
@@ -1271,6 +1272,44 @@ TEST_F(MultiprocessMessagePipeTest, WriteCloseSendPeer) {
END_CHILD()
}
+DEFINE_TEST_CLIENT_TEST_WITH_PIPE(BootstrapMessagePipeAsyncClient,
+ MultiprocessMessagePipeTest, parent) {
+ // Receive one end of a platform channel from the parent.
+ MojoHandle channel_handle;
+ EXPECT_EQ("hi", ReadMessageWithHandles(parent, &channel_handle, 1));
+ ScopedPlatformHandle channel;
+ EXPECT_EQ(MOJO_RESULT_OK,
+ edk::PassWrappedPlatformHandle(channel_handle, &channel));
+ ASSERT_TRUE(channel.is_valid());
+
+ // Create a new pipe using our end of the channel.
+ ScopedMessagePipeHandle pipe = edk::CreateMessagePipe(std::move(channel));
+
+ // Ensure that we can read and write on the new pipe.
+ VerifyEcho(pipe.get().value(), "goodbye");
+}
+
+TEST_F(MultiprocessMessagePipeTest, BootstrapMessagePipeAsync) {
+ // Tests that new cross-process message pipes can be created synchronously
+ // using asynchronous negotiation over an arbitrary platform channel.
+ RUN_CHILD_ON_PIPE(BootstrapMessagePipeAsyncClient, child)
+ // Pass one end of a platform channel to the child.
+ PlatformChannelPair platform_channel;
+ MojoHandle client_channel_handle;
+ EXPECT_EQ(MOJO_RESULT_OK,
+ CreatePlatformHandleWrapper(platform_channel.PassClientHandle(),
+ &client_channel_handle));
+ WriteMessageWithHandles(child, "hi", &client_channel_handle, 1);
+
+ // Create a new pipe using our end of the channel.
+ ScopedMessagePipeHandle pipe =
+ edk::CreateMessagePipe(platform_channel.PassServerHandle());
+
+ // Ensure that we can read and write on the new pipe.
+ VerifyEcho(pipe.get().value(), "goodbye");
+ END_CHILD()
+}
+
} // namespace
} // namespace edk
} // namespace mojo