| Index: net/quic/congestion_control/windowed_filter_test.cc
|
| diff --git a/net/quic/congestion_control/windowed_filter_test.cc b/net/quic/congestion_control/windowed_filter_test.cc
|
| index 5c09e7c5732b07e67db6ee29406d29350d419e0a..fd540d0c5ef8e60288db51eca5470248896ff6fb 100644
|
| --- a/net/quic/congestion_control/windowed_filter_test.cc
|
| +++ b/net/quic/congestion_control/windowed_filter_test.cc
|
| @@ -19,9 +19,11 @@ class WindowedFilterTest : public ::testing::Test {
|
| // Set the window to 99ms, so 25ms is more than a quarter rtt.
|
| WindowedFilterTest()
|
| : windowed_min_rtt_(QuicTime::Delta::FromMilliseconds(99),
|
| - QuicTime::Delta::Zero()),
|
| + QuicTime::Delta::Zero(),
|
| + QuicTime::Zero()),
|
| windowed_max_bw_(QuicTime::Delta::FromMilliseconds(99),
|
| - QuicBandwidth::Zero()) {}
|
| + QuicBandwidth::Zero(),
|
| + QuicTime::Zero()) {}
|
|
|
| // Sets up windowed_min_rtt_ to have the following values:
|
| // Best = 20ms, recorded at 25ms
|
| @@ -74,10 +76,31 @@ class WindowedFilterTest : public ::testing::Test {
|
| }
|
|
|
| protected:
|
| - WindowedFilter<QuicTime::Delta, MinFilter<QuicTime::Delta>> windowed_min_rtt_;
|
| - WindowedFilter<QuicBandwidth, MaxFilter<QuicBandwidth>> windowed_max_bw_;
|
| + WindowedFilter<QuicTime::Delta,
|
| + MinFilter<QuicTime::Delta>,
|
| + QuicTime,
|
| + QuicTime::Delta>
|
| + windowed_min_rtt_;
|
| + WindowedFilter<QuicBandwidth,
|
| + MaxFilter<QuicBandwidth>,
|
| + QuicTime,
|
| + QuicTime::Delta>
|
| + windowed_max_bw_;
|
| };
|
|
|
| +namespace {
|
| +// Test helper function: updates the filter with a lot of small values in order
|
| +// to ensure that it is not susceptible to noise.
|
| +void UpdateWithIrrelevantSamples(
|
| + WindowedFilter<uint64_t, MaxFilter<uint64_t>, uint64_t, uint64_t>* filter,
|
| + uint64_t max_value,
|
| + uint64_t time) {
|
| + for (uint64_t i = 0; i < 1000; i++) {
|
| + filter->Update(i % max_value, time);
|
| + }
|
| +}
|
| +} // namespace
|
| +
|
| TEST_F(WindowedFilterTest, UninitializedEstimates) {
|
| EXPECT_EQ(QuicTime::Delta::Zero(), windowed_min_rtt_.GetBest());
|
| EXPECT_EQ(QuicTime::Delta::Zero(), windowed_min_rtt_.GetSecondBest());
|
| @@ -159,6 +182,7 @@ TEST_F(WindowedFilterTest, SampleChangesThirdBestMin) {
|
| // Latest sample was recorded at 100ms.
|
| QuicTime now = QuicTime::Zero() + QuicTime::Delta::FromMilliseconds(101);
|
| windowed_min_rtt_.Update(rtt_sample, now);
|
| + windowed_min_rtt_.Update(rtt_sample, now);
|
| EXPECT_EQ(rtt_sample, windowed_min_rtt_.GetThirdBest());
|
| EXPECT_EQ(QuicTime::Delta::FromMilliseconds(40),
|
| windowed_min_rtt_.GetSecondBest());
|
| @@ -325,6 +349,44 @@ TEST_F(WindowedFilterTest, ExpireAllMaxs) {
|
| EXPECT_EQ(bw_sample, windowed_max_bw_.GetBest());
|
| }
|
|
|
| +// Test the windowed filter where the time used is an exact counter instead of a
|
| +// timestamp. This is useful if, for example, the time is measured in round
|
| +// trips.
|
| +TEST_F(WindowedFilterTest, ExpireCounterBasedMax) {
|
| + // Create a window which starts at t = 0 and expires after two cycles.
|
| + WindowedFilter<uint64_t, MaxFilter<uint64_t>, uint64_t, uint64_t> max_filter(
|
| + 2, 0, 0);
|
| +
|
| + // Insert 50000 at t = 1.
|
| + const uint64_t kBest = 50000;
|
| + max_filter.Update(50000, 1);
|
| + EXPECT_EQ(kBest, max_filter.GetBest());
|
| + UpdateWithIrrelevantSamples(&max_filter, 20, 1);
|
| + EXPECT_EQ(kBest, max_filter.GetBest());
|
| +
|
| + // Insert 40000 at t = 2. Nothing is expected to expire.
|
| + max_filter.Update(40000, 2);
|
| + EXPECT_EQ(kBest, max_filter.GetBest());
|
| + UpdateWithIrrelevantSamples(&max_filter, 20, 2);
|
| + EXPECT_EQ(kBest, max_filter.GetBest());
|
| +
|
| + // Insert 30000 at t = 3. Nothing is expected to expire yet.
|
| + max_filter.Update(30000, 3);
|
| + EXPECT_EQ(kBest, max_filter.GetBest());
|
| + UpdateWithIrrelevantSamples(&max_filter, 20, 3);
|
| + EXPECT_EQ(kBest, max_filter.GetBest());
|
| + VLOG(0) << max_filter.GetSecondBest();
|
| + VLOG(0) << max_filter.GetThirdBest();
|
| +
|
| + // Insert 20000 at t = 4. 50000 at t = 1 expires, so 40000 becomes the new
|
| + // maximum.
|
| + const uint64_t kNewBest = 40000;
|
| + max_filter.Update(20000, 4);
|
| + EXPECT_EQ(kNewBest, max_filter.GetBest());
|
| + UpdateWithIrrelevantSamples(&max_filter, 20, 4);
|
| + EXPECT_EQ(kNewBest, max_filter.GetBest());
|
| +}
|
| +
|
| } // namespace
|
| } // namespace test
|
| } // namespace net
|
|
|