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

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

Issue 1441073006: Move throttling of background timers into the renderer scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Try again for MSVC Created 5 years, 1 month 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
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 6a75618f927c2e5ef80cee96e7eac49dc07fb24b..ace2560df5a2d2ccd32a65d0962c230b6569f863 100644
--- a/third_party/WebKit/Source/platform/TimerTest.cpp
+++ b/third_party/WebKit/Source/platform/TimerTest.cpp
@@ -135,11 +135,6 @@ public:
return nullptr;
}
- void postTimerTaskAt(const WebTraceLocation&, WebTaskRunner::Task* task, double monotonicTime) override
- {
- m_timerTasks.push(DelayedTask(task, (monotonicTime - monotonicallyIncreasingTime()) * 1000));
- }
-
void runUntilIdle()
{
while (m_timerTasks.size()) {
@@ -703,6 +698,7 @@ TEST_F(TimerTest, RepeatInterval_Repeating)
TEST_F(TimerTest, AugmentRepeatInterval)
{
Timer<TimerTest> timer(this, &TimerTest::countingTask);
+ fprintf(stderr, "m_startTime = %f\n", m_startTime);
Sami 2015/11/17 10:12:21 Might want to remove this :)
alex clarke (OOO till 29th) 2015/11/23 17:13:46 Done.
timer.startRepeating(10, BLINK_FROM_HERE);
EXPECT_FLOAT_EQ(10.0, timer.repeatInterval());
EXPECT_FLOAT_EQ(10.0, timer.nextFireInterval());
@@ -717,80 +713,6 @@ TEST_F(TimerTest, AugmentRepeatInterval)
EXPECT_THAT(m_runTimes, ElementsAre(m_startTime + 20.0, m_startTime + 40.0));
}
-class MockTimerWithAlignment : public TimerBase {
-public:
- MockTimerWithAlignment() : m_lastFireTime(0.0), m_alignedFireTime(0.0) { }
-
- void fired() override
- {
- }
-
- double alignedFireTime(double fireTime) const override
- {
- m_lastFireTime = fireTime;
- return m_alignedFireTime;
- }
-
- void setAlignedFireTime(double alignedFireTime)
- {
- m_alignedFireTime = alignedFireTime;
- }
-
- double lastFireTime() const
- {
- return m_lastFireTime;
- }
-
-private:
- mutable double m_lastFireTime;
- double m_alignedFireTime;
-};
-
-TEST_F(TimerTest, TimerAlignment_OneShotZero)
-{
- MockTimerWithAlignment timer;
- timer.setAlignedFireTime(m_startTime + 1.0);
-
- timer.start(0.0, 0.0, BLINK_FROM_HERE);
-
- // The nextFireInterval gets overrriden.
- EXPECT_FLOAT_EQ(1.0, timer.nextFireInterval());
- EXPECT_FLOAT_EQ(0.0, timer.nextUnalignedFireInterval());
- EXPECT_FLOAT_EQ(m_startTime, timer.lastFireTime());
-}
-
-TEST_F(TimerTest, TimerAlignment_OneShotNonZero)
-{
- MockTimerWithAlignment timer;
- timer.setAlignedFireTime(m_startTime + 1.0);
-
- timer.start(0.5, 0.0, BLINK_FROM_HERE);
-
- // The nextFireInterval gets overrriden.
- EXPECT_FLOAT_EQ(1.0, timer.nextFireInterval());
- EXPECT_FLOAT_EQ(0.5, timer.nextUnalignedFireInterval());
- EXPECT_FLOAT_EQ(m_startTime + 0.5, timer.lastFireTime());
-}
-
-TEST_F(TimerTest, DidChangeAlignmentInterval)
-{
- MockTimerWithAlignment timer;
- timer.setAlignedFireTime(m_startTime + 1.0);
-
- timer.start(0.0, 0.0, BLINK_FROM_HERE);
-
- EXPECT_FLOAT_EQ(1.0, timer.nextFireInterval());
- EXPECT_FLOAT_EQ(0.0, timer.nextUnalignedFireInterval());
- EXPECT_FLOAT_EQ(m_startTime, timer.lastFireTime());
-
- timer.setAlignedFireTime(m_startTime);
- timer.didChangeAlignmentInterval(monotonicallyIncreasingTime());
-
- EXPECT_FLOAT_EQ(0.0, timer.nextFireInterval());
- EXPECT_FLOAT_EQ(0.0, timer.nextUnalignedFireInterval());
- EXPECT_FLOAT_EQ(m_startTime, timer.lastFireTime());
-}
-
TEST_F(TimerTest, RepeatingTimerDoesNotDrift)
{
Timer<TimerTest> timer(this, &TimerTest::recordNextFireTimeTask);

Powered by Google App Engine
This is Rietveld 408576698