| Index: Source/platform/scroll/ScrollableAreaTest.cpp
|
| diff --git a/Source/platform/scroll/ScrollableAreaTest.cpp b/Source/platform/scroll/ScrollableAreaTest.cpp
|
| index a435664b5411f4ba1beeb51afc39be2e9548c9c4..0d6426fc095ffdcd74403348aa00ce041e138c0d 100644
|
| --- a/Source/platform/scroll/ScrollableAreaTest.cpp
|
| +++ b/Source/platform/scroll/ScrollableAreaTest.cpp
|
| @@ -6,6 +6,9 @@
|
|
|
| #include "platform/scroll/ScrollableArea.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,11 +50,86 @@ private:
|
| IntPoint m_maximumScrollPosition;
|
| };
|
|
|
| +class FakeWebThread : public WebThread {
|
| +public:
|
| + FakeWebThread() { }
|
| + ~FakeWebThread() override { }
|
| +
|
| + void postTask(const WebTraceLocation&, Task*)
|
| + {
|
| + ASSERT_NOT_REACHED();
|
| + }
|
| +
|
| + virtual void postDelayedTask(const WebTraceLocation&, Task*, long long)
|
| + {
|
| + ASSERT_NOT_REACHED();
|
| + }
|
| +
|
| + virtual bool isCurrentThread() const
|
| + {
|
| + ASSERT_NOT_REACHED();
|
| + return true;
|
| + }
|
| +
|
| + virtual PlatformThreadId threadId() const
|
| + {
|
| + ASSERT_NOT_REACHED();
|
| + return 0;
|
| + }
|
| +
|
| + WebScheduler* scheduler() const override
|
| + {
|
| + return nullptr;
|
| + }
|
| +
|
| + virtual void enterRunLoop()
|
| + {
|
| + ASSERT_NOT_REACHED();
|
| + }
|
| +
|
| + virtual void exitRunLoop()
|
| + {
|
| + ASSERT_NOT_REACHED();
|
| + }
|
| +};
|
| +
|
| +// The FakePlatform is needed on mac because ScrollAnimatorMac's constructor creates several timers.
|
| +// We need just enough scaffolding for the Timer constructor to not segfault.
|
| +class FakePlatform : public Platform {
|
| +public:
|
| + FakePlatform() { }
|
| + ~FakePlatform() override { }
|
| +
|
| + WebThread* currentThread() override
|
| + {
|
| + return &m_webThread;
|
| + }
|
| +
|
| + void cryptographicallyRandomValues(unsigned char*, size_t) override
|
| + {
|
| + ASSERT_NOT_REACHED();
|
| + }
|
| +
|
| + const unsigned char* getTraceCategoryEnabledFlag(const char*) override
|
| + {
|
| + return reinterpret_cast<const unsigned char*>("");
|
| + }
|
| +
|
| +private:
|
| + FakeWebThread m_webThread;
|
| +};
|
| +
|
| TEST(ScrollableAreaTest, ScrollAnimatorCurrentPositionShouldBeSync)
|
| {
|
| + Platform* oldPlatform = Platform::current();
|
| + FakePlatform fakePlatform;
|
| + Platform::initialize(&fakePlatform);
|
| +
|
| MockScrollableArea scrollableArea(IntPoint(0, 100));
|
| scrollableArea.notifyScrollPositionChanged(IntPoint(0, 10000));
|
| EXPECT_EQ(100.0, scrollableArea.scrollAnimator()->currentPosition().y());
|
| +
|
| + Platform::initialize(oldPlatform);
|
| }
|
|
|
| } // unnamed namespace
|
|
|