Index: net/quic/congestion_control/pacing_sender_test.cc |
diff --git a/net/quic/congestion_control/pacing_sender_test.cc b/net/quic/congestion_control/pacing_sender_test.cc |
index 768cc22165cb4c695cb2e0ccdb152102bf721ab2..f887c542fd689fd98081c9ecb72cdd65c9224ea5 100644 |
--- a/net/quic/congestion_control/pacing_sender_test.cc |
+++ b/net/quic/congestion_control/pacing_sender_test.cc |
@@ -19,6 +19,7 @@ namespace net { |
namespace test { |
const QuicByteCount kBytesInFlight = 1024; |
+const int kInitialBurstPackets = 10; |
class PacingSenderTest : public ::testing::Test { |
protected: |
@@ -142,11 +143,6 @@ TEST_F(PacingSenderTest, VariousSending) { |
.WillRepeatedly(Return(QuicBandwidth::FromBytesAndTimeDelta( |
kMaxPacketSize, QuicTime::Delta::FromMilliseconds(2)))); |
- // Send a whole pile of packets, and verify that they are not paced. |
- for (int i = 0 ; i < 1000; ++i) { |
- CheckPacketIsSentImmediately(); |
- } |
- |
// Now update the RTT and verify that packets are actually paced. |
EXPECT_CALL(*mock_sender_, OnCongestionEvent(true, kBytesInFlight, _, _)); |
SendAlgorithmInterface::CongestionVector empty_map; |
@@ -217,11 +213,6 @@ TEST_F(PacingSenderTest, CongestionAvoidanceSending) { |
.WillRepeatedly(Return(QuicBandwidth::FromBytesAndTimeDelta( |
kMaxPacketSize, QuicTime::Delta::FromMilliseconds(2)))); |
- // Send a whole pile of packets, and verify that they are not paced. |
- for (int i = 0 ; i < 1000; ++i) { |
- CheckPacketIsSentImmediately(); |
- } |
- |
// Now update the RTT and verify that packets are actually paced. |
EXPECT_CALL(*mock_sender_, OnCongestionEvent(true, kBytesInFlight, _, _)); |
SendAlgorithmInterface::CongestionVector empty_map; |
@@ -296,17 +287,71 @@ TEST_F(PacingSenderTest, InitialBurst) { |
pacing_sender_->OnCongestionEvent(true, kBytesInFlight, empty_map, empty_map); |
// Send 10 packets, and verify that they are not paced. |
- for (int i = 0 ; i < 10; ++i) { |
+ for (int i = 0 ; i < kInitialBurstPackets; ++i) { |
CheckPacketIsSentImmediately(); |
} |
+ // The first packet was a "make up", then we sent two packets "into the |
+ // future", so the delay should be 2ms. |
CheckPacketIsSentImmediately(); |
CheckPacketIsSentImmediately(); |
CheckPacketIsSentImmediately(); |
+ CheckPacketIsDelayed(QuicTime::Delta::FromMilliseconds(2)); |
+ |
+ clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); |
+ CheckPacketIsSentImmediately(); |
+ |
+ // Next time TimeUntilSend is called with no bytes in flight, the tokens |
+ // should be refilled and there should be no delay. |
+ EXPECT_CALL(*mock_sender_, |
+ TimeUntilSend(clock_.Now(), |
+ 0, |
+ HAS_RETRANSMITTABLE_DATA)). |
+ WillOnce(Return(zero_time_)); |
+ EXPECT_EQ(zero_time_, |
+ pacing_sender_->TimeUntilSend(clock_.Now(), |
+ 0, |
+ HAS_RETRANSMITTABLE_DATA)); |
+ for (int i = 0 ; i < kInitialBurstPackets; ++i) { |
+ CheckPacketIsSentImmediately(); |
+ } |
// The first packet was a "make up", then we sent two packets "into the |
- // future", so the delay should be 2. |
+ // future", so the delay should be 2ms. |
+ CheckPacketIsSentImmediately(); |
+ CheckPacketIsSentImmediately(); |
+ CheckPacketIsSentImmediately(); |
CheckPacketIsDelayed(QuicTime::Delta::FromMilliseconds(2)); |
+} |
+ |
+TEST_F(PacingSenderTest, InitialBurstNoRttMeasurement) { |
+ pacing_sender_.reset(); |
+ mock_sender_ = new StrictMock<MockSendAlgorithm>(); |
+ pacing_sender_.reset(new PacingSender(mock_sender_, |
+ QuicTime::Delta::FromMilliseconds(1), |
+ 10)); |
+ // Start the test in slow start. |
+ EXPECT_CALL(*mock_sender_, InSlowStart()).WillRepeatedly(Return(true)); |
+ |
+ // Configure bandwith of 1 packet per 2 ms, for which the pacing rate |
+ // will be 1 packet per 1 ms. |
+ EXPECT_CALL(*mock_sender_, BandwidthEstimate()) |
+ .WillRepeatedly(Return(QuicBandwidth::FromBytesAndTimeDelta( |
+ kMaxPacketSize, QuicTime::Delta::FromMilliseconds(2)))); |
+ |
+ // Send 10 packets, and verify that they are not paced. |
+ for (int i = 0 ; i < kInitialBurstPackets; ++i) { |
+ CheckPacketIsSentImmediately(); |
+ } |
+ |
+ // The first packet was a "make up", then we sent two packets "into the |
+ // future", so the delay should be 2ms. |
+ CheckPacketIsSentImmediately(); |
+ CheckPacketIsSentImmediately(); |
+ CheckPacketIsSentImmediately(); |
+ CheckPacketIsDelayed(QuicTime::Delta::FromMilliseconds(2)); |
+ |
+ |
clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); |
CheckPacketIsSentImmediately(); |
@@ -321,14 +366,16 @@ TEST_F(PacingSenderTest, InitialBurst) { |
pacing_sender_->TimeUntilSend(clock_.Now(), |
0, |
HAS_RETRANSMITTABLE_DATA)); |
- for (int i = 0 ; i < 10; ++i) { |
+ // Send 10 packets, and verify that they are not paced. |
+ for (int i = 0 ; i < kInitialBurstPackets; ++i) { |
CheckPacketIsSentImmediately(); |
} |
+ // The first packet was a "make up", then we sent two packets "into the |
+ // future", so the delay should be 2ms. |
CheckPacketIsSentImmediately(); |
CheckPacketIsSentImmediately(); |
CheckPacketIsSentImmediately(); |
- |
CheckPacketIsDelayed(QuicTime::Delta::FromMilliseconds(2)); |
} |