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 78d121446e8c4f6fa5e67c6db2c3b4b64e18d428..e9e0bafd82a2ab73c49b4cde0fe012784a3b88dc 100644 |
--- a/third_party/WebKit/Source/platform/scroll/ScrollAnimatorTest.cpp |
+++ b/third_party/WebKit/Source/platform/scroll/ScrollAnimatorTest.cpp |
@@ -53,8 +53,10 @@ class MockScrollableArea : public GarbageCollectedFinalized<MockScrollableArea>, |
USING_GARBAGE_COLLECTED_MIXIN(MockScrollableArea); |
public: |
- static MockScrollableArea* create(bool scrollAnimatorEnabled) { |
- return new MockScrollableArea(scrollAnimatorEnabled); |
+ static MockScrollableArea* create(bool scrollAnimatorEnabled, |
+ const ScrollOffset& minOffset, |
+ const ScrollOffset& maxOffset) { |
+ return new MockScrollableArea(scrollAnimatorEnabled, minOffset, maxOffset); |
} |
MOCK_CONST_METHOD0(visualRectForScrollbarParts, LayoutRect()); |
@@ -62,11 +64,9 @@ class MockScrollableArea : public GarbageCollectedFinalized<MockScrollableArea>, |
MOCK_CONST_METHOD1(scrollSize, int(ScrollbarOrientation)); |
MOCK_CONST_METHOD0(isScrollCornerVisible, bool()); |
MOCK_CONST_METHOD0(scrollCornerRect, IntRect()); |
- MOCK_METHOD2(setScrollOffset, void(const DoublePoint&, ScrollType)); |
+ MOCK_METHOD2(updateScrollOffset, void(const ScrollOffset&, ScrollType)); |
MOCK_METHOD0(scrollControlWasSetNeedsPaintInvalidation, void()); |
MOCK_CONST_METHOD0(enclosingScrollableArea, ScrollableArea*()); |
- MOCK_CONST_METHOD0(minimumScrollPosition, IntPoint()); |
- MOCK_CONST_METHOD0(maximumScrollPosition, IntPoint()); |
MOCK_CONST_METHOD1(visibleContentRect, IntRect(IncludeScrollbarsInRect)); |
MOCK_CONST_METHOD0(contentsSize, IntSize()); |
MOCK_CONST_METHOD0(scrollbarsCanBeActive, bool()); |
@@ -76,30 +76,36 @@ class MockScrollableArea : public GarbageCollectedFinalized<MockScrollableArea>, |
bool userInputScrollable(ScrollbarOrientation) const override { return true; } |
bool shouldPlaceVerticalScrollbarOnLeft() const override { return false; } |
- IntPoint scrollPosition() const override { return IntPoint(); } |
+ IntSize scrollOffsetInt() const override { return IntSize(); } |
int visibleHeight() const override { return 768; } |
int visibleWidth() const override { return 1024; } |
bool scrollAnimatorEnabled() const override { |
return m_scrollAnimatorEnabled; |
} |
int pageStep(ScrollbarOrientation) const override { return 0; } |
+ IntSize minimumScrollOffsetInt() const override { |
+ return flooredIntSize(m_minOffset); |
+ } |
+ IntSize maximumScrollOffsetInt() const override { |
+ return flooredIntSize(m_maxOffset); |
+ } |
void setScrollAnimator(ScrollAnimator* scrollAnimator) { |
animator = scrollAnimator; |
} |
- DoublePoint scrollPositionDouble() const override { |
+ ScrollOffset scrollOffset() const override { |
if (animator) |
- return animator->currentPosition(); |
- return ScrollableArea::scrollPositionDouble(); |
+ return animator->currentOffset(); |
+ return ScrollableArea::scrollOffset(); |
} |
- void setScrollPosition(const DoublePoint& position, |
- ScrollType type, |
- ScrollBehavior behavior = ScrollBehaviorInstant) { |
+ void setScrollOffset(const ScrollOffset& offset, |
+ ScrollType type, |
+ ScrollBehavior behavior = ScrollBehaviorInstant) { |
if (animator) |
- animator->setCurrentPosition(toFloatPoint(position)); |
- ScrollableArea::setScrollPosition(position, type, behavior); |
+ animator->setCurrentOffset(offset); |
+ ScrollableArea::setScrollOffset(offset, type, behavior); |
} |
DEFINE_INLINE_VIRTUAL_TRACE() { |
@@ -108,10 +114,16 @@ class MockScrollableArea : public GarbageCollectedFinalized<MockScrollableArea>, |
} |
private: |
- explicit MockScrollableArea(bool scrollAnimatorEnabled) |
- : m_scrollAnimatorEnabled(scrollAnimatorEnabled) {} |
+ explicit MockScrollableArea(bool scrollAnimatorEnabled, |
+ const ScrollOffset& minOffset, |
+ const ScrollOffset& maxOffset) |
+ : m_scrollAnimatorEnabled(scrollAnimatorEnabled), |
+ m_minOffset(minOffset), |
+ m_maxOffset(maxOffset) {} |
bool m_scrollAnimatorEnabled; |
+ ScrollOffset m_minOffset; |
+ ScrollOffset m_maxOffset; |
Member<ScrollAnimator> animator; |
}; |
@@ -144,23 +156,18 @@ class TestScrollAnimator : public ScrollAnimator { |
} // namespace |
static void reset(ScrollAnimator& scrollAnimator) { |
- scrollAnimator.scrollToOffsetWithoutAnimation(FloatPoint()); |
+ scrollAnimator.scrollToOffsetWithoutAnimation(ScrollOffset()); |
} |
// TODO(skobes): Add unit tests for composited scrolling paths. |
TEST(ScrollAnimatorTest, MainThreadStates) { |
- MockScrollableArea* scrollableArea = MockScrollableArea::create(true); |
+ MockScrollableArea* scrollableArea = MockScrollableArea::create( |
+ true, ScrollOffset(), ScrollOffset(1000, 1000)); |
ScrollAnimator* scrollAnimator = |
new ScrollAnimator(scrollableArea, 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(2); |
+ EXPECT_CALL(*scrollableArea, updateScrollOffset(_, _)).Times(2); |
// Once from userScroll, once from updateCompositorAnimations. |
EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(2); |
EXPECT_CALL(*scrollableArea, scheduleAnimation()) |
@@ -206,17 +213,12 @@ TEST(ScrollAnimatorTest, MainThreadStates) { |
} |
TEST(ScrollAnimatorTest, MainThreadEnabled) { |
- MockScrollableArea* scrollableArea = MockScrollableArea::create(true); |
+ MockScrollableArea* scrollableArea = MockScrollableArea::create( |
+ true, ScrollOffset(), ScrollOffset(1000, 1000)); |
ScrollAnimator* scrollAnimator = |
new ScrollAnimator(scrollableArea, 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(9); |
+ EXPECT_CALL(*scrollableArea, updateScrollOffset(_, _)).Times(9); |
EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(6); |
EXPECT_CALL(*scrollableArea, scheduleAnimation()) |
.Times(AtLeast(1)) |
@@ -239,9 +241,9 @@ TEST(ScrollAnimatorTest, MainThreadEnabled) { |
scrollAnimator->updateCompositorAnimations(); |
scrollAnimator->tickAnimation(getMockedTime()); |
- EXPECT_NE(100, scrollAnimator->currentPosition().x()); |
- EXPECT_NE(0, scrollAnimator->currentPosition().x()); |
- EXPECT_EQ(0, scrollAnimator->currentPosition().y()); |
+ EXPECT_NE(100, scrollAnimator->currentOffset().width()); |
+ EXPECT_NE(0, scrollAnimator->currentOffset().width()); |
+ EXPECT_EQ(0, scrollAnimator->currentOffset().height()); |
reset(*scrollAnimator); |
scrollAnimator->userScroll(ScrollByPage, FloatSize(100, 0)); |
@@ -251,9 +253,9 @@ TEST(ScrollAnimatorTest, MainThreadEnabled) { |
scrollAnimator->updateCompositorAnimations(); |
scrollAnimator->tickAnimation(getMockedTime()); |
- EXPECT_NE(100, scrollAnimator->currentPosition().x()); |
- EXPECT_NE(0, scrollAnimator->currentPosition().x()); |
- EXPECT_EQ(0, scrollAnimator->currentPosition().y()); |
+ EXPECT_NE(100, scrollAnimator->currentOffset().width()); |
+ EXPECT_NE(0, scrollAnimator->currentOffset().width()); |
+ EXPECT_EQ(0, scrollAnimator->currentOffset().height()); |
reset(*scrollAnimator); |
scrollAnimator->userScroll(ScrollByPixel, FloatSize(100, 0)); |
@@ -263,9 +265,9 @@ TEST(ScrollAnimatorTest, MainThreadEnabled) { |
scrollAnimator->updateCompositorAnimations(); |
scrollAnimator->tickAnimation(getMockedTime()); |
- EXPECT_NE(100, scrollAnimator->currentPosition().x()); |
- EXPECT_NE(0, scrollAnimator->currentPosition().x()); |
- EXPECT_EQ(0, scrollAnimator->currentPosition().y()); |
+ EXPECT_NE(100, scrollAnimator->currentOffset().width()); |
+ EXPECT_NE(0, scrollAnimator->currentOffset().width()); |
+ EXPECT_EQ(0, scrollAnimator->currentOffset().height()); |
gMockedTime += 1.0; |
scrollAnimator->updateCompositorAnimations(); |
@@ -274,33 +276,28 @@ TEST(ScrollAnimatorTest, MainThreadEnabled) { |
gMockedTime += 0.05; |
scrollAnimator->updateCompositorAnimations(); |
EXPECT_FALSE(scrollAnimator->hasAnimationThatRequiresService()); |
- EXPECT_EQ(100, scrollAnimator->currentPosition().x()); |
+ EXPECT_EQ(100, scrollAnimator->currentOffset().width()); |
reset(*scrollAnimator); |
scrollAnimator->userScroll(ScrollByPrecisePixel, FloatSize(100, 0)); |
EXPECT_FALSE(scrollAnimator->hasAnimationThatRequiresService()); |
- EXPECT_EQ(100, scrollAnimator->currentPosition().x()); |
- EXPECT_NE(0, scrollAnimator->currentPosition().x()); |
- EXPECT_EQ(0, scrollAnimator->currentPosition().y()); |
+ EXPECT_EQ(100, scrollAnimator->currentOffset().width()); |
+ EXPECT_NE(0, scrollAnimator->currentOffset().width()); |
+ EXPECT_EQ(0, scrollAnimator->currentOffset().height()); |
reset(*scrollAnimator); |
} |
// Test that a smooth scroll offset animation is aborted when followed by a |
// non-smooth scroll offset animation. |
TEST(ScrollAnimatorTest, AnimatedScrollAborted) { |
- MockScrollableArea* scrollableArea = MockScrollableArea::create(true); |
+ MockScrollableArea* scrollableArea = MockScrollableArea::create( |
+ true, ScrollOffset(), ScrollOffset(1000, 1000)); |
ScrollAnimator* scrollAnimator = |
new ScrollAnimator(scrollableArea, 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(3); |
+ EXPECT_CALL(*scrollableArea, updateScrollOffset(_, _)).Times(3); |
EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(2); |
EXPECT_CALL(*scrollableArea, scheduleAnimation()) |
.Times(AtLeast(1)) |
@@ -320,11 +317,11 @@ TEST(ScrollAnimatorTest, AnimatedScrollAborted) { |
scrollAnimator->updateCompositorAnimations(); |
scrollAnimator->tickAnimation(getMockedTime()); |
- EXPECT_NE(100, scrollAnimator->currentPosition().x()); |
- EXPECT_NE(0, scrollAnimator->currentPosition().x()); |
- EXPECT_EQ(0, scrollAnimator->currentPosition().y()); |
+ EXPECT_NE(100, scrollAnimator->currentOffset().width()); |
+ EXPECT_NE(0, scrollAnimator->currentOffset().width()); |
+ EXPECT_EQ(0, scrollAnimator->currentOffset().height()); |
- float x = scrollAnimator->currentPosition().x(); |
+ float x = scrollAnimator->currentOffset().width(); |
// Instant scroll. |
result = scrollAnimator->userScroll(ScrollByPrecisePixel, FloatSize(100, 0)); |
@@ -332,8 +329,8 @@ TEST(ScrollAnimatorTest, AnimatedScrollAborted) { |
gMockedTime += 0.05; |
scrollAnimator->updateCompositorAnimations(); |
EXPECT_FALSE(scrollAnimator->hasRunningAnimation()); |
- EXPECT_EQ(x + 100, scrollAnimator->currentPosition().x()); |
- EXPECT_EQ(0, scrollAnimator->currentPosition().y()); |
+ EXPECT_EQ(x + 100, scrollAnimator->currentOffset().width()); |
+ EXPECT_EQ(0, scrollAnimator->currentOffset().height()); |
reset(*scrollAnimator); |
} |
@@ -341,17 +338,12 @@ TEST(ScrollAnimatorTest, AnimatedScrollAborted) { |
// Test that a smooth scroll offset animation running on the compositor is |
// completed on the main thread. |
TEST(ScrollAnimatorTest, AnimatedScrollTakeover) { |
- MockScrollableArea* scrollableArea = MockScrollableArea::create(true); |
+ MockScrollableArea* scrollableArea = MockScrollableArea::create( |
+ true, ScrollOffset(), ScrollOffset(1000, 1000)); |
TestScrollAnimator* scrollAnimator = |
new TestScrollAnimator(scrollableArea, 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(2); |
+ EXPECT_CALL(*scrollableArea, updateScrollOffset(_, _)).Times(2); |
// Called from userScroll, updateCompositorAnimations, then |
// takeOverCompositorAnimation (to re-register after RunningOnCompositor). |
EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(3); |
@@ -388,70 +380,60 @@ TEST(ScrollAnimatorTest, AnimatedScrollTakeover) { |
EXPECT_EQ(scrollAnimator->m_runState, |
ScrollAnimatorCompositorCoordinator::RunState::RunningOnMainThread); |
scrollAnimator->tickAnimation(getMockedTime()); |
- EXPECT_NE(100, scrollAnimator->currentPosition().x()); |
- EXPECT_NE(0, scrollAnimator->currentPosition().x()); |
- EXPECT_EQ(0, scrollAnimator->currentPosition().y()); |
+ EXPECT_NE(100, scrollAnimator->currentOffset().width()); |
+ EXPECT_NE(0, scrollAnimator->currentOffset().width()); |
+ EXPECT_EQ(0, scrollAnimator->currentOffset().height()); |
reset(*scrollAnimator); |
} |
TEST(ScrollAnimatorTest, Disabled) { |
- MockScrollableArea* scrollableArea = MockScrollableArea::create(false); |
+ MockScrollableArea* scrollableArea = MockScrollableArea::create( |
+ false, ScrollOffset(), ScrollOffset(1000, 1000)); |
ScrollAnimator* scrollAnimator = |
new ScrollAnimator(scrollableArea, 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(8); |
+ EXPECT_CALL(*scrollableArea, updateScrollOffset(_, _)).Times(8); |
EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(0); |
scrollAnimator->userScroll(ScrollByLine, FloatSize(100, 0)); |
- EXPECT_EQ(100, scrollAnimator->currentPosition().x()); |
- EXPECT_EQ(0, scrollAnimator->currentPosition().y()); |
+ EXPECT_EQ(100, scrollAnimator->currentOffset().width()); |
+ EXPECT_EQ(0, scrollAnimator->currentOffset().height()); |
reset(*scrollAnimator); |
scrollAnimator->userScroll(ScrollByPage, FloatSize(100, 0)); |
- EXPECT_EQ(100, scrollAnimator->currentPosition().x()); |
- EXPECT_EQ(0, scrollAnimator->currentPosition().y()); |
+ EXPECT_EQ(100, scrollAnimator->currentOffset().width()); |
+ EXPECT_EQ(0, scrollAnimator->currentOffset().height()); |
reset(*scrollAnimator); |
scrollAnimator->userScroll(ScrollByDocument, FloatSize(100, 0)); |
- EXPECT_EQ(100, scrollAnimator->currentPosition().x()); |
- EXPECT_EQ(0, scrollAnimator->currentPosition().y()); |
+ EXPECT_EQ(100, scrollAnimator->currentOffset().width()); |
+ EXPECT_EQ(0, scrollAnimator->currentOffset().height()); |
reset(*scrollAnimator); |
scrollAnimator->userScroll(ScrollByPixel, FloatSize(100, 0)); |
- EXPECT_EQ(100, scrollAnimator->currentPosition().x()); |
- EXPECT_EQ(0, scrollAnimator->currentPosition().y()); |
+ EXPECT_EQ(100, scrollAnimator->currentOffset().width()); |
+ EXPECT_EQ(0, scrollAnimator->currentOffset().height()); |
reset(*scrollAnimator); |
} |
// Test that cancelling an animation resets the animation state. |
// See crbug.com/598548. |
TEST(ScrollAnimatorTest, CancellingAnimationResetsState) { |
- MockScrollableArea* scrollableArea = MockScrollableArea::create(true); |
+ MockScrollableArea* scrollableArea = MockScrollableArea::create( |
+ true, ScrollOffset(), ScrollOffset(1000, 1000)); |
ScrollAnimator* scrollAnimator = |
new ScrollAnimator(scrollableArea, getMockedTime); |
- EXPECT_CALL(*scrollableArea, minimumScrollPosition()) |
- .Times(AtLeast(1)) |
- .WillRepeatedly(Return(IntPoint())); |
- EXPECT_CALL(*scrollableArea, maximumScrollPosition()) |
- .Times(AtLeast(1)) |
- .WillRepeatedly(Return(IntPoint(1000, 1000))); |
- // Called from first userScroll, setCurrentPosition, and second userScroll. |
- EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(3); |
+ // Called from first userScroll, setCurrentOffset, and second userScroll. |
+ EXPECT_CALL(*scrollableArea, updateScrollOffset(_, _)).Times(3); |
// Called from userScroll, updateCompositorAnimations. |
EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(4); |
EXPECT_CALL(*scrollableArea, scheduleAnimation()) |
.Times(AtLeast(1)) |
.WillRepeatedly(Return(true)); |
- EXPECT_EQ(0, scrollAnimator->currentPosition().x()); |
- EXPECT_EQ(0, scrollAnimator->currentPosition().y()); |
+ EXPECT_EQ(0, scrollAnimator->currentOffset().width()); |
+ EXPECT_EQ(0, scrollAnimator->currentOffset().height()); |
// WaitingToSendToCompositor |
scrollAnimator->userScroll(ScrollByLine, FloatSize(10, 0)); |
@@ -469,7 +451,7 @@ TEST(ScrollAnimatorTest, CancellingAnimationResetsState) { |
ScrollAnimatorCompositorCoordinator::RunState::RunningOnMainThread); |
// Amount scrolled so far. |
- float offsetX = scrollAnimator->currentPosition().x(); |
+ float offsetX = scrollAnimator->currentOffset().width(); |
// Interrupt user scroll. |
scrollAnimator->cancelAnimation(); |
@@ -478,7 +460,7 @@ TEST(ScrollAnimatorTest, CancellingAnimationResetsState) { |
ScrollAnimatorCompositorCoordinator::RunState::PostAnimationCleanup); |
// Another userScroll after modified scroll offset. |
- scrollAnimator->setCurrentPosition(FloatPoint(offsetX + 15, 0)); |
+ scrollAnimator->setCurrentOffset(ScrollOffset(offsetX + 15, 0)); |
scrollAnimator->userScroll(ScrollByLine, FloatSize(10, 0)); |
EXPECT_EQ( |
scrollAnimator->m_runState, |
@@ -492,26 +474,21 @@ TEST(ScrollAnimatorTest, CancellingAnimationResetsState) { |
scrollAnimator->m_runState, |
ScrollAnimatorCompositorCoordinator::RunState::PostAnimationCleanup); |
- EXPECT_EQ(offsetX + 15 + 10, scrollAnimator->currentPosition().x()); |
- EXPECT_EQ(0, scrollAnimator->currentPosition().y()); |
+ EXPECT_EQ(offsetX + 15 + 10, scrollAnimator->currentOffset().width()); |
+ EXPECT_EQ(0, scrollAnimator->currentOffset().height()); |
reset(*scrollAnimator); |
} |
// Test the behavior when in WaitingToCancelOnCompositor and a new user scroll |
// happens. |
TEST(ScrollAnimatorTest, CancellingCompositorAnimation) { |
- MockScrollableArea* scrollableArea = MockScrollableArea::create(true); |
+ MockScrollableArea* scrollableArea = MockScrollableArea::create( |
+ true, ScrollOffset(), ScrollOffset(1000, 1000)); |
TestScrollAnimator* scrollAnimator = |
new TestScrollAnimator(scrollableArea, getMockedTime); |
- EXPECT_CALL(*scrollableArea, minimumScrollPosition()) |
- .Times(AtLeast(1)) |
- .WillRepeatedly(Return(IntPoint())); |
- EXPECT_CALL(*scrollableArea, maximumScrollPosition()) |
- .Times(AtLeast(1)) |
- .WillRepeatedly(Return(IntPoint(1000, 1000))); |
// Called when reset, not setting anywhere else. |
- EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(1); |
+ EXPECT_CALL(*scrollableArea, updateScrollOffset(_, _)).Times(1); |
// Called from userScroll, and first update. |
EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(4); |
EXPECT_CALL(*scrollableArea, scheduleAnimation()) |
@@ -527,8 +504,8 @@ TEST(ScrollAnimatorTest, CancellingCompositorAnimation) { |
EXPECT_TRUE(result.didScrollX); |
EXPECT_FLOAT_EQ(0.0, result.unusedScrollDeltaX); |
EXPECT_TRUE(scrollAnimator->hasRunningAnimation()); |
- EXPECT_EQ(100, scrollAnimator->desiredTargetPosition().x()); |
- EXPECT_EQ(0, scrollAnimator->desiredTargetPosition().y()); |
+ EXPECT_EQ(100, scrollAnimator->desiredTargetOffset().width()); |
+ EXPECT_EQ(0, scrollAnimator->desiredTargetOffset().height()); |
// Update compositor animation. |
gMockedTime += 0.05; |
@@ -543,10 +520,10 @@ TEST(ScrollAnimatorTest, CancellingCompositorAnimation) { |
ScrollAnimatorCompositorCoordinator::RunState:: |
WaitingToCancelOnCompositor); |
- // Unrelated scroll position update. |
- scrollAnimator->setCurrentPosition(FloatPoint(50, 0)); |
+ // Unrelated scroll offset update. |
+ scrollAnimator->setCurrentOffset(ScrollOffset(50, 0)); |
- // Desired target position should be that of the second scroll. |
+ // Desired target offset should be that of the second scroll. |
result = scrollAnimator->userScroll(ScrollByLine, FloatSize(100, 0)); |
EXPECT_TRUE(scrollAnimator->hasAnimationThatRequiresService()); |
EXPECT_TRUE(result.didScrollX); |
@@ -554,8 +531,8 @@ TEST(ScrollAnimatorTest, CancellingCompositorAnimation) { |
EXPECT_EQ(scrollAnimator->m_runState, |
ScrollAnimatorCompositorCoordinator::RunState:: |
WaitingToCancelOnCompositorButNewScroll); |
- EXPECT_EQ(150, scrollAnimator->desiredTargetPosition().x()); |
- EXPECT_EQ(0, scrollAnimator->desiredTargetPosition().y()); |
+ EXPECT_EQ(150, scrollAnimator->desiredTargetOffset().width()); |
+ EXPECT_EQ(0, scrollAnimator->desiredTargetOffset().height()); |
// Update compositor animation. |
gMockedTime += 0.05; |
@@ -571,8 +548,8 @@ TEST(ScrollAnimatorTest, CancellingCompositorAnimation) { |
EXPECT_EQ(scrollAnimator->m_runState, |
ScrollAnimatorCompositorCoordinator::RunState:: |
RunningOnCompositorButNeedsUpdate); |
- EXPECT_EQ(250, scrollAnimator->desiredTargetPosition().x()); |
- EXPECT_EQ(0, scrollAnimator->desiredTargetPosition().y()); |
+ EXPECT_EQ(250, scrollAnimator->desiredTargetOffset().width()); |
+ EXPECT_EQ(0, scrollAnimator->desiredTargetOffset().height()); |
reset(*scrollAnimator); |
// Forced GC in order to finalize objects depending on the mock object. |
@@ -582,7 +559,8 @@ TEST(ScrollAnimatorTest, CancellingCompositorAnimation) { |
// This test verifies that impl only animation updates get cleared once they |
// are pushed to compositor animation host. |
TEST(ScrollAnimatorTest, ImplOnlyAnimationUpdatesCleared) { |
- MockScrollableArea* scrollableArea = MockScrollableArea::create(true); |
+ MockScrollableArea* scrollableArea = MockScrollableArea::create( |
+ true, ScrollOffset(), ScrollOffset(1000, 1000)); |
TestScrollAnimator* animator = |
new TestScrollAnimator(scrollableArea, getMockedTime); |
@@ -618,19 +596,14 @@ TEST(ScrollAnimatorTest, ImplOnlyAnimationUpdatesCleared) { |
} |
TEST(ScrollAnimatorTest, MainThreadAnimationTargetAdjustment) { |
- MockScrollableArea* scrollableArea = MockScrollableArea::create(true); |
+ MockScrollableArea* scrollableArea = MockScrollableArea::create( |
+ true, ScrollOffset(-100, -100), ScrollOffset(1000, 1000)); |
ScrollAnimator* animator = new ScrollAnimator(scrollableArea, getMockedTime); |
scrollableArea->setScrollAnimator(animator); |
- EXPECT_CALL(*scrollableArea, minimumScrollPosition()) |
- .Times(AtLeast(1)) |
- .WillRepeatedly(Return(IntPoint(-100, -100))); |
- EXPECT_CALL(*scrollableArea, maximumScrollPosition()) |
- .Times(AtLeast(1)) |
- .WillRepeatedly(Return(IntPoint(1000, 1000))); |
// Twice from tickAnimation, once from reset, and twice from |
- // adjustAnimationAndSetScrollPosition. |
- EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(5); |
+ // adjustAnimationAndSetScrollOffset. |
+ EXPECT_CALL(*scrollableArea, updateScrollOffset(_, _)).Times(5); |
// One from call to userScroll and one from updateCompositorAnimations. |
EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(2); |
EXPECT_CALL(*scrollableArea, scheduleAnimation()) |
@@ -639,24 +612,24 @@ TEST(ScrollAnimatorTest, MainThreadAnimationTargetAdjustment) { |
// Idle |
EXPECT_FALSE(animator->hasAnimationThatRequiresService()); |
- EXPECT_EQ(FloatPoint(), animator->currentPosition()); |
+ EXPECT_EQ(ScrollOffset(), animator->currentOffset()); |
// WaitingToSendToCompositor |
- animator->userScroll(ScrollByLine, FloatSize(100, 100)); |
+ animator->userScroll(ScrollByLine, ScrollOffset(100, 100)); |
// RunningOnMainThread |
gMockedTime += 0.05; |
animator->updateCompositorAnimations(); |
animator->tickAnimation(getMockedTime()); |
- FloatPoint pos = animator->currentPosition(); |
- EXPECT_EQ(FloatPoint(100, 100), animator->desiredTargetPosition()); |
- EXPECT_GT(pos.x(), 0); |
- EXPECT_GT(pos.y(), 0); |
+ ScrollOffset offset = animator->currentOffset(); |
+ EXPECT_EQ(ScrollOffset(100, 100), animator->desiredTargetOffset()); |
+ EXPECT_GT(offset.width(), 0); |
+ EXPECT_GT(offset.height(), 0); |
// Adjustment |
- FloatPoint newPos = pos + FloatSize(10, -10); |
- animator->adjustAnimationAndSetScrollPosition(newPos, AnchoringScroll); |
- EXPECT_EQ(FloatPoint(110, 90), animator->desiredTargetPosition()); |
+ ScrollOffset newOffset = offset + ScrollOffset(10, -10); |
+ animator->adjustAnimationAndSetScrollOffset(newOffset, AnchoringScroll); |
+ EXPECT_EQ(ScrollOffset(110, 90), animator->desiredTargetOffset()); |
// Adjusting after finished animation should do nothing. |
gMockedTime += 1.0; |
@@ -665,12 +638,12 @@ TEST(ScrollAnimatorTest, MainThreadAnimationTargetAdjustment) { |
EXPECT_EQ( |
animator->runStateForTesting(), |
ScrollAnimatorCompositorCoordinator::RunState::PostAnimationCleanup); |
- newPos = animator->currentPosition() + FloatSize(10, -10); |
- animator->adjustAnimationAndSetScrollPosition(newPos, AnchoringScroll); |
+ newOffset = animator->currentOffset() + ScrollOffset(10, -10); |
+ animator->adjustAnimationAndSetScrollOffset(newOffset, AnchoringScroll); |
EXPECT_EQ( |
animator->runStateForTesting(), |
ScrollAnimatorCompositorCoordinator::RunState::PostAnimationCleanup); |
- EXPECT_EQ(FloatPoint(110, 90), animator->desiredTargetPosition()); |
+ EXPECT_EQ(ScrollOffset(110, 90), animator->desiredTargetOffset()); |
reset(*animator); |