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

Side by Side Diff: net/quic/reliable_quic_stream_test.cc

Issue 1541263002: Landing Recent QUIC changes until 12/18/2015 13:57 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: replace -1 with 0xff for InvalidPathId Created 4 years, 11 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
« no previous file with comments | « net/quic/reliable_quic_stream.cc ('k') | net/quic/test_tools/quic_test_utils.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/quic/reliable_quic_stream.h" 5 #include "net/quic/reliable_quic_stream.h"
6 6
7 #include "net/quic/quic_connection.h" 7 #include "net/quic/quic_connection.h"
8 #include "net/quic/quic_flags.h" 8 #include "net/quic/quic_flags.h"
9 #include "net/quic/quic_utils.h" 9 #include "net/quic/quic_utils.h"
10 #include "net/quic/quic_write_blocked_list.h" 10 #include "net/quic/quic_write_blocked_list.h"
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 597
598 // Receive a stream frame that violates flow control: the byte offset is 598 // Receive a stream frame that violates flow control: the byte offset is
599 // higher than the receive window offset. 599 // higher than the receive window offset.
600 QuicStreamFrame frame(stream_->id(), false, 600 QuicStreamFrame frame(stream_->id(), false,
601 kInitialSessionFlowControlWindowForTest + 1, 601 kInitialSessionFlowControlWindowForTest + 1,
602 StringPiece(".")); 602 StringPiece("."));
603 EXPECT_GT(frame.offset, QuicFlowControllerPeer::ReceiveWindowOffset( 603 EXPECT_GT(frame.offset, QuicFlowControllerPeer::ReceiveWindowOffset(
604 stream_->flow_controller())); 604 stream_->flow_controller()));
605 605
606 // Stream should not accept the frame, and the connection should be closed. 606 // Stream should not accept the frame, and the connection should be closed.
607 EXPECT_CALL(*connection_, 607 EXPECT_CALL(*connection_, SendConnectionCloseWithDetails(
608 SendConnectionClose(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA)); 608 QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA, _));
609 stream_->OnStreamFrame(frame); 609 stream_->OnStreamFrame(frame);
610 } 610 }
611 611
612 // Verify that after the consumer calls StopReading(), the stream still sends 612 // Verify that after the consumer calls StopReading(), the stream still sends
613 // flow control updates. 613 // flow control updates.
614 TEST_F(ReliableQuicStreamTest, StopReadingSendsFlowControl) { 614 TEST_F(ReliableQuicStreamTest, StopReadingSendsFlowControl) {
615 Initialize(kShouldProcessData); 615 Initialize(kShouldProcessData);
616 616
617 stream_->StopReading(); 617 stream_->StopReading();
618 618
619 // Connection should not get terminated due to flow control errors. 619 // Connection should not get terminated due to flow control errors.
620 EXPECT_CALL(*connection_, 620 EXPECT_CALL(*connection_, SendConnectionCloseWithDetails(
621 SendConnectionClose(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA)) 621 QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA, _))
622 .Times(0); 622 .Times(0);
623 EXPECT_CALL(*connection_, SendWindowUpdate(_, _)).Times(AtLeast(1)); 623 EXPECT_CALL(*connection_, SendWindowUpdate(_, _)).Times(AtLeast(1));
624 624
625 string data(1000, 'x'); 625 string data(1000, 'x');
626 for (QuicStreamOffset offset = 0; 626 for (QuicStreamOffset offset = 0;
627 offset < 2 * kInitialStreamFlowControlWindowForTest; 627 offset < 2 * kInitialStreamFlowControlWindowForTest;
628 offset += data.length()) { 628 offset += data.length()) {
629 QuicStreamFrame frame(stream_->id(), false, offset, data); 629 QuicStreamFrame frame(stream_->id(), false, offset, data);
630 stream_->OnStreamFrame(frame); 630 stream_->OnStreamFrame(frame);
631 } 631 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 EXPECT_EQ(FEC_PROTECT_OPTIONAL, stream_->fec_policy()); 722 EXPECT_EQ(FEC_PROTECT_OPTIONAL, stream_->fec_policy());
723 stream_->SetFromConfig(); 723 stream_->SetFromConfig();
724 EXPECT_EQ(FEC_PROTECT_ALWAYS, stream_->fec_policy()); 724 EXPECT_EQ(FEC_PROTECT_ALWAYS, stream_->fec_policy());
725 } 725 }
726 726
727 TEST_F(ReliableQuicStreamTest, EarlyResponseFinHandling) { 727 TEST_F(ReliableQuicStreamTest, EarlyResponseFinHandling) {
728 // Verify that if the server completes the response before reading the end of 728 // Verify that if the server completes the response before reading the end of
729 // the request, the received FIN is recorded. 729 // the request, the received FIN is recorded.
730 730
731 Initialize(kShouldProcessData); 731 Initialize(kShouldProcessData);
732 EXPECT_CALL(*connection_, SendConnectionClose(_)).Times(0); 732 EXPECT_CALL(*connection_, SendConnectionCloseWithDetails(_, _)).Times(0);
733 EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)) 733 EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _))
734 .WillRepeatedly(Invoke(MockQuicSpdySession::ConsumeAllData)); 734 .WillRepeatedly(Invoke(MockQuicSpdySession::ConsumeAllData));
735 735
736 // Receive data for the request. 736 // Receive data for the request.
737 QuicStreamFrame frame1(stream_->id(), false, 0, StringPiece("Start")); 737 QuicStreamFrame frame1(stream_->id(), false, 0, StringPiece("Start"));
738 stream_->OnStreamFrame(frame1); 738 stream_->OnStreamFrame(frame1);
739 // When QuicSimpleServerStream sends the response, it calls 739 // When QuicSimpleServerStream sends the response, it calls
740 // ReliableQuicStream::CloseReadSide() first. 740 // ReliableQuicStream::CloseReadSide() first.
741 ReliableQuicStreamPeer::CloseReadSide(stream_); 741 ReliableQuicStreamPeer::CloseReadSide(stream_);
742 // Send data and FIN for the response. 742 // Send data and FIN for the response.
743 stream_->WriteOrBufferData(kData1, false, nullptr); 743 stream_->WriteOrBufferData(kData1, false, nullptr);
744 EXPECT_TRUE(ReliableQuicStreamPeer::read_side_closed(stream_)); 744 EXPECT_TRUE(ReliableQuicStreamPeer::read_side_closed(stream_));
745 // Receive remaining data and FIN for the request. 745 // Receive remaining data and FIN for the request.
746 QuicStreamFrame frame2(stream_->id(), true, 0, StringPiece("End")); 746 QuicStreamFrame frame2(stream_->id(), true, 0, StringPiece("End"));
747 stream_->OnStreamFrame(frame2); 747 stream_->OnStreamFrame(frame2);
748 EXPECT_TRUE(stream_->fin_received()); 748 EXPECT_TRUE(stream_->fin_received());
749 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); 749 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset());
750 } 750 }
751 751
752 } // namespace 752 } // namespace
753 } // namespace test 753 } // namespace test
754 } // namespace net 754 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/reliable_quic_stream.cc ('k') | net/quic/test_tools/quic_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698