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

Unified Diff: third_party/WebKit/Source/core/layout/ImageQualityControllerTest.cpp

Issue 2266443002: Optimize posting of WTF::Closure and improve scheduler test mocks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cut back to just the WTF::Closure fix plus the scheduler test mock refactor. 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/ImageQualityControllerTest.cpp
diff --git a/third_party/WebKit/Source/core/layout/ImageQualityControllerTest.cpp b/third_party/WebKit/Source/core/layout/ImageQualityControllerTest.cpp
index 6ce9112bd97431f8f6fd132625e30f9fd810248b..291560cb655d7571402fc5fe3712681443972d73 100644
--- a/third_party/WebKit/Source/core/layout/ImageQualityControllerTest.cpp
+++ b/third_party/WebKit/Source/core/layout/ImageQualityControllerTest.cpp
@@ -8,6 +8,7 @@
#include "core/layout/LayoutTestHelper.h"
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/paint/PaintController.h"
+#include "platform/scheduler/test/fake_web_task_runner.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "wtf/PtrUtil.h"
#include <memory>
@@ -110,39 +111,7 @@ TEST_F(ImageQualityControllerTest, MediumQualityFilterForUnscaledImage)
EXPECT_EQ(InterpolationMedium, controller()->chooseInterpolationQuality(*img, testImage.get(), testImage.get(), LayoutSize(1, 1)));
}
-class MockTaskRunner : public WebTaskRunner {
-public:
- void setTime(double newTime) { m_time = newTime; }
-
- MockTaskRunner()
- : WebTaskRunner(), m_time(0.0), m_currentTask(nullptr)
- { }
-
- virtual ~MockTaskRunner()
- {
- if (m_currentTask)
- delete m_currentTask;
- }
-
-private:
- void postTask(const WebTraceLocation&, Task*) override { }
- void postDelayedTask(const WebTraceLocation&, Task* task, double) override
- {
- if (m_currentTask)
- delete m_currentTask;
- m_currentTask = task;
-
- }
- bool runsTasksOnCurrentThread() override { return true; }
- std::unique_ptr<WebTaskRunner> clone() override { return nullptr; }
- double virtualTimeSeconds() const override { return 0.0; }
- double monotonicallyIncreasingVirtualTimeSeconds() const override { return m_time; }
- SingleThreadTaskRunner* taskRunner() override { return nullptr; }
-
- double m_time;
- Task* m_currentTask;
-};
-
+// TODO(alexclarke): Remove this when possible.
class MockTimer : public TaskRunnerTimer<ImageQualityController> {
public:
using TimerFiredFunction = typename TaskRunnerTimer<ImageQualityController>::TimerFiredFunction;
@@ -164,7 +133,7 @@ public:
}
private:
- MockTaskRunner m_taskRunner;
+ scheduler::FakeWebTaskRunner m_taskRunner;
};
TEST_F(ImageQualityControllerTest, LowQualityFilterForResizingImage)

Powered by Google App Engine
This is Rietveld 408576698