Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(714)

Unified Diff: third_party/WebKit/Source/platform/TimerTest.cpp

Issue 2020513003: Prevent augmentRepeatInterval from computing a negative delay (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/Timer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/TimerTest.cpp
diff --git a/third_party/WebKit/Source/platform/TimerTest.cpp b/third_party/WebKit/Source/platform/TimerTest.cpp
index 13ca89e1c5c72dd9fb804586fae91556f6304bfd..22a5a8a1ff71ec3c7014b09c9878c712917cd1e3 100644
--- a/third_party/WebKit/Source/platform/TimerTest.cpp
+++ b/third_party/WebKit/Source/platform/TimerTest.cpp
@@ -699,6 +699,21 @@ TEST_F(TimerTest, AugmentRepeatInterval)
EXPECT_THAT(m_runTimes, ElementsAre(m_startTime + 20.0, m_startTime + 40.0));
}
+TEST_F(TimerTest, AugmentRepeatInterval_TimerFireDelayed)
+{
+ Timer<TimerTest> timer(this, &TimerTest::countingTask);
+ timer.startRepeating(10, BLINK_FROM_HERE);
+ EXPECT_FLOAT_EQ(10.0, timer.repeatInterval());
+ EXPECT_FLOAT_EQ(10.0, timer.nextFireInterval());
+
+ advanceTimeBy(123.0); // Make the timer long overdue.
+ timer.augmentRepeatInterval(10);
+
+ EXPECT_FLOAT_EQ(20.0, timer.repeatInterval());
+ // The timer is overdue so it should be scheduled to fire immediatly.
+ EXPECT_FLOAT_EQ(0.0, timer.nextFireInterval());
+}
+
TEST_F(TimerTest, RepeatingTimerDoesNotDrift)
{
Timer<TimerTest> timer(this, &TimerTest::recordNextFireTimeTask);
« no previous file with comments | « third_party/WebKit/Source/platform/Timer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698