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

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

Issue 197473012: Export QUIC response retransmit packet and byte counts via faster stats. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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_ack_notifier_test.cc ('k') | net/quic/test_tools/quic_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/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 3581 matching lines...) Expand 10 before | Expand all | Expand 10 after
3592 EXPECT_TRUE(writer_->IsWriteBlocked()); 3592 EXPECT_TRUE(writer_->IsWriteBlocked());
3593 TriggerConnectionClose(); 3593 TriggerConnectionClose();
3594 EXPECT_EQ(1u, writer_->packets_write_attempts()); 3594 EXPECT_EQ(1u, writer_->packets_write_attempts());
3595 } 3595 }
3596 3596
3597 TEST_P(QuicConnectionTest, AckNotifierTriggerCallback) { 3597 TEST_P(QuicConnectionTest, AckNotifierTriggerCallback) {
3598 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 3598 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
3599 3599
3600 // Create a delegate which we expect to be called. 3600 // Create a delegate which we expect to be called.
3601 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); 3601 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate);
3602 EXPECT_CALL(*delegate, OnAckNotification()).Times(1); 3602 EXPECT_CALL(*delegate, OnAckNotification(_, _, _, _)).Times(1);
3603 3603
3604 // Send some data, which will register the delegate to be notified. 3604 // Send some data, which will register the delegate to be notified.
3605 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get()); 3605 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get());
3606 3606
3607 // Process an ACK from the server which should trigger the callback. 3607 // Process an ACK from the server which should trigger the callback.
3608 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); 3608 EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
3609 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1); 3609 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1);
3610 QuicAckFrame frame = InitAckFrame(1, 0); 3610 QuicAckFrame frame = InitAckFrame(1, 0);
3611 ProcessAckPacket(&frame); 3611 ProcessAckPacket(&frame);
3612 } 3612 }
3613 3613
3614 TEST_P(QuicConnectionTest, AckNotifierFailToTriggerCallback) { 3614 TEST_P(QuicConnectionTest, AckNotifierFailToTriggerCallback) {
3615 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 3615 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
3616 3616
3617 // Create a delegate which we don't expect to be called. 3617 // Create a delegate which we don't expect to be called.
3618 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); 3618 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate);
3619 EXPECT_CALL(*delegate, OnAckNotification()).Times(0); 3619 EXPECT_CALL(*delegate, OnAckNotification(_, _, _, _)).Times(0);
3620 3620
3621 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); 3621 EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
3622 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(2); 3622 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(2);
3623 3623
3624 // Send some data, which will register the delegate to be notified. This will 3624 // Send some data, which will register the delegate to be notified. This will
3625 // not be ACKed and so the delegate should never be called. 3625 // not be ACKed and so the delegate should never be called.
3626 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get()); 3626 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get());
3627 3627
3628 // Send some other data which we will ACK. 3628 // Send some other data which we will ACK.
3629 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); 3629 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL);
(...skipping 10 matching lines...) Expand all
3640 EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)); 3640 EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _));
3641 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)); 3641 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _));
3642 ProcessAckPacket(&frame); 3642 ProcessAckPacket(&frame);
3643 } 3643 }
3644 3644
3645 TEST_P(QuicConnectionTest, AckNotifierCallbackAfterRetransmission) { 3645 TEST_P(QuicConnectionTest, AckNotifierCallbackAfterRetransmission) {
3646 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 3646 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
3647 3647
3648 // Create a delegate which we expect to be called. 3648 // Create a delegate which we expect to be called.
3649 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); 3649 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate);
3650 EXPECT_CALL(*delegate, OnAckNotification()).Times(1); 3650 EXPECT_CALL(*delegate, OnAckNotification(_, _, _, _)).Times(1);
3651 3651
3652 // Send four packets, and register to be notified on ACK of packet 2. 3652 // Send four packets, and register to be notified on ACK of packet 2.
3653 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); 3653 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL);
3654 connection_.SendStreamDataWithString(3, "bar", 0, !kFin, delegate.get()); 3654 connection_.SendStreamDataWithString(3, "bar", 0, !kFin, delegate.get());
3655 connection_.SendStreamDataWithString(3, "baz", 0, !kFin, NULL); 3655 connection_.SendStreamDataWithString(3, "baz", 0, !kFin, NULL);
3656 connection_.SendStreamDataWithString(3, "qux", 0, !kFin, NULL); 3656 connection_.SendStreamDataWithString(3, "qux", 0, !kFin, NULL);
3657 3657
3658 // Now we receive ACK for packets 1, 3, and 4 and lose 2. 3658 // Now we receive ACK for packets 1, 3, and 4 and lose 2.
3659 QuicAckFrame frame = InitAckFrame(4, 0); 3659 QuicAckFrame frame = InitAckFrame(4, 0);
3660 NackPacket(2, &frame); 3660 NackPacket(2, &frame);
(...skipping 22 matching lines...) Expand all
3683 // ACK) triggers notification on our end. 3683 // ACK) triggers notification on our end.
3684 TEST_P(QuicConnectionTest, AckNotifierCallbackAfterFECRecovery) { 3684 TEST_P(QuicConnectionTest, AckNotifierCallbackAfterFECRecovery) {
3685 if (version() < QUIC_VERSION_15) { 3685 if (version() < QUIC_VERSION_15) {
3686 return; 3686 return;
3687 } 3687 }
3688 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 3688 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
3689 EXPECT_CALL(visitor_, OnCanWrite()); 3689 EXPECT_CALL(visitor_, OnCanWrite());
3690 3690
3691 // Create a delegate which we expect to be called. 3691 // Create a delegate which we expect to be called.
3692 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); 3692 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate);
3693 EXPECT_CALL(*delegate, OnAckNotification()).Times(1); 3693 EXPECT_CALL(*delegate, OnAckNotification(_, _, _, _)).Times(1);
3694 3694
3695 // Expect ACKs for 1 packet. 3695 // Expect ACKs for 1 packet.
3696 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); 3696 EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
3697 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1); 3697 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1);
3698 3698
3699 // Send one packet, and register to be notified on ACK. 3699 // Send one packet, and register to be notified on ACK.
3700 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get()); 3700 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get());
3701 3701
3702 // Ack packet gets dropped, but we receive an FEC packet that covers it. 3702 // Ack packet gets dropped, but we receive an FEC packet that covers it.
3703 // Should recover the Ack packet and trigger the notification callback. 3703 // Should recover the Ack packet and trigger the notification callback.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
3825 QuicBlockedFrame blocked; 3825 QuicBlockedFrame blocked;
3826 blocked.stream_id = 3; 3826 blocked.stream_id = 3;
3827 EXPECT_CALL(visitor_, OnBlockedFrames(_)); 3827 EXPECT_CALL(visitor_, OnBlockedFrames(_));
3828 ProcessFramePacket(QuicFrame(&blocked)); 3828 ProcessFramePacket(QuicFrame(&blocked));
3829 EXPECT_TRUE(ack_alarm->IsSet()); 3829 EXPECT_TRUE(ack_alarm->IsSet());
3830 } 3830 }
3831 3831
3832 } // namespace 3832 } // namespace
3833 } // namespace test 3833 } // namespace test
3834 } // namespace net 3834 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_ack_notifier_test.cc ('k') | net/quic/test_tools/quic_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698