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

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

Issue 230663004: Fix WebKeyboardEvent interruption of compositor scrolling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Created 6 years, 8 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 b880436f0d40af68d9ec73fb9ffcb783887592c7..2f0be4a7c2ca9a81678a04ef7f816788d5238804 100644
--- a/content/renderer/input/input_handler_proxy_unittest.cc
+++ b/content/renderer/input/input_handler_proxy_unittest.cc
@@ -23,6 +23,7 @@ using blink::WebFloatPoint;
using blink::WebFloatSize;
using blink::WebGestureEvent;
using blink::WebInputEvent;
+using blink::WebKeyboardEvent;
using blink::WebMouseWheelEvent;
using blink::WebPoint;
using blink::WebSize;
@@ -1257,5 +1258,57 @@ TEST_F(InputHandlerProxyTest, MultiTouchPointHitTestPositive) {
EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch));
}
+TEST_F(InputHandlerProxyTest, GestureFlingCancelledByKeyboardEvent) {
+ // We shouldn't send any events to the widget for this gesture.
+ expected_disposition_ = InputHandlerProxy::DID_HANDLE;
+ VERIFY_AND_RESET_MOCKS();
+
+ EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
+ .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
+ gesture_.type = WebInputEvent::GestureScrollBegin;
+ gesture_.sourceDevice = WebGestureEvent::Touchscreen;
+ EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
+ EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
+ testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
+
+ // Keyboard events received during a scroll should have no effect.
+ WebKeyboardEvent key_event;
+ key_event.type = WebInputEvent::KeyDown;
+ EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE,
+ input_handler_->HandleInputEvent(key_event));
+ EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
+ testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
+
+ // On the fling start, animation should be scheduled, but no scrolling occurs.
+ gesture_.type = WebInputEvent::GestureFlingStart;
+ WebFloatPoint fling_delta = WebFloatPoint(1000, 1000);
+ gesture_.data.flingStart.velocityX = fling_delta.x;
+ gesture_.data.flingStart.velocityY = fling_delta.y;
+ EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
+ .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
+ EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
+ EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
+ EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
+ testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
+
+ // Keyboard events received during a fling should cancel the active fling.
+ EXPECT_CALL(mock_input_handler_, ScrollEnd());
+ EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE,
+ input_handler_->HandleInputEvent(key_event));
+ EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
+ testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
+
+ // The call to animate should have no effect, as the fling was cancelled.
+ base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
+ input_handler_->Animate(time);
+ testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
+
+ // A fling cancel should be dropped, as there is nothing to cancel.
+ gesture_.type = WebInputEvent::GestureFlingCancel;
+ EXPECT_EQ(InputHandlerProxy::DROP_EVENT,
+ input_handler_->HandleInputEvent(gesture_));
+ EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
+}
+
} // 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