Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Unified Diff: mojo/edk/system/multiprocess_message_pipe_unittest.cc

Issue 1675603002: [mojo-edk] Simplify multiprocess pipe bootstrap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix some callers to work with sync APIs Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/system/core.cc ('k') | mojo/edk/system/node_channel.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/multiprocess_message_pipe_unittest.cc
diff --git a/mojo/edk/system/multiprocess_message_pipe_unittest.cc b/mojo/edk/system/multiprocess_message_pipe_unittest.cc
index 00c2ab564d4c3df196c0c93d337e1f99a6430b2e..ece85a1f001ca7bd2158c38a0732e7a2784fb6a9 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
« no previous file with comments | « mojo/edk/system/core.cc ('k') | mojo/edk/system/node_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698