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

Side by Side Diff: mojo/edk/system/shared_buffer_dispatcher_unittest.cc

Issue 1689053003: Support read-only duplicates of Mojo shared buffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-shm-interop
Patch Set: Rebase and fix comment. Created 4 years, 8 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
« no previous file with comments | « mojo/edk/system/shared_buffer_dispatcher.cc ('k') | mojo/edk/system/shared_buffer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "mojo/edk/system/shared_buffer_dispatcher.h" 5 #include "mojo/edk/system/shared_buffer_dispatcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 213
214 TEST_F(SharedBufferDispatcherTest, DuplicateBufferHandleOptionsValid) { 214 TEST_F(SharedBufferDispatcherTest, DuplicateBufferHandleOptionsValid) {
215 scoped_refptr<SharedBufferDispatcher> dispatcher1; 215 scoped_refptr<SharedBufferDispatcher> dispatcher1;
216 EXPECT_EQ(MOJO_RESULT_OK, SharedBufferDispatcher::Create( 216 EXPECT_EQ(MOJO_RESULT_OK, SharedBufferDispatcher::Create(
217 SharedBufferDispatcher::kDefaultCreateOptions, 217 SharedBufferDispatcher::kDefaultCreateOptions,
218 nullptr, 100, &dispatcher1)); 218 nullptr, 100, &dispatcher1));
219 219
220 MojoDuplicateBufferHandleOptions options[] = { 220 MojoDuplicateBufferHandleOptions options[] = {
221 {sizeof(MojoDuplicateBufferHandleOptions), 221 {sizeof(MojoDuplicateBufferHandleOptions),
222 MOJO_DUPLICATE_BUFFER_HANDLE_OPTIONS_FLAG_NONE}, 222 MOJO_DUPLICATE_BUFFER_HANDLE_OPTIONS_FLAG_NONE},
223 {sizeof(MojoDuplicateBufferHandleOptions),
224 MOJO_DUPLICATE_BUFFER_HANDLE_OPTIONS_FLAG_READ_ONLY},
223 {sizeof(MojoDuplicateBufferHandleOptionsFlags), ~0u}}; 225 {sizeof(MojoDuplicateBufferHandleOptionsFlags), ~0u}};
224 for (size_t i = 0; i < arraysize(options); i++) { 226 for (size_t i = 0; i < arraysize(options); i++) {
225 scoped_refptr<Dispatcher> dispatcher2; 227 scoped_refptr<Dispatcher> dispatcher2;
226 EXPECT_EQ(MOJO_RESULT_OK, dispatcher1->DuplicateBufferHandle( 228 EXPECT_EQ(MOJO_RESULT_OK, dispatcher1->DuplicateBufferHandle(
227 &options[i], &dispatcher2)); 229 &options[i], &dispatcher2));
228 ASSERT_TRUE(dispatcher2); 230 ASSERT_TRUE(dispatcher2);
229 EXPECT_EQ(Dispatcher::Type::SHARED_BUFFER, dispatcher2->GetType()); 231 EXPECT_EQ(Dispatcher::Type::SHARED_BUFFER, dispatcher2->GetType());
232 {
233 scoped_ptr<PlatformSharedBufferMapping> mapping;
234 EXPECT_EQ(MOJO_RESULT_OK, dispatcher2->MapBuffer(0, 100, 0, &mapping));
235 }
230 EXPECT_EQ(MOJO_RESULT_OK, dispatcher2->Close()); 236 EXPECT_EQ(MOJO_RESULT_OK, dispatcher2->Close());
231 } 237 }
232 238
233 EXPECT_EQ(MOJO_RESULT_OK, dispatcher1->Close()); 239 EXPECT_EQ(MOJO_RESULT_OK, dispatcher1->Close());
234 } 240 }
235 241
236 TEST_F(SharedBufferDispatcherTest, DuplicateBufferHandleOptionsInvalid) { 242 TEST_F(SharedBufferDispatcherTest, DuplicateBufferHandleOptionsInvalid) {
237 scoped_refptr<SharedBufferDispatcher> dispatcher1; 243 scoped_refptr<SharedBufferDispatcher> dispatcher1;
238 EXPECT_EQ(MOJO_RESULT_OK, SharedBufferDispatcher::Create( 244 EXPECT_EQ(MOJO_RESULT_OK, SharedBufferDispatcher::Create(
239 SharedBufferDispatcher::kDefaultCreateOptions, 245 SharedBufferDispatcher::kDefaultCreateOptions,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 303 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
298 dispatcher->MapBuffer(0, 0, MOJO_MAP_BUFFER_FLAG_NONE, &mapping)); 304 dispatcher->MapBuffer(0, 0, MOJO_MAP_BUFFER_FLAG_NONE, &mapping));
299 EXPECT_FALSE(mapping); 305 EXPECT_FALSE(mapping);
300 306
301 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); 307 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close());
302 } 308 }
303 309
304 } // namespace 310 } // namespace
305 } // namespace edk 311 } // namespace edk
306 } // namespace mojo 312 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/shared_buffer_dispatcher.cc ('k') | mojo/edk/system/shared_buffer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698