Index: third_party/WebKit/Source/platform/scroll/ScrollAnimatorTest.cpp |
diff --git a/third_party/WebKit/Source/platform/scroll/ScrollAnimatorTest.cpp b/third_party/WebKit/Source/platform/scroll/ScrollAnimatorTest.cpp |
index b72c7105ce4976c93be31e0f759ff0eb1fb89603..d21b14968c2ed37d0795574bb78c9ff4d45e66cf 100644 |
--- a/third_party/WebKit/Source/platform/scroll/ScrollAnimatorTest.cpp |
+++ b/third_party/WebKit/Source/platform/scroll/ScrollAnimatorTest.cpp |
@@ -73,6 +73,7 @@ public: |
MOCK_CONST_METHOD0(scrollbarsCanBeActive, bool()); |
MOCK_CONST_METHOD0(scrollableAreaBoundingBox, IntRect()); |
MOCK_METHOD0(registerForAnimation, void()); |
+ MOCK_METHOD0(scheduleAnimation, bool()); |
bool userInputScrollable(ScrollbarOrientation) const override { return true; } |
bool shouldPlaceVerticalScrollbarOnLeft() const override { return false; } |
@@ -101,30 +102,32 @@ static void reset(ScrollAnimator& scrollAnimator) |
scrollAnimator.scrollToOffsetWithoutAnimation(FloatPoint()); |
} |
-TEST(ScrollAnimatorTest, Enabled) |
+TEST(ScrollAnimatorTest, MainThreadEnabled) |
{ |
OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea = MockScrollableArea::create(true); |
OwnPtrWillBeRawPtr<ScrollAnimator> scrollAnimator = adoptPtrWillBeNoop(new ScrollAnimator(scrollableArea.get(), getMockedTime)); |
EXPECT_CALL(*scrollableArea, minimumScrollPosition()).Times(AtLeast(1)).WillRepeatedly(Return(IntPoint())); |
EXPECT_CALL(*scrollableArea, maximumScrollPosition()).Times(AtLeast(1)).WillRepeatedly(Return(IntPoint(1000, 1000))); |
- EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(12); |
+ EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(9); |
EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(3); |
+ EXPECT_CALL(*scrollableArea, scheduleAnimation()).Times(AtLeast(1)).WillRepeatedly(Return(true)); |
- EXPECT_FALSE(scrollAnimator->hasRunningAnimation()); |
+ EXPECT_FALSE(scrollAnimator->hasAnimationThatRequiresService()); |
ScrollResultOneDimensional result = scrollAnimator->userScroll(HorizontalScrollbar, ScrollByLine, 100, -1); |
- EXPECT_FALSE(scrollAnimator->hasRunningAnimation()); |
+ EXPECT_FALSE(scrollAnimator->hasAnimationThatRequiresService()); |
EXPECT_FALSE(result.didScroll); |
EXPECT_FLOAT_EQ(-1.0f, result.unusedScrollDelta); |
result = scrollAnimator->userScroll(HorizontalScrollbar, ScrollByLine, 100, 1); |
- EXPECT_TRUE(scrollAnimator->hasRunningAnimation()); |
+ EXPECT_TRUE(scrollAnimator->hasAnimationThatRequiresService()); |
EXPECT_TRUE(result.didScroll); |
EXPECT_FLOAT_EQ(0.0, result.unusedScrollDelta); |
gMockedTime += 0.05; |
- scrollAnimator->serviceScrollAnimations(); |
+ scrollAnimator->updateCompositorAnimations(); |
+ scrollAnimator->tickAnimation(getMockedTime()); |
EXPECT_NE(100, scrollAnimator->currentPosition().x()); |
EXPECT_NE(0, scrollAnimator->currentPosition().x()); |
@@ -132,10 +135,11 @@ TEST(ScrollAnimatorTest, Enabled) |
reset(*scrollAnimator); |
scrollAnimator->userScroll(HorizontalScrollbar, ScrollByPage, 100, 1); |
- EXPECT_TRUE(scrollAnimator->hasRunningAnimation()); |
+ EXPECT_TRUE(scrollAnimator->hasAnimationThatRequiresService()); |
gMockedTime += 0.05; |
- scrollAnimator->serviceScrollAnimations(); |
+ scrollAnimator->updateCompositorAnimations(); |
+ scrollAnimator->tickAnimation(getMockedTime()); |
EXPECT_NE(100, scrollAnimator->currentPosition().x()); |
EXPECT_NE(0, scrollAnimator->currentPosition().x()); |
@@ -143,25 +147,27 @@ TEST(ScrollAnimatorTest, Enabled) |
reset(*scrollAnimator); |
scrollAnimator->userScroll(HorizontalScrollbar, ScrollByPixel, 4, 25); |
- EXPECT_TRUE(scrollAnimator->hasRunningAnimation()); |
+ EXPECT_TRUE(scrollAnimator->hasAnimationThatRequiresService()); |
gMockedTime += 0.05; |
- scrollAnimator->serviceScrollAnimations(); |
+ scrollAnimator->updateCompositorAnimations(); |
+ scrollAnimator->tickAnimation(getMockedTime()); |
EXPECT_NE(100, scrollAnimator->currentPosition().x()); |
EXPECT_NE(0, scrollAnimator->currentPosition().x()); |
EXPECT_EQ(0, scrollAnimator->currentPosition().y()); |
gMockedTime += 1.0; |
- scrollAnimator->serviceScrollAnimations(); |
+ scrollAnimator->updateCompositorAnimations(); |
+ scrollAnimator->tickAnimation(getMockedTime()); |
- EXPECT_FALSE(scrollAnimator->hasRunningAnimation()); |
+ EXPECT_FALSE(scrollAnimator->hasAnimationThatRequiresService()); |
EXPECT_EQ(100, scrollAnimator->currentPosition().x()); |
reset(*scrollAnimator); |
scrollAnimator->userScroll(HorizontalScrollbar, ScrollByPrecisePixel, 4, 25); |
- EXPECT_FALSE(scrollAnimator->hasRunningAnimation()); |
+ EXPECT_FALSE(scrollAnimator->hasAnimationThatRequiresService()); |
EXPECT_EQ(100, scrollAnimator->currentPosition().x()); |
EXPECT_NE(0, scrollAnimator->currentPosition().x()); |