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

Unified Diff: content/renderer/input/input_handler_proxy_unittest.cc

Issue 473053002: Properly resume scrolling if a fling ends during a suppressed scroll (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 6 years, 4 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 | « content/renderer/input/input_handler_proxy.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/input/input_handler_proxy_unittest.cc
diff --git a/content/renderer/input/input_handler_proxy_unittest.cc b/content/renderer/input/input_handler_proxy_unittest.cc
index d932424e9a6a5bad9912caccba17b4432f87a2be..d9ca67ce3895f427d8e9a681ffc0a8efe730ed5b 100644
--- a/content/renderer/input/input_handler_proxy_unittest.cc
+++ b/content/renderer/input/input_handler_proxy_unittest.cc
@@ -1856,5 +1856,75 @@ TEST_F(InputHandlerProxyTest, NoFlingBoostIfFlingTooSlow) {
VERIFY_AND_RESET_MOCKS();
}
+TEST_F(InputHandlerProxyTest, FlingBoostTerminatedDuringScrollSequence) {
+ base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10);
+ base::TimeTicks time = base::TimeTicks() + dt;
+ base::TimeTicks last_animate_time = time;
+ WebFloatPoint fling_delta = WebFloatPoint(1000, 0);
+ WebPoint fling_point = WebPoint(7, 13);
+ StartFling(
+ time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point);
+
+ // Now cancel the fling. The fling cancellation should be deferred to allow
+ // fling boosting events to arrive.
+ time += dt;
+ CancelFling(time);
+
+ // The GestureScrollBegin should be swallowed by the fling.
+ time += dt;
+ gesture_.timeStampSeconds = InSecondsF(time);
+ gesture_.type = WebInputEvent::GestureScrollBegin;
+ EXPECT_CALL(mock_input_handler_,
+ IsCurrentlyScrollingLayerAt(testing::_, testing::_))
+ .WillOnce(testing::Return(true));
+ EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
+
+ VERIFY_AND_RESET_MOCKS();
+
+ // Now animate the fling to completion (in this case, the fling should
+ // terminate because the input handler reports a failed scroll). As the fling
+ // was cancelled during an active scroll sequence, a synthetic
+ // GestureScrollBegin should be processed, resuming the scroll.
+ time += dt;
+ float expected_delta =
+ (time - last_animate_time).InSecondsF() * -fling_delta.x;
+ EXPECT_CALL(mock_input_handler_,
+ ScrollBy(testing::_,
+ testing::Property(&gfx::Vector2dF::x,
+ testing::Eq(expected_delta))))
+ .WillOnce(testing::Return(false));
+ EXPECT_CALL(mock_input_handler_, ScrollEnd());
+ EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
+ .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
+ input_handler_->Animate(time);
+
+ VERIFY_AND_RESET_MOCKS();
+
+ // Subsequent GestureScrollUpdates after the cancelled, boosted fling should
+ // cause scrolling as usual.
+ time += dt;
+ expected_delta = 7.3f;
+ gesture_.timeStampSeconds = InSecondsF(time);
+ gesture_.type = WebInputEvent::GestureScrollUpdate;
+ gesture_.data.scrollUpdate.deltaX = -expected_delta;
+ EXPECT_CALL(mock_input_handler_,
+ ScrollBy(testing::_,
+ testing::Property(&gfx::Vector2dF::x,
+ testing::Eq(expected_delta))))
+ .WillOnce(testing::Return(true));
+ EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
+
+ VERIFY_AND_RESET_MOCKS();
+
+ // GestureScrollEnd should terminate the resumed scroll properly.
+ time += dt;
+ gesture_.timeStampSeconds = InSecondsF(time);
+ gesture_.type = WebInputEvent::GestureScrollEnd;
+ EXPECT_CALL(mock_input_handler_, ScrollEnd());
+ EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
+
+ VERIFY_AND_RESET_MOCKS();
+}
+
} // namespace
} // namespace content
« no previous file with comments | « content/renderer/input/input_handler_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698