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

Side by Side Diff: mojo/edk/system/data_pipe_impl_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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 // This file contains tests that are shared between different implementations of 5 // This file contains tests that are shared between different implementations of
6 // |DataPipeImpl|. 6 // |DataPipeImpl|.
7 7
8 #include "mojo/edk/system/data_pipe_impl.h" 8 #include "mojo/edk/system/data_pipe_impl.h"
9 9
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 class RemoteProducerDataPipeImplTestHelper 378 class RemoteProducerDataPipeImplTestHelper
379 : public RemoteDataPipeImplTestHelper { 379 : public RemoteDataPipeImplTestHelper {
380 public: 380 public:
381 RemoteProducerDataPipeImplTestHelper() {} 381 RemoteProducerDataPipeImplTestHelper() {}
382 ~RemoteProducerDataPipeImplTestHelper() override {} 382 ~RemoteProducerDataPipeImplTestHelper() override {}
383 383
384 void DoTransfer() override { 384 void DoTransfer() override {
385 // This is the producer dispatcher we'll send. 385 // This is the producer dispatcher we'll send.
386 auto to_send = DataPipeProducerDispatcher::Create(); 386 auto to_send = DataPipeProducerDispatcher::Create();
387 to_send->Init(dp()); 387 to_send->Init(dp());
388 Handle handle_to_send(std::move(to_send), MOJO_HANDLE_RIGHT_TRANSFER | 388 Handle handle_to_send(std::move(to_send),
389 MOJO_HANDLE_RIGHT_READ | 389 DataPipeProducerDispatcher::kDefaultHandleRights);
390 MOJO_HANDLE_RIGHT_WRITE);
391 RefPtr<Dispatcher> to_receive; 390 RefPtr<Dispatcher> to_receive;
392 SendHandle(0, handle_to_send, &to_receive); 391 SendHandle(0, handle_to_send, &to_receive);
393 // |handle_to_send.dispatcher| should have been closed. This is |DCHECK()|ed 392 // |handle_to_send.dispatcher| should have been closed. This is |DCHECK()|ed
394 // when it is destroyed. 393 // when it is destroyed.
395 EXPECT_TRUE(handle_to_send.dispatcher->HasOneRef()); 394 EXPECT_TRUE(handle_to_send.dispatcher->HasOneRef());
396 handle_to_send.reset(); 395 handle_to_send.reset();
397 396
398 ASSERT_EQ(Dispatcher::Type::DATA_PIPE_PRODUCER, to_receive->GetType()); 397 ASSERT_EQ(Dispatcher::Type::DATA_PIPE_PRODUCER, to_receive->GetType());
399 producer_dispatcher_ = RefPtr<DataPipeProducerDispatcher>( 398 producer_dispatcher_ = RefPtr<DataPipeProducerDispatcher>(
400 static_cast<DataPipeProducerDispatcher*>(to_receive.get())); 399 static_cast<DataPipeProducerDispatcher*>(to_receive.get()));
(...skipping 29 matching lines...) Expand all
430 class RemoteConsumerDataPipeImplTestHelper 429 class RemoteConsumerDataPipeImplTestHelper
431 : public RemoteDataPipeImplTestHelper { 430 : public RemoteDataPipeImplTestHelper {
432 public: 431 public:
433 RemoteConsumerDataPipeImplTestHelper() {} 432 RemoteConsumerDataPipeImplTestHelper() {}
434 ~RemoteConsumerDataPipeImplTestHelper() override {} 433 ~RemoteConsumerDataPipeImplTestHelper() override {}
435 434
436 void DoTransfer() override { 435 void DoTransfer() override {
437 // This is the consumer dispatcher we'll send. 436 // This is the consumer dispatcher we'll send.
438 auto to_send = DataPipeConsumerDispatcher::Create(); 437 auto to_send = DataPipeConsumerDispatcher::Create();
439 to_send->Init(dp()); 438 to_send->Init(dp());
440 Handle handle_to_send(std::move(to_send), MOJO_HANDLE_RIGHT_TRANSFER | 439 Handle handle_to_send(std::move(to_send),
441 MOJO_HANDLE_RIGHT_READ | 440 DataPipeConsumerDispatcher::kDefaultHandleRights);
442 MOJO_HANDLE_RIGHT_WRITE);
443 RefPtr<Dispatcher> to_receive; 441 RefPtr<Dispatcher> to_receive;
444 SendHandle(0, handle_to_send, &to_receive); 442 SendHandle(0, handle_to_send, &to_receive);
445 // |handle_to_send.dispatcher| should have been closed. This is |DCHECK()|ed 443 // |handle_to_send.dispatcher| should have been closed. This is |DCHECK()|ed
446 // when it is destroyed. 444 // when it is destroyed.
447 EXPECT_TRUE(handle_to_send.dispatcher->HasOneRef()); 445 EXPECT_TRUE(handle_to_send.dispatcher->HasOneRef());
448 handle_to_send.reset(); 446 handle_to_send.reset();
449 447
450 ASSERT_EQ(Dispatcher::Type::DATA_PIPE_CONSUMER, to_receive->GetType()); 448 ASSERT_EQ(Dispatcher::Type::DATA_PIPE_CONSUMER, to_receive->GetType());
451 consumer_dispatcher_ = RefPtr<DataPipeConsumerDispatcher>( 449 consumer_dispatcher_ = RefPtr<DataPipeConsumerDispatcher>(
452 static_cast<DataPipeConsumerDispatcher*>(to_receive.get())); 450 static_cast<DataPipeConsumerDispatcher*>(to_receive.get()));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 class RemoteProducerDataPipeImplTestHelper2 485 class RemoteProducerDataPipeImplTestHelper2
488 : public RemoteProducerDataPipeImplTestHelper { 486 : public RemoteProducerDataPipeImplTestHelper {
489 public: 487 public:
490 RemoteProducerDataPipeImplTestHelper2() {} 488 RemoteProducerDataPipeImplTestHelper2() {}
491 ~RemoteProducerDataPipeImplTestHelper2() override {} 489 ~RemoteProducerDataPipeImplTestHelper2() override {}
492 490
493 void DoTransfer() override { 491 void DoTransfer() override {
494 // This is the producer dispatcher we'll send. 492 // This is the producer dispatcher we'll send.
495 auto to_send = DataPipeProducerDispatcher::Create(); 493 auto to_send = DataPipeProducerDispatcher::Create();
496 to_send->Init(dp()); 494 to_send->Init(dp());
497 Handle handle_to_send(std::move(to_send), MOJO_HANDLE_RIGHT_TRANSFER | 495 Handle handle_to_send(std::move(to_send),
498 MOJO_HANDLE_RIGHT_READ | 496 DataPipeProducerDispatcher::kDefaultHandleRights);
499 MOJO_HANDLE_RIGHT_WRITE);
500 RefPtr<Dispatcher> to_receive; 497 RefPtr<Dispatcher> to_receive;
501 SendHandle(0, handle_to_send, &to_receive); 498 SendHandle(0, handle_to_send, &to_receive);
502 // |handle_to_send.dispatcher| should have been closed. This is |DCHECK()|ed 499 // |handle_to_send.dispatcher| should have been closed. This is |DCHECK()|ed
503 // when it is destroyed. 500 // when it is destroyed.
504 EXPECT_TRUE(handle_to_send.dispatcher->HasOneRef()); 501 EXPECT_TRUE(handle_to_send.dispatcher->HasOneRef());
505 handle_to_send.reset(); 502 handle_to_send.reset();
506 ASSERT_EQ(Dispatcher::Type::DATA_PIPE_PRODUCER, to_receive->GetType()); 503 ASSERT_EQ(Dispatcher::Type::DATA_PIPE_PRODUCER, to_receive->GetType());
507 handle_to_send = Handle(std::move(to_receive), MOJO_HANDLE_RIGHT_TRANSFER | 504 handle_to_send = Handle(std::move(to_receive),
508 MOJO_HANDLE_RIGHT_READ | 505 DataPipeProducerDispatcher::kDefaultHandleRights);
509 MOJO_HANDLE_RIGHT_WRITE);
510 506
511 // Now send it back the other way. 507 // Now send it back the other way.
512 SendHandle(1, handle_to_send, &to_receive); 508 SendHandle(1, handle_to_send, &to_receive);
513 // |handle_to_send.dispatcher| should have been closed. This is |DCHECK()|ed 509 // |handle_to_send.dispatcher| should have been closed. This is |DCHECK()|ed
514 // when it is destroyed. 510 // when it is destroyed.
515 EXPECT_TRUE(handle_to_send.dispatcher->HasOneRef()); 511 EXPECT_TRUE(handle_to_send.dispatcher->HasOneRef());
516 handle_to_send.reset(); 512 handle_to_send.reset();
517 513
518 ASSERT_EQ(Dispatcher::Type::DATA_PIPE_PRODUCER, to_receive->GetType()); 514 ASSERT_EQ(Dispatcher::Type::DATA_PIPE_PRODUCER, to_receive->GetType());
519 producer_dispatcher_ = RefPtr<DataPipeProducerDispatcher>( 515 producer_dispatcher_ = RefPtr<DataPipeProducerDispatcher>(
(...skipping 17 matching lines...) Expand all
537 class RemoteConsumerDataPipeImplTestHelper2 533 class RemoteConsumerDataPipeImplTestHelper2
538 : public RemoteConsumerDataPipeImplTestHelper { 534 : public RemoteConsumerDataPipeImplTestHelper {
539 public: 535 public:
540 RemoteConsumerDataPipeImplTestHelper2() {} 536 RemoteConsumerDataPipeImplTestHelper2() {}
541 ~RemoteConsumerDataPipeImplTestHelper2() override {} 537 ~RemoteConsumerDataPipeImplTestHelper2() override {}
542 538
543 void DoTransfer() override { 539 void DoTransfer() override {
544 // This is the consumer dispatcher we'll send. 540 // This is the consumer dispatcher we'll send.
545 auto to_send = DataPipeConsumerDispatcher::Create(); 541 auto to_send = DataPipeConsumerDispatcher::Create();
546 to_send->Init(dp()); 542 to_send->Init(dp());
547 Handle handle_to_send(std::move(to_send), MOJO_HANDLE_RIGHT_TRANSFER | 543 Handle handle_to_send(std::move(to_send),
548 MOJO_HANDLE_RIGHT_READ | 544 DataPipeConsumerDispatcher::kDefaultHandleRights);
549 MOJO_HANDLE_RIGHT_WRITE);
550 RefPtr<Dispatcher> to_receive; 545 RefPtr<Dispatcher> to_receive;
551 SendHandle(0, handle_to_send, &to_receive); 546 SendHandle(0, handle_to_send, &to_receive);
552 // |handle_to_send.dispatcher| should have been closed. This is |DCHECK()|ed 547 // |handle_to_send.dispatcher| should have been closed. This is |DCHECK()|ed
553 // when it is destroyed. 548 // when it is destroyed.
554 EXPECT_TRUE(handle_to_send.dispatcher->HasOneRef()); 549 EXPECT_TRUE(handle_to_send.dispatcher->HasOneRef());
555 handle_to_send.reset(); 550 handle_to_send.reset();
556 ASSERT_EQ(Dispatcher::Type::DATA_PIPE_CONSUMER, to_receive->GetType()); 551 ASSERT_EQ(Dispatcher::Type::DATA_PIPE_CONSUMER, to_receive->GetType());
557 handle_to_send = Handle(std::move(to_receive), MOJO_HANDLE_RIGHT_TRANSFER | 552 handle_to_send = Handle(std::move(to_receive),
558 MOJO_HANDLE_RIGHT_READ | 553 DataPipeConsumerDispatcher::kDefaultHandleRights);
559 MOJO_HANDLE_RIGHT_WRITE);
560 554
561 // Now send it back the other way. 555 // Now send it back the other way.
562 SendHandle(1, handle_to_send, &to_receive); 556 SendHandle(1, handle_to_send, &to_receive);
563 // |handle_to_send.dispatcher| should have been closed. This is |DCHECK()|ed 557 // |handle_to_send.dispatcher| should have been closed. This is |DCHECK()|ed
564 // when it is destroyed. 558 // when it is destroyed.
565 EXPECT_TRUE(handle_to_send.dispatcher->HasOneRef()); 559 EXPECT_TRUE(handle_to_send.dispatcher->HasOneRef());
566 handle_to_send.reset(); 560 handle_to_send.reset();
567 561
568 ASSERT_EQ(Dispatcher::Type::DATA_PIPE_CONSUMER, to_receive->GetType()); 562 ASSERT_EQ(Dispatcher::Type::DATA_PIPE_CONSUMER, to_receive->GetType());
569 consumer_dispatcher_ = RefPtr<DataPipeConsumerDispatcher>( 563 consumer_dispatcher_ = RefPtr<DataPipeConsumerDispatcher>(
(...skipping 2371 matching lines...) Expand 10 before | Expand all | Expand 10 after
2941 &waiter, MOJO_HANDLE_SIGNAL_READ_THRESHOLD, 0, &hss)); 2935 &waiter, MOJO_HANDLE_SIGNAL_READ_THRESHOLD, 0, &hss));
2942 EXPECT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfied_signals); 2936 EXPECT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfied_signals);
2943 EXPECT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfiable_signals); 2937 EXPECT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfiable_signals);
2944 2938
2945 this->ConsumerClose(); 2939 this->ConsumerClose();
2946 } 2940 }
2947 2941
2948 } // namespace 2942 } // namespace
2949 } // namespace system 2943 } // namespace system
2950 } // namespace mojo 2944 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/data_pipe_consumer_dispatcher.cc ('k') | mojo/edk/system/data_pipe_producer_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698