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 |