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

Unified Diff: ipc/ipc_message_utils_unittest.cc

Issue 2875453002: Add a size parameter to SharedMemoryHandle. (Closed)
Patch Set: Remove extraneous period. Created 3 years, 7 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') | mojo/edk/embedder/platform_shared_buffer.cc » ('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 4561c2e5cb9380b8139cd03ae75e2cb59ed52531..5b16c4d0bcc9cb5b3ee0d218c10e0182515c3cef 100644
--- a/ipc/ipc_message_utils_unittest.cc
+++ b/ipc/ipc_message_utils_unittest.cc
@@ -11,6 +11,7 @@
#include "base/files/file_path.h"
#include "base/json/json_reader.h"
#include "base/memory/ptr_util.h"
+#include "base/memory/shared_memory.h"
#include "base/unguessable_token.h"
#include "ipc/ipc_channel_handle.h"
#include "ipc/ipc_message.h"
@@ -195,6 +196,25 @@ TEST(IPCMessageUtilsTest, OptionalSet) {
EXPECT_EQ(opt.value(), unserialized_opt.value());
}
+TEST(IPCMessageUtilsTest, SharedMemoryHandle) {
+ base::SharedMemoryCreateOptions options;
+ options.size = 1004;
+ base::SharedMemory shmem;
+ ASSERT_TRUE(shmem.Create(options));
+
+ base::SharedMemoryHandle pre_pickle = shmem.handle().Duplicate();
+ ASSERT_TRUE(pre_pickle.IsValid());
+
+ IPC::Message message;
+ IPC::WriteParam(&message, pre_pickle);
+
+ base::SharedMemoryHandle post_pickle;
+ base::PickleIterator iter(message);
+ EXPECT_TRUE(IPC::ReadParam(&message, &iter, &post_pickle));
+ EXPECT_EQ(pre_pickle.GetGUID(), post_pickle.GetGUID());
+ EXPECT_EQ(pre_pickle.GetSize(), post_pickle.GetSize());
+}
+
TEST(IPCMessageUtilsTest, UnguessableTokenTest) {
base::UnguessableToken token = base::UnguessableToken::Create();
base::Pickle pickle;
« no previous file with comments | « ipc/ipc_message_utils.cc ('k') | mojo/edk/embedder/platform_shared_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698