OLD | NEW |
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 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 &SaveProxyAckNotifierDelegate, &proxy_delegate))), | 550 &SaveProxyAckNotifierDelegate, &proxy_delegate))), |
551 Return(QuicConsumedData(0, true)))); | 551 Return(QuicConsumedData(0, true)))); |
552 stream_->OnCanWrite(); | 552 stream_->OnCanWrite(); |
553 | 553 |
554 // Handle the acks. | 554 // Handle the acks. |
555 proxy_delegate->OnAckNotification(1, 2, 3, 4, zero_); | 555 proxy_delegate->OnAckNotification(1, 2, 3, 4, zero_); |
556 EXPECT_CALL(*delegate, OnAckNotification(11, 22, 33, 44, zero_)); | 556 EXPECT_CALL(*delegate, OnAckNotification(11, 22, 33, 44, zero_)); |
557 proxy_delegate->OnAckNotification(10, 20, 30, 40, zero_); | 557 proxy_delegate->OnAckNotification(10, 20, 30, 40, zero_); |
558 } | 558 } |
559 | 559 |
560 | |
561 // Verify that when we receive a packet which violates flow control (i.e. sends | 560 // Verify that when we receive a packet which violates flow control (i.e. sends |
562 // too much data on the stream) that the stream sequencer never sees this frame, | 561 // too much data on the stream) that the stream sequencer never sees this frame, |
563 // as we check for violation and close the connection early. | 562 // as we check for violation and close the connection early. |
564 TEST_F(ReliableQuicStreamTest, | 563 TEST_F(ReliableQuicStreamTest, |
565 StreamSequencerNeverSeesPacketsViolatingFlowControl) { | 564 StreamSequencerNeverSeesPacketsViolatingFlowControl) { |
566 ValueRestore<bool> old_stream_flag( | 565 ValueRestore<bool> old_stream_flag( |
567 &FLAGS_enable_quic_stream_flow_control_2, true); | 566 &FLAGS_enable_quic_stream_flow_control_2, true); |
568 ValueRestore<bool> old_connection_flag( | 567 ValueRestore<bool> old_connection_flag( |
569 &FLAGS_enable_quic_connection_flow_control, true); | 568 &FLAGS_enable_quic_connection_flow_control, true); |
570 | 569 |
571 Initialize(kShouldProcessData); | 570 Initialize(kShouldProcessData); |
572 | 571 |
573 // Receive a stream frame that violates flow control: the byte offset is | 572 // Receive a stream frame that violates flow control: the byte offset is |
574 // higher than the receive window offset. | 573 // higher than the receive window offset. |
575 QuicStreamFrame frame(stream_->id(), false, | 574 QuicStreamFrame frame(stream_->id(), false, |
576 kInitialFlowControlWindowForTest + 1, | 575 kInitialFlowControlWindowForTest + 1, |
577 MakeIOVector(".")); | 576 MakeIOVector(".")); |
578 EXPECT_GT(frame.offset, QuicFlowControllerPeer::ReceiveWindowOffset( | 577 EXPECT_GT(frame.offset, QuicFlowControllerPeer::ReceiveWindowOffset( |
579 stream_->flow_controller())); | 578 stream_->flow_controller())); |
580 | 579 |
581 // Stream should not accept the frame, and the connection should be closed. | 580 // Stream should not accept the frame, and the connection should be closed. |
582 EXPECT_CALL(*connection_, | 581 EXPECT_CALL(*connection_, |
583 SendConnectionClose(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA)); | 582 SendConnectionClose(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA)); |
584 EXPECT_FALSE(stream_->OnStreamFrame(frame)); | 583 EXPECT_FALSE(stream_->OnStreamFrame(frame)); |
585 } | 584 } |
586 | 585 |
| 586 TEST_F(ReliableQuicStreamTest, FinalByteOffsetFromFin) { |
| 587 Initialize(kShouldProcessData); |
| 588 |
| 589 EXPECT_FALSE(stream_->HasFinalReceivedByteOffset()); |
| 590 |
| 591 QuicStreamFrame stream_frame_no_fin(stream_->id(), false, 1234, |
| 592 MakeIOVector(".")); |
| 593 stream_->OnStreamFrame(stream_frame_no_fin); |
| 594 EXPECT_FALSE(stream_->HasFinalReceivedByteOffset()); |
| 595 |
| 596 QuicStreamFrame stream_frame_with_fin(stream_->id(), true, 1234, |
| 597 MakeIOVector(".")); |
| 598 stream_->OnStreamFrame(stream_frame_with_fin); |
| 599 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); |
| 600 } |
| 601 |
| 602 TEST_F(ReliableQuicStreamTest, FinalByteOffsetFromRst) { |
| 603 Initialize(kShouldProcessData); |
| 604 |
| 605 EXPECT_FALSE(stream_->HasFinalReceivedByteOffset()); |
| 606 QuicRstStreamFrame rst_frame(stream_->id(), QUIC_STREAM_CANCELLED, 1234); |
| 607 stream_->OnStreamReset(rst_frame); |
| 608 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); |
| 609 } |
| 610 |
587 } // namespace | 611 } // namespace |
588 } // namespace test | 612 } // namespace test |
589 } // namespace net | 613 } // namespace net |
OLD | NEW |