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

Side by Side Diff: third_party/WebKit/Source/core/layout/ImageQualityControllerTest.cpp

Issue 2191533003: Refactor Timer classes in preparation for landing FrameTimers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/layout/ImageQualityController.h" 5 #include "core/layout/ImageQualityController.h"
6 6
7 #include "core/layout/LayoutImage.h" 7 #include "core/layout/LayoutImage.h"
8 #include "core/layout/LayoutTestHelper.h" 8 #include "core/layout/LayoutTestHelper.h"
9 #include "platform/graphics/GraphicsContext.h" 9 #include "platform/graphics/GraphicsContext.h"
10 #include "platform/graphics/paint/PaintController.h" 10 #include "platform/graphics/paint/PaintController.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 } 134 }
135 bool runsTasksOnCurrentThread() override { return true; } 135 bool runsTasksOnCurrentThread() override { return true; }
136 std::unique_ptr<WebTaskRunner> clone() override { return nullptr; } 136 std::unique_ptr<WebTaskRunner> clone() override { return nullptr; }
137 double virtualTimeSeconds() const override { return 0.0; } 137 double virtualTimeSeconds() const override { return 0.0; }
138 double monotonicallyIncreasingVirtualTimeSeconds() const override { return m _time; } 138 double monotonicallyIncreasingVirtualTimeSeconds() const override { return m _time; }
139 139
140 double m_time; 140 double m_time;
141 Task* m_currentTask; 141 Task* m_currentTask;
142 }; 142 };
143 143
144 class MockTimer : public Timer<ImageQualityController> { 144 class MockTimer : public TaskRunnerTimer<ImageQualityController> {
145 typedef void (ImageQualityController::*TimerFiredFunction)(Timer*);
146 public: 145 public:
146 using TimerFiredFunction = typename TaskRunnerTimer<ImageQualityController>: :TimerFiredFunction;
147
147 MockTimer(ImageQualityController* o, TimerFiredFunction f) 148 MockTimer(ImageQualityController* o, TimerFiredFunction f)
148 : Timer<ImageQualityController>(o, f, &m_taskRunner) 149 : TaskRunnerTimer(&m_taskRunner, o, f)
149 { 150 {
150 } 151 }
151 152
152 void fire() 153 void fire()
153 { 154 {
154 this->Timer<ImageQualityController>::fired(); 155 this->Timer<ImageQualityController>::fired();
155 stop(); 156 stop();
156 } 157 }
157 158
158 void setTime(double newTime) 159 void setTime(double newTime)
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 // This animation is far enough in the future to make the timer restart, sin ce it is half over. 270 // This animation is far enough in the future to make the timer restart, sin ce it is half over.
270 nextTime = 0.1 + ImageQualityController::cTimerRestartThreshold + 0.01; 271 nextTime = 0.1 + ImageQualityController::cTimerRestartThreshold + 0.01;
271 EXPECT_EQ(true, controller()->shouldPaintAtLowQuality(*img, testImage.get(), testImage.get(), LayoutSize(4, 4), nextTime)); 272 EXPECT_EQ(true, controller()->shouldPaintAtLowQuality(*img, testImage.get(), testImage.get(), LayoutSize(4, 4), nextTime));
272 // Now the timer has restarted, leading to a larger fire interval. 273 // Now the timer has restarted, leading to a larger fire interval.
273 EXPECT_EQ(ImageQualityController::cLowQualityTimeThreshold, mockTimer->nextF ireInterval()); 274 EXPECT_EQ(ImageQualityController::cLowQualityTimeThreshold, mockTimer->nextF ireInterval());
274 } 275 }
275 276
276 #endif 277 #endif
277 278
278 } // namespace blink 279 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698