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

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

Issue 1915153002: EDK: Add Dispatcher::SupportsEntrypointClass(). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 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') | no next file » | 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 <limits> 7 #include <limits>
8 #include <memory> 8 #include <memory>
9 9
10 #include "mojo/edk/embedder/simple_platform_support.h" 10 #include "mojo/edk/embedder/simple_platform_support.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 EXPECT_EQ('x', static_cast<char*>(mapping2->GetBase())[0]); 176 EXPECT_EQ('x', static_cast<char*>(mapping2->GetBase())[0]);
177 177
178 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); 178 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close());
179 179
180 // Check that we can still read/write to mappings after the dispatcher has 180 // Check that we can still read/write to mappings after the dispatcher has
181 // gone away. 181 // gone away.
182 static_cast<char*>(mapping2->GetBase())[1] = 'y'; 182 static_cast<char*>(mapping2->GetBase())[1] = 'y';
183 EXPECT_EQ('y', static_cast<char*>(mapping1->GetBase())[kSize / 2 + 1]); 183 EXPECT_EQ('y', static_cast<char*>(mapping1->GetBase())[kSize / 2 + 1]);
184 } 184 }
185 185
186 TEST_F(SharedBufferDispatcherTest, SupportsEntrypointClass) {
187 MojoResult result = MOJO_RESULT_INTERNAL;
188 auto d = SharedBufferDispatcher::Create(
189 platform_support(), SharedBufferDispatcher::kDefaultCreateOptions, 100u,
190 &result);
191 ASSERT_TRUE(d);
192 EXPECT_EQ(MOJO_RESULT_OK, result);
193
194 EXPECT_FALSE(
195 d->SupportsEntrypointClass(Dispatcher::EntrypointClass::MESSAGE_PIPE));
196 EXPECT_FALSE(d->SupportsEntrypointClass(
197 Dispatcher::EntrypointClass::DATA_PIPE_PRODUCER));
198 EXPECT_FALSE(d->SupportsEntrypointClass(
199 Dispatcher::EntrypointClass::DATA_PIPE_CONSUMER));
200 EXPECT_TRUE(d->SupportsEntrypointClass(Dispatcher::EntrypointClass::BUFFER));
201
202 // TODO(vtl): Check that it actually returns |MOJO_RESULT_INVALID_ARGUMENT|
203 // for methods in unsupported entrypoint classes.
204
205 EXPECT_EQ(MOJO_RESULT_OK, d->Close());
206 }
207
186 TEST_F(SharedBufferDispatcherTest, DuplicateBufferHandle) { 208 TEST_F(SharedBufferDispatcherTest, DuplicateBufferHandle) {
187 const uint64_t kSize = 100u; 209 const uint64_t kSize = 100u;
188 210
189 MojoResult result = MOJO_RESULT_INTERNAL; 211 MojoResult result = MOJO_RESULT_INTERNAL;
190 auto dispatcher1 = SharedBufferDispatcher::Create( 212 auto dispatcher1 = SharedBufferDispatcher::Create(
191 platform_support(), SharedBufferDispatcher::kDefaultCreateOptions, kSize, 213 platform_support(), SharedBufferDispatcher::kDefaultCreateOptions, kSize,
192 &result); 214 &result);
193 EXPECT_EQ(MOJO_RESULT_OK, result); 215 EXPECT_EQ(MOJO_RESULT_OK, result);
194 216
195 // Map and write something. 217 // Map and write something.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 341 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
320 dispatcher->MapBuffer(0, 0, MOJO_MAP_BUFFER_FLAG_NONE, &mapping)); 342 dispatcher->MapBuffer(0, 0, MOJO_MAP_BUFFER_FLAG_NONE, &mapping));
321 EXPECT_FALSE(mapping); 343 EXPECT_FALSE(mapping);
322 344
323 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); 345 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close());
324 } 346 }
325 347
326 } // namespace 348 } // namespace
327 } // namespace system 349 } // namespace system
328 } // namespace mojo 350 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/shared_buffer_dispatcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698