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

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

Issue 612323013: QUIC - (no behavior change) s/NULL/nullptr/g in .../quic/... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/crypto_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_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_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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 Initialize(kShouldProcessData); 153 Initialize(kShouldProcessData);
154 154
155 size_t length = 1 + QuicPacketCreator::StreamFramePacketOverhead( 155 size_t length = 1 + QuicPacketCreator::StreamFramePacketOverhead(
156 PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, 156 PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
157 PACKET_6BYTE_SEQUENCE_NUMBER, 0u, NOT_IN_FEC_GROUP); 157 PACKET_6BYTE_SEQUENCE_NUMBER, 0u, NOT_IN_FEC_GROUP);
158 QuicConnectionPeer::GetPacketCreator(connection_)->set_max_packet_length( 158 QuicConnectionPeer::GetPacketCreator(connection_)->set_max_packet_length(
159 length); 159 length);
160 160
161 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)).WillOnce( 161 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)).WillOnce(
162 Return(QuicConsumedData(kDataLen, true))); 162 Return(QuicConsumedData(kDataLen, true)));
163 stream_->WriteOrBufferData(kData1, false, NULL); 163 stream_->WriteOrBufferData(kData1, false, nullptr);
164 EXPECT_FALSE(HasWriteBlockedStreams()); 164 EXPECT_FALSE(HasWriteBlockedStreams());
165 } 165 }
166 166
167 TEST_F(ReliableQuicStreamTest, NoBlockingIfNoDataOrFin) { 167 TEST_F(ReliableQuicStreamTest, NoBlockingIfNoDataOrFin) {
168 Initialize(kShouldProcessData); 168 Initialize(kShouldProcessData);
169 169
170 // Write no data and no fin. If we consume nothing we should not be write 170 // Write no data and no fin. If we consume nothing we should not be write
171 // blocked. 171 // blocked.
172 EXPECT_DFATAL(stream_->WriteOrBufferData(StringPiece(), false, NULL), ""); 172 EXPECT_DFATAL(stream_->WriteOrBufferData(StringPiece(), false, nullptr), "");
173 EXPECT_FALSE(HasWriteBlockedStreams()); 173 EXPECT_FALSE(HasWriteBlockedStreams());
174 } 174 }
175 175
176 TEST_F(ReliableQuicStreamTest, BlockIfOnlySomeDataConsumed) { 176 TEST_F(ReliableQuicStreamTest, BlockIfOnlySomeDataConsumed) {
177 Initialize(kShouldProcessData); 177 Initialize(kShouldProcessData);
178 178
179 // Write some data and no fin. If we consume some but not all of the data, 179 // Write some data and no fin. If we consume some but not all of the data,
180 // we should be write blocked a not all the data was consumed. 180 // we should be write blocked a not all the data was consumed.
181 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)) 181 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _))
182 .WillOnce(Return(QuicConsumedData(1, false))); 182 .WillOnce(Return(QuicConsumedData(1, false)));
183 stream_->WriteOrBufferData(StringPiece(kData1, 2), false, NULL); 183 stream_->WriteOrBufferData(StringPiece(kData1, 2), false, nullptr);
184 ASSERT_EQ(1u, write_blocked_list_->NumBlockedStreams()); 184 ASSERT_EQ(1u, write_blocked_list_->NumBlockedStreams());
185 } 185 }
186 186
187 TEST_F(ReliableQuicStreamTest, BlockIfFinNotConsumedWithData) { 187 TEST_F(ReliableQuicStreamTest, BlockIfFinNotConsumedWithData) {
188 Initialize(kShouldProcessData); 188 Initialize(kShouldProcessData);
189 189
190 // Write some data and no fin. If we consume all the data but not the fin, 190 // Write some data and no fin. If we consume all the data but not the fin,
191 // we should be write blocked because the fin was not consumed. 191 // we should be write blocked because the fin was not consumed.
192 // (This should never actually happen as the fin should be sent out with the 192 // (This should never actually happen as the fin should be sent out with the
193 // last data) 193 // last data)
194 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)) 194 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _))
195 .WillOnce(Return(QuicConsumedData(2, false))); 195 .WillOnce(Return(QuicConsumedData(2, false)));
196 stream_->WriteOrBufferData(StringPiece(kData1, 2), true, NULL); 196 stream_->WriteOrBufferData(StringPiece(kData1, 2), true, nullptr);
197 ASSERT_EQ(1u, write_blocked_list_->NumBlockedStreams()); 197 ASSERT_EQ(1u, write_blocked_list_->NumBlockedStreams());
198 } 198 }
199 199
200 TEST_F(ReliableQuicStreamTest, BlockIfSoloFinNotConsumed) { 200 TEST_F(ReliableQuicStreamTest, BlockIfSoloFinNotConsumed) {
201 Initialize(kShouldProcessData); 201 Initialize(kShouldProcessData);
202 202
203 // Write no data and a fin. If we consume nothing we should be write blocked, 203 // Write no data and a fin. If we consume nothing we should be write blocked,
204 // as the fin was not consumed. 204 // as the fin was not consumed.
205 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)) 205 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _))
206 .WillOnce(Return(QuicConsumedData(0, false))); 206 .WillOnce(Return(QuicConsumedData(0, false)));
207 stream_->WriteOrBufferData(StringPiece(), true, NULL); 207 stream_->WriteOrBufferData(StringPiece(), true, nullptr);
208 ASSERT_EQ(1u, write_blocked_list_->NumBlockedStreams()); 208 ASSERT_EQ(1u, write_blocked_list_->NumBlockedStreams());
209 } 209 }
210 210
211 TEST_F(ReliableQuicStreamTest, WriteOrBufferData) { 211 TEST_F(ReliableQuicStreamTest, WriteOrBufferData) {
212 Initialize(kShouldProcessData); 212 Initialize(kShouldProcessData);
213 213
214 EXPECT_FALSE(HasWriteBlockedStreams()); 214 EXPECT_FALSE(HasWriteBlockedStreams());
215 size_t length = 1 + QuicPacketCreator::StreamFramePacketOverhead( 215 size_t length = 1 + QuicPacketCreator::StreamFramePacketOverhead(
216 PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, 216 PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
217 PACKET_6BYTE_SEQUENCE_NUMBER, 0u, NOT_IN_FEC_GROUP); 217 PACKET_6BYTE_SEQUENCE_NUMBER, 0u, NOT_IN_FEC_GROUP);
218 QuicConnectionPeer::GetPacketCreator(connection_)->set_max_packet_length( 218 QuicConnectionPeer::GetPacketCreator(connection_)->set_max_packet_length(
219 length); 219 length);
220 220
221 EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)).WillOnce( 221 EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)).WillOnce(
222 Return(QuicConsumedData(kDataLen - 1, false))); 222 Return(QuicConsumedData(kDataLen - 1, false)));
223 stream_->WriteOrBufferData(kData1, false, NULL); 223 stream_->WriteOrBufferData(kData1, false, nullptr);
224 EXPECT_TRUE(HasWriteBlockedStreams()); 224 EXPECT_TRUE(HasWriteBlockedStreams());
225 225
226 // Queue a bytes_consumed write. 226 // Queue a bytes_consumed write.
227 stream_->WriteOrBufferData(kData2, false, NULL); 227 stream_->WriteOrBufferData(kData2, false, nullptr);
228 228
229 // Make sure we get the tail of the first write followed by the bytes_consumed 229 // Make sure we get the tail of the first write followed by the bytes_consumed
230 InSequence s; 230 InSequence s;
231 EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)). 231 EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)).
232 WillOnce(Return(QuicConsumedData(1, false))); 232 WillOnce(Return(QuicConsumedData(1, false)));
233 EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)). 233 EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)).
234 WillOnce(Return(QuicConsumedData(kDataLen - 2, false))); 234 WillOnce(Return(QuicConsumedData(kDataLen - 2, false)));
235 stream_->OnCanWrite(); 235 stream_->OnCanWrite();
236 236
237 // And finally the end of the bytes_consumed. 237 // And finally the end of the bytes_consumed.
(...skipping 11 matching lines...) Expand all
249 EXPECT_FALSE(HasWriteBlockedStreams()); 249 EXPECT_FALSE(HasWriteBlockedStreams());
250 size_t length = 1 + QuicPacketCreator::StreamFramePacketOverhead( 250 size_t length = 1 + QuicPacketCreator::StreamFramePacketOverhead(
251 PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, 251 PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
252 PACKET_6BYTE_SEQUENCE_NUMBER, 0u, IN_FEC_GROUP); 252 PACKET_6BYTE_SEQUENCE_NUMBER, 0u, IN_FEC_GROUP);
253 QuicConnectionPeer::GetPacketCreator(connection_)->set_max_packet_length( 253 QuicConnectionPeer::GetPacketCreator(connection_)->set_max_packet_length(
254 length); 254 length);
255 255
256 // Write first data onto stream, which will cause one session write. 256 // Write first data onto stream, which will cause one session write.
257 EXPECT_CALL(*session_, WritevData(_, _, _, _, MUST_FEC_PROTECT, _)).WillOnce( 257 EXPECT_CALL(*session_, WritevData(_, _, _, _, MUST_FEC_PROTECT, _)).WillOnce(
258 Return(QuicConsumedData(kDataLen - 1, false))); 258 Return(QuicConsumedData(kDataLen - 1, false)));
259 stream_->WriteOrBufferData(kData1, false, NULL); 259 stream_->WriteOrBufferData(kData1, false, nullptr);
260 EXPECT_TRUE(HasWriteBlockedStreams()); 260 EXPECT_TRUE(HasWriteBlockedStreams());
261 261
262 // Queue a bytes_consumed write. 262 // Queue a bytes_consumed write.
263 stream_->WriteOrBufferData(kData2, false, NULL); 263 stream_->WriteOrBufferData(kData2, false, nullptr);
264 264
265 // Make sure we get the tail of the first write followed by the bytes_consumed 265 // Make sure we get the tail of the first write followed by the bytes_consumed
266 InSequence s; 266 InSequence s;
267 EXPECT_CALL(*session_, WritevData(_, _, _, _, MUST_FEC_PROTECT, _)). 267 EXPECT_CALL(*session_, WritevData(_, _, _, _, MUST_FEC_PROTECT, _)).
268 WillOnce(Return(QuicConsumedData(1, false))); 268 WillOnce(Return(QuicConsumedData(1, false)));
269 EXPECT_CALL(*session_, WritevData(_, _, _, _, MUST_FEC_PROTECT, _)). 269 EXPECT_CALL(*session_, WritevData(_, _, _, _, MUST_FEC_PROTECT, _)).
270 WillOnce(Return(QuicConsumedData(kDataLen - 2, false))); 270 WillOnce(Return(QuicConsumedData(kDataLen - 2, false)));
271 stream_->OnCanWrite(); 271 stream_->OnCanWrite();
272 272
273 // And finally the end of the bytes_consumed. 273 // And finally the end of the bytes_consumed.
(...skipping 11 matching lines...) Expand all
285 EXPECT_FALSE(HasWriteBlockedStreams()); 285 EXPECT_FALSE(HasWriteBlockedStreams());
286 size_t length = 1 + QuicPacketCreator::StreamFramePacketOverhead( 286 size_t length = 1 + QuicPacketCreator::StreamFramePacketOverhead(
287 PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, 287 PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
288 PACKET_6BYTE_SEQUENCE_NUMBER, 0u, NOT_IN_FEC_GROUP); 288 PACKET_6BYTE_SEQUENCE_NUMBER, 0u, NOT_IN_FEC_GROUP);
289 QuicConnectionPeer::GetPacketCreator(connection_)->set_max_packet_length( 289 QuicConnectionPeer::GetPacketCreator(connection_)->set_max_packet_length(
290 length); 290 length);
291 291
292 // Write first data onto stream, which will cause one session write. 292 // Write first data onto stream, which will cause one session write.
293 EXPECT_CALL(*session_, WritevData(_, _, _, _, MAY_FEC_PROTECT, _)).WillOnce( 293 EXPECT_CALL(*session_, WritevData(_, _, _, _, MAY_FEC_PROTECT, _)).WillOnce(
294 Return(QuicConsumedData(kDataLen - 1, false))); 294 Return(QuicConsumedData(kDataLen - 1, false)));
295 stream_->WriteOrBufferData(kData1, false, NULL); 295 stream_->WriteOrBufferData(kData1, false, nullptr);
296 EXPECT_TRUE(HasWriteBlockedStreams()); 296 EXPECT_TRUE(HasWriteBlockedStreams());
297 297
298 // Queue a bytes_consumed write. 298 // Queue a bytes_consumed write.
299 stream_->WriteOrBufferData(kData2, false, NULL); 299 stream_->WriteOrBufferData(kData2, false, nullptr);
300 300
301 // Make sure we get the tail of the first write followed by the bytes_consumed 301 // Make sure we get the tail of the first write followed by the bytes_consumed
302 InSequence s; 302 InSequence s;
303 EXPECT_CALL(*session_, WritevData(_, _, _, _, MAY_FEC_PROTECT, _)). 303 EXPECT_CALL(*session_, WritevData(_, _, _, _, MAY_FEC_PROTECT, _)).
304 WillOnce(Return(QuicConsumedData(1, false))); 304 WillOnce(Return(QuicConsumedData(1, false)));
305 EXPECT_CALL(*session_, WritevData(_, _, _, _, MAY_FEC_PROTECT, _)). 305 EXPECT_CALL(*session_, WritevData(_, _, _, _, MAY_FEC_PROTECT, _)).
306 WillOnce(Return(QuicConsumedData(kDataLen - 2, false))); 306 WillOnce(Return(QuicConsumedData(kDataLen - 2, false)));
307 stream_->OnCanWrite(); 307 stream_->OnCanWrite();
308 308
309 // And finally the end of the bytes_consumed. 309 // And finally the end of the bytes_consumed.
(...skipping 19 matching lines...) Expand all
329 // before termination. 329 // before termination.
330 // Test that if no FIN has been sent, we send a RST. 330 // Test that if no FIN has been sent, we send a RST.
331 331
332 Initialize(kShouldProcessData); 332 Initialize(kShouldProcessData);
333 EXPECT_FALSE(fin_sent()); 333 EXPECT_FALSE(fin_sent());
334 EXPECT_FALSE(rst_sent()); 334 EXPECT_FALSE(rst_sent());
335 335
336 // Write some data, with no FIN. 336 // Write some data, with no FIN.
337 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)) 337 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _))
338 .WillOnce(Return(QuicConsumedData(1, false))); 338 .WillOnce(Return(QuicConsumedData(1, false)));
339 stream_->WriteOrBufferData(StringPiece(kData1, 1), false, NULL); 339 stream_->WriteOrBufferData(StringPiece(kData1, 1), false, nullptr);
340 EXPECT_FALSE(fin_sent()); 340 EXPECT_FALSE(fin_sent());
341 EXPECT_FALSE(rst_sent()); 341 EXPECT_FALSE(rst_sent());
342 342
343 // Now close the stream, and expect that we send a RST. 343 // Now close the stream, and expect that we send a RST.
344 EXPECT_CALL(*session_, SendRstStream(_, _, _)); 344 EXPECT_CALL(*session_, SendRstStream(_, _, _));
345 stream_->OnClose(); 345 stream_->OnClose();
346 EXPECT_FALSE(fin_sent()); 346 EXPECT_FALSE(fin_sent());
347 EXPECT_TRUE(rst_sent()); 347 EXPECT_TRUE(rst_sent());
348 } 348 }
349 349
350 TEST_F(ReliableQuicStreamTest, RstNotSentIfFinSent) { 350 TEST_F(ReliableQuicStreamTest, RstNotSentIfFinSent) {
351 // For flow control accounting, a stream must send either a FIN or a RST frame 351 // For flow control accounting, a stream must send either a FIN or a RST frame
352 // before termination. 352 // before termination.
353 // Test that if a FIN has been sent, we don't also send a RST. 353 // Test that if a FIN has been sent, we don't also send a RST.
354 354
355 Initialize(kShouldProcessData); 355 Initialize(kShouldProcessData);
356 EXPECT_FALSE(fin_sent()); 356 EXPECT_FALSE(fin_sent());
357 EXPECT_FALSE(rst_sent()); 357 EXPECT_FALSE(rst_sent());
358 358
359 // Write some data, with FIN. 359 // Write some data, with FIN.
360 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)) 360 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _))
361 .WillOnce(Return(QuicConsumedData(1, true))); 361 .WillOnce(Return(QuicConsumedData(1, true)));
362 stream_->WriteOrBufferData(StringPiece(kData1, 1), true, NULL); 362 stream_->WriteOrBufferData(StringPiece(kData1, 1), true, nullptr);
363 EXPECT_TRUE(fin_sent()); 363 EXPECT_TRUE(fin_sent());
364 EXPECT_FALSE(rst_sent()); 364 EXPECT_FALSE(rst_sent());
365 365
366 // Now close the stream, and expect that we do not send a RST. 366 // Now close the stream, and expect that we do not send a RST.
367 stream_->OnClose(); 367 stream_->OnClose();
368 EXPECT_TRUE(fin_sent()); 368 EXPECT_TRUE(fin_sent());
369 EXPECT_FALSE(rst_sent()); 369 EXPECT_FALSE(rst_sent());
370 } 370 }
371 371
372 TEST_F(ReliableQuicStreamTest, OnlySendOneRst) { 372 TEST_F(ReliableQuicStreamTest, OnlySendOneRst) {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 506
507 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)) 507 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _))
508 .WillOnce(DoAll(WithArgs<5>(Invoke(CreateFunctor( 508 .WillOnce(DoAll(WithArgs<5>(Invoke(CreateFunctor(
509 &SaveProxyAckNotifierDelegate, &proxy_delegate))), 509 &SaveProxyAckNotifierDelegate, &proxy_delegate))),
510 Return(QuicConsumedData(kInitialWriteSize, false)))); 510 Return(QuicConsumedData(kInitialWriteSize, false))));
511 stream_->WriteOrBufferData(kData, false, delegate.get()); 511 stream_->WriteOrBufferData(kData, false, delegate.get());
512 EXPECT_TRUE(HasWriteBlockedStreams()); 512 EXPECT_TRUE(HasWriteBlockedStreams());
513 513
514 // Handle the ack of the first write. 514 // Handle the ack of the first write.
515 proxy_delegate->OnAckNotification(1, 2, 3, 4, zero_); 515 proxy_delegate->OnAckNotification(1, 2, 3, 4, zero_);
516 proxy_delegate = NULL; 516 proxy_delegate = nullptr;
517 517
518 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)).WillOnce( 518 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)).WillOnce(
519 DoAll(WithArgs<5>(Invoke(CreateFunctor( 519 DoAll(WithArgs<5>(Invoke(CreateFunctor(
520 &SaveProxyAckNotifierDelegate, &proxy_delegate))), 520 &SaveProxyAckNotifierDelegate, &proxy_delegate))),
521 Return(QuicConsumedData(kDataSize - kInitialWriteSize, false)))); 521 Return(QuicConsumedData(kDataSize - kInitialWriteSize, false))));
522 stream_->OnCanWrite(); 522 stream_->OnCanWrite();
523 523
524 // Handle the ack for the second write. 524 // Handle the ack for the second write.
525 EXPECT_CALL(*delegate.get(), OnAckNotification(101, 202, 303, 404, zero_)); 525 EXPECT_CALL(*delegate.get(), OnAckNotification(101, 202, 303, 404, zero_));
526 proxy_delegate->OnAckNotification(100, 200, 300, 400, zero_); 526 proxy_delegate->OnAckNotification(100, 200, 300, 400, zero_);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 643
644 EXPECT_FALSE(stream_->HasFinalReceivedByteOffset()); 644 EXPECT_FALSE(stream_->HasFinalReceivedByteOffset());
645 QuicRstStreamFrame rst_frame(stream_->id(), QUIC_STREAM_CANCELLED, 1234); 645 QuicRstStreamFrame rst_frame(stream_->id(), QUIC_STREAM_CANCELLED, 1234);
646 stream_->OnStreamReset(rst_frame); 646 stream_->OnStreamReset(rst_frame);
647 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); 647 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset());
648 } 648 }
649 649
650 } // namespace 650 } // namespace
651 } // namespace test 651 } // namespace test
652 } // namespace net 652 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/reliable_quic_stream.cc ('k') | net/quic/test_tools/crypto_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698