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

Side by Side Diff: mojo/system/raw_channel_unittest.cc

Issue 256503005: Mojo: Handle "nested" Shutdown() in RawChannelWin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | mojo/system/raw_channel_win.cc » ('j') | 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/system/raw_channel.h" 5 #include "mojo/system/raw_channel.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 } 578 }
579 579
580 private: 580 private:
581 RawChannel* const raw_channel_; 581 RawChannel* const raw_channel_;
582 base::WaitableEvent done_event_; 582 base::WaitableEvent done_event_;
583 bool did_shutdown_; 583 bool did_shutdown_;
584 584
585 DISALLOW_COPY_AND_ASSIGN(ShutdownOnReadMessageRawChannelDelegate); 585 DISALLOW_COPY_AND_ASSIGN(ShutdownOnReadMessageRawChannelDelegate);
586 }; 586 };
587 587
588 // TODO(vtl): crbug.com/366768 588 TEST_F(RawChannelTest, ShutdownOnReadMessage) {
589 #if defined(OS_WIN)
590 #define MAYBE_ShutdownOnReadMessage DISABLED_ShutdownOnReadMessage
591 #else
592 #define MAYBE_ShutdownOnReadMessage ShutdownOnReadMessage
593 #endif
594 TEST_F(RawChannelTest, MAYBE_ShutdownOnReadMessage) {
595 // Write a few messages into the other end. 589 // Write a few messages into the other end.
596 for (size_t count = 0; count < 5; count++) 590 for (size_t count = 0; count < 5; count++)
597 EXPECT_TRUE(WriteTestMessageToHandle(handles[1].get(), 10)); 591 EXPECT_TRUE(WriteTestMessageToHandle(handles[1].get(), 10));
598 592
599 scoped_ptr<RawChannel> rc(RawChannel::Create(handles[0].Pass())); 593 scoped_ptr<RawChannel> rc(RawChannel::Create(handles[0].Pass()));
600 ShutdownOnReadMessageRawChannelDelegate delegate(rc.get()); 594 ShutdownOnReadMessageRawChannelDelegate delegate(rc.get());
601 io_thread()->PostTaskAndWait(FROM_HERE, 595 io_thread()->PostTaskAndWait(FROM_HERE,
602 base::Bind(&InitOnIOThread, rc.get(), 596 base::Bind(&InitOnIOThread, rc.get(),
603 base::Unretained(&delegate))); 597 base::Unretained(&delegate)));
604 598
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 634
641 private: 635 private:
642 RawChannel* const raw_channel_; 636 RawChannel* const raw_channel_;
643 const FatalError shutdown_on_error_type_; 637 const FatalError shutdown_on_error_type_;
644 base::WaitableEvent done_event_; 638 base::WaitableEvent done_event_;
645 bool did_shutdown_; 639 bool did_shutdown_;
646 640
647 DISALLOW_COPY_AND_ASSIGN(ShutdownOnFatalErrorRawChannelDelegate); 641 DISALLOW_COPY_AND_ASSIGN(ShutdownOnFatalErrorRawChannelDelegate);
648 }; 642 };
649 643
650 // TODO(vtl): crbug.com/366768 644 TEST_F(RawChannelTest, ShutdownOnFatalErrorRead) {
651 #if defined(OS_WIN)
652 #define MAYBE_ShutdownOnFatalErrorRead DISABLED_ShutdownOnFatalErrorRead
653 #else
654 #define MAYBE_ShutdownOnFatalErrorRead ShutdownOnFatalErrorRead
655 #endif
656 TEST_F(RawChannelTest, MAYBE_ShutdownOnFatalErrorRead) {
657 scoped_ptr<RawChannel> rc(RawChannel::Create(handles[0].Pass())); 645 scoped_ptr<RawChannel> rc(RawChannel::Create(handles[0].Pass()));
658 ShutdownOnFatalErrorRawChannelDelegate delegate( 646 ShutdownOnFatalErrorRawChannelDelegate delegate(
659 rc.get(), RawChannel::Delegate::FATAL_ERROR_FAILED_READ); 647 rc.get(), RawChannel::Delegate::FATAL_ERROR_FAILED_READ);
660 io_thread()->PostTaskAndWait(FROM_HERE, 648 io_thread()->PostTaskAndWait(FROM_HERE,
661 base::Bind(&InitOnIOThread, rc.get(), 649 base::Bind(&InitOnIOThread, rc.get(),
662 base::Unretained(&delegate))); 650 base::Unretained(&delegate)));
663 651
664 // Close the handle of the other end, which should stuff fail. 652 // Close the handle of the other end, which should stuff fail.
665 handles[1].reset(); 653 handles[1].reset();
666 654
667 // Wait for the delegate, which will shut the |RawChannel| down. 655 // Wait for the delegate, which will shut the |RawChannel| down.
668 delegate.Wait(); 656 delegate.Wait();
669 } 657 }
670 658
671 // TODO(vtl): crbug.com/366768 659 TEST_F(RawChannelTest, ShutdownOnFatalErrorWrite) {
672 #if defined(OS_WIN)
673 #define MAYBE_ShutdownOnFatalErrorWrite DISABLED_ShutdownOnFatalErrorWrite
674 #else
675 #define MAYBE_ShutdownOnFatalErrorWrite ShutdownOnFatalErrorWrite
676 #endif
677 TEST_F(RawChannelTest, MAYBE_ShutdownOnFatalErrorWrite) {
678 scoped_ptr<RawChannel> rc(RawChannel::Create(handles[0].Pass())); 660 scoped_ptr<RawChannel> rc(RawChannel::Create(handles[0].Pass()));
679 ShutdownOnFatalErrorRawChannelDelegate delegate( 661 ShutdownOnFatalErrorRawChannelDelegate delegate(
680 rc.get(), RawChannel::Delegate::FATAL_ERROR_FAILED_WRITE); 662 rc.get(), RawChannel::Delegate::FATAL_ERROR_FAILED_WRITE);
681 io_thread()->PostTaskAndWait(FROM_HERE, 663 io_thread()->PostTaskAndWait(FROM_HERE,
682 base::Bind(&InitOnIOThread, rc.get(), 664 base::Bind(&InitOnIOThread, rc.get(),
683 base::Unretained(&delegate))); 665 base::Unretained(&delegate)));
684 666
685 // Close the handle of the other end, which should stuff fail. 667 // Close the handle of the other end, which should stuff fail.
686 handles[1].reset(); 668 handles[1].reset();
687 669
688 EXPECT_FALSE(rc->WriteMessage(MakeTestMessage(1))); 670 EXPECT_FALSE(rc->WriteMessage(MakeTestMessage(1)));
689 671
690 // Wait for the delegate, which will shut the |RawChannel| down. 672 // Wait for the delegate, which will shut the |RawChannel| down.
691 delegate.Wait(); 673 delegate.Wait();
692 } 674 }
693 675
694 } // namespace 676 } // namespace
695 } // namespace system 677 } // namespace system
696 } // namespace mojo 678 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | mojo/system/raw_channel_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698