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

Unified Diff: third_party/WebKit/Source/platform/scroll/ScrollAnimatorTest.cpp

Issue 1852753002: Restore handling of new scroll when waiting to cancel current scroll on cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase master review feedback Created 4 years, 9 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 | « third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3bc1b300d57f11d7300ebaf4a89b93916338506f..0298780e888e23de675fc26ca134613779f37009 100644
--- a/third_party/WebKit/Source/platform/scroll/ScrollAnimatorTest.cpp
+++ b/third_party/WebKit/Source/platform/scroll/ScrollAnimatorTest.cpp
@@ -444,4 +444,77 @@ TEST(ScrollAnimatorTest, CancellingAnimationResetsState)
reset(*scrollAnimator);
}
+// Test the behavior when in WaitingToCancelOnCompositor and a new user scroll
+// happens.
+TEST(ScrollAnimatorTest, CancellingCompositorAnimation)
+{
+ RawPtr<MockScrollableArea> scrollableArea = MockScrollableArea::create(true);
+ RawPtr<TestScrollAnimator> scrollAnimator = adoptPtrWillBeNoop(new TestScrollAnimator(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)));
+ // Called when reset, not setting anywhere else.
+ EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(1);
+ // Called from first and last user scroll, and first update.
+ EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(3);
+ EXPECT_CALL(*scrollableArea, scheduleAnimation()).Times(AtLeast(1))
+ .WillRepeatedly(Return(true));
+
+ EXPECT_FALSE(scrollAnimator->hasAnimationThatRequiresService());
+
+ // First user scroll.
+ ScrollResult result = scrollAnimator->userScroll(ScrollByLine, FloatSize(100, 0));
+ EXPECT_TRUE(scrollAnimator->hasAnimationThatRequiresService());
+ 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());
+
+ // Update compositor animation.
+ gMockedTime += 0.05;
+ scrollAnimator->setShouldSendToCompositor(true);
+ scrollAnimator->updateCompositorAnimations();
+ EXPECT_EQ(scrollAnimator->m_runState,
+ ScrollAnimatorCompositorCoordinator::RunState::RunningOnCompositor);
+
+ // Cancel
+ scrollAnimator->cancelAnimation();
+ EXPECT_EQ(scrollAnimator->m_runState,
+ ScrollAnimatorCompositorCoordinator::RunState::WaitingToCancelOnCompositor);
+
+ // Second user scroll should not affect the run state.
+ result = scrollAnimator->userScroll(ScrollByLine, FloatSize(100, 0));
+ EXPECT_TRUE(scrollAnimator->hasAnimationThatRequiresService());
+ EXPECT_TRUE(result.didScrollX);
+ EXPECT_FLOAT_EQ(0.0, result.unusedScrollDeltaX);
+ EXPECT_EQ(scrollAnimator->m_runState,
+ ScrollAnimatorCompositorCoordinator::RunState::WaitingToCancelOnCompositor);
+ // Desired target position is what it was before.
+ EXPECT_EQ(100, scrollAnimator->desiredTargetPosition().x());
+ EXPECT_EQ(0, scrollAnimator->desiredTargetPosition().y());
+
+ // Update compositor animation.
+ gMockedTime += 0.05;
+ scrollAnimator->updateCompositorAnimations();
+ EXPECT_EQ(scrollAnimator->m_runState,
+ ScrollAnimatorCompositorCoordinator::RunState::Idle);
+
+ // Third user scroll after compositor update is treated like a new scroll.
+ result = scrollAnimator->userScroll(ScrollByLine, FloatSize(100, 0));
+ EXPECT_TRUE(scrollAnimator->hasAnimationThatRequiresService());
+ EXPECT_TRUE(result.didScrollX);
+ EXPECT_FLOAT_EQ(0.0, result.unusedScrollDeltaX);
+ EXPECT_EQ(scrollAnimator->m_runState,
+ ScrollAnimatorCompositorCoordinator::RunState::WaitingToSendToCompositor);
+ EXPECT_EQ(100, scrollAnimator->desiredTargetPosition().x());
+ EXPECT_EQ(0, scrollAnimator->desiredTargetPosition().y());
+ reset(*scrollAnimator);
+
+ // Forced GC in order to finalize objects depending on the mock object.
+ Heap::collectAllGarbage();
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698