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

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

Issue 956333002: Refactor TimeBase to post tasks. Workers to use real Idle tasks. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 8 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_tests.gyp ('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..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
« no previous file with comments | « Source/platform/blink_platform_tests.gyp ('k') | Source/web/tests/TextFinderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698