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 |
- |
- |