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

Side by Side Diff: mojo/public/c/system/tests/buffer_unittest.cc

Issue 2056513002: Plumb MojoReplaceHandleWithReducedRights() out. (Closed) Base URL: https://github.com/domokit/mojo.git@work790_replace_reduce_1
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file tests the C buffer API (the functions declared in 5 // This file tests the C buffer API (the functions declared in
6 // mojo/public/c/system/buffer.h). 6 // mojo/public/c/system/buffer.h).
7 7
8 #include "mojo/public/c/system/buffer.h" 8 #include "mojo/public/c/system/buffer.h"
9 #include "mojo/public/c/system/handle.h" 9 #include "mojo/public/c/system/handle.h"
10 #include "mojo/public/c/system/result.h" 10 #include "mojo/public/c/system/result.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace { 13 namespace {
14 14
15 const MojoHandleRights kDefaultSharedBufferHandleRights = 15 const MojoHandleRights kDefaultSharedBufferHandleRights =
16 MOJO_HANDLE_RIGHT_DUPLICATE | MOJO_HANDLE_RIGHT_TRANSFER | 16 MOJO_HANDLE_RIGHT_DUPLICATE | MOJO_HANDLE_RIGHT_TRANSFER |
17 MOJO_HANDLE_RIGHT_GET_OPTIONS | MOJO_HANDLE_RIGHT_SET_OPTIONS | 17 MOJO_HANDLE_RIGHT_GET_OPTIONS | MOJO_HANDLE_RIGHT_SET_OPTIONS |
18 MOJO_HANDLE_RIGHT_MAP_READABLE | MOJO_HANDLE_RIGHT_MAP_WRITABLE | 18 MOJO_HANDLE_RIGHT_MAP_READABLE | MOJO_HANDLE_RIGHT_MAP_WRITABLE |
19 MOJO_HANDLE_RIGHT_MAP_EXECUTABLE; 19 MOJO_HANDLE_RIGHT_MAP_EXECUTABLE;
20 20
21 // The only handle that's guaranteed to be invalid is |MOJO_HANDLE_INVALID|. 21 // The only handle that's guaranteed to be invalid is |MOJO_HANDLE_INVALID|.
22 // Tests that everything that takes a handle properly recognizes it. 22 // Tests that everything that takes a handle properly recognizes it.
23 TEST(BufferTest, InvalidHandle) { 23 TEST(BufferTest, InvalidHandle) {
24 // Shared buffer:
25 MojoHandle out_handle = MOJO_HANDLE_INVALID; 24 MojoHandle out_handle = MOJO_HANDLE_INVALID;
26 EXPECT_EQ( 25 EXPECT_EQ(
27 MOJO_RESULT_INVALID_ARGUMENT, 26 MOJO_RESULT_INVALID_ARGUMENT,
28 MojoDuplicateBufferHandle(MOJO_HANDLE_INVALID, nullptr, &out_handle)); 27 MojoDuplicateBufferHandle(MOJO_HANDLE_INVALID, nullptr, &out_handle));
29 MojoBufferInformation buffer_info = {}; 28 MojoBufferInformation buffer_info = {};
30 EXPECT_EQ( 29 EXPECT_EQ(
31 MOJO_RESULT_INVALID_ARGUMENT, 30 MOJO_RESULT_INVALID_ARGUMENT,
32 MojoGetBufferInformation(MOJO_HANDLE_INVALID, &buffer_info, 31 MojoGetBufferInformation(MOJO_HANDLE_INVALID, &buffer_info,
33 static_cast<uint32_t>(sizeof(buffer_info)))); 32 static_cast<uint32_t>(sizeof(buffer_info))));
34 void* write_pointer = nullptr; 33 void* write_pointer = nullptr;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 EXPECT_EQ(MOJO_RESULT_PERMISSION_DENIED, MojoDuplicateHandle(h2, &h3)); 127 EXPECT_EQ(MOJO_RESULT_PERMISSION_DENIED, MojoDuplicateHandle(h2, &h3));
129 EXPECT_EQ(MOJO_HANDLE_INVALID, h3); 128 EXPECT_EQ(MOJO_HANDLE_INVALID, h3);
130 129
131 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h1)); 130 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h1));
132 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h2)); 131 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h2));
133 } 132 }
134 133
135 // TODO(vtl): Add multi-threaded tests. 134 // TODO(vtl): Add multi-threaded tests.
136 135
137 } // namespace 136 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698