Fixes Flaky test by set larger timer(100 ->1000 ms) for CancelableAlarm.

PiperOrigin-RevId: 450911652
This commit is contained in:
edwinwu
2022-05-25 06:46:42 -07:00
committed by Copybara-Service
parent 8e048f7be0
commit f39770d690
+3 -3
View File
@@ -70,9 +70,9 @@ TEST(CancelableAlarmTest, CanCreateRecurringAlarm) {
AtomicReference<int> count(0);
CancelableAlarm alarm(
"test_alarm", [&count]() { count.Set(count.Get() + 1); },
absl::Milliseconds(100), &alarm_executor, /*is_recurring=*/true);
// Wait for 2 rounds (>100ms * 2) and expect the `count` = 2.
SystemClock::Sleep(absl::Milliseconds(290));
absl::Milliseconds(1000), &alarm_executor, /*is_recurring=*/true);
// Wait for 2 rounds (>1000ms * 2) and expect the `count` = 2.
SystemClock::Sleep(absl::Milliseconds(2800));
alarm.Cancel();
EXPECT_EQ(count.Get(), 2);
}