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

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

Issue 1160203002: Make Dispatcher::Type an enum class. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 6 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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 scoped_refptr<DataPipeProducerDispatcher> to_send = 369 scoped_refptr<DataPipeProducerDispatcher> to_send =
370 new DataPipeProducerDispatcher(); 370 new DataPipeProducerDispatcher();
371 to_send->Init(dp()); 371 to_send->Init(dp());
372 scoped_refptr<Dispatcher> to_receive; 372 scoped_refptr<Dispatcher> to_receive;
373 SendDispatcher(0, to_send, &to_receive); 373 SendDispatcher(0, to_send, &to_receive);
374 // |to_send| should have been closed. This is |DCHECK()|ed when it is 374 // |to_send| should have been closed. This is |DCHECK()|ed when it is
375 // destroyed. 375 // destroyed.
376 EXPECT_TRUE(to_send->HasOneRef()); 376 EXPECT_TRUE(to_send->HasOneRef());
377 to_send = nullptr; 377 to_send = nullptr;
378 378
379 ASSERT_EQ(Dispatcher::kTypeDataPipeProducer, to_receive->GetType()); 379 ASSERT_EQ(Dispatcher::Type::DATA_PIPE_PRODUCER, to_receive->GetType());
380 producer_dispatcher_ = 380 producer_dispatcher_ =
381 static_cast<DataPipeProducerDispatcher*>(to_receive.get()); 381 static_cast<DataPipeProducerDispatcher*>(to_receive.get());
382 } 382 }
383 383
384 DataPipe* DataPipeForProducer() override { 384 DataPipe* DataPipeForProducer() override {
385 if (producer_dispatcher_) 385 if (producer_dispatcher_)
386 return producer_dispatcher_->GetDataPipeForTest(); 386 return producer_dispatcher_->GetDataPipeForTest();
387 return dp().get(); 387 return dp().get();
388 } 388 }
389 DataPipe* DataPipeForConsumer() override { return dp().get(); } 389 DataPipe* DataPipeForConsumer() override { return dp().get(); }
(...skipping 29 matching lines...) Expand all
419 scoped_refptr<DataPipeConsumerDispatcher> to_send = 419 scoped_refptr<DataPipeConsumerDispatcher> to_send =
420 new DataPipeConsumerDispatcher(); 420 new DataPipeConsumerDispatcher();
421 to_send->Init(dp()); 421 to_send->Init(dp());
422 scoped_refptr<Dispatcher> to_receive; 422 scoped_refptr<Dispatcher> to_receive;
423 SendDispatcher(0, to_send, &to_receive); 423 SendDispatcher(0, to_send, &to_receive);
424 // |to_send| should have been closed. This is |DCHECK()|ed when it is 424 // |to_send| should have been closed. This is |DCHECK()|ed when it is
425 // destroyed. 425 // destroyed.
426 EXPECT_TRUE(to_send->HasOneRef()); 426 EXPECT_TRUE(to_send->HasOneRef());
427 to_send = nullptr; 427 to_send = nullptr;
428 428
429 ASSERT_EQ(Dispatcher::kTypeDataPipeConsumer, to_receive->GetType()); 429 ASSERT_EQ(Dispatcher::Type::DATA_PIPE_CONSUMER, to_receive->GetType());
430 consumer_dispatcher_ = 430 consumer_dispatcher_ =
431 static_cast<DataPipeConsumerDispatcher*>(to_receive.get()); 431 static_cast<DataPipeConsumerDispatcher*>(to_receive.get());
432 } 432 }
433 433
434 DataPipe* DataPipeForProducer() override { return dp().get(); } 434 DataPipe* DataPipeForProducer() override { return dp().get(); }
435 DataPipe* DataPipeForConsumer() override { 435 DataPipe* DataPipeForConsumer() override {
436 if (consumer_dispatcher_) 436 if (consumer_dispatcher_)
437 return consumer_dispatcher_->GetDataPipeForTest(); 437 return consumer_dispatcher_->GetDataPipeForTest();
438 return dp().get(); 438 return dp().get();
439 } 439 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 // This is the producer dispatcher we'll send. 473 // This is the producer dispatcher we'll send.
474 scoped_refptr<DataPipeProducerDispatcher> to_send = 474 scoped_refptr<DataPipeProducerDispatcher> to_send =
475 new DataPipeProducerDispatcher(); 475 new DataPipeProducerDispatcher();
476 to_send->Init(dp()); 476 to_send->Init(dp());
477 scoped_refptr<Dispatcher> to_receive; 477 scoped_refptr<Dispatcher> to_receive;
478 SendDispatcher(0, to_send, &to_receive); 478 SendDispatcher(0, to_send, &to_receive);
479 // |to_send| should have been closed. This is |DCHECK()|ed when it is 479 // |to_send| should have been closed. This is |DCHECK()|ed when it is
480 // destroyed. 480 // destroyed.
481 EXPECT_TRUE(to_send->HasOneRef()); 481 EXPECT_TRUE(to_send->HasOneRef());
482 to_send = nullptr; 482 to_send = nullptr;
483 ASSERT_EQ(Dispatcher::kTypeDataPipeProducer, to_receive->GetType()); 483 ASSERT_EQ(Dispatcher::Type::DATA_PIPE_PRODUCER, to_receive->GetType());
484 to_send = static_cast<DataPipeProducerDispatcher*>(to_receive.get()); 484 to_send = static_cast<DataPipeProducerDispatcher*>(to_receive.get());
485 to_receive = nullptr; 485 to_receive = nullptr;
486 486
487 // Now send it back the other way. 487 // Now send it back the other way.
488 SendDispatcher(1, to_send, &to_receive); 488 SendDispatcher(1, to_send, &to_receive);
489 // |producer_dispatcher_| should have been closed. This is |DCHECK()|ed when 489 // |producer_dispatcher_| should have been closed. This is |DCHECK()|ed when
490 // it is destroyed. 490 // it is destroyed.
491 EXPECT_TRUE(to_send->HasOneRef()); 491 EXPECT_TRUE(to_send->HasOneRef());
492 to_send = nullptr; 492 to_send = nullptr;
493 493
494 ASSERT_EQ(Dispatcher::kTypeDataPipeProducer, to_receive->GetType()); 494 ASSERT_EQ(Dispatcher::Type::DATA_PIPE_PRODUCER, to_receive->GetType());
495 producer_dispatcher_ = 495 producer_dispatcher_ =
496 static_cast<DataPipeProducerDispatcher*>(to_receive.get()); 496 static_cast<DataPipeProducerDispatcher*>(to_receive.get());
497 } 497 }
498 498
499 private: 499 private:
500 DISALLOW_COPY_AND_ASSIGN(RemoteProducerDataPipeImplTestHelper2); 500 DISALLOW_COPY_AND_ASSIGN(RemoteProducerDataPipeImplTestHelper2);
501 }; 501 };
502 502
503 // RemoteConsumerDataPipeImplTestHelper2 --------------------------------------- 503 // RemoteConsumerDataPipeImplTestHelper2 ---------------------------------------
504 504
(...skipping 15 matching lines...) Expand all
520 // This is the consumer dispatcher we'll send. 520 // This is the consumer dispatcher we'll send.
521 scoped_refptr<DataPipeConsumerDispatcher> to_send = 521 scoped_refptr<DataPipeConsumerDispatcher> to_send =
522 new DataPipeConsumerDispatcher(); 522 new DataPipeConsumerDispatcher();
523 to_send->Init(dp()); 523 to_send->Init(dp());
524 scoped_refptr<Dispatcher> to_receive; 524 scoped_refptr<Dispatcher> to_receive;
525 SendDispatcher(0, to_send, &to_receive); 525 SendDispatcher(0, to_send, &to_receive);
526 // |to_send| should have been closed. This is |DCHECK()|ed when it is 526 // |to_send| should have been closed. This is |DCHECK()|ed when it is
527 // destroyed. 527 // destroyed.
528 EXPECT_TRUE(to_send->HasOneRef()); 528 EXPECT_TRUE(to_send->HasOneRef());
529 to_send = nullptr; 529 to_send = nullptr;
530 ASSERT_EQ(Dispatcher::kTypeDataPipeConsumer, to_receive->GetType()); 530 ASSERT_EQ(Dispatcher::Type::DATA_PIPE_CONSUMER, to_receive->GetType());
531 to_send = static_cast<DataPipeConsumerDispatcher*>(to_receive.get()); 531 to_send = static_cast<DataPipeConsumerDispatcher*>(to_receive.get());
532 to_receive = nullptr; 532 to_receive = nullptr;
533 533
534 // Now send it back the other way. 534 // Now send it back the other way.
535 SendDispatcher(1, to_send, &to_receive); 535 SendDispatcher(1, to_send, &to_receive);
536 // |consumer_dispatcher_| should have been closed. This is |DCHECK()|ed when 536 // |consumer_dispatcher_| should have been closed. This is |DCHECK()|ed when
537 // it is destroyed. 537 // it is destroyed.
538 EXPECT_TRUE(to_send->HasOneRef()); 538 EXPECT_TRUE(to_send->HasOneRef());
539 to_send = nullptr; 539 to_send = nullptr;
540 540
541 ASSERT_EQ(Dispatcher::kTypeDataPipeConsumer, to_receive->GetType()); 541 ASSERT_EQ(Dispatcher::Type::DATA_PIPE_CONSUMER, to_receive->GetType());
542 consumer_dispatcher_ = 542 consumer_dispatcher_ =
543 static_cast<DataPipeConsumerDispatcher*>(to_receive.get()); 543 static_cast<DataPipeConsumerDispatcher*>(to_receive.get());
544 } 544 }
545 545
546 private: 546 private:
547 DISALLOW_COPY_AND_ASSIGN(RemoteConsumerDataPipeImplTestHelper2); 547 DISALLOW_COPY_AND_ASSIGN(RemoteConsumerDataPipeImplTestHelper2);
548 }; 548 };
549 549
550 // Test case instantiation ----------------------------------------------------- 550 // Test case instantiation -----------------------------------------------------
551 551
(...skipping 1838 matching lines...) Expand 10 before | Expand all | Expand 10 after
2390 this->ConsumerQueryData(MakeUserPointer(&num_bytes))); 2390 this->ConsumerQueryData(MakeUserPointer(&num_bytes)));
2391 EXPECT_EQ(1u * sizeof(int32_t), num_bytes); 2391 EXPECT_EQ(1u * sizeof(int32_t), num_bytes);
2392 2392
2393 this->ProducerClose(); 2393 this->ProducerClose();
2394 this->ConsumerClose(); 2394 this->ConsumerClose();
2395 } 2395 }
2396 2396
2397 } // namespace 2397 } // namespace
2398 } // namespace system 2398 } // namespace system
2399 } // namespace mojo 2399 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698