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

Unified Diff: ipc/ipc_message_utils_unittest.cc

Issue 2047233002: Support using a Mojo message pipe in a ChannelHandle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-handle-attachemnt-public-api
Patch Set: comments Created 4 years, 6 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 | « ipc/ipc_message_utils.cc ('k') | ipc/ipc_mojo_param_traits.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_message_utils_unittest.cc
diff --git a/ipc/ipc_message_utils_unittest.cc b/ipc/ipc_message_utils_unittest.cc
index 977c9e0606f4f1cba59394f3fad522b9242612f4..7b77c52d563cc8f4da34a7ea5e48b3bce4202657 100644
--- a/ipc/ipc_message_utils_unittest.cc
+++ b/ipc/ipc_message_utils_unittest.cc
@@ -10,6 +10,7 @@
#include "base/files/file_path.h"
#include "base/json/json_reader.h"
+#include "ipc/ipc_channel_handle.h"
#include "ipc/ipc_message.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -134,5 +135,28 @@ TEST(IPCMessageUtilsTest, JsonValueSize) {
EXPECT_EQ(sizer.payload_size(), pickle.payload_size());
}
+TEST(IPCMessageUtilsTest, MojoChannelHandle) {
+ mojo::MessagePipe message_pipe;
+ IPC::ChannelHandle channel_handle(message_pipe.handle0.release());
+
+ IPC::Message message;
+ IPC::WriteParam(&message, channel_handle);
+
+ base::PickleSizer sizer;
+ IPC::GetParamSize(&sizer, channel_handle);
+ EXPECT_EQ(sizer.payload_size(), message.payload_size());
+
+ base::PickleIterator iter(message);
+ IPC::ChannelHandle result_handle;
+ EXPECT_TRUE(IPC::ReadParam(&message, &iter, &result_handle));
+ EXPECT_TRUE(result_handle.name.empty());
+#if defined(OS_POSIX)
+ EXPECT_EQ(-1, result_handle.socket.fd);
+#elif defined(OS_WIN)
+ EXPECT_EQ(nullptr, result_handle.pipe.handle);
+#endif
+ EXPECT_EQ(channel_handle.mojo_handle, result_handle.mojo_handle);
+}
+
} // namespace
} // namespace IPC
« no previous file with comments | « ipc/ipc_message_utils.cc ('k') | ipc/ipc_mojo_param_traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698