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

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

Issue 1946423002: EDK: Remove Core::AddDispatcher(). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stdint.h> 5 #include <stdint.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 Init(std::move(ep)); 318 Init(std::move(ep));
319 319
320 // Make a shared buffer. 320 // Make a shared buffer.
321 MojoResult result = MOJO_RESULT_INTERNAL; 321 MojoResult result = MOJO_RESULT_INTERNAL;
322 auto dispatcher = SharedBufferDispatcher::Create( 322 auto dispatcher = SharedBufferDispatcher::Create(
323 platform_support(), SharedBufferDispatcher::kDefaultCreateOptions, 100, 323 platform_support(), SharedBufferDispatcher::kDefaultCreateOptions, 100,
324 &result); 324 &result);
325 EXPECT_EQ(MOJO_RESULT_OK, result); 325 EXPECT_EQ(MOJO_RESULT_OK, result);
326 ASSERT_TRUE(dispatcher); 326 ASSERT_TRUE(dispatcher);
327 Handle handle(std::move(dispatcher), 327 Handle handle(std::move(dispatcher),
328 MOJO_HANDLE_RIGHT_DUPLICATE | MOJO_HANDLE_RIGHT_TRANSFER | 328 SharedBufferDispatcher::kDefaultHandleRights);
329 MOJO_HANDLE_RIGHT_READ | MOJO_HANDLE_RIGHT_WRITE);
330 329
331 // Make a mapping. 330 // Make a mapping.
332 std::unique_ptr<PlatformSharedBufferMapping> mapping; 331 std::unique_ptr<PlatformSharedBufferMapping> mapping;
333 EXPECT_EQ(MOJO_RESULT_OK, handle.dispatcher->MapBuffer( 332 EXPECT_EQ(MOJO_RESULT_OK, handle.dispatcher->MapBuffer(
334 0, 100, MOJO_MAP_BUFFER_FLAG_NONE, &mapping)); 333 0, 100, MOJO_MAP_BUFFER_FLAG_NONE, &mapping));
335 ASSERT_TRUE(mapping); 334 ASSERT_TRUE(mapping);
336 ASSERT_TRUE(mapping->GetBase()); 335 ASSERT_TRUE(mapping->GetBase());
337 ASSERT_EQ(100u, mapping->GetLength()); 336 ASSERT_EQ(100u, mapping->GetLength());
338 337
339 // Send the shared buffer. 338 // Send the shared buffer.
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 size_t pipe_count = GetParam(); 472 size_t pipe_count = GetParam();
474 for (size_t i = 0; i < pipe_count; ++i) { 473 for (size_t i = 0; i < pipe_count; ++i) {
475 util::ScopedFILE fp(test_dir.CreateFile()); 474 util::ScopedFILE fp(test_dir.CreateFile());
476 const std::string world("world"); 475 const std::string world("world");
477 CHECK_EQ(fwrite(&world[0], 1, world.size(), fp.get()), world.size()); 476 CHECK_EQ(fwrite(&world[0], 1, world.size(), fp.get()), world.size());
478 fflush(fp.get()); 477 fflush(fp.get());
479 rewind(fp.get()); 478 rewind(fp.get());
480 479
481 Handle handle(PlatformHandleDispatcher::Create(ScopedPlatformHandle( 480 Handle handle(PlatformHandleDispatcher::Create(ScopedPlatformHandle(
482 PlatformHandleFromFILE(std::move(fp)))), 481 PlatformHandleFromFILE(std::move(fp)))),
483 MOJO_HANDLE_RIGHT_TRANSFER | MOJO_HANDLE_RIGHT_READ | 482 PlatformHandleDispatcher::kDefaultHandleRights);
484 MOJO_HANDLE_RIGHT_WRITE);
485 handles.push_back(std::move(handle)); 483 handles.push_back(std::move(handle));
486 HandleTransport transport(test::HandleTryStartTransport(handles.back())); 484 HandleTransport transport(test::HandleTryStartTransport(handles.back()));
487 ASSERT_TRUE(transport.is_valid()); 485 ASSERT_TRUE(transport.is_valid());
488 transports.push_back(transport); 486 transports.push_back(transport);
489 } 487 }
490 488
491 char message[128]; 489 char message[128];
492 sprintf(message, "hello %d", static_cast<int>(pipe_count)); 490 sprintf(message, "hello %d", static_cast<int>(pipe_count));
493 EXPECT_EQ(MOJO_RESULT_OK, 491 EXPECT_EQ(MOJO_RESULT_OK,
494 mp->WriteMessage(0, UserPointer<const void>(message), 492 mp->WriteMessage(0, UserPointer<const void>(message),
(...skipping 22 matching lines...) Expand all
517 // Android multi-process tests are not executing the new process. This is flaky. 515 // Android multi-process tests are not executing the new process. This is flaky.
518 #if !defined(OS_ANDROID) 516 #if !defined(OS_ANDROID)
519 INSTANTIATE_TEST_CASE_P(PipeCount, 517 INSTANTIATE_TEST_CASE_P(PipeCount,
520 MultiprocessMessagePipeTestWithPipeCount, 518 MultiprocessMessagePipeTestWithPipeCount,
521 testing::Values(1u, 128u, 140u)); 519 testing::Values(1u, 128u, 140u));
522 #endif 520 #endif
523 521
524 } // namespace 522 } // namespace
525 } // namespace system 523 } // namespace system
526 } // namespace mojo 524 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/message_pipe_dispatcher.cc ('k') | mojo/edk/system/platform_handle_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698