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

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

Issue 1947733002: EDK: Rename DispatcherTransport to HandleTransport. (Closed) Base URL: https://github.com/domokit/mojo.git@work790_edk_handle_11-x-work788_edk_handle_10
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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 // Make a mapping. 331 // Make a mapping.
332 std::unique_ptr<PlatformSharedBufferMapping> mapping; 332 std::unique_ptr<PlatformSharedBufferMapping> mapping;
333 EXPECT_EQ(MOJO_RESULT_OK, handle.dispatcher->MapBuffer( 333 EXPECT_EQ(MOJO_RESULT_OK, handle.dispatcher->MapBuffer(
334 0, 100, MOJO_MAP_BUFFER_FLAG_NONE, &mapping)); 334 0, 100, MOJO_MAP_BUFFER_FLAG_NONE, &mapping));
335 ASSERT_TRUE(mapping); 335 ASSERT_TRUE(mapping);
336 ASSERT_TRUE(mapping->GetBase()); 336 ASSERT_TRUE(mapping->GetBase());
337 ASSERT_EQ(100u, mapping->GetLength()); 337 ASSERT_EQ(100u, mapping->GetLength());
338 338
339 // Send the shared buffer. 339 // Send the shared buffer.
340 const std::string go1("go 1"); 340 const std::string go1("go 1");
341 DispatcherTransport transport(test::HandleTryStartTransport(handle)); 341 HandleTransport transport(test::HandleTryStartTransport(handle));
342 ASSERT_TRUE(transport.is_valid()); 342 ASSERT_TRUE(transport.is_valid());
343 343
344 std::vector<DispatcherTransport> transports; 344 std::vector<HandleTransport> transports;
345 transports.push_back(transport); 345 transports.push_back(transport);
346 EXPECT_EQ(MOJO_RESULT_OK, 346 EXPECT_EQ(MOJO_RESULT_OK,
347 mp->WriteMessage(0, UserPointer<const void>(&go1[0]), 347 mp->WriteMessage(0, UserPointer<const void>(&go1[0]),
348 static_cast<uint32_t>(go1.size()), &transports, 348 static_cast<uint32_t>(go1.size()), &transports,
349 MOJO_WRITE_MESSAGE_FLAG_NONE)); 349 MOJO_WRITE_MESSAGE_FLAG_NONE));
350 transport.End(); 350 transport.End();
351 351
352 EXPECT_TRUE(handle.dispatcher->HasOneRef()); 352 EXPECT_TRUE(handle.dispatcher->HasOneRef());
353 handle.reset(); 353 handle.reset();
354 354
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 TEST_P(MultiprocessMessagePipeTestWithPipeCount, PlatformHandlePassing) { 461 TEST_P(MultiprocessMessagePipeTestWithPipeCount, PlatformHandlePassing) {
462 test::ScopedTestDir test_dir; 462 test::ScopedTestDir test_dir;
463 463
464 helper()->StartChild("CheckPlatformHandleFile"); 464 helper()->StartChild("CheckPlatformHandleFile");
465 465
466 RefPtr<ChannelEndpoint> ep; 466 RefPtr<ChannelEndpoint> ep;
467 auto mp = MessagePipe::CreateLocalProxy(&ep); 467 auto mp = MessagePipe::CreateLocalProxy(&ep);
468 Init(std::move(ep)); 468 Init(std::move(ep));
469 469
470 std::vector<Handle> handles; 470 std::vector<Handle> handles;
471 std::vector<DispatcherTransport> transports; 471 std::vector<HandleTransport> transports;
472 472
473 size_t pipe_count = GetParam(); 473 size_t pipe_count = GetParam();
474 for (size_t i = 0; i < pipe_count; ++i) { 474 for (size_t i = 0; i < pipe_count; ++i) {
475 util::ScopedFILE fp(test_dir.CreateFile()); 475 util::ScopedFILE fp(test_dir.CreateFile());
476 const std::string world("world"); 476 const std::string world("world");
477 CHECK_EQ(fwrite(&world[0], 1, world.size(), fp.get()), world.size()); 477 CHECK_EQ(fwrite(&world[0], 1, world.size(), fp.get()), world.size());
478 fflush(fp.get()); 478 fflush(fp.get());
479 rewind(fp.get()); 479 rewind(fp.get());
480 480
481 Handle handle(PlatformHandleDispatcher::Create(ScopedPlatformHandle( 481 Handle handle(PlatformHandleDispatcher::Create(ScopedPlatformHandle(
482 PlatformHandleFromFILE(std::move(fp)))), 482 PlatformHandleFromFILE(std::move(fp)))),
483 MOJO_HANDLE_RIGHT_TRANSFER | MOJO_HANDLE_RIGHT_READ | 483 MOJO_HANDLE_RIGHT_TRANSFER | MOJO_HANDLE_RIGHT_READ |
484 MOJO_HANDLE_RIGHT_WRITE); 484 MOJO_HANDLE_RIGHT_WRITE);
485 handles.push_back(std::move(handle)); 485 handles.push_back(std::move(handle));
486 DispatcherTransport transport( 486 HandleTransport transport(test::HandleTryStartTransport(handles.back()));
487 test::HandleTryStartTransport(handles.back()));
488 ASSERT_TRUE(transport.is_valid()); 487 ASSERT_TRUE(transport.is_valid());
489 transports.push_back(transport); 488 transports.push_back(transport);
490 } 489 }
491 490
492 char message[128]; 491 char message[128];
493 sprintf(message, "hello %d", static_cast<int>(pipe_count)); 492 sprintf(message, "hello %d", static_cast<int>(pipe_count));
494 EXPECT_EQ(MOJO_RESULT_OK, 493 EXPECT_EQ(MOJO_RESULT_OK,
495 mp->WriteMessage(0, UserPointer<const void>(message), 494 mp->WriteMessage(0, UserPointer<const void>(message),
496 static_cast<uint32_t>(strlen(message)), 495 static_cast<uint32_t>(strlen(message)),
497 &transports, MOJO_WRITE_MESSAGE_FLAG_NONE)); 496 &transports, MOJO_WRITE_MESSAGE_FLAG_NONE));
(...skipping 20 matching lines...) Expand all
518 // Android multi-process tests are not executing the new process. This is flaky. 517 // Android multi-process tests are not executing the new process. This is flaky.
519 #if !defined(OS_ANDROID) 518 #if !defined(OS_ANDROID)
520 INSTANTIATE_TEST_CASE_P(PipeCount, 519 INSTANTIATE_TEST_CASE_P(PipeCount,
521 MultiprocessMessagePipeTestWithPipeCount, 520 MultiprocessMessagePipeTestWithPipeCount,
522 testing::Values(1u, 128u, 140u)); 521 testing::Values(1u, 128u, 140u));
523 #endif 522 #endif
524 523
525 } // namespace 524 } // namespace
526 } // namespace system 525 } // namespace system
527 } // namespace mojo 526 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/message_pipe_dispatcher.cc ('k') | mojo/edk/system/platform_handle_dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698