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

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

Issue 350973003: Killing off quic V17. Not flag protected. (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
« no previous file with comments | « net/quic/quic_connection_test.cc ('k') | net/quic/quic_flow_controller.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/quic_data_stream.h" 5 #include "net/quic/quic_data_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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 size_t bytes_read = stream_->Readv(vec, 2); 275 size_t bytes_read = stream_->Readv(vec, 2);
276 ASSERT_EQ(2u, bytes_read) << i; 276 ASSERT_EQ(2u, bytes_read) << i;
277 ASSERT_EQ(data.data()[i], buffer1[0]) << i; 277 ASSERT_EQ(data.data()[i], buffer1[0]) << i;
278 ASSERT_EQ(data.data()[i + 1], buffer2[0]) << i; 278 ASSERT_EQ(data.data()[i + 1], buffer2[0]) << i;
279 } 279 }
280 } 280 }
281 281
282 TEST_P(QuicDataStreamTest, StreamFlowControlBlocked) { 282 TEST_P(QuicDataStreamTest, StreamFlowControlBlocked) {
283 // Tests that we send a BLOCKED frame to the peer when we attempt to write, 283 // Tests that we send a BLOCKED frame to the peer when we attempt to write,
284 // but are flow control blocked. 284 // but are flow control blocked.
285 if (GetParam() < QUIC_VERSION_17) { 285 if (GetParam() <= QUIC_VERSION_16) {
286 return; 286 return;
287 } 287 }
288 288
289 Initialize(kShouldProcessData); 289 Initialize(kShouldProcessData);
290 290
291 // Set a small flow control limit. 291 // Set a small flow control limit.
292 const uint64 kWindow = 36; 292 const uint64 kWindow = 36;
293 QuicFlowControllerPeer::SetSendWindowOffset(stream_->flow_controller(), 293 QuicFlowControllerPeer::SetSendWindowOffset(stream_->flow_controller(),
294 kWindow); 294 kWindow);
295 EXPECT_EQ(kWindow, QuicFlowControllerPeer::SendWindowOffset( 295 EXPECT_EQ(kWindow, QuicFlowControllerPeer::SendWindowOffset(
(...skipping 17 matching lines...) Expand all
313 // And we should have queued the overflowed data. 313 // And we should have queued the overflowed data.
314 EXPECT_EQ(kOverflow, 314 EXPECT_EQ(kOverflow,
315 ReliableQuicStreamPeer::SizeOfQueuedData(stream_.get())); 315 ReliableQuicStreamPeer::SizeOfQueuedData(stream_.get()));
316 } 316 }
317 317
318 TEST_P(QuicDataStreamTest, StreamFlowControlNoWindowUpdateIfNotConsumed) { 318 TEST_P(QuicDataStreamTest, StreamFlowControlNoWindowUpdateIfNotConsumed) {
319 // The flow control receive window decreases whenever we add new bytes to the 319 // The flow control receive window decreases whenever we add new bytes to the
320 // sequencer, whether they are consumed immediately or buffered. However we 320 // sequencer, whether they are consumed immediately or buffered. However we
321 // only send WINDOW_UPDATE frames based on increasing number of bytes 321 // only send WINDOW_UPDATE frames based on increasing number of bytes
322 // consumed. 322 // consumed.
323 if (GetParam() < QUIC_VERSION_17) { 323 if (GetParam() <= QUIC_VERSION_16) {
324 return; 324 return;
325 } 325 }
326 326
327 // Don't process data - it will be buffered instead. 327 // Don't process data - it will be buffered instead.
328 Initialize(!kShouldProcessData); 328 Initialize(!kShouldProcessData);
329 329
330 // Expect no WINDOW_UPDATE frames to be sent. 330 // Expect no WINDOW_UPDATE frames to be sent.
331 EXPECT_CALL(*connection_, SendWindowUpdate(_, _)).Times(0); 331 EXPECT_CALL(*connection_, SendWindowUpdate(_, _)).Times(0);
332 332
333 // Set a small flow control receive window. 333 // Set a small flow control receive window.
(...skipping 26 matching lines...) Expand all
360 stream_->OnStreamFrame(frame2); 360 stream_->OnStreamFrame(frame2);
361 EXPECT_EQ( 361 EXPECT_EQ(
362 kWindow - (2 * kWindow / 3), 362 kWindow - (2 * kWindow / 3),
363 QuicFlowControllerPeer::ReceiveWindowSize(stream_->flow_controller())); 363 QuicFlowControllerPeer::ReceiveWindowSize(stream_->flow_controller()));
364 } 364 }
365 365
366 TEST_P(QuicDataStreamTest, StreamFlowControlWindowUpdate) { 366 TEST_P(QuicDataStreamTest, StreamFlowControlWindowUpdate) {
367 // Tests that on receipt of data, the stream updates its receive window offset 367 // Tests that on receipt of data, the stream updates its receive window offset
368 // appropriately, and sends WINDOW_UPDATE frames when its receive window drops 368 // appropriately, and sends WINDOW_UPDATE frames when its receive window drops
369 // too low. 369 // too low.
370 if (GetParam() < QUIC_VERSION_17) { 370 if (GetParam() <= QUIC_VERSION_16) {
371 return; 371 return;
372 } 372 }
373 373
374 Initialize(kShouldProcessData); 374 Initialize(kShouldProcessData);
375 375
376 // Set a small flow control limit. 376 // Set a small flow control limit.
377 const uint64 kWindow = 36; 377 const uint64 kWindow = 36;
378 QuicFlowControllerPeer::SetReceiveWindowOffset(stream_->flow_controller(), 378 QuicFlowControllerPeer::SetReceiveWindowOffset(stream_->flow_controller(),
379 kWindow); 379 kWindow);
380 QuicFlowControllerPeer::SetMaxReceiveWindow(stream_->flow_controller(), 380 QuicFlowControllerPeer::SetMaxReceiveWindow(stream_->flow_controller(),
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 session_->flow_controller()) + 464 session_->flow_controller()) +
465 1 + kWindow / 2)); 465 1 + kWindow / 2));
466 QuicStreamFrame frame3(kClientDataStreamId1, false, (kWindow / 4), 466 QuicStreamFrame frame3(kClientDataStreamId1, false, (kWindow / 4),
467 MakeIOVector("a")); 467 MakeIOVector("a"));
468 stream_->OnStreamFrame(frame3); 468 stream_->OnStreamFrame(frame3);
469 } 469 }
470 470
471 TEST_P(QuicDataStreamTest, StreamFlowControlViolation) { 471 TEST_P(QuicDataStreamTest, StreamFlowControlViolation) {
472 // Tests that on if the peer sends too much data (i.e. violates the flow 472 // Tests that on if the peer sends too much data (i.e. violates the flow
473 // control protocol), then we terminate the connection. 473 // control protocol), then we terminate the connection.
474 if (GetParam() < QUIC_VERSION_17) { 474 if (GetParam() <= QUIC_VERSION_16) {
475 return; 475 return;
476 } 476 }
477 477
478 // Stream should not process data, so that data gets buffered in the 478 // Stream should not process data, so that data gets buffered in the
479 // sequencer, triggering flow control limits. 479 // sequencer, triggering flow control limits.
480 Initialize(!kShouldProcessData); 480 Initialize(!kShouldProcessData);
481 481
482 // Set a small flow control limit. 482 // Set a small flow control limit.
483 const uint64 kWindow = 50; 483 const uint64 kWindow = 50;
484 QuicFlowControllerPeer::SetReceiveWindowOffset(stream_->flow_controller(), 484 QuicFlowControllerPeer::SetReceiveWindowOffset(stream_->flow_controller(),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 QuicStreamFrame frame(kClientDataStreamId1, false, 0, MakeIOVector(body)); 532 QuicStreamFrame frame(kClientDataStreamId1, false, 0, MakeIOVector(body));
533 533
534 EXPECT_CALL(*connection_, 534 EXPECT_CALL(*connection_,
535 SendConnectionClose(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA)); 535 SendConnectionClose(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA));
536 stream_->OnStreamFrame(frame); 536 stream_->OnStreamFrame(frame);
537 } 537 }
538 538
539 TEST_P(QuicDataStreamTest, StreamFlowControlFinNotBlocked) { 539 TEST_P(QuicDataStreamTest, StreamFlowControlFinNotBlocked) {
540 // An attempt to write a FIN with no data should not be flow control blocked, 540 // An attempt to write a FIN with no data should not be flow control blocked,
541 // even if the send window is 0. 541 // even if the send window is 0.
542 if (GetParam() < QUIC_VERSION_17) { 542 if (GetParam() <= QUIC_VERSION_16) {
543 return; 543 return;
544 } 544 }
545 545
546 Initialize(kShouldProcessData); 546 Initialize(kShouldProcessData);
547 547
548 // Set a flow control limit of zero. 548 // Set a flow control limit of zero.
549 QuicFlowControllerPeer::SetReceiveWindowOffset(stream_->flow_controller(), 0); 549 QuicFlowControllerPeer::SetReceiveWindowOffset(stream_->flow_controller(), 0);
550 EXPECT_EQ(0u, QuicFlowControllerPeer::ReceiveWindowOffset( 550 EXPECT_EQ(0u, QuicFlowControllerPeer::ReceiveWindowOffset(
551 stream_->flow_controller())); 551 stream_->flow_controller()));
552 552
553 // Send a frame with a FIN but no data. This should not be blocked. 553 // Send a frame with a FIN but no data. This should not be blocked.
554 string body = ""; 554 string body = "";
555 bool fin = true; 555 bool fin = true;
556 556
557 EXPECT_CALL(*connection_, SendBlocked(kClientDataStreamId1)).Times(0); 557 EXPECT_CALL(*connection_, SendBlocked(kClientDataStreamId1)).Times(0);
558 EXPECT_CALL(*session_, WritevData(kClientDataStreamId1, _, _, _, _, _)) 558 EXPECT_CALL(*session_, WritevData(kClientDataStreamId1, _, _, _, _, _))
559 .WillOnce(Return(QuicConsumedData(0, fin))); 559 .WillOnce(Return(QuicConsumedData(0, fin)));
560 560
561 stream_->WriteOrBufferData(body, fin, NULL); 561 stream_->WriteOrBufferData(body, fin, NULL);
562 } 562 }
563 563
564 } // namespace 564 } // namespace
565 } // namespace test 565 } // namespace test
566 } // namespace net 566 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection_test.cc ('k') | net/quic/quic_flow_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698