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

Unified Diff: mojo/system/remote_message_pipe_unittest.cc

Issue 471773002: Mojo: Add a platform interface for shared memory (embedder::PlatformSharedBuffer). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win fix Created 6 years, 4 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/system/raw_shared_buffer_win.cc ('k') | mojo/system/shared_buffer_dispatcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/system/remote_message_pipe_unittest.cc
diff --git a/mojo/system/remote_message_pipe_unittest.cc b/mojo/system/remote_message_pipe_unittest.cc
index e026c30aa8653f1c79e52e2cd31b5d3a90c26b73..5f5c9fb1df52ae5c9eedc5871d34803c70941329 100644
--- a/mojo/system/remote_message_pipe_unittest.cc
+++ b/mojo/system/remote_message_pipe_unittest.cc
@@ -21,6 +21,7 @@
#include "build/build_config.h" // TODO(vtl): Remove this.
#include "mojo/common/test/test_utils.h"
#include "mojo/embedder/platform_channel_pair.h"
+#include "mojo/embedder/platform_shared_buffer.h"
#include "mojo/embedder/scoped_platform_handle.h"
#include "mojo/system/channel.h"
#include "mojo/system/local_message_pipe_endpoint.h"
@@ -708,16 +709,16 @@ TEST_F(RemoteMessagePipeTest, MAYBE_SharedBufferPassing) {
ASSERT_TRUE(dispatcher);
// Make a mapping.
- scoped_ptr<RawSharedBufferMapping> mapping0;
+ scoped_ptr<embedder::PlatformSharedBufferMapping> mapping0;
EXPECT_EQ(
MOJO_RESULT_OK,
dispatcher->MapBuffer(0, 100, MOJO_MAP_BUFFER_FLAG_NONE, &mapping0));
ASSERT_TRUE(mapping0);
- ASSERT_TRUE(mapping0->base());
- ASSERT_EQ(100u, mapping0->length());
- static_cast<char*>(mapping0->base())[0] = 'A';
- static_cast<char*>(mapping0->base())[50] = 'B';
- static_cast<char*>(mapping0->base())[99] = 'C';
+ ASSERT_TRUE(mapping0->GetBase());
+ ASSERT_EQ(100u, mapping0->GetLength());
+ static_cast<char*>(mapping0->GetBase())[0] = 'A';
+ static_cast<char*>(mapping0->GetBase())[50] = 'B';
+ static_cast<char*>(mapping0->GetBase())[99] = 'C';
// Prepare to wait on MP 1, port 1. (Add the waiter now. Otherwise, if we do
// it later, it might already be readable.)
@@ -780,27 +781,27 @@ TEST_F(RemoteMessagePipeTest, MAYBE_SharedBufferPassing) {
dispatcher = static_cast<SharedBufferDispatcher*>(read_dispatchers[0].get());
// Make another mapping.
- scoped_ptr<RawSharedBufferMapping> mapping1;
+ scoped_ptr<embedder::PlatformSharedBufferMapping> mapping1;
EXPECT_EQ(
MOJO_RESULT_OK,
dispatcher->MapBuffer(0, 100, MOJO_MAP_BUFFER_FLAG_NONE, &mapping1));
ASSERT_TRUE(mapping1);
- ASSERT_TRUE(mapping1->base());
- ASSERT_EQ(100u, mapping1->length());
- EXPECT_NE(mapping1->base(), mapping0->base());
- EXPECT_EQ('A', static_cast<char*>(mapping1->base())[0]);
- EXPECT_EQ('B', static_cast<char*>(mapping1->base())[50]);
- EXPECT_EQ('C', static_cast<char*>(mapping1->base())[99]);
+ ASSERT_TRUE(mapping1->GetBase());
+ ASSERT_EQ(100u, mapping1->GetLength());
+ EXPECT_NE(mapping1->GetBase(), mapping0->GetBase());
+ EXPECT_EQ('A', static_cast<char*>(mapping1->GetBase())[0]);
+ EXPECT_EQ('B', static_cast<char*>(mapping1->GetBase())[50]);
+ EXPECT_EQ('C', static_cast<char*>(mapping1->GetBase())[99]);
// Write stuff either way.
- static_cast<char*>(mapping1->base())[1] = 'x';
- EXPECT_EQ('x', static_cast<char*>(mapping0->base())[1]);
- static_cast<char*>(mapping0->base())[2] = 'y';
- EXPECT_EQ('y', static_cast<char*>(mapping1->base())[2]);
+ static_cast<char*>(mapping1->GetBase())[1] = 'x';
+ EXPECT_EQ('x', static_cast<char*>(mapping0->GetBase())[1]);
+ static_cast<char*>(mapping0->GetBase())[2] = 'y';
+ EXPECT_EQ('y', static_cast<char*>(mapping1->GetBase())[2]);
// Kill the first mapping; the second should still be valid.
mapping0.reset();
- EXPECT_EQ('A', static_cast<char*>(mapping1->base())[0]);
+ EXPECT_EQ('A', static_cast<char*>(mapping1->GetBase())[0]);
// Close everything that belongs to us.
mp0->Close(0);
@@ -808,7 +809,7 @@ TEST_F(RemoteMessagePipeTest, MAYBE_SharedBufferPassing) {
EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close());
// The second mapping should still be good.
- EXPECT_EQ('x', static_cast<char*>(mapping1->base())[1]);
+ EXPECT_EQ('x', static_cast<char*>(mapping1->GetBase())[1]);
}
#if defined(OS_POSIX)
« no previous file with comments | « mojo/system/raw_shared_buffer_win.cc ('k') | mojo/system/shared_buffer_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698