diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /third_party/libwebrtc/net/dcsctp/timer/timer_test.cc | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/net/dcsctp/timer/timer_test.cc')
-rw-r--r-- | third_party/libwebrtc/net/dcsctp/timer/timer_test.cc | 203 |
1 files changed, 103 insertions, 100 deletions
diff --git a/third_party/libwebrtc/net/dcsctp/timer/timer_test.cc b/third_party/libwebrtc/net/dcsctp/timer/timer_test.cc index 93876160bb..9a7c029ec5 100644 --- a/third_party/libwebrtc/net/dcsctp/timer/timer_test.cc +++ b/third_party/libwebrtc/net/dcsctp/timer/timer_test.cc @@ -13,6 +13,7 @@ #include "absl/types/optional.h" #include "api/task_queue/task_queue_base.h" +#include "api/units/time_delta.h" #include "net/dcsctp/public/timeout.h" #include "net/dcsctp/timer/fake_timeout.h" #include "rtc_base/gunit.h" @@ -21,6 +22,8 @@ namespace dcsctp { namespace { using ::testing::Return; +using ::webrtc::TimeDelta; +using ::webrtc::Timestamp; class TimerTest : public testing::Test { protected: @@ -29,10 +32,10 @@ class TimerTest : public testing::Test { manager_([this](webrtc::TaskQueueBase::DelayPrecision precision) { return timeout_manager_.CreateTimeout(precision); }) { - ON_CALL(on_expired_, Call).WillByDefault(Return(absl::nullopt)); + ON_CALL(on_expired_, Call).WillByDefault(Return(TimeDelta::Zero())); } - void AdvanceTimeAndRunTimers(DurationMs duration) { + void AdvanceTimeAndRunTimers(TimeDelta duration) { now_ = now_ + duration; for (;;) { @@ -45,16 +48,16 @@ class TimerTest : public testing::Test { } } - TimeMs now_ = TimeMs(0); + Timestamp now_ = Timestamp::Zero(); FakeTimeoutManager timeout_manager_; TimerManager manager_; - testing::MockFunction<absl::optional<DurationMs>()> on_expired_; + testing::MockFunction<TimeDelta()> on_expired_; }; TEST_F(TimerTest, TimerIsInitiallyStopped) { std::unique_ptr<Timer> t1 = manager_.CreateTimer( "t1", on_expired_.AsStdFunction(), - TimerOptions(DurationMs(5000), TimerBackoffAlgorithm::kFixed)); + TimerOptions(TimeDelta::Seconds(5), TimerBackoffAlgorithm::kFixed)); EXPECT_FALSE(t1->is_running()); } @@ -62,50 +65,50 @@ TEST_F(TimerTest, TimerIsInitiallyStopped) { TEST_F(TimerTest, TimerExpiresAtGivenTime) { std::unique_ptr<Timer> t1 = manager_.CreateTimer( "t1", on_expired_.AsStdFunction(), - TimerOptions(DurationMs(5000), TimerBackoffAlgorithm::kFixed)); + TimerOptions(TimeDelta::Seconds(5), TimerBackoffAlgorithm::kFixed)); EXPECT_CALL(on_expired_, Call).Times(0); t1->Start(); EXPECT_TRUE(t1->is_running()); - AdvanceTimeAndRunTimers(DurationMs(4000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(4)); EXPECT_CALL(on_expired_, Call).Times(1); - AdvanceTimeAndRunTimers(DurationMs(1000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(1)); } TEST_F(TimerTest, TimerReschedulesAfterExpiredWithFixedBackoff) { std::unique_ptr<Timer> t1 = manager_.CreateTimer( "t1", on_expired_.AsStdFunction(), - TimerOptions(DurationMs(5000), TimerBackoffAlgorithm::kFixed)); + TimerOptions(TimeDelta::Seconds(5), TimerBackoffAlgorithm::kFixed)); EXPECT_CALL(on_expired_, Call).Times(0); t1->Start(); EXPECT_EQ(t1->expiration_count(), 0); - AdvanceTimeAndRunTimers(DurationMs(4000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(4)); // Fire first time EXPECT_CALL(on_expired_, Call).Times(1); - AdvanceTimeAndRunTimers(DurationMs(1000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(1)); EXPECT_TRUE(t1->is_running()); EXPECT_EQ(t1->expiration_count(), 1); EXPECT_CALL(on_expired_, Call).Times(0); - AdvanceTimeAndRunTimers(DurationMs(4000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(4)); // Second time EXPECT_CALL(on_expired_, Call).Times(1); - AdvanceTimeAndRunTimers(DurationMs(1000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(1)); EXPECT_TRUE(t1->is_running()); EXPECT_EQ(t1->expiration_count(), 2); EXPECT_CALL(on_expired_, Call).Times(0); - AdvanceTimeAndRunTimers(DurationMs(4000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(4)); // Third time EXPECT_CALL(on_expired_, Call).Times(1); - AdvanceTimeAndRunTimers(DurationMs(1000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(1)); EXPECT_TRUE(t1->is_running()); EXPECT_EQ(t1->expiration_count(), 3); } @@ -113,151 +116,151 @@ TEST_F(TimerTest, TimerReschedulesAfterExpiredWithFixedBackoff) { TEST_F(TimerTest, TimerWithNoRestarts) { std::unique_ptr<Timer> t1 = manager_.CreateTimer( "t1", on_expired_.AsStdFunction(), - TimerOptions(DurationMs(5000), TimerBackoffAlgorithm::kFixed, + TimerOptions(TimeDelta::Seconds(5), TimerBackoffAlgorithm::kFixed, /*max_restart=*/0)); EXPECT_CALL(on_expired_, Call).Times(0); t1->Start(); - AdvanceTimeAndRunTimers(DurationMs(4000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(4)); // Fire first time EXPECT_CALL(on_expired_, Call).Times(1); - AdvanceTimeAndRunTimers(DurationMs(1000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(1)); EXPECT_FALSE(t1->is_running()); // Second time - shouldn't fire EXPECT_CALL(on_expired_, Call).Times(0); - AdvanceTimeAndRunTimers(DurationMs(5000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(5)); EXPECT_FALSE(t1->is_running()); } TEST_F(TimerTest, TimerWithOneRestart) { std::unique_ptr<Timer> t1 = manager_.CreateTimer( "t1", on_expired_.AsStdFunction(), - TimerOptions(DurationMs(5000), TimerBackoffAlgorithm::kFixed, + TimerOptions(TimeDelta::Seconds(5), TimerBackoffAlgorithm::kFixed, /*max_restart=*/1)); EXPECT_CALL(on_expired_, Call).Times(0); t1->Start(); - AdvanceTimeAndRunTimers(DurationMs(4000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(4)); // Fire first time EXPECT_CALL(on_expired_, Call).Times(1); - AdvanceTimeAndRunTimers(DurationMs(1000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(1)); EXPECT_TRUE(t1->is_running()); EXPECT_CALL(on_expired_, Call).Times(0); - AdvanceTimeAndRunTimers(DurationMs(4000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(4)); // Second time - max restart limit reached. EXPECT_CALL(on_expired_, Call).Times(1); - AdvanceTimeAndRunTimers(DurationMs(1000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(1)); EXPECT_FALSE(t1->is_running()); // Third time - should not fire. EXPECT_CALL(on_expired_, Call).Times(0); - AdvanceTimeAndRunTimers(DurationMs(5000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(5)); EXPECT_FALSE(t1->is_running()); } TEST_F(TimerTest, TimerWithTwoRestart) { std::unique_ptr<Timer> t1 = manager_.CreateTimer( "t1", on_expired_.AsStdFunction(), - TimerOptions(DurationMs(5000), TimerBackoffAlgorithm::kFixed, + TimerOptions(TimeDelta::Seconds(5), TimerBackoffAlgorithm::kFixed, /*max_restart=*/2)); EXPECT_CALL(on_expired_, Call).Times(0); t1->Start(); - AdvanceTimeAndRunTimers(DurationMs(4000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(4)); // Fire first time EXPECT_CALL(on_expired_, Call).Times(1); - AdvanceTimeAndRunTimers(DurationMs(1000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(1)); EXPECT_TRUE(t1->is_running()); EXPECT_CALL(on_expired_, Call).Times(0); - AdvanceTimeAndRunTimers(DurationMs(4000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(4)); // Second time EXPECT_CALL(on_expired_, Call).Times(1); - AdvanceTimeAndRunTimers(DurationMs(1000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(1)); EXPECT_TRUE(t1->is_running()); EXPECT_CALL(on_expired_, Call).Times(0); - AdvanceTimeAndRunTimers(DurationMs(4000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(4)); // Third time EXPECT_CALL(on_expired_, Call).Times(1); - AdvanceTimeAndRunTimers(DurationMs(1000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(1)); EXPECT_FALSE(t1->is_running()); } TEST_F(TimerTest, TimerWithExponentialBackoff) { std::unique_ptr<Timer> t1 = manager_.CreateTimer( "t1", on_expired_.AsStdFunction(), - TimerOptions(DurationMs(5000), TimerBackoffAlgorithm::kExponential)); + TimerOptions(TimeDelta::Seconds(5), TimerBackoffAlgorithm::kExponential)); t1->Start(); // Fire first time at 5 seconds EXPECT_CALL(on_expired_, Call).Times(1); - AdvanceTimeAndRunTimers(DurationMs(5000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(5)); // Second time at 5*2^1 = 10 seconds later. EXPECT_CALL(on_expired_, Call).Times(0); - AdvanceTimeAndRunTimers(DurationMs(9000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(9)); EXPECT_CALL(on_expired_, Call).Times(1); - AdvanceTimeAndRunTimers(DurationMs(1000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(1)); // Third time at 5*2^2 = 20 seconds later. EXPECT_CALL(on_expired_, Call).Times(0); - AdvanceTimeAndRunTimers(DurationMs(19000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(19)); EXPECT_CALL(on_expired_, Call).Times(1); - AdvanceTimeAndRunTimers(DurationMs(1000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(1)); // Fourth time at 5*2^3 = 40 seconds later. EXPECT_CALL(on_expired_, Call).Times(0); - AdvanceTimeAndRunTimers(DurationMs(39000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(39)); EXPECT_CALL(on_expired_, Call).Times(1); - AdvanceTimeAndRunTimers(DurationMs(1000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(1)); } TEST_F(TimerTest, StartTimerWillStopAndStart) { std::unique_ptr<Timer> t1 = manager_.CreateTimer( "t1", on_expired_.AsStdFunction(), - TimerOptions(DurationMs(5000), TimerBackoffAlgorithm::kExponential)); + TimerOptions(TimeDelta::Seconds(5), TimerBackoffAlgorithm::kExponential)); t1->Start(); - AdvanceTimeAndRunTimers(DurationMs(3000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(3)); t1->Start(); EXPECT_CALL(on_expired_, Call).Times(0); - AdvanceTimeAndRunTimers(DurationMs(2000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(2)); EXPECT_CALL(on_expired_, Call).Times(1); - AdvanceTimeAndRunTimers(DurationMs(3000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(3)); } TEST_F(TimerTest, ExpirationCounterWillResetIfStopped) { std::unique_ptr<Timer> t1 = manager_.CreateTimer( "t1", on_expired_.AsStdFunction(), - TimerOptions(DurationMs(5000), TimerBackoffAlgorithm::kExponential)); + TimerOptions(TimeDelta::Seconds(5), TimerBackoffAlgorithm::kExponential)); t1->Start(); // Fire first time at 5 seconds EXPECT_CALL(on_expired_, Call).Times(1); - AdvanceTimeAndRunTimers(DurationMs(5000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(5)); EXPECT_EQ(t1->expiration_count(), 1); // Second time at 5*2^1 = 10 seconds later. EXPECT_CALL(on_expired_, Call).Times(0); - AdvanceTimeAndRunTimers(DurationMs(9000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(9)); EXPECT_CALL(on_expired_, Call).Times(1); - AdvanceTimeAndRunTimers(DurationMs(1000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(1)); EXPECT_EQ(t1->expiration_count(), 2); t1->Start(); @@ -265,79 +268,79 @@ TEST_F(TimerTest, ExpirationCounterWillResetIfStopped) { // Third time at 5*2^0 = 5 seconds later. EXPECT_CALL(on_expired_, Call).Times(0); - AdvanceTimeAndRunTimers(DurationMs(4000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(4)); EXPECT_CALL(on_expired_, Call).Times(1); - AdvanceTimeAndRunTimers(DurationMs(1000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(1)); EXPECT_EQ(t1->expiration_count(), 1); } TEST_F(TimerTest, StopTimerWillMakeItNotExpire) { std::unique_ptr<Timer> t1 = manager_.CreateTimer( "t1", on_expired_.AsStdFunction(), - TimerOptions(DurationMs(5000), TimerBackoffAlgorithm::kExponential)); + TimerOptions(TimeDelta::Seconds(5), TimerBackoffAlgorithm::kExponential)); t1->Start(); EXPECT_TRUE(t1->is_running()); EXPECT_CALL(on_expired_, Call).Times(0); - AdvanceTimeAndRunTimers(DurationMs(4000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(4)); t1->Stop(); EXPECT_FALSE(t1->is_running()); EXPECT_CALL(on_expired_, Call).Times(0); - AdvanceTimeAndRunTimers(DurationMs(1000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(1)); } TEST_F(TimerTest, ReturningNewDurationWhenExpired) { std::unique_ptr<Timer> t1 = manager_.CreateTimer( "t1", on_expired_.AsStdFunction(), - TimerOptions(DurationMs(5000), TimerBackoffAlgorithm::kFixed)); + TimerOptions(TimeDelta::Seconds(5), TimerBackoffAlgorithm::kFixed)); EXPECT_CALL(on_expired_, Call).Times(0); t1->Start(); - EXPECT_EQ(t1->duration(), DurationMs(5000)); + EXPECT_EQ(t1->duration(), TimeDelta::Seconds(5)); - AdvanceTimeAndRunTimers(DurationMs(4000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(4)); // Fire first time - EXPECT_CALL(on_expired_, Call).WillOnce(Return(DurationMs(2000))); - AdvanceTimeAndRunTimers(DurationMs(1000)); - EXPECT_EQ(t1->duration(), DurationMs(2000)); + EXPECT_CALL(on_expired_, Call).WillOnce(Return(TimeDelta::Seconds(2))); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(1)); + EXPECT_EQ(t1->duration(), TimeDelta::Seconds(2)); EXPECT_CALL(on_expired_, Call).Times(0); - AdvanceTimeAndRunTimers(DurationMs(1000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(1)); // Second time - EXPECT_CALL(on_expired_, Call).WillOnce(Return(DurationMs(10000))); - AdvanceTimeAndRunTimers(DurationMs(1000)); - EXPECT_EQ(t1->duration(), DurationMs(10000)); + EXPECT_CALL(on_expired_, Call).WillOnce(Return(TimeDelta::Seconds(10))); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(1)); + EXPECT_EQ(t1->duration(), TimeDelta::Seconds(10)); EXPECT_CALL(on_expired_, Call).Times(0); - AdvanceTimeAndRunTimers(DurationMs(9000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(9)); EXPECT_CALL(on_expired_, Call).Times(1); - AdvanceTimeAndRunTimers(DurationMs(1000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(1)); } TEST_F(TimerTest, TimersHaveMaximumDuration) { std::unique_ptr<Timer> t1 = manager_.CreateTimer( "t1", on_expired_.AsStdFunction(), - TimerOptions(DurationMs(1000), TimerBackoffAlgorithm::kExponential)); + TimerOptions(TimeDelta::Seconds(1), TimerBackoffAlgorithm::kExponential)); - t1->set_duration(DurationMs(2 * *Timer::kMaxTimerDuration)); + t1->set_duration(2 * Timer::kMaxTimerDuration); EXPECT_EQ(t1->duration(), Timer::kMaxTimerDuration); } TEST_F(TimerTest, TimersHaveMaximumBackoffDuration) { std::unique_ptr<Timer> t1 = manager_.CreateTimer( "t1", on_expired_.AsStdFunction(), - TimerOptions(DurationMs(1000), TimerBackoffAlgorithm::kExponential)); + TimerOptions(TimeDelta::Seconds(1), TimerBackoffAlgorithm::kExponential)); t1->Start(); - int max_exponent = static_cast<int>(log2(*Timer::kMaxTimerDuration / 1000)); + int max_exponent = static_cast<int>(log2(Timer::kMaxTimerDuration.seconds())); for (int i = 0; i < max_exponent; ++i) { EXPECT_CALL(on_expired_, Call).Times(1); - AdvanceTimeAndRunTimers(DurationMs(1000 * (1 << i))); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(1 * (1 << i))); } // Reached the maximum duration. @@ -357,77 +360,77 @@ TEST_F(TimerTest, TimersHaveMaximumBackoffDuration) { TEST_F(TimerTest, TimerCanBeStartedFromWithinExpirationHandler) { std::unique_ptr<Timer> t1 = manager_.CreateTimer( "t1", on_expired_.AsStdFunction(), - TimerOptions(DurationMs(1000), TimerBackoffAlgorithm::kFixed)); + TimerOptions(TimeDelta::Seconds(1), TimerBackoffAlgorithm::kFixed)); t1->Start(); // Start a timer, but don't return any new duration in callback. EXPECT_CALL(on_expired_, Call).WillOnce([&]() { EXPECT_TRUE(t1->is_running()); - t1->set_duration(DurationMs(5000)); + t1->set_duration(TimeDelta::Seconds(5)); t1->Start(); - return absl::nullopt; + return TimeDelta::Zero(); }); - AdvanceTimeAndRunTimers(DurationMs(1000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(1)); EXPECT_CALL(on_expired_, Call).Times(0); - AdvanceTimeAndRunTimers(DurationMs(4999)); + AdvanceTimeAndRunTimers(TimeDelta::Millis(4999)); // Start a timer, and return any new duration in callback. EXPECT_CALL(on_expired_, Call).WillOnce([&]() { EXPECT_TRUE(t1->is_running()); - t1->set_duration(DurationMs(5000)); + t1->set_duration(TimeDelta::Seconds(5)); t1->Start(); - return absl::make_optional(DurationMs(8000)); + return TimeDelta::Seconds(8); }); - AdvanceTimeAndRunTimers(DurationMs(1)); + AdvanceTimeAndRunTimers(TimeDelta::Millis(1)); EXPECT_CALL(on_expired_, Call).Times(0); - AdvanceTimeAndRunTimers(DurationMs(7999)); + AdvanceTimeAndRunTimers(TimeDelta::Millis(7999)); EXPECT_CALL(on_expired_, Call).Times(1); - AdvanceTimeAndRunTimers(DurationMs(1)); + AdvanceTimeAndRunTimers(TimeDelta::Millis(1)); } TEST_F(TimerTest, DurationStaysWithinMaxTimerBackOffDuration) { std::unique_ptr<Timer> t1 = manager_.CreateTimer( "t1", on_expired_.AsStdFunction(), - TimerOptions(DurationMs(1000), TimerBackoffAlgorithm::kExponential, - /*max_restarts=*/absl::nullopt, DurationMs(5000))); + TimerOptions(TimeDelta::Seconds(1), TimerBackoffAlgorithm::kExponential, + /*max_restarts=*/absl::nullopt, TimeDelta::Seconds(5))); t1->Start(); // Initial timeout, 1000 ms EXPECT_CALL(on_expired_, Call).Times(1); - AdvanceTimeAndRunTimers(DurationMs(1000)); + AdvanceTimeAndRunTimers(TimeDelta::Seconds(1)); // Exponential backoff -> 2000 ms EXPECT_CALL(on_expired_, Call).Times(0); - AdvanceTimeAndRunTimers(DurationMs(1999)); + AdvanceTimeAndRunTimers(TimeDelta::Millis(1999)); EXPECT_CALL(on_expired_, Call).Times(1); - AdvanceTimeAndRunTimers(DurationMs(1)); + AdvanceTimeAndRunTimers(TimeDelta::Millis(1)); // Exponential backoff -> 4000 ms EXPECT_CALL(on_expired_, Call).Times(0); - AdvanceTimeAndRunTimers(DurationMs(3999)); + AdvanceTimeAndRunTimers(TimeDelta::Millis(3999)); EXPECT_CALL(on_expired_, Call).Times(1); - AdvanceTimeAndRunTimers(DurationMs(1)); + AdvanceTimeAndRunTimers(TimeDelta::Millis(1)); // Limited backoff -> 5000ms EXPECT_CALL(on_expired_, Call).Times(0); - AdvanceTimeAndRunTimers(DurationMs(4999)); + AdvanceTimeAndRunTimers(TimeDelta::Millis(4999)); EXPECT_CALL(on_expired_, Call).Times(1); - AdvanceTimeAndRunTimers(DurationMs(1)); + AdvanceTimeAndRunTimers(TimeDelta::Millis(1)); // ... where it plateaus EXPECT_CALL(on_expired_, Call).Times(0); - AdvanceTimeAndRunTimers(DurationMs(4999)); + AdvanceTimeAndRunTimers(TimeDelta::Millis(4999)); EXPECT_CALL(on_expired_, Call).Times(1); - AdvanceTimeAndRunTimers(DurationMs(1)); + AdvanceTimeAndRunTimers(TimeDelta::Millis(1)); } TEST(TimerManagerTest, TimerManagerPassesPrecisionToCreateTimeoutMethod) { - FakeTimeoutManager timeout_manager([&]() { return TimeMs(0); }); + FakeTimeoutManager timeout_manager([&]() { return Timestamp::Zero(); }); absl::optional<webrtc::TaskQueueBase::DelayPrecision> create_timer_precison; TimerManager manager([&](webrtc::TaskQueueBase::DelayPrecision precision) { create_timer_precison = precision; @@ -435,22 +438,22 @@ TEST(TimerManagerTest, TimerManagerPassesPrecisionToCreateTimeoutMethod) { }); // Default TimerOptions. manager.CreateTimer( - "test_timer", []() { return absl::optional<DurationMs>(); }, - TimerOptions(DurationMs(123))); + "test_timer", []() { return TimeDelta::Zero(); }, + TimerOptions(TimeDelta::Millis(123))); EXPECT_EQ(create_timer_precison, webrtc::TaskQueueBase::DelayPrecision::kLow); // High precision TimerOptions. manager.CreateTimer( - "test_timer", []() { return absl::optional<DurationMs>(); }, - TimerOptions(DurationMs(123), TimerBackoffAlgorithm::kExponential, - absl::nullopt, DurationMs::InfiniteDuration(), + "test_timer", []() { return TimeDelta::Zero(); }, + TimerOptions(TimeDelta::Millis(123), TimerBackoffAlgorithm::kExponential, + absl::nullopt, TimeDelta::PlusInfinity(), webrtc::TaskQueueBase::DelayPrecision::kHigh)); EXPECT_EQ(create_timer_precison, webrtc::TaskQueueBase::DelayPrecision::kHigh); // Low precision TimerOptions. manager.CreateTimer( - "test_timer", []() { return absl::optional<DurationMs>(); }, - TimerOptions(DurationMs(123), TimerBackoffAlgorithm::kExponential, - absl::nullopt, DurationMs::InfiniteDuration(), + "test_timer", []() { return TimeDelta::Zero(); }, + TimerOptions(TimeDelta::Millis(123), TimerBackoffAlgorithm::kExponential, + absl::nullopt, TimeDelta::PlusInfinity(), webrtc::TaskQueueBase::DelayPrecision::kLow)); EXPECT_EQ(create_timer_precison, webrtc::TaskQueueBase::DelayPrecision::kLow); } |