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

Unified Diff: ui/events/blink/input_handler_proxy_unittest.cc

Issue 2625453002: Touchpad and wheel scroll latching for ChromeOS behind flag. (Closed)
Patch Set: ScrollEnd gets called when the fling ends before hitting a scroll extent. Created 3 years, 11 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 | « ui/events/blink/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: ui/events/blink/input_handler_proxy_unittest.cc
diff --git a/ui/events/blink/input_handler_proxy_unittest.cc b/ui/events/blink/input_handler_proxy_unittest.cc
index 0b7a14b7f1f258c5e4be18b7ed319903e5248f3e..00e94d1a19ff1242e2c84f4d9abea1dcf0ed9c1e 100644
--- a/ui/events/blink/input_handler_proxy_unittest.cc
+++ b/ui/events/blink/input_handler_proxy_unittest.cc
@@ -454,6 +454,10 @@ class InputHandlerProxyTest
input_handler_->smooth_scroll_enabled_ = value;
}
+ void SetTouchpadAndWheelScrollLatchingEnabled(bool value) {
+ input_handler_->touchpad_and_wheel_scroll_latching_enabled_ = value;
+ }
+
base::HistogramTester& histogram_tester() {
return histogram_tester_;
}
@@ -918,6 +922,100 @@ TEST_P(InputHandlerProxyTest, GestureFlingStartedTouchpad) {
EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
}
+TEST_P(InputHandlerProxyTest, GestureFlingTouchpadScrollLatchingEnabled) {
+ SetTouchpadAndWheelScrollLatchingEnabled(true);
+ // 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(kImplThreadScrollState));
+
+ // HandleGestureScrollBegin will set gesture_scroll_on_impl_thread_.
+ gesture_.setType(WebInputEvent::GestureScrollBegin);
+ EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
+ EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
+
+ VERIFY_AND_RESET_MOCKS();
+
+ // On the fling start, we should schedule an animation but not actually start
+ // scrolling.
+ gesture_.setType(WebInputEvent::GestureFlingStart);
+ WebFloatPoint fling_delta = WebFloatPoint(1000, 0);
+ WebPoint fling_point = WebPoint(7, 13);
+ WebPoint fling_global_point = WebPoint(17, 23);
+ // Note that for trackpad, wheel events with the Control modifier are
+ // special (reserved for zoom), so don't set that here.
+ int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey;
+ gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, fling_delta,
+ fling_point, fling_global_point, modifiers);
+ EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
+ EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
+ .WillOnce(testing::Return(kImplThreadScrollState));
+
+ // When scroll latching is enabled, ScrollEnd shouldn't get called while
+ // handling GestureFlingStart.
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0);
+ EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
+
+ VERIFY_AND_RESET_MOCKS();
+
+ // The first animate call won't start scrolling.
+ EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
+ base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
+ Animate(time);
+
+ VERIFY_AND_RESET_MOCKS();
+
+ // The second call should start scrolling in the -X direction.
+ EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
+ EXPECT_CALL(mock_input_handler_,
+ GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
+ .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
+
+ // When scroll latching is enabled, ScrollBegin shouldn't get called for
+ // every tick.
+ EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
+ .Times(0);
+ EXPECT_CALL(
+ mock_input_handler_,
+ ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
+ .WillOnce(testing::Return(scroll_result_did_scroll_));
+
+ // When scroll latching is enabled, ScrollEnd shouldn't get called for every
+ // tick.
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0);
+ time += base::TimeDelta::FromMilliseconds(100);
+ Animate(time);
+
+ VERIFY_AND_RESET_MOCKS();
+
+ // The last call should stop scrolling.
+ EXPECT_CALL(mock_input_handler_,
+ GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
+ .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
+
+ // When scroll latching is enabled, ScrollBegin shouldn't get called for
+ // every tick.
+ EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
+ .Times(0);
+ EXPECT_CALL(
+ mock_input_handler_,
+ ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
+ .WillOnce(testing::Return(scroll_result_did_not_scroll_));
+
+ // When scroll latching is enabled, ScrollEnd gets called when the last
+ // ScrollBy did not scroll.
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
+ time += base::TimeDelta::FromMilliseconds(100);
+ Animate(time);
+
+ // Fling has ended, the last Animate won't cause any more wheel ticks.
+ EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0);
bokan 2017/01/12 19:33:17 This needs to go above the Animate call to be effe
sahel 2017/01/12 19:45:22 Thanks for the doc, I will do that. I think it's e
+
+ VERIFY_AND_RESET_MOCKS();
+}
+
TEST_P(InputHandlerProxyTest, GestureFlingOnMainThreadTouchpad) {
// We should send all events to the widget for this gesture.
expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
« no previous file with comments | « ui/events/blink/input_handler_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698