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

Unified Diff: mojo/public/platform/native/system_impl_private_unittest.cc

Issue 1993283002: Add thunks for MojoGetRights(), etc. (Closed) Base URL: https://github.com/domokit/mojo.git@work795_core_get_rights
Patch Set: I'm an idiot Created 4 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
Index: mojo/public/platform/native/system_impl_private_unittest.cc
diff --git a/mojo/public/platform/native/system_impl_private_unittest.cc b/mojo/public/platform/native/system_impl_private_unittest.cc
index 871d055cd051b137fed1620f64cc92fdac898e49..215ccd40e7cb4d8fc5fbbebe48039830088818fd 100644
--- a/mojo/public/platform/native/system_impl_private_unittest.cc
+++ b/mojo/public/platform/native/system_impl_private_unittest.cc
@@ -12,6 +12,22 @@
namespace mojo {
namespace {
+const MojoHandleRights kDefaultMessagePipeHandleRights =
+ MOJO_HANDLE_RIGHT_TRANSFER | MOJO_HANDLE_RIGHT_READ |
+ MOJO_HANDLE_RIGHT_WRITE | MOJO_HANDLE_RIGHT_GET_OPTIONS |
+ MOJO_HANDLE_RIGHT_SET_OPTIONS;
+const MojoHandleRights kDefaultDataPipeProducerHandleRights =
+ MOJO_HANDLE_RIGHT_TRANSFER | MOJO_HANDLE_RIGHT_WRITE |
+ MOJO_HANDLE_RIGHT_GET_OPTIONS | MOJO_HANDLE_RIGHT_SET_OPTIONS;
+const MojoHandleRights kDefaultDataPipeConsumerHandleRights =
+ MOJO_HANDLE_RIGHT_TRANSFER | MOJO_HANDLE_RIGHT_READ |
+ MOJO_HANDLE_RIGHT_GET_OPTIONS | MOJO_HANDLE_RIGHT_SET_OPTIONS;
+const MojoHandleRights kDefaultSharedBufferHandleRights =
+ MOJO_HANDLE_RIGHT_DUPLICATE | MOJO_HANDLE_RIGHT_TRANSFER |
+ MOJO_HANDLE_RIGHT_GET_OPTIONS | MOJO_HANDLE_RIGHT_SET_OPTIONS |
+ MOJO_HANDLE_RIGHT_MAP_READABLE | MOJO_HANDLE_RIGHT_MAP_WRITABLE |
+ MOJO_HANDLE_RIGHT_MAP_EXECUTABLE;
+
TEST(SystemImplTest, GetTimeTicksNow) {
MojoSystemImpl system = MojoSystemImplCreateImpl();
const MojoTimeTicks start = MojoSystemImplGetTimeTicksNow(system);
@@ -37,6 +53,15 @@ TEST(SystemImplTest, BasicMessagePipe) {
MojoSystemImplCreateMessagePipe(sys0, nullptr, &h0, &h1));
EXPECT_NE(h0, MOJO_HANDLE_INVALID);
EXPECT_NE(h1, MOJO_HANDLE_INVALID);
+ EXPECT_NE(h0, h1);
+
+ // Both handles should have the correct rights.
+ MojoHandleRights rights = MOJO_HANDLE_RIGHT_NONE;
+ EXPECT_EQ(MOJO_RESULT_OK, MojoSystemImplGetRights(sys0, h0, &rights));
+ EXPECT_EQ(kDefaultMessagePipeHandleRights, rights);
+ rights = MOJO_HANDLE_RIGHT_NONE;
+ EXPECT_EQ(MOJO_RESULT_OK, MojoSystemImplGetRights(sys0, h1, &rights));
+ EXPECT_EQ(kDefaultMessagePipeHandleRights, rights);
// Move the other end of the pipe to a different SystemImpl.
EXPECT_EQ(MOJO_RESULT_OK, MojoSystemImplTransferHandle(sys0, h1, sys1, &h1));
@@ -147,6 +172,15 @@ TEST(SystemImplTest, BasicDataPipe) {
MojoSystemImplCreateDataPipe(sys0, nullptr, &hp, &hc));
EXPECT_NE(hp, MOJO_HANDLE_INVALID);
EXPECT_NE(hc, MOJO_HANDLE_INVALID);
+ EXPECT_NE(hp, hc);
+
+ // Both handles should have the correct rights.
+ MojoHandleRights rights = MOJO_HANDLE_RIGHT_NONE;
+ EXPECT_EQ(MOJO_RESULT_OK, MojoSystemImplGetRights(sys0, hp, &rights));
+ EXPECT_EQ(kDefaultDataPipeProducerHandleRights, rights);
+ rights = MOJO_HANDLE_RIGHT_NONE;
+ EXPECT_EQ(MOJO_RESULT_OK, MojoSystemImplGetRights(sys0, hc, &rights));
+ EXPECT_EQ(kDefaultDataPipeConsumerHandleRights, rights);
// Move the other end of the pipe to a different SystemImpl.
EXPECT_EQ(MOJO_RESULT_OK, MojoSystemImplTransferHandle(sys0, hc, sys1, &hc));
@@ -574,6 +608,11 @@ TEST(SystemImplTest, BasicSharedBuffer) {
MojoSystemImplCreateSharedBuffer(sys0, nullptr, kSize, &h0));
EXPECT_NE(h0, MOJO_HANDLE_INVALID);
+ // The handle should have the correct rights.
+ MojoHandleRights rights = MOJO_HANDLE_RIGHT_NONE;
+ EXPECT_EQ(MOJO_RESULT_OK, MojoSystemImplGetRights(sys0, h0, &rights));
+ EXPECT_EQ(kDefaultSharedBufferHandleRights, rights);
+
// Check the buffer information.
{
MojoBufferInformation info = {};
@@ -598,6 +637,11 @@ TEST(SystemImplTest, BasicSharedBuffer) {
MojoSystemImplDuplicateBufferHandle(sys0, h0, nullptr, &h1));
EXPECT_NE(h1, MOJO_HANDLE_INVALID);
+ // The new handle should have the correct rights.
+ rights = MOJO_HANDLE_RIGHT_NONE;
+ EXPECT_EQ(MOJO_RESULT_OK, MojoSystemImplGetRights(sys0, h1, &rights));
+ EXPECT_EQ(kDefaultSharedBufferHandleRights, rights);
+
// Move the other end of the pipe to a different SystemImpl.
EXPECT_EQ(MOJO_RESULT_OK, MojoSystemImplTransferHandle(sys0, h1, sys1, &h1));
EXPECT_NE(h1, MOJO_HANDLE_INVALID);
« no previous file with comments | « mojo/public/platform/native/system_impl_private_thunks.c ('k') | mojo/public/platform/native/system_thunks.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698