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

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

Issue 420313005: Land Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Final_0723
Patch Set: change QUIC packet size to 1350 Created 6 years, 4 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 (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_ack_notifier.h" 7 #include "net/quic/quic_ack_notifier.h"
8 #include "net/quic/quic_connection.h" 8 #include "net/quic/quic_connection.h"
9 #include "net/quic/quic_flags.h" 9 #include "net/quic/quic_flags.h"
10 #include "net/quic/quic_utils.h" 10 #include "net/quic/quic_utils.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 QuicWriteBlockedList* write_blocked_list_; 147 QuicWriteBlockedList* write_blocked_list_;
148 uint32 initial_flow_control_window_bytes_; 148 uint32 initial_flow_control_window_bytes_;
149 QuicTime::Delta zero_; 149 QuicTime::Delta zero_;
150 QuicVersionVector supported_versions_; 150 QuicVersionVector supported_versions_;
151 }; 151 };
152 152
153 TEST_F(ReliableQuicStreamTest, WriteAllData) { 153 TEST_F(ReliableQuicStreamTest, WriteAllData) {
154 Initialize(kShouldProcessData); 154 Initialize(kShouldProcessData);
155 155
156 size_t length = 1 + QuicPacketCreator::StreamFramePacketOverhead( 156 size_t length = 1 + QuicPacketCreator::StreamFramePacketOverhead(
157 connection_->version(), PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, 157 PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
158 PACKET_6BYTE_SEQUENCE_NUMBER, 0u, NOT_IN_FEC_GROUP); 158 PACKET_6BYTE_SEQUENCE_NUMBER, 0u, NOT_IN_FEC_GROUP);
159 QuicConnectionPeer::GetPacketCreator(connection_)->set_max_packet_length( 159 QuicConnectionPeer::GetPacketCreator(connection_)->set_max_packet_length(
160 length); 160 length);
161 161
162 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)).WillOnce( 162 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)).WillOnce(
163 Return(QuicConsumedData(kDataLen, true))); 163 Return(QuicConsumedData(kDataLen, true)));
164 stream_->WriteOrBufferData(kData1, false, NULL); 164 stream_->WriteOrBufferData(kData1, false, NULL);
165 EXPECT_FALSE(HasWriteBlockedStreams()); 165 EXPECT_FALSE(HasWriteBlockedStreams());
166 } 166 }
167 167
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 .WillOnce(Return(QuicConsumedData(0, false))); 207 .WillOnce(Return(QuicConsumedData(0, false)));
208 stream_->WriteOrBufferData(StringPiece(), true, NULL); 208 stream_->WriteOrBufferData(StringPiece(), true, NULL);
209 ASSERT_EQ(1u, write_blocked_list_->NumBlockedStreams()); 209 ASSERT_EQ(1u, write_blocked_list_->NumBlockedStreams());
210 } 210 }
211 211
212 TEST_F(ReliableQuicStreamTest, WriteOrBufferData) { 212 TEST_F(ReliableQuicStreamTest, WriteOrBufferData) {
213 Initialize(kShouldProcessData); 213 Initialize(kShouldProcessData);
214 214
215 EXPECT_FALSE(HasWriteBlockedStreams()); 215 EXPECT_FALSE(HasWriteBlockedStreams());
216 size_t length = 1 + QuicPacketCreator::StreamFramePacketOverhead( 216 size_t length = 1 + QuicPacketCreator::StreamFramePacketOverhead(
217 connection_->version(), PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, 217 PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
218 PACKET_6BYTE_SEQUENCE_NUMBER, 0u, NOT_IN_FEC_GROUP); 218 PACKET_6BYTE_SEQUENCE_NUMBER, 0u, NOT_IN_FEC_GROUP);
219 QuicConnectionPeer::GetPacketCreator(connection_)->set_max_packet_length( 219 QuicConnectionPeer::GetPacketCreator(connection_)->set_max_packet_length(
220 length); 220 length);
221 221
222 EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)).WillOnce( 222 EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)).WillOnce(
223 Return(QuicConsumedData(kDataLen - 1, false))); 223 Return(QuicConsumedData(kDataLen - 1, false)));
224 stream_->WriteOrBufferData(kData1, false, NULL); 224 stream_->WriteOrBufferData(kData1, false, NULL);
225 EXPECT_TRUE(HasWriteBlockedStreams()); 225 EXPECT_TRUE(HasWriteBlockedStreams());
226 226
227 // Queue a bytes_consumed write. 227 // Queue a bytes_consumed write.
(...skipping 14 matching lines...) Expand all
242 } 242 }
243 243
244 TEST_F(ReliableQuicStreamTest, WriteOrBufferDataWithFecProtectAlways) { 244 TEST_F(ReliableQuicStreamTest, WriteOrBufferDataWithFecProtectAlways) {
245 Initialize(kShouldProcessData); 245 Initialize(kShouldProcessData);
246 246
247 // Set FEC policy on stream. 247 // Set FEC policy on stream.
248 ReliableQuicStreamPeer::SetFecPolicy(stream_.get(), FEC_PROTECT_ALWAYS); 248 ReliableQuicStreamPeer::SetFecPolicy(stream_.get(), FEC_PROTECT_ALWAYS);
249 249
250 EXPECT_FALSE(HasWriteBlockedStreams()); 250 EXPECT_FALSE(HasWriteBlockedStreams());
251 size_t length = 1 + QuicPacketCreator::StreamFramePacketOverhead( 251 size_t length = 1 + QuicPacketCreator::StreamFramePacketOverhead(
252 connection_->version(), PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, 252 PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
253 PACKET_6BYTE_SEQUENCE_NUMBER, 0u, IN_FEC_GROUP); 253 PACKET_6BYTE_SEQUENCE_NUMBER, 0u, IN_FEC_GROUP);
254 QuicConnectionPeer::GetPacketCreator(connection_)->set_max_packet_length( 254 QuicConnectionPeer::GetPacketCreator(connection_)->set_max_packet_length(
255 length); 255 length);
256 256
257 // Write first data onto stream, which will cause one session write. 257 // Write first data onto stream, which will cause one session write.
258 EXPECT_CALL(*session_, WritevData(_, _, _, _, MUST_FEC_PROTECT, _)).WillOnce( 258 EXPECT_CALL(*session_, WritevData(_, _, _, _, MUST_FEC_PROTECT, _)).WillOnce(
259 Return(QuicConsumedData(kDataLen - 1, false))); 259 Return(QuicConsumedData(kDataLen - 1, false)));
260 stream_->WriteOrBufferData(kData1, false, NULL); 260 stream_->WriteOrBufferData(kData1, false, NULL);
261 EXPECT_TRUE(HasWriteBlockedStreams()); 261 EXPECT_TRUE(HasWriteBlockedStreams());
262 262
(...skipping 15 matching lines...) Expand all
278 } 278 }
279 279
280 TEST_F(ReliableQuicStreamTest, WriteOrBufferDataWithFecProtectOptional) { 280 TEST_F(ReliableQuicStreamTest, WriteOrBufferDataWithFecProtectOptional) {
281 Initialize(kShouldProcessData); 281 Initialize(kShouldProcessData);
282 282
283 // Set FEC policy on stream. 283 // Set FEC policy on stream.
284 ReliableQuicStreamPeer::SetFecPolicy(stream_.get(), FEC_PROTECT_OPTIONAL); 284 ReliableQuicStreamPeer::SetFecPolicy(stream_.get(), FEC_PROTECT_OPTIONAL);
285 285
286 EXPECT_FALSE(HasWriteBlockedStreams()); 286 EXPECT_FALSE(HasWriteBlockedStreams());
287 size_t length = 1 + QuicPacketCreator::StreamFramePacketOverhead( 287 size_t length = 1 + QuicPacketCreator::StreamFramePacketOverhead(
288 connection_->version(), PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, 288 PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
289 PACKET_6BYTE_SEQUENCE_NUMBER, 0u, NOT_IN_FEC_GROUP); 289 PACKET_6BYTE_SEQUENCE_NUMBER, 0u, NOT_IN_FEC_GROUP);
290 QuicConnectionPeer::GetPacketCreator(connection_)->set_max_packet_length( 290 QuicConnectionPeer::GetPacketCreator(connection_)->set_max_packet_length(
291 length); 291 length);
292 292
293 // Write first data onto stream, which will cause one session write. 293 // Write first data onto stream, which will cause one session write.
294 EXPECT_CALL(*session_, WritevData(_, _, _, _, MAY_FEC_PROTECT, _)).WillOnce( 294 EXPECT_CALL(*session_, WritevData(_, _, _, _, MAY_FEC_PROTECT, _)).WillOnce(
295 Return(QuicConsumedData(kDataLen - 1, false))); 295 Return(QuicConsumedData(kDataLen - 1, false)));
296 stream_->WriteOrBufferData(kData1, false, NULL); 296 stream_->WriteOrBufferData(kData1, false, NULL);
297 EXPECT_TRUE(HasWriteBlockedStreams()); 297 EXPECT_TRUE(HasWriteBlockedStreams());
298 298
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 // higher than the receive window offset. 643 // higher than the receive window offset.
644 QuicStreamFrame frame(stream_->id(), false, 644 QuicStreamFrame frame(stream_->id(), false,
645 kInitialSessionFlowControlWindowForTest + 1, 645 kInitialSessionFlowControlWindowForTest + 1,
646 MakeIOVector(".")); 646 MakeIOVector("."));
647 EXPECT_GT(frame.offset, QuicFlowControllerPeer::ReceiveWindowOffset( 647 EXPECT_GT(frame.offset, QuicFlowControllerPeer::ReceiveWindowOffset(
648 stream_->flow_controller())); 648 stream_->flow_controller()));
649 649
650 // Stream should not accept the frame, and the connection should be closed. 650 // Stream should not accept the frame, and the connection should be closed.
651 EXPECT_CALL(*connection_, 651 EXPECT_CALL(*connection_,
652 SendConnectionClose(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA)); 652 SendConnectionClose(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA));
653 EXPECT_FALSE(stream_->OnStreamFrame(frame)); 653 stream_->OnStreamFrame(frame);
654 } 654 }
655 655
656 TEST_F(ReliableQuicStreamTest, FinalByteOffsetFromFin) { 656 TEST_F(ReliableQuicStreamTest, FinalByteOffsetFromFin) {
657 Initialize(kShouldProcessData); 657 Initialize(kShouldProcessData);
658 658
659 EXPECT_FALSE(stream_->HasFinalReceivedByteOffset()); 659 EXPECT_FALSE(stream_->HasFinalReceivedByteOffset());
660 660
661 QuicStreamFrame stream_frame_no_fin(stream_->id(), false, 1234, 661 QuicStreamFrame stream_frame_no_fin(stream_->id(), false, 1234,
662 MakeIOVector(".")); 662 MakeIOVector("."));
663 stream_->OnStreamFrame(stream_frame_no_fin); 663 stream_->OnStreamFrame(stream_frame_no_fin);
(...skipping 10 matching lines...) Expand all
674 674
675 EXPECT_FALSE(stream_->HasFinalReceivedByteOffset()); 675 EXPECT_FALSE(stream_->HasFinalReceivedByteOffset());
676 QuicRstStreamFrame rst_frame(stream_->id(), QUIC_STREAM_CANCELLED, 1234); 676 QuicRstStreamFrame rst_frame(stream_->id(), QUIC_STREAM_CANCELLED, 1234);
677 stream_->OnStreamReset(rst_frame); 677 stream_->OnStreamReset(rst_frame);
678 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); 678 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset());
679 } 679 }
680 680
681 } // namespace 681 } // namespace
682 } // namespace test 682 } // namespace test
683 } // namespace net 683 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698