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

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

Issue 242593002: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Build fix. Use uint32 instead of int Created 6 years, 8 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.cc ('k') | net/quic/quic_crypto_stream.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/quic_connection.h" 5 #include "net/quic/quic_connection.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 3601 matching lines...) Expand 10 before | Expand all | Expand 10 after
3612 EXPECT_TRUE(writer_->IsWriteBlocked()); 3612 EXPECT_TRUE(writer_->IsWriteBlocked());
3613 TriggerConnectionClose(); 3613 TriggerConnectionClose();
3614 EXPECT_EQ(1u, writer_->packets_write_attempts()); 3614 EXPECT_EQ(1u, writer_->packets_write_attempts());
3615 } 3615 }
3616 3616
3617 TEST_P(QuicConnectionTest, AckNotifierTriggerCallback) { 3617 TEST_P(QuicConnectionTest, AckNotifierTriggerCallback) {
3618 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 3618 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
3619 3619
3620 // Create a delegate which we expect to be called. 3620 // Create a delegate which we expect to be called.
3621 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); 3621 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate);
3622 EXPECT_CALL(*delegate, OnAckNotification(_, _, _, _)).Times(1); 3622 EXPECT_CALL(*delegate, OnAckNotification(_, _, _, _, _)).Times(1);
3623 3623
3624 // Send some data, which will register the delegate to be notified. 3624 // Send some data, which will register the delegate to be notified.
3625 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get()); 3625 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get());
3626 3626
3627 // Process an ACK from the server which should trigger the callback. 3627 // Process an ACK from the server which should trigger the callback.
3628 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); 3628 EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
3629 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1); 3629 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1);
3630 QuicAckFrame frame = InitAckFrame(1, 0); 3630 QuicAckFrame frame = InitAckFrame(1, 0);
3631 ProcessAckPacket(&frame); 3631 ProcessAckPacket(&frame);
3632 } 3632 }
3633 3633
3634 TEST_P(QuicConnectionTest, AckNotifierFailToTriggerCallback) { 3634 TEST_P(QuicConnectionTest, AckNotifierFailToTriggerCallback) {
3635 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 3635 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
3636 3636
3637 // Create a delegate which we don't expect to be called. 3637 // Create a delegate which we don't expect to be called.
3638 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); 3638 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate);
3639 EXPECT_CALL(*delegate, OnAckNotification(_, _, _, _)).Times(0); 3639 EXPECT_CALL(*delegate, OnAckNotification(_, _, _, _, _)).Times(0);
3640 3640
3641 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); 3641 EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
3642 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(2); 3642 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(2);
3643 3643
3644 // Send some data, which will register the delegate to be notified. This will 3644 // Send some data, which will register the delegate to be notified. This will
3645 // not be ACKed and so the delegate should never be called. 3645 // not be ACKed and so the delegate should never be called.
3646 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get()); 3646 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get());
3647 3647
3648 // Send some other data which we will ACK. 3648 // Send some other data which we will ACK.
3649 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); 3649 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL);
(...skipping 10 matching lines...) Expand all
3660 EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)); 3660 EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _));
3661 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)); 3661 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _));
3662 ProcessAckPacket(&frame); 3662 ProcessAckPacket(&frame);
3663 } 3663 }
3664 3664
3665 TEST_P(QuicConnectionTest, AckNotifierCallbackAfterRetransmission) { 3665 TEST_P(QuicConnectionTest, AckNotifierCallbackAfterRetransmission) {
3666 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 3666 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
3667 3667
3668 // Create a delegate which we expect to be called. 3668 // Create a delegate which we expect to be called.
3669 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); 3669 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate);
3670 EXPECT_CALL(*delegate, OnAckNotification(_, _, _, _)).Times(1); 3670 EXPECT_CALL(*delegate, OnAckNotification(_, _, _, _, _)).Times(1);
3671 3671
3672 // Send four packets, and register to be notified on ACK of packet 2. 3672 // Send four packets, and register to be notified on ACK of packet 2.
3673 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); 3673 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL);
3674 connection_.SendStreamDataWithString(3, "bar", 0, !kFin, delegate.get()); 3674 connection_.SendStreamDataWithString(3, "bar", 0, !kFin, delegate.get());
3675 connection_.SendStreamDataWithString(3, "baz", 0, !kFin, NULL); 3675 connection_.SendStreamDataWithString(3, "baz", 0, !kFin, NULL);
3676 connection_.SendStreamDataWithString(3, "qux", 0, !kFin, NULL); 3676 connection_.SendStreamDataWithString(3, "qux", 0, !kFin, NULL);
3677 3677
3678 // Now we receive ACK for packets 1, 3, and 4 and lose 2. 3678 // Now we receive ACK for packets 1, 3, and 4 and lose 2.
3679 QuicAckFrame frame = InitAckFrame(4, 0); 3679 QuicAckFrame frame = InitAckFrame(4, 0);
3680 NackPacket(2, &frame); 3680 NackPacket(2, &frame);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3722 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); 3722 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
3723 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, 2u, _, _)); 3723 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, 2u, _, _));
3724 connection_.GetRetransmissionAlarm()->Fire(); 3724 connection_.GetRetransmissionAlarm()->Fire();
3725 EXPECT_EQ(2u, last_header()->packet_sequence_number); 3725 EXPECT_EQ(2u, last_header()->packet_sequence_number);
3726 // We do not raise the high water mark yet. 3726 // We do not raise the high water mark yet.
3727 EXPECT_EQ(1u, outgoing_ack()->sent_info.least_unacked); 3727 EXPECT_EQ(1u, outgoing_ack()->sent_info.least_unacked);
3728 3728
3729 // Ack the original packet. 3729 // Ack the original packet.
3730 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 3730 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
3731 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); 3731 EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
3732 EXPECT_CALL(*delegate, OnAckNotification(1, _, 1, _)); 3732 EXPECT_CALL(*delegate, OnAckNotification(1, _, 1, _, _));
3733 QuicAckFrame ack_frame = InitAckFrame(1, 0); 3733 QuicAckFrame ack_frame = InitAckFrame(1, 0);
3734 ProcessAckPacket(&ack_frame); 3734 ProcessAckPacket(&ack_frame);
3735 3735
3736 // Delegate is not notified again when the retransmit is acked. 3736 // Delegate is not notified again when the retransmit is acked.
3737 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); 3737 EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
3738 EXPECT_CALL(*send_algorithm_, OnPacketAcked(2, _)); 3738 EXPECT_CALL(*send_algorithm_, OnPacketAcked(2, _));
3739 QuicAckFrame second_ack_frame = InitAckFrame(2, 0); 3739 QuicAckFrame second_ack_frame = InitAckFrame(2, 0);
3740 ProcessAckPacket(&second_ack_frame); 3740 ProcessAckPacket(&second_ack_frame);
3741 } 3741 }
3742 3742
(...skipping 25 matching lines...) Expand all
3768 EXPECT_CALL(*send_algorithm_, OnPacketAcked(4, _)); 3768 EXPECT_CALL(*send_algorithm_, OnPacketAcked(4, _));
3769 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) 3769 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
3770 .WillOnce(Return(lost_packets)); 3770 .WillOnce(Return(lost_packets));
3771 EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _)); 3771 EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _));
3772 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)); 3772 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _));
3773 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)); 3773 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _));
3774 ProcessAckPacket(&frame); 3774 ProcessAckPacket(&frame);
3775 3775
3776 // Now we get an ACK for packet 2, which was previously nacked. 3776 // Now we get an ACK for packet 2, which was previously nacked.
3777 SequenceNumberSet no_lost_packets; 3777 SequenceNumberSet no_lost_packets;
3778 EXPECT_CALL(*delegate, OnAckNotification(1, _, 1, _)); 3778 EXPECT_CALL(*delegate, OnAckNotification(1, _, 1, _, _));
3779 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) 3779 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
3780 .WillOnce(Return(no_lost_packets)); 3780 .WillOnce(Return(no_lost_packets));
3781 QuicAckFrame second_ack_frame = InitAckFrame(4, 0); 3781 QuicAckFrame second_ack_frame = InitAckFrame(4, 0);
3782 ProcessAckPacket(&second_ack_frame); 3782 ProcessAckPacket(&second_ack_frame);
3783 3783
3784 // Verify that the delegate is not notified again when the 3784 // Verify that the delegate is not notified again when the
3785 // retransmit is acked. 3785 // retransmit is acked.
3786 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); 3786 EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
3787 EXPECT_CALL(*send_algorithm_, OnPacketAcked(5, _)); 3787 EXPECT_CALL(*send_algorithm_, OnPacketAcked(5, _));
3788 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) 3788 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
3789 .WillOnce(Return(no_lost_packets)); 3789 .WillOnce(Return(no_lost_packets));
3790 QuicAckFrame third_ack_frame = InitAckFrame(5, 0); 3790 QuicAckFrame third_ack_frame = InitAckFrame(5, 0);
3791 ProcessAckPacket(&third_ack_frame); 3791 ProcessAckPacket(&third_ack_frame);
3792 } 3792 }
3793 3793
3794 // TODO(rjshade): Add a similar test that FEC recovery on peer (and resulting 3794 // TODO(rjshade): Add a similar test that FEC recovery on peer (and resulting
3795 // ACK) triggers notification on our end. 3795 // ACK) triggers notification on our end.
3796 TEST_P(QuicConnectionTest, AckNotifierCallbackAfterFECRecovery) { 3796 TEST_P(QuicConnectionTest, AckNotifierCallbackAfterFECRecovery) {
3797 if (version() < QUIC_VERSION_15) { 3797 if (version() < QUIC_VERSION_15) {
3798 return; 3798 return;
3799 } 3799 }
3800 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 3800 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
3801 EXPECT_CALL(visitor_, OnCanWrite()); 3801 EXPECT_CALL(visitor_, OnCanWrite());
3802 3802
3803 // Create a delegate which we expect to be called. 3803 // Create a delegate which we expect to be called.
3804 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); 3804 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate);
3805 EXPECT_CALL(*delegate, OnAckNotification(_, _, _, _)).Times(1); 3805 EXPECT_CALL(*delegate, OnAckNotification(_, _, _, _, _)).Times(1);
3806 3806
3807 // Expect ACKs for 1 packet. 3807 // Expect ACKs for 1 packet.
3808 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); 3808 EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
3809 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1); 3809 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1);
3810 3810
3811 // Send one packet, and register to be notified on ACK. 3811 // Send one packet, and register to be notified on ACK.
3812 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get()); 3812 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get());
3813 3813
3814 // Ack packet gets dropped, but we receive an FEC packet that covers it. 3814 // Ack packet gets dropped, but we receive an FEC packet that covers it.
3815 // Should recover the Ack packet and trigger the notification callback. 3815 // Should recover the Ack packet and trigger the notification callback.
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
3951 TestConnection connection(connection_id_, IPEndPoint(), helper_.get(), 3951 TestConnection connection(connection_id_, IPEndPoint(), helper_.get(),
3952 writer_.get(), true, version(), 3952 writer_.get(), true, version(),
3953 kSmallerFlowControlWindow); 3953 kSmallerFlowControlWindow);
3954 EXPECT_EQ(kDefaultFlowControlSendWindow, 3954 EXPECT_EQ(kDefaultFlowControlSendWindow,
3955 connection.max_flow_control_receive_window_bytes()); 3955 connection.max_flow_control_receive_window_bytes());
3956 } 3956 }
3957 3957
3958 } // namespace 3958 } // namespace
3959 } // namespace test 3959 } // namespace test
3960 } // namespace net 3960 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_crypto_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698