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

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

Issue 1350023003: Add a Mojo EDK for Chrome that uses one OS pipe per message pipe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more cleanup Created 5 years, 2 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 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 "third_party/mojo/src/mojo/edk/system/shared_buffer_dispatcher.h" 5 #include "mojo/edk/system/shared_buffer_dispatcher.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "mojo/edk/embedder/platform_shared_buffer.h"
11 #include "mojo/edk/embedder/simple_platform_support.h"
12 #include "mojo/edk/system/dispatcher.h"
10 #include "mojo/public/cpp/system/macros.h" 13 #include "mojo/public/cpp/system/macros.h"
11 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
12 #include "third_party/mojo/src/mojo/edk/embedder/platform_shared_buffer.h"
13 #include "third_party/mojo/src/mojo/edk/embedder/simple_platform_support.h"
14 #include "third_party/mojo/src/mojo/edk/system/dispatcher.h"
15 15
16 namespace mojo { 16 namespace mojo {
17 namespace system { 17 namespace edk {
18 namespace { 18 namespace {
19 19
20 // NOTE(vtl): There's currently not much to test for in 20 // NOTE(vtl): There's currently not much to test for in
21 // |SharedBufferDispatcher::ValidateCreateOptions()|, but the tests should be 21 // |SharedBufferDispatcher::ValidateCreateOptions()|, but the tests should be
22 // expanded if/when options are added, so I've kept the general form of the 22 // expanded if/when options are added, so I've kept the general form of the
23 // tests from data_pipe_unittest.cc. 23 // tests from data_pipe_unittest.cc.
24 24
25 const uint32_t kSizeOfCreateOptions = sizeof(MojoCreateSharedBufferOptions); 25 const uint32_t kSizeOfCreateOptions = sizeof(MojoCreateSharedBufferOptions);
26 26
27 // Does a cursory sanity check of |validated_options|. Calls 27 // Does a cursory sanity check of |validated_options|. Calls
28 // |ValidateCreateOptions()| on already-validated options. The validated options 28 // |ValidateCreateOptions()| on already-validated options. The validated options
29 // should be valid, and the revalidated copy should be the same. 29 // should be valid, and the revalidated copy should be the same.
30 void RevalidateCreateOptions( 30 void RevalidateCreateOptions(
31 const MojoCreateSharedBufferOptions& validated_options) { 31 const MojoCreateSharedBufferOptions& validated_options) {
32 EXPECT_EQ(kSizeOfCreateOptions, validated_options.struct_size); 32 EXPECT_EQ(kSizeOfCreateOptions, validated_options.struct_size);
33 // Nothing to check for flags. 33 // Nothing to check for flags.
34 34
35 MojoCreateSharedBufferOptions revalidated_options = {}; 35 MojoCreateSharedBufferOptions revalidated_options = {};
36 EXPECT_EQ(MOJO_RESULT_OK, 36 EXPECT_EQ(MOJO_RESULT_OK,
37 SharedBufferDispatcher::ValidateCreateOptions( 37 SharedBufferDispatcher::ValidateCreateOptions(
38 MakeUserPointer(&validated_options), &revalidated_options)); 38 &validated_options, &revalidated_options));
39 EXPECT_EQ(validated_options.struct_size, revalidated_options.struct_size); 39 EXPECT_EQ(validated_options.struct_size, revalidated_options.struct_size);
40 EXPECT_EQ(validated_options.flags, revalidated_options.flags); 40 EXPECT_EQ(validated_options.flags, revalidated_options.flags);
41 } 41 }
42 42
43 class SharedBufferDispatcherTest : public testing::Test { 43 class SharedBufferDispatcherTest : public testing::Test {
44 public: 44 public:
45 SharedBufferDispatcherTest() {} 45 SharedBufferDispatcherTest() {}
46 ~SharedBufferDispatcherTest() override {} 46 ~SharedBufferDispatcherTest() override {}
47 47
48 embedder::PlatformSupport* platform_support() { return &platform_support_; } 48 PlatformSupport* platform_support() { return &platform_support_; }
49 49
50 private: 50 private:
51 embedder::SimplePlatformSupport platform_support_; 51 SimplePlatformSupport platform_support_;
52 52
53 MOJO_DISALLOW_COPY_AND_ASSIGN(SharedBufferDispatcherTest); 53 MOJO_DISALLOW_COPY_AND_ASSIGN(SharedBufferDispatcherTest);
54 }; 54 };
55 55
56 // Tests valid inputs to |ValidateCreateOptions()|. 56 // Tests valid inputs to |ValidateCreateOptions()|.
57 TEST_F(SharedBufferDispatcherTest, ValidateCreateOptionsValid) { 57 TEST_F(SharedBufferDispatcherTest, ValidateCreateOptionsValid) {
58 // Default options. 58 // Default options.
59 { 59 {
60 MojoCreateSharedBufferOptions validated_options = {}; 60 MojoCreateSharedBufferOptions validated_options = {};
61 EXPECT_EQ(MOJO_RESULT_OK, SharedBufferDispatcher::ValidateCreateOptions( 61 EXPECT_EQ(MOJO_RESULT_OK, SharedBufferDispatcher::ValidateCreateOptions(
62 NullUserPointer(), &validated_options)); 62 nullptr, &validated_options));
63 RevalidateCreateOptions(validated_options); 63 RevalidateCreateOptions(validated_options);
64 } 64 }
65 65
66 // Different flags. 66 // Different flags.
67 MojoCreateSharedBufferOptionsFlags flags_values[] = { 67 MojoCreateSharedBufferOptionsFlags flags_values[] = {
68 MOJO_CREATE_SHARED_BUFFER_OPTIONS_FLAG_NONE}; 68 MOJO_CREATE_SHARED_BUFFER_OPTIONS_FLAG_NONE};
69 for (size_t i = 0; i < MOJO_ARRAYSIZE(flags_values); i++) { 69 for (size_t i = 0; i < MOJO_ARRAYSIZE(flags_values); i++) {
70 const MojoCreateSharedBufferOptionsFlags flags = flags_values[i]; 70 const MojoCreateSharedBufferOptionsFlags flags = flags_values[i];
71 71
72 // Different capacities (size 1). 72 // Different capacities (size 1).
73 for (uint32_t capacity = 1; capacity <= 100 * 1000 * 1000; capacity *= 10) { 73 for (uint32_t capacity = 1; capacity <= 100 * 1000 * 1000; capacity *= 10) {
74 MojoCreateSharedBufferOptions options = { 74 MojoCreateSharedBufferOptions options = {
75 kSizeOfCreateOptions, // |struct_size|. 75 kSizeOfCreateOptions, // |struct_size|.
76 flags // |flags|. 76 flags // |flags|.
77 }; 77 };
78 MojoCreateSharedBufferOptions validated_options = {}; 78 MojoCreateSharedBufferOptions validated_options = {};
79 EXPECT_EQ(MOJO_RESULT_OK, 79 EXPECT_EQ(MOJO_RESULT_OK,
80 SharedBufferDispatcher::ValidateCreateOptions( 80 SharedBufferDispatcher::ValidateCreateOptions(
81 MakeUserPointer(&options), &validated_options)) 81 &options, &validated_options))
82 << capacity; 82 << capacity;
83 RevalidateCreateOptions(validated_options); 83 RevalidateCreateOptions(validated_options);
84 EXPECT_EQ(options.flags, validated_options.flags); 84 EXPECT_EQ(options.flags, validated_options.flags);
85 } 85 }
86 } 86 }
87 } 87 }
88 88
89 TEST_F(SharedBufferDispatcherTest, ValidateCreateOptionsInvalid) { 89 TEST_F(SharedBufferDispatcherTest, ValidateCreateOptionsInvalid) {
90 // Invalid |struct_size|. 90 // Invalid |struct_size|.
91 { 91 {
92 MojoCreateSharedBufferOptions options = { 92 MojoCreateSharedBufferOptions options = {
93 1, // |struct_size|. 93 1, // |struct_size|.
94 MOJO_CREATE_SHARED_BUFFER_OPTIONS_FLAG_NONE // |flags|. 94 MOJO_CREATE_SHARED_BUFFER_OPTIONS_FLAG_NONE // |flags|.
95 }; 95 };
96 MojoCreateSharedBufferOptions unused; 96 MojoCreateSharedBufferOptions unused;
97 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 97 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
98 SharedBufferDispatcher::ValidateCreateOptions( 98 SharedBufferDispatcher::ValidateCreateOptions(
99 MakeUserPointer(&options), &unused)); 99 &options, &unused));
100 } 100 }
101 101
102 // Unknown |flags|. 102 // Unknown |flags|.
103 { 103 {
104 MojoCreateSharedBufferOptions options = { 104 MojoCreateSharedBufferOptions options = {
105 kSizeOfCreateOptions, // |struct_size|. 105 kSizeOfCreateOptions, // |struct_size|.
106 ~0u // |flags|. 106 ~0u // |flags|.
107 }; 107 };
108 MojoCreateSharedBufferOptions unused; 108 MojoCreateSharedBufferOptions unused;
109 EXPECT_EQ(MOJO_RESULT_UNIMPLEMENTED, 109 EXPECT_EQ(MOJO_RESULT_UNIMPLEMENTED,
110 SharedBufferDispatcher::ValidateCreateOptions( 110 SharedBufferDispatcher::ValidateCreateOptions(
111 MakeUserPointer(&options), &unused)); 111 &options, &unused));
112 } 112 }
113 } 113 }
114 114
115 TEST_F(SharedBufferDispatcherTest, CreateAndMapBuffer) { 115 TEST_F(SharedBufferDispatcherTest, CreateAndMapBuffer) {
116 scoped_refptr<SharedBufferDispatcher> dispatcher; 116 scoped_refptr<SharedBufferDispatcher> dispatcher;
117 EXPECT_EQ(MOJO_RESULT_OK, SharedBufferDispatcher::Create( 117 EXPECT_EQ(MOJO_RESULT_OK, SharedBufferDispatcher::Create(
118 platform_support(), 118 platform_support(),
119 SharedBufferDispatcher::kDefaultCreateOptions, 119 SharedBufferDispatcher::kDefaultCreateOptions,
120 100, &dispatcher)); 120 100, &dispatcher));
121 ASSERT_TRUE(dispatcher); 121 ASSERT_TRUE(dispatcher);
122 EXPECT_EQ(Dispatcher::Type::SHARED_BUFFER, dispatcher->GetType()); 122 EXPECT_EQ(Dispatcher::Type::SHARED_BUFFER, dispatcher->GetType());
123 123
124 // Make a couple of mappings. 124 // Make a couple of mappings.
125 scoped_ptr<embedder::PlatformSharedBufferMapping> mapping1; 125 scoped_ptr<PlatformSharedBufferMapping> mapping1;
126 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->MapBuffer( 126 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->MapBuffer(
127 0, 100, MOJO_MAP_BUFFER_FLAG_NONE, &mapping1)); 127 0, 100, MOJO_MAP_BUFFER_FLAG_NONE, &mapping1));
128 ASSERT_TRUE(mapping1); 128 ASSERT_TRUE(mapping1);
129 ASSERT_TRUE(mapping1->GetBase()); 129 ASSERT_TRUE(mapping1->GetBase());
130 EXPECT_EQ(100u, mapping1->GetLength()); 130 EXPECT_EQ(100u, mapping1->GetLength());
131 // Write something. 131 // Write something.
132 static_cast<char*>(mapping1->GetBase())[50] = 'x'; 132 static_cast<char*>(mapping1->GetBase())[50] = 'x';
133 133
134 scoped_ptr<embedder::PlatformSharedBufferMapping> mapping2; 134 scoped_ptr<PlatformSharedBufferMapping> mapping2;
135 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->MapBuffer( 135 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->MapBuffer(
136 50, 50, MOJO_MAP_BUFFER_FLAG_NONE, &mapping2)); 136 50, 50, MOJO_MAP_BUFFER_FLAG_NONE, &mapping2));
137 ASSERT_TRUE(mapping2); 137 ASSERT_TRUE(mapping2);
138 ASSERT_TRUE(mapping2->GetBase()); 138 ASSERT_TRUE(mapping2->GetBase());
139 EXPECT_EQ(50u, mapping2->GetLength()); 139 EXPECT_EQ(50u, mapping2->GetLength());
140 EXPECT_EQ('x', static_cast<char*>(mapping2->GetBase())[0]); 140 EXPECT_EQ('x', static_cast<char*>(mapping2->GetBase())[0]);
141 141
142 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); 142 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close());
143 143
144 // Check that we can still read/write to mappings after the dispatcher has 144 // Check that we can still read/write to mappings after the dispatcher has
145 // gone away. 145 // gone away.
146 static_cast<char*>(mapping2->GetBase())[1] = 'y'; 146 static_cast<char*>(mapping2->GetBase())[1] = 'y';
147 EXPECT_EQ('y', static_cast<char*>(mapping1->GetBase())[51]); 147 EXPECT_EQ('y', static_cast<char*>(mapping1->GetBase())[51]);
148 } 148 }
149 149
150 TEST_F(SharedBufferDispatcherTest, DuplicateBufferHandle) { 150 TEST_F(SharedBufferDispatcherTest, DuplicateBufferHandle) {
151 scoped_refptr<SharedBufferDispatcher> dispatcher1; 151 scoped_refptr<SharedBufferDispatcher> dispatcher1;
152 EXPECT_EQ(MOJO_RESULT_OK, SharedBufferDispatcher::Create( 152 EXPECT_EQ(MOJO_RESULT_OK, SharedBufferDispatcher::Create(
153 platform_support(), 153 platform_support(),
154 SharedBufferDispatcher::kDefaultCreateOptions, 154 SharedBufferDispatcher::kDefaultCreateOptions,
155 100, &dispatcher1)); 155 100, &dispatcher1));
156 156
157 // Map and write something. 157 // Map and write something.
158 scoped_ptr<embedder::PlatformSharedBufferMapping> mapping; 158 scoped_ptr<PlatformSharedBufferMapping> mapping;
159 EXPECT_EQ(MOJO_RESULT_OK, dispatcher1->MapBuffer( 159 EXPECT_EQ(MOJO_RESULT_OK, dispatcher1->MapBuffer(
160 0, 100, MOJO_MAP_BUFFER_FLAG_NONE, &mapping)); 160 0, 100, MOJO_MAP_BUFFER_FLAG_NONE, &mapping));
161 static_cast<char*>(mapping->GetBase())[0] = 'x'; 161 static_cast<char*>(mapping->GetBase())[0] = 'x';
162 mapping.reset(); 162 mapping.reset();
163 163
164 // Duplicate |dispatcher1| and then close it. 164 // Duplicate |dispatcher1| and then close it.
165 scoped_refptr<Dispatcher> dispatcher2; 165 scoped_refptr<Dispatcher> dispatcher2;
166 EXPECT_EQ(MOJO_RESULT_OK, dispatcher1->DuplicateBufferHandle( 166 EXPECT_EQ(MOJO_RESULT_OK, dispatcher1->DuplicateBufferHandle(
167 NullUserPointer(), &dispatcher2)); 167 nullptr, &dispatcher2));
168 ASSERT_TRUE(dispatcher2); 168 ASSERT_TRUE(dispatcher2);
169 EXPECT_EQ(Dispatcher::Type::SHARED_BUFFER, dispatcher2->GetType()); 169 EXPECT_EQ(Dispatcher::Type::SHARED_BUFFER, dispatcher2->GetType());
170 170
171 EXPECT_EQ(MOJO_RESULT_OK, dispatcher1->Close()); 171 EXPECT_EQ(MOJO_RESULT_OK, dispatcher1->Close());
172 172
173 // Map |dispatcher2| and read something. 173 // Map |dispatcher2| and read something.
174 EXPECT_EQ(MOJO_RESULT_OK, dispatcher2->MapBuffer( 174 EXPECT_EQ(MOJO_RESULT_OK, dispatcher2->MapBuffer(
175 0, 100, MOJO_MAP_BUFFER_FLAG_NONE, &mapping)); 175 0, 100, MOJO_MAP_BUFFER_FLAG_NONE, &mapping));
176 EXPECT_EQ('x', static_cast<char*>(mapping->GetBase())[0]); 176 EXPECT_EQ('x', static_cast<char*>(mapping->GetBase())[0]);
177 177
178 EXPECT_EQ(MOJO_RESULT_OK, dispatcher2->Close()); 178 EXPECT_EQ(MOJO_RESULT_OK, dispatcher2->Close());
179 } 179 }
180 180
181 TEST_F(SharedBufferDispatcherTest, DuplicateBufferHandleOptionsValid) { 181 TEST_F(SharedBufferDispatcherTest, DuplicateBufferHandleOptionsValid) {
182 scoped_refptr<SharedBufferDispatcher> dispatcher1; 182 scoped_refptr<SharedBufferDispatcher> dispatcher1;
183 EXPECT_EQ(MOJO_RESULT_OK, SharedBufferDispatcher::Create( 183 EXPECT_EQ(MOJO_RESULT_OK, SharedBufferDispatcher::Create(
184 platform_support(), 184 platform_support(),
185 SharedBufferDispatcher::kDefaultCreateOptions, 185 SharedBufferDispatcher::kDefaultCreateOptions,
186 100, &dispatcher1)); 186 100, &dispatcher1));
187 187
188 MojoDuplicateBufferHandleOptions options[] = { 188 MojoDuplicateBufferHandleOptions options[] = {
189 {sizeof(MojoDuplicateBufferHandleOptions), 189 {sizeof(MojoDuplicateBufferHandleOptions),
190 MOJO_DUPLICATE_BUFFER_HANDLE_OPTIONS_FLAG_NONE}, 190 MOJO_DUPLICATE_BUFFER_HANDLE_OPTIONS_FLAG_NONE},
191 {sizeof(MojoDuplicateBufferHandleOptionsFlags), ~0u}}; 191 {sizeof(MojoDuplicateBufferHandleOptionsFlags), ~0u}};
192 for (size_t i = 0; i < MOJO_ARRAYSIZE(options); i++) { 192 for (size_t i = 0; i < MOJO_ARRAYSIZE(options); i++) {
193 scoped_refptr<Dispatcher> dispatcher2; 193 scoped_refptr<Dispatcher> dispatcher2;
194 EXPECT_EQ(MOJO_RESULT_OK, dispatcher1->DuplicateBufferHandle( 194 EXPECT_EQ(MOJO_RESULT_OK, dispatcher1->DuplicateBufferHandle(
195 MakeUserPointer(&options[i]), &dispatcher2)); 195 &options[i], &dispatcher2));
196 ASSERT_TRUE(dispatcher2); 196 ASSERT_TRUE(dispatcher2);
197 EXPECT_EQ(Dispatcher::Type::SHARED_BUFFER, dispatcher2->GetType()); 197 EXPECT_EQ(Dispatcher::Type::SHARED_BUFFER, dispatcher2->GetType());
198 EXPECT_EQ(MOJO_RESULT_OK, dispatcher2->Close()); 198 EXPECT_EQ(MOJO_RESULT_OK, dispatcher2->Close());
199 } 199 }
200 200
201 EXPECT_EQ(MOJO_RESULT_OK, dispatcher1->Close()); 201 EXPECT_EQ(MOJO_RESULT_OK, dispatcher1->Close());
202 } 202 }
203 203
204 TEST_F(SharedBufferDispatcherTest, DuplicateBufferHandleOptionsInvalid) { 204 TEST_F(SharedBufferDispatcherTest, DuplicateBufferHandleOptionsInvalid) {
205 scoped_refptr<SharedBufferDispatcher> dispatcher1; 205 scoped_refptr<SharedBufferDispatcher> dispatcher1;
206 EXPECT_EQ(MOJO_RESULT_OK, SharedBufferDispatcher::Create( 206 EXPECT_EQ(MOJO_RESULT_OK, SharedBufferDispatcher::Create(
207 platform_support(), 207 platform_support(),
208 SharedBufferDispatcher::kDefaultCreateOptions, 208 SharedBufferDispatcher::kDefaultCreateOptions,
209 100, &dispatcher1)); 209 100, &dispatcher1));
210 210
211 // Invalid |struct_size|. 211 // Invalid |struct_size|.
212 { 212 {
213 MojoDuplicateBufferHandleOptions options = { 213 MojoDuplicateBufferHandleOptions options = {
214 1u, MOJO_DUPLICATE_BUFFER_HANDLE_OPTIONS_FLAG_NONE}; 214 1u, MOJO_DUPLICATE_BUFFER_HANDLE_OPTIONS_FLAG_NONE};
215 scoped_refptr<Dispatcher> dispatcher2; 215 scoped_refptr<Dispatcher> dispatcher2;
216 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 216 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
217 dispatcher1->DuplicateBufferHandle(MakeUserPointer(&options), 217 dispatcher1->DuplicateBufferHandle(&options, &dispatcher2));
218 &dispatcher2));
219 EXPECT_FALSE(dispatcher2); 218 EXPECT_FALSE(dispatcher2);
220 } 219 }
221 220
222 // Unknown |flags|. 221 // Unknown |flags|.
223 { 222 {
224 MojoDuplicateBufferHandleOptions options = { 223 MojoDuplicateBufferHandleOptions options = {
225 sizeof(MojoDuplicateBufferHandleOptions), ~0u}; 224 sizeof(MojoDuplicateBufferHandleOptions), ~0u};
226 scoped_refptr<Dispatcher> dispatcher2; 225 scoped_refptr<Dispatcher> dispatcher2;
227 EXPECT_EQ(MOJO_RESULT_UNIMPLEMENTED, 226 EXPECT_EQ(MOJO_RESULT_UNIMPLEMENTED,
228 dispatcher1->DuplicateBufferHandle(MakeUserPointer(&options), 227 dispatcher1->DuplicateBufferHandle(&options, &dispatcher2));
229 &dispatcher2));
230 EXPECT_FALSE(dispatcher2); 228 EXPECT_FALSE(dispatcher2);
231 } 229 }
232 230
233 EXPECT_EQ(MOJO_RESULT_OK, dispatcher1->Close()); 231 EXPECT_EQ(MOJO_RESULT_OK, dispatcher1->Close());
234 } 232 }
235 233
236 TEST_F(SharedBufferDispatcherTest, CreateInvalidNumBytes) { 234 TEST_F(SharedBufferDispatcherTest, CreateInvalidNumBytes) {
237 // Size too big. 235 // Size too big.
238 scoped_refptr<SharedBufferDispatcher> dispatcher; 236 scoped_refptr<SharedBufferDispatcher> dispatcher;
239 EXPECT_EQ( 237 EXPECT_EQ(
(...skipping 11 matching lines...) Expand all
251 EXPECT_FALSE(dispatcher); 249 EXPECT_FALSE(dispatcher);
252 } 250 }
253 251
254 TEST_F(SharedBufferDispatcherTest, MapBufferInvalidArguments) { 252 TEST_F(SharedBufferDispatcherTest, MapBufferInvalidArguments) {
255 scoped_refptr<SharedBufferDispatcher> dispatcher; 253 scoped_refptr<SharedBufferDispatcher> dispatcher;
256 EXPECT_EQ(MOJO_RESULT_OK, SharedBufferDispatcher::Create( 254 EXPECT_EQ(MOJO_RESULT_OK, SharedBufferDispatcher::Create(
257 platform_support(), 255 platform_support(),
258 SharedBufferDispatcher::kDefaultCreateOptions, 256 SharedBufferDispatcher::kDefaultCreateOptions,
259 100, &dispatcher)); 257 100, &dispatcher));
260 258
261 scoped_ptr<embedder::PlatformSharedBufferMapping> mapping; 259 scoped_ptr<PlatformSharedBufferMapping> mapping;
262 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 260 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
263 dispatcher->MapBuffer(0, 101, MOJO_MAP_BUFFER_FLAG_NONE, &mapping)); 261 dispatcher->MapBuffer(0, 101, MOJO_MAP_BUFFER_FLAG_NONE, &mapping));
264 EXPECT_FALSE(mapping); 262 EXPECT_FALSE(mapping);
265 263
266 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 264 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
267 dispatcher->MapBuffer(1, 100, MOJO_MAP_BUFFER_FLAG_NONE, &mapping)); 265 dispatcher->MapBuffer(1, 100, MOJO_MAP_BUFFER_FLAG_NONE, &mapping));
268 EXPECT_FALSE(mapping); 266 EXPECT_FALSE(mapping);
269 267
270 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 268 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
271 dispatcher->MapBuffer(0, 0, MOJO_MAP_BUFFER_FLAG_NONE, &mapping)); 269 dispatcher->MapBuffer(0, 0, MOJO_MAP_BUFFER_FLAG_NONE, &mapping));
272 EXPECT_FALSE(mapping); 270 EXPECT_FALSE(mapping);
273 271
274 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); 272 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close());
275 } 273 }
276 274
277 } // namespace 275 } // namespace
278 } // namespace system 276 } // namespace edk
279 } // namespace mojo 277 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698