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

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

Issue 330333006: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)). 232 EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)).
233 WillOnce(Return(QuicConsumedData(kDataLen - 2, false))); 233 WillOnce(Return(QuicConsumedData(kDataLen - 2, false)));
234 stream_->OnCanWrite(); 234 stream_->OnCanWrite();
235 235
236 // And finally the end of the bytes_consumed. 236 // And finally the end of the bytes_consumed.
237 EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)). 237 EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)).
238 WillOnce(Return(QuicConsumedData(2, true))); 238 WillOnce(Return(QuicConsumedData(2, true)));
239 stream_->OnCanWrite(); 239 stream_->OnCanWrite();
240 } 240 }
241 241
242 TEST_F(ReliableQuicStreamTest, WriteOrBufferDataWithFecProtectAlways) {
243 Initialize(kShouldProcessData);
244
245 // Set FEC policy on stream.
246 ReliableQuicStreamPeer::SetFecPolicy(stream_.get(), PROTECT_ALWAYS);
247
248 EXPECT_FALSE(HasWriteBlockedStreams());
249 size_t length = 1 + QuicPacketCreator::StreamFramePacketOverhead(
250 connection_->version(), PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
251 PACKET_6BYTE_SEQUENCE_NUMBER, 0u, IN_FEC_GROUP);
252 QuicConnectionPeer::GetPacketCreator(connection_)->set_max_packet_length(
253 length);
254
255 // Write first data onto stream, which will cause one session write.
256 EXPECT_CALL(*session_, WritevData(_, _, _, _, MUST_FEC_PROTECT, _)).WillOnce(
257 Return(QuicConsumedData(kDataLen - 1, false)));
258 stream_->WriteOrBufferData(kData1, false, NULL);
259 EXPECT_TRUE(HasWriteBlockedStreams());
260
261 // Queue a bytes_consumed write.
262 stream_->WriteOrBufferData(kData2, false, NULL);
263
264 // Make sure we get the tail of the first write followed by the bytes_consumed
265 InSequence s;
266 EXPECT_CALL(*session_, WritevData(_, _, _, _, MUST_FEC_PROTECT, _)).
267 WillOnce(Return(QuicConsumedData(1, false)));
268 EXPECT_CALL(*session_, WritevData(_, _, _, _, MUST_FEC_PROTECT, _)).
269 WillOnce(Return(QuicConsumedData(kDataLen - 2, false)));
270 stream_->OnCanWrite();
271
272 // And finally the end of the bytes_consumed.
273 EXPECT_CALL(*session_, WritevData(_, _, _, _, MUST_FEC_PROTECT, _)).
274 WillOnce(Return(QuicConsumedData(2, true)));
275 stream_->OnCanWrite();
276 }
277
278 TEST_F(ReliableQuicStreamTest, WriteOrBufferDataWithFecProtectOptional) {
279 Initialize(kShouldProcessData);
280
281 // Set FEC policy on stream.
282 ReliableQuicStreamPeer::SetFecPolicy(stream_.get(), PROTECT_OPTIONAL);
283
284 EXPECT_FALSE(HasWriteBlockedStreams());
285 size_t length = 1 + QuicPacketCreator::StreamFramePacketOverhead(
286 connection_->version(), PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
287 PACKET_6BYTE_SEQUENCE_NUMBER, 0u, NOT_IN_FEC_GROUP);
288 QuicConnectionPeer::GetPacketCreator(connection_)->set_max_packet_length(
289 length);
290
291 // Write first data onto stream, which will cause one session write.
292 EXPECT_CALL(*session_, WritevData(_, _, _, _, MAY_FEC_PROTECT, _)).WillOnce(
293 Return(QuicConsumedData(kDataLen - 1, false)));
294 stream_->WriteOrBufferData(kData1, false, NULL);
295 EXPECT_TRUE(HasWriteBlockedStreams());
296
297 // Queue a bytes_consumed write.
298 stream_->WriteOrBufferData(kData2, false, NULL);
299
300 // Make sure we get the tail of the first write followed by the bytes_consumed
301 InSequence s;
302 EXPECT_CALL(*session_, WritevData(_, _, _, _, MAY_FEC_PROTECT, _)).
303 WillOnce(Return(QuicConsumedData(1, false)));
304 EXPECT_CALL(*session_, WritevData(_, _, _, _, MAY_FEC_PROTECT, _)).
305 WillOnce(Return(QuicConsumedData(kDataLen - 2, false)));
306 stream_->OnCanWrite();
307
308 // And finally the end of the bytes_consumed.
309 EXPECT_CALL(*session_, WritevData(_, _, _, _, MAY_FEC_PROTECT, _)).
310 WillOnce(Return(QuicConsumedData(2, true)));
311 stream_->OnCanWrite();
312 }
313
242 TEST_F(ReliableQuicStreamTest, ConnectionCloseAfterStreamClose) { 314 TEST_F(ReliableQuicStreamTest, ConnectionCloseAfterStreamClose) {
243 Initialize(kShouldProcessData); 315 Initialize(kShouldProcessData);
244 316
245 stream_->CloseReadSide(); 317 stream_->CloseReadSide();
246 stream_->CloseWriteSide(); 318 stream_->CloseWriteSide();
247 EXPECT_EQ(QUIC_STREAM_NO_ERROR, stream_->stream_error()); 319 EXPECT_EQ(QUIC_STREAM_NO_ERROR, stream_->stream_error());
248 EXPECT_EQ(QUIC_NO_ERROR, stream_->connection_error()); 320 EXPECT_EQ(QUIC_NO_ERROR, stream_->connection_error());
249 stream_->OnConnectionClosed(QUIC_INTERNAL_ERROR, false); 321 stream_->OnConnectionClosed(QUIC_INTERNAL_ERROR, false);
250 EXPECT_EQ(QUIC_STREAM_NO_ERROR, stream_->stream_error()); 322 EXPECT_EQ(QUIC_STREAM_NO_ERROR, stream_->stream_error());
251 EXPECT_EQ(QUIC_NO_ERROR, stream_->connection_error()); 323 EXPECT_EQ(QUIC_NO_ERROR, stream_->connection_error());
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 676
605 EXPECT_FALSE(stream_->HasFinalReceivedByteOffset()); 677 EXPECT_FALSE(stream_->HasFinalReceivedByteOffset());
606 QuicRstStreamFrame rst_frame(stream_->id(), QUIC_STREAM_CANCELLED, 1234); 678 QuicRstStreamFrame rst_frame(stream_->id(), QUIC_STREAM_CANCELLED, 1234);
607 stream_->OnStreamReset(rst_frame); 679 stream_->OnStreamReset(rst_frame);
608 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); 680 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset());
609 } 681 }
610 682
611 } // namespace 683 } // namespace
612 } // namespace test 684 } // namespace test
613 } // namespace net 685 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698