Index: net/quic/congestion_control/time_loss_algorithm_test.cc |
diff --git a/net/quic/congestion_control/time_loss_algorithm_test.cc b/net/quic/congestion_control/time_loss_algorithm_test.cc |
index 0ccd305619aef725efa72bbb6c01294f4edf8620..ffca81602d30aa02c15c84e3b228dd9bb156fb28 100644 |
--- a/net/quic/congestion_control/time_loss_algorithm_test.cc |
+++ b/net/quic/congestion_control/time_loss_algorithm_test.cc |
@@ -6,6 +6,7 @@ |
#include "base/logging.h" |
#include "base/stl_util.h" |
+#include "net/quic/congestion_control/rtt_stats.h" |
#include "net/quic/congestion_control/time_loss_algorithm.h" |
#include "net/quic/quic_unacked_packet_map.h" |
#include "net/quic/test_tools/mock_clock.h" |
@@ -18,8 +19,10 @@ namespace { |
class TimeLossAlgorithmTest : public ::testing::Test { |
protected: |
TimeLossAlgorithmTest() |
- : unacked_packets_(true), |
- srtt_(QuicTime::Delta::FromMilliseconds(100)) { } |
+ : unacked_packets_() { |
+ rtt_stats_.UpdateRtt(QuicTime::Delta::FromMilliseconds(100), |
+ QuicTime::Delta::Zero()); |
+ } |
void SendDataPacket(QuicPacketSequenceNumber sequence_number) { |
SerializedPacket packet(sequence_number, PACKET_1BYTE_SEQUENCE_NUMBER, |
@@ -33,7 +36,7 @@ class TimeLossAlgorithmTest : public ::testing::Test { |
size_t num_losses) { |
SequenceNumberSet lost_packets = |
loss_algorithm_.DetectLostPackets( |
- unacked_packets_, clock_.Now(), largest_observed, srtt_, srtt_); |
+ unacked_packets_, clock_.Now(), largest_observed, rtt_stats_); |
EXPECT_EQ(num_losses, lost_packets.size()); |
for (size_t i = 0; i < num_losses; ++i) { |
EXPECT_TRUE(ContainsKey(lost_packets, losses_expected[i])); |
@@ -42,7 +45,7 @@ class TimeLossAlgorithmTest : public ::testing::Test { |
QuicUnackedPacketMap unacked_packets_; |
TimeLossAlgorithm loss_algorithm_; |
- QuicTime::Delta srtt_; |
+ RttStats rtt_stats_; |
MockClock clock_; |
}; |
@@ -57,7 +60,7 @@ TEST_F(TimeLossAlgorithmTest, NoLossFor500Nacks) { |
unacked_packets_.NackPacket(1, i); |
VerifyLosses(2, NULL, 0); |
} |
- EXPECT_EQ(srtt_.Multiply(1.25), |
+ EXPECT_EQ(rtt_stats_.SmoothedRtt().Multiply(1.25), |
loss_algorithm_.GetLossTimeout().Subtract(clock_.Now())); |
} |
@@ -66,7 +69,7 @@ TEST_F(TimeLossAlgorithmTest, NoLossUntilTimeout) { |
// Transmit 10 packets at 1/10th an RTT interval. |
for (size_t i = 1; i <= kNumSentPackets; ++i) { |
SendDataPacket(i); |
- clock_.AdvanceTime(srtt_.Multiply(0.1)); |
+ clock_.AdvanceTime(rtt_stats_.SmoothedRtt().Multiply(0.1)); |
} |
// Expect the timer to not be set. |
EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); |
@@ -75,11 +78,11 @@ TEST_F(TimeLossAlgorithmTest, NoLossUntilTimeout) { |
unacked_packets_.SetNotPending(2); |
VerifyLosses(2, NULL, 0); |
// Expect the timer to be set to 0.25 RTT's in the future. |
- EXPECT_EQ(srtt_.Multiply(0.25), |
+ EXPECT_EQ(rtt_stats_.SmoothedRtt().Multiply(0.25), |
loss_algorithm_.GetLossTimeout().Subtract(clock_.Now())); |
unacked_packets_.NackPacket(1, 5); |
VerifyLosses(2, NULL, 0); |
- clock_.AdvanceTime(srtt_.Multiply(0.25)); |
+ clock_.AdvanceTime(rtt_stats_.SmoothedRtt().Multiply(0.25)); |
QuicPacketSequenceNumber lost[] = { 1 }; |
VerifyLosses(2, lost, arraysize(lost)); |
EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); |
@@ -90,7 +93,7 @@ TEST_F(TimeLossAlgorithmTest, NoLossWithoutNack) { |
// Transmit 10 packets at 1/10th an RTT interval. |
for (size_t i = 1; i <= kNumSentPackets; ++i) { |
SendDataPacket(i); |
- clock_.AdvanceTime(srtt_.Multiply(0.1)); |
+ clock_.AdvanceTime(rtt_stats_.SmoothedRtt().Multiply(0.1)); |
} |
// Expect the timer to not be set. |
EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); |
@@ -99,9 +102,9 @@ TEST_F(TimeLossAlgorithmTest, NoLossWithoutNack) { |
VerifyLosses(1, NULL, 0); |
// The timer should still not be set. |
EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); |
- clock_.AdvanceTime(srtt_.Multiply(0.25)); |
+ clock_.AdvanceTime(rtt_stats_.SmoothedRtt().Multiply(0.25)); |
VerifyLosses(1, NULL, 0); |
- clock_.AdvanceTime(srtt_); |
+ clock_.AdvanceTime(rtt_stats_.SmoothedRtt()); |
VerifyLosses(1, NULL, 0); |
EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); |
@@ -113,7 +116,7 @@ TEST_F(TimeLossAlgorithmTest, MultipleLossesAtOnce) { |
for (size_t i = 1; i <= kNumSentPackets; ++i) { |
SendDataPacket(i); |
} |
- clock_.AdvanceTime(srtt_); |
+ clock_.AdvanceTime(rtt_stats_.SmoothedRtt()); |
// Expect the timer to not be set. |
EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); |
// The packet should not be lost until 1.25 RTTs pass. |
@@ -123,9 +126,9 @@ TEST_F(TimeLossAlgorithmTest, MultipleLossesAtOnce) { |
unacked_packets_.SetNotPending(10); |
VerifyLosses(10, NULL, 0); |
// Expect the timer to be set to 0.25 RTT's in the future. |
- EXPECT_EQ(srtt_.Multiply(0.25), |
+ EXPECT_EQ(rtt_stats_.SmoothedRtt().Multiply(0.25), |
loss_algorithm_.GetLossTimeout().Subtract(clock_.Now())); |
- clock_.AdvanceTime(srtt_.Multiply(0.25)); |
+ clock_.AdvanceTime(rtt_stats_.SmoothedRtt().Multiply(0.25)); |
QuicPacketSequenceNumber lost[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; |
VerifyLosses(10, lost, arraysize(lost)); |
EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); |