| Index: remoting/base/rate_counter_unittest.cc
|
| diff --git a/remoting/base/rate_counter_unittest.cc b/remoting/base/rate_counter_unittest.cc
|
| index 91b91c511ad06e9778cc5dc2a24a794d52e7f5fe..8d4188ec98db686fefd3442eb7bce2f3c815bcd1 100644
|
| --- a/remoting/base/rate_counter_unittest.cc
|
| +++ b/remoting/base/rate_counter_unittest.cc
|
| @@ -6,6 +6,7 @@
|
| #include <stdint.h>
|
|
|
| #include "base/macros.h"
|
| +#include "base/test/simple_test_tick_clock.h"
|
| #include "remoting/base/rate_counter.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| @@ -18,10 +19,11 @@ TEST(RateCounterTest, OneSecondWindow) {
|
| RateCounter rate_counter(base::TimeDelta::FromSeconds(1));
|
| EXPECT_EQ(0, rate_counter.Rate());
|
|
|
| - base::Time now = base::Time::Now();
|
| + base::SimpleTestTickClock tick_clock;
|
| + rate_counter.set_tick_clock_for_tests(&tick_clock);
|
| +
|
| for (size_t i = 0; i < arraysize(kTestValues); ++i) {
|
| - now += base::TimeDelta::FromSeconds(1);
|
| - rate_counter.SetCurrentTimeForTest(now);
|
| + tick_clock.Advance(base::TimeDelta::FromSeconds(1));
|
| rate_counter.Record(kTestValues[i]);
|
| EXPECT_EQ(static_cast<double>(kTestValues[i]), rate_counter.Rate());
|
| }
|
| @@ -32,7 +34,8 @@ TEST(RateCounterTest, OneSecondWindowAllSamples) {
|
| RateCounter rate_counter(base::TimeDelta::FromSeconds(1));
|
| EXPECT_EQ(0, rate_counter.Rate());
|
|
|
| - rate_counter.SetCurrentTimeForTest(base::Time::Now());
|
| + base::SimpleTestTickClock tick_clock;
|
| + rate_counter.set_tick_clock_for_tests(&tick_clock);
|
|
|
| double expected = 0.0;
|
| for (size_t i = 0; i < arraysize(kTestValues); ++i) {
|
| @@ -50,10 +53,11 @@ TEST(RateCounterTest, TwoSecondWindow) {
|
| RateCounter rate_counter(base::TimeDelta::FromSeconds(2));
|
| EXPECT_EQ(0, rate_counter.Rate());
|
|
|
| - base::Time now = base::Time::Now();
|
| + base::SimpleTestTickClock tick_clock;
|
| + rate_counter.set_tick_clock_for_tests(&tick_clock);
|
| +
|
| for (size_t i = 0; i < arraysize(kTestValues); ++i) {
|
| - now += base::TimeDelta::FromSeconds(1);
|
| - rate_counter.SetCurrentTimeForTest(now);
|
| + tick_clock.Advance(base::TimeDelta::FromSeconds(1));
|
| rate_counter.Record(kTestValues[i]);
|
| double expected = kTestValues[i];
|
| if (i > 0)
|
| @@ -71,11 +75,12 @@ TEST(RateCounterTest, LongWindow) {
|
| RateCounter rate_counter(base::TimeDelta::FromSeconds(kWindowSeconds));
|
| EXPECT_EQ(0, rate_counter.Rate());
|
|
|
| + base::SimpleTestTickClock tick_clock;
|
| + rate_counter.set_tick_clock_for_tests(&tick_clock);
|
| +
|
| double expected = 0.0;
|
| - base::Time now = base::Time::Now();
|
| for (size_t i = 0; i < arraysize(kTestValues); ++i) {
|
| - now += base::TimeDelta::FromSeconds(1);
|
| - rate_counter.SetCurrentTimeForTest(now);
|
| + tick_clock.Advance(base::TimeDelta::FromSeconds(1));
|
| rate_counter.Record(kTestValues[i]);
|
| if (i != 0)
|
| expected += kTestValues[i];
|
|
|