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

Unified Diff: Source/platform/scroll/ScrollableAreaTest.cpp

Issue 1134523002: Implement timers by posting delayed tasks (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased. Created 5 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 | « Source/platform/blink_platform.gypi ('k') | Source/web/tests/TextFinderTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/scroll/ScrollableAreaTest.cpp
diff --git a/Source/platform/scroll/ScrollableAreaTest.cpp b/Source/platform/scroll/ScrollableAreaTest.cpp
index a435664b5411f4ba1beeb51afc39be2e9548c9c4..68794648ae04333b0c68e583f7e9d7ba2d42089d 100644
--- a/Source/platform/scroll/ScrollableAreaTest.cpp
+++ b/Source/platform/scroll/ScrollableAreaTest.cpp
@@ -6,6 +6,10 @@
#include "platform/scroll/ScrollableArea.h"
+#include "platform/TestingPlatformSupport.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebScheduler.h"
+#include "public/platform/WebThread.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
@@ -47,7 +51,70 @@ private:
IntPoint m_maximumScrollPosition;
};
-TEST(ScrollableAreaTest, ScrollAnimatorCurrentPositionShouldBeSync)
+class FakeWebThread : public WebThread {
+public:
+ FakeWebThread() { }
+ ~FakeWebThread() override { }
+
+ void postTask(const WebTraceLocation&, Task*) override
+ {
+ ASSERT_NOT_REACHED();
+ }
+
+ void postDelayedTask(const WebTraceLocation&, Task*, long long) override
+ {
+ ASSERT_NOT_REACHED();
+ }
+
+ bool isCurrentThread() const override
+ {
+ ASSERT_NOT_REACHED();
+ return true;
+ }
+
+ WebScheduler* scheduler() const override
+ {
+ return nullptr;
+ }
+};
+
+// The FakePlatform is needed because ScrollAnimatorMac's constructor creates several timers.
+// We need just enough scaffolding for the Timer constructor to not segfault.
+class FakePlatform : public TestingPlatformSupport {
+public:
+ FakePlatform() : TestingPlatformSupport(TestingPlatformSupport::Config()) { }
+ ~FakePlatform() override { }
+
+ WebThread* currentThread() override
+ {
+ return &m_webThread;
+ }
+
+private:
+ FakeWebThread m_webThread;
+};
+
+class ScrollableAreaTest : public testing::Test {
+public:
+ ScrollableAreaTest() : m_oldPlatform(nullptr) { }
+
+ void SetUp() override
+ {
+ m_oldPlatform = Platform::current();
+ Platform::initialize(&m_fakePlatform);
+ }
+
+ void TearDown() override
+ {
+ Platform::initialize(m_oldPlatform);
+ }
+
+private:
+ FakePlatform m_fakePlatform;
+ Platform* m_oldPlatform; // Not owned.
+};
+
+TEST_F(ScrollableAreaTest, ScrollAnimatorCurrentPositionShouldBeSync)
{
MockScrollableArea scrollableArea(IntPoint(0, 100));
scrollableArea.notifyScrollPositionChanged(IntPoint(0, 10000));
@@ -55,5 +122,3 @@ TEST(ScrollableAreaTest, ScrollAnimatorCurrentPositionShouldBeSync)
}
} // unnamed namespace
-
-
« no previous file with comments | « Source/platform/blink_platform.gypi ('k') | Source/web/tests/TextFinderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698