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

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

Issue 2802993003: Event unittests cover both wheel scroll latching and propagating cases. (Closed)
Patch Set: Created 3 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 | « no previous file | 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 8fc6a4ab5883482c425dd2fc04df4950502db26c..c434f871a220d011c5f604df291491125e0ca9a4 100644
--- a/ui/events/blink/input_handler_proxy_unittest.cc
+++ b/ui/events/blink/input_handler_proxy_unittest.cc
@@ -181,6 +181,7 @@ class MockInputHandler : public cc::InputHandler {
MOCK_METHOD1(ScrollBy, cc::InputHandlerScrollResult(cc::ScrollState*));
MOCK_METHOD1(ScrollEnd, void(cc::ScrollState*));
MOCK_METHOD0(FlingScrollBegin, cc::InputHandler::ScrollStatus());
+ MOCK_METHOD0(ScrollingShouldSwitchtoMainThread, bool());
std::unique_ptr<cc::SwapPromiseMonitor> CreateLatencyInfoSwapPromiseMonitor(
ui::LatencyInfo* latency) override {
@@ -198,8 +199,6 @@ class MockInputHandler : public cc::InputHandler {
return false;
}
- bool ScrollingShouldSwitchtoMainThread() override { return false; }
-
void BindToClient(cc::InputHandlerClient* client,
bool touchpad_and_wheel_scroll_latching_enabled) override {}
@@ -371,14 +370,17 @@ class InputHandlerProxyTest
: public testing::Test,
public testing::WithParamInterface<InputHandlerProxyTestType> {
public:
- InputHandlerProxyTest()
+ InputHandlerProxyTest(bool touchpad_and_wheel_scroll_latching_enabled = true)
: synchronous_root_scroll_(GetParam() == ROOT_SCROLL_SYNCHRONOUS_HANDLER),
install_synchronous_handler_(
GetParam() == ROOT_SCROLL_SYNCHRONOUS_HANDLER ||
GetParam() == CHILD_SCROLL_SYNCHRONOUS_HANDLER),
- expected_disposition_(InputHandlerProxy::DID_HANDLE) {
+ expected_disposition_(InputHandlerProxy::DID_HANDLE),
+ touchpad_and_wheel_scroll_latching_enabled_(
+ touchpad_and_wheel_scroll_latching_enabled) {
input_handler_.reset(
- new TestInputHandlerProxy(&mock_input_handler_, &mock_client_, false));
+ new TestInputHandlerProxy(&mock_input_handler_, &mock_client_,
+ touchpad_and_wheel_scroll_latching_enabled_));
scroll_result_did_scroll_.did_scroll = true;
scroll_result_did_not_scroll_.did_scroll = false;
@@ -396,9 +398,7 @@ class InputHandlerProxyTest
gesture_.sourceDevice = blink::WebGestureDeviceTouchpad;
}
- ~InputHandlerProxyTest() {
- input_handler_.reset();
- }
+ virtual ~InputHandlerProxyTest() { input_handler_.reset(); }
// This is defined as a macro so the line numbers can be traced back to the
// correct spot when it fails.
@@ -481,6 +481,14 @@ class InputHandlerProxyTest
}
protected:
+ void GestureFlingAnimatesTouchpad();
+ void DidReceiveInputEvent_ForFling();
+ void GestureScrollStarted();
+ void GestureFlingPassiveListener();
+ void GestureFlingStartedTouchpad();
+ void GestureFlingStopsAtContentEdge();
+ void GestureFlingTransferResetsTouchpad();
+
const bool synchronous_root_scroll_;
const bool install_synchronous_handler_;
testing::StrictMock<MockInputHandler> mock_input_handler_;
@@ -493,6 +501,14 @@ class InputHandlerProxyTest
base::HistogramTester histogram_tester_;
cc::InputHandlerScrollResult scroll_result_did_scroll_;
cc::InputHandlerScrollResult scroll_result_did_not_scroll_;
+ bool touchpad_and_wheel_scroll_latching_enabled_;
+};
+
+class InputHandlerProxyWithoutWheelScrollLatchingTest
+ : public InputHandlerProxyTest {
+ public:
+ InputHandlerProxyWithoutWheelScrollLatchingTest()
+ : InputHandlerProxyTest(false) {}
};
class InputHandlerProxyEventQueueTest : public testing::Test {
@@ -506,7 +522,7 @@ class InputHandlerProxyEventQueueTest : public testing::Test {
void SetUp() override {
event_disposition_recorder_.clear();
input_handler_proxy_ = base::MakeUnique<TestInputHandlerProxy>(
- &mock_input_handler_, &mock_client_, false);
+ &mock_input_handler_, &mock_client_, true);
sahel 2017/04/06 19:22:29 This test class is independent of wheel scroll lat
dtapuska 2017/04/06 20:11:25 Probably would be best to parameterize it anyway.
sahel 2017/04/07 18:10:24 Done.
if (input_handler_proxy_->compositor_event_queue_)
input_handler_proxy_->compositor_event_queue_ =
base::MakeUnique<CompositorThreadEventQueue>();
@@ -614,7 +630,7 @@ TEST_P(InputHandlerProxyTest, MouseWheelBlockingListener) {
VERIFY_AND_RESET_MOCKS();
}
-TEST_P(InputHandlerProxyTest, GestureScrollStarted) {
+void InputHandlerProxyTest::GestureScrollStarted() {
// We shouldn't send any events to the widget for this gesture.
expected_disposition_ = InputHandlerProxy::DID_HANDLE;
VERIFY_AND_RESET_MOCKS();
@@ -636,6 +652,8 @@ TEST_P(InputHandlerProxyTest, GestureScrollStarted) {
mock_input_handler_,
ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0))))
.WillOnce(testing::Return(scroll_result_did_not_scroll_));
+ EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
+ .WillOnce(testing::Return(false));
EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
// Mark the event as handled if scroll happens.
@@ -660,6 +678,12 @@ TEST_P(InputHandlerProxyTest, GestureScrollStarted) {
VERIFY_AND_RESET_MOCKS();
}
+TEST_P(InputHandlerProxyTest, GestureScrollStarted) {
+ GestureScrollStarted();
+}
+TEST_P(InputHandlerProxyWithoutWheelScrollLatchingTest, GestureScrollStarted) {
+ GestureScrollStarted();
+}
TEST_P(InputHandlerProxyTest, GestureScrollOnMainThread) {
// We should send all events to the widget for this gesture.
@@ -944,14 +968,25 @@ TEST_P(InputHandlerProxyTest, GesturePinchAfterScrollOnMainThread) {
VERIFY_AND_RESET_MOCKS();
}
-TEST_P(InputHandlerProxyTest, GestureFlingStartedTouchpad) {
+void InputHandlerProxyTest::GestureFlingStartedTouchpad() {
// 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();
+
EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
+ if (!touchpad_and_wheel_scroll_latching_enabled_)
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
gesture_.setType(WebInputEvent::GestureFlingStart);
@@ -961,10 +996,24 @@ TEST_P(InputHandlerProxyTest, GestureFlingStartedTouchpad) {
VERIFY_AND_RESET_MOCKS();
+ if (touchpad_and_wheel_scroll_latching_enabled_) {
+ // The fling cancellation shouldn't get deferred because velocityX is less
+ // than minimum.
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(1);
+ }
// Verify that a GestureFlingCancel during an animation cancels it.
gesture_.setType(WebInputEvent::GestureFlingCancel);
gesture_.sourceDevice = blink::WebGestureDeviceTouchpad;
EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
+
+ VERIFY_AND_RESET_MOCKS();
+}
+TEST_P(InputHandlerProxyTest, GestureFlingStartedTouchpad) {
+ GestureFlingStartedTouchpad();
+}
+TEST_P(InputHandlerProxyWithoutWheelScrollLatchingTest,
+ GestureFlingStartedTouchpad) {
+ GestureFlingStartedTouchpad();
}
TEST_P(InputHandlerProxyTest, GestureFlingTouchpadScrollLatchingEnabled) {
@@ -1057,6 +1106,8 @@ TEST_P(InputHandlerProxyTest, GestureFlingTouchpadScrollLatchingEnabled) {
mock_input_handler_,
ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
.WillOnce(testing::Return(scroll_result_did_not_scroll_));
+ EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
+ .WillOnce(testing::Return(false));
// When scroll latching is enabled, ScrollEnd gets called when the last
// ScrollBy did not scroll.
@@ -1120,11 +1171,21 @@ TEST_P(InputHandlerProxyTest, GestureFlingIgnoredTouchpad) {
EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
}
-TEST_P(InputHandlerProxyTest, GestureFlingAnimatesTouchpad) {
+void InputHandlerProxyTest::GestureFlingAnimatesTouchpad() {
// 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());
sahel 2017/04/06 19:22:29 in latching implementation for handling fling on i
dtapuska 2017/04/06 20:11:25 Seems reasonable to me.
sahel 2017/04/07 18:10:24 Acknowledged.
+
+ VERIFY_AND_RESET_MOCKS();
+
// On the fling start, we should schedule an animation but not actually start
// scrolling.
gesture_.setType(WebInputEvent::GestureFlingStart);
@@ -1142,7 +1203,8 @@ TEST_P(InputHandlerProxyTest, GestureFlingAnimatesTouchpad) {
EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
+ if (!touchpad_and_wheel_scroll_latching_enabled_)
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
VERIFY_AND_RESET_MOCKS();
@@ -1165,13 +1227,16 @@ TEST_P(InputHandlerProxyTest, GestureFlingAnimatesTouchpad) {
EXPECT_CALL(mock_input_handler_,
GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
.WillOnce(testing::Return(cc::EventListenerProperties::kNone));
- EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
- .WillOnce(testing::Return(kImplThreadScrollState));
+ if (!touchpad_and_wheel_scroll_latching_enabled_) {
+ EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
+ .WillOnce(testing::Return(kImplThreadScrollState));
+ }
EXPECT_CALL(
mock_input_handler_,
ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
.WillOnce(testing::Return(scroll_result_did_scroll_));
- EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
+ if (!touchpad_and_wheel_scroll_latching_enabled_)
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
time += base::TimeDelta::FromMilliseconds(100);
Animate(time);
@@ -1185,10 +1250,21 @@ TEST_P(InputHandlerProxyTest, GestureFlingAnimatesTouchpad) {
EXPECT_CALL(mock_input_handler_,
GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
.WillOnce(testing::Return(cc::EventListenerProperties::kNone));
- EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
- .WillOnce(testing::Return(kMainThreadScrollState));
- EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0);
- EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0);
+ if (!touchpad_and_wheel_scroll_latching_enabled_) {
+ EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
+ .WillOnce(testing::Return(kMainThreadScrollState));
+
+ EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0);
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0);
+ } else {
+ EXPECT_CALL(
+ mock_input_handler_,
+ ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
+ .WillOnce(testing::Return(scroll_result_did_not_scroll_));
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
+ EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
+ .WillOnce(testing::Return(true));
+ }
// Expected wheel fling animation parameters:
// *) fling_delta and fling_point should match the original GestureFlingStart
// event
@@ -1234,12 +1310,29 @@ TEST_P(InputHandlerProxyTest, GestureFlingAnimatesTouchpad) {
VERIFY_AND_RESET_MOCKS();
}
+TEST_P(InputHandlerProxyTest, GestureFlingAnimatesTouchpad) {
+ GestureFlingAnimatesTouchpad();
+}
+TEST_P(InputHandlerProxyWithoutWheelScrollLatchingTest,
+ GestureFlingAnimatesTouchpad) {
+ GestureFlingAnimatesTouchpad();
+}
-TEST_P(InputHandlerProxyTest, GestureFlingPassiveListener) {
+void InputHandlerProxyTest::GestureFlingPassiveListener() {
// 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);
@@ -1254,7 +1347,8 @@ TEST_P(InputHandlerProxyTest, GestureFlingPassiveListener) {
EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
+ if (!touchpad_and_wheel_scroll_latching_enabled_)
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
VERIFY_AND_RESET_MOCKS();
@@ -1278,8 +1372,10 @@ TEST_P(InputHandlerProxyTest, GestureFlingPassiveListener) {
EXPECT_CALL(mock_input_handler_,
GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
.WillOnce(testing::Return(cc::EventListenerProperties::kPassive));
- EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
- .WillOnce(testing::Return(kImplThreadScrollState));
+ if (!touchpad_and_wheel_scroll_latching_enabled_) {
+ EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
+ .WillOnce(testing::Return(kImplThreadScrollState));
+ }
EXPECT_CALL(
mock_input_handler_,
ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
@@ -1295,7 +1391,8 @@ TEST_P(InputHandlerProxyTest, GestureFlingPassiveListener) {
EXPECT_CALL(mock_client_, DispatchNonBlockingEventToMainThread_(
WheelEventsMatch(expected_wheel)))
.Times(1);
- EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(1);
+ if (!touchpad_and_wheel_scroll_latching_enabled_)
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(1);
time += base::TimeDelta::FromMilliseconds(100);
Animate(time);
@@ -1306,15 +1403,36 @@ TEST_P(InputHandlerProxyTest, GestureFlingPassiveListener) {
expected_disposition_ = InputHandlerProxy::DID_HANDLE;
gesture_.setType(WebInputEvent::GestureFlingCancel);
EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
+ if (touchpad_and_wheel_scroll_latching_enabled_) {
+ // The fling cancellation should be deferred.
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0);
+ }
VERIFY_AND_RESET_MOCKS();
}
+TEST_P(InputHandlerProxyTest, GestureFlingPassiveListener) {
+ GestureFlingPassiveListener();
+}
+TEST_P(InputHandlerProxyWithoutWheelScrollLatchingTest,
+ GestureFlingPassiveListener) {
+ GestureFlingPassiveListener();
+}
-TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) {
+void InputHandlerProxyTest::GestureFlingTransferResetsTouchpad() {
// 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();
+
// Start a gesture fling in the -X direction with zero Y movement.
WebFloatPoint fling_delta = WebFloatPoint(1000, 0);
WebPoint fling_point = WebPoint(7, 13);
@@ -1330,7 +1448,8 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) {
EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
+ if (!touchpad_and_wheel_scroll_latching_enabled_)
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
VERIFY_AND_RESET_MOCKS();
@@ -1349,13 +1468,16 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) {
EXPECT_CALL(mock_input_handler_,
GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
.WillOnce(testing::Return(cc::EventListenerProperties::kNone));
- EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
- .WillOnce(testing::Return(kImplThreadScrollState));
+ if (!touchpad_and_wheel_scroll_latching_enabled_) {
+ EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
+ .WillOnce(testing::Return(kImplThreadScrollState));
+ }
EXPECT_CALL(
mock_input_handler_,
ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
.WillOnce(testing::Return(scroll_result_did_scroll_));
- EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
+ if (!touchpad_and_wheel_scroll_latching_enabled_)
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
time += base::TimeDelta::FromMilliseconds(100);
Animate(time);
@@ -1369,11 +1491,19 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) {
EXPECT_CALL(mock_input_handler_,
GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
.WillOnce(testing::Return(cc::EventListenerProperties::kNone));
- EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
- .WillOnce(testing::Return(kMainThreadScrollState));
-
- EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0);
- EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0);
+ if (!touchpad_and_wheel_scroll_latching_enabled_) {
+ EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
+ .WillOnce(testing::Return(kMainThreadScrollState));
+ EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0);
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0);
+ } else {
+ EXPECT_CALL(
+ mock_input_handler_,
+ ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
+ .WillOnce(testing::Return(scroll_result_did_not_scroll_));
+ EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
+ .WillOnce(testing::Return(true));
+ }
// Expected wheel fling animation parameters:
// *) fling_delta and fling_point should match the original GestureFlingStart
@@ -1397,6 +1527,9 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) {
testing::Eq(10)),
testing::Field(&WebActiveWheelFlingParameters::cumulativeScroll,
testing::Field(&WebSize::width, testing::Gt(0))))));
+ if (touchpad_and_wheel_scroll_latching_enabled_)
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
+
time += base::TimeDelta::FromMilliseconds(100);
Animate(time);
@@ -1423,6 +1556,17 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) {
VERIFY_AND_RESET_MOCKS();
input_handler_->MainThreadHasStoppedFlinging();
+ EXPECT_CALL(mock_input_handler_, ScrollBegin(::testing::_, ::testing::_))
+ .WillOnce(testing::Return(kImplThreadScrollState));
+
+ // HandleGestureScrollBegin will set gesture_scroll_on_impl_thread_.
+ expected_disposition_ = InputHandlerProxy::DID_HANDLE;
+ 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();
+
// Start a second gesture fling, this time in the +Y direction with no X.
fling_delta = WebFloatPoint(0, -1000);
fling_point = WebPoint(95, 87);
@@ -1436,7 +1580,8 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) {
EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
+ if (!touchpad_and_wheel_scroll_latching_enabled_)
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
expected_disposition_ = InputHandlerProxy::DID_HANDLE;
EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
@@ -1456,13 +1601,16 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) {
EXPECT_CALL(mock_input_handler_,
GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
.WillOnce(testing::Return(cc::EventListenerProperties::kNone));
- EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
- .WillOnce(testing::Return(kImplThreadScrollState));
+ if (!touchpad_and_wheel_scroll_latching_enabled_) {
+ EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
+ .WillOnce(testing::Return(kImplThreadScrollState));
+ }
EXPECT_CALL(
mock_input_handler_,
ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0))))
.WillOnce(testing::Return(scroll_result_did_scroll_));
- EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
+ if (!touchpad_and_wheel_scroll_latching_enabled_)
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
time += base::TimeDelta::FromMilliseconds(100);
Animate(time);
@@ -1472,10 +1620,19 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) {
EXPECT_CALL(mock_input_handler_,
GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
.WillOnce(testing::Return(cc::EventListenerProperties::kNone));
- EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
- .WillOnce(testing::Return(kMainThreadScrollState));
- EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0);
- EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0);
+ if (!touchpad_and_wheel_scroll_latching_enabled_) {
+ EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
+ .WillOnce(testing::Return(kMainThreadScrollState));
+ EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0);
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0);
+ } else {
+ EXPECT_CALL(
+ mock_input_handler_,
+ ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0))))
+ .WillOnce(testing::Return(scroll_result_did_not_scroll_));
+ EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
+ .WillOnce(testing::Return(true));
+ }
// We should get parameters from the second fling, nothing from the first
// fling should "leak".
@@ -1494,11 +1651,22 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) {
testing::Eq(30)),
testing::Field(&WebActiveWheelFlingParameters::cumulativeScroll,
testing::Field(&WebSize::height, testing::Lt(0))))));
+
+ if (touchpad_and_wheel_scroll_latching_enabled_)
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
+
time += base::TimeDelta::FromMilliseconds(100);
Animate(time);
VERIFY_AND_RESET_MOCKS();
}
+TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) {
+ GestureFlingTransferResetsTouchpad();
+}
+TEST_P(InputHandlerProxyWithoutWheelScrollLatchingTest,
+ GestureFlingTransferResetsTouchpad) {
+ GestureFlingTransferResetsTouchpad();
+}
TEST_P(InputHandlerProxyTest, GestureFlingStartedTouchscreen) {
// We shouldn't send any events to the widget for this gesture.
@@ -1906,11 +2074,21 @@ TEST_P(InputHandlerProxyTest,
VERIFY_AND_RESET_MOCKS();
}
-TEST_P(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) {
+void InputHandlerProxyTest::GestureFlingStopsAtContentEdge() {
// 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);
@@ -1919,7 +2097,8 @@ TEST_P(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) {
gesture_.data.flingStart.velocityY = fling_delta.y;
EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
+ if (!touchpad_and_wheel_scroll_latching_enabled_)
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
VERIFY_AND_RESET_MOCKS();
@@ -1934,13 +2113,16 @@ TEST_P(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) {
EXPECT_CALL(mock_input_handler_,
GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
.WillOnce(testing::Return(cc::EventListenerProperties::kNone));
- EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
- .WillOnce(testing::Return(kImplThreadScrollState));
+ if (!touchpad_and_wheel_scroll_latching_enabled_) {
+ EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
+ .WillOnce(testing::Return(kImplThreadScrollState));
+ }
EXPECT_CALL(
mock_input_handler_,
ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0))))
.WillOnce(testing::Return(scroll_result_did_scroll_));
- EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
+ if (!touchpad_and_wheel_scroll_latching_enabled_)
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
time += base::TimeDelta::FromMilliseconds(100);
Animate(time);
@@ -1956,8 +2138,10 @@ TEST_P(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) {
EXPECT_CALL(mock_input_handler_,
GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
.WillOnce(testing::Return(cc::EventListenerProperties::kNone));
- EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
- .WillOnce(testing::Return(kImplThreadScrollState));
+ if (!touchpad_and_wheel_scroll_latching_enabled_) {
+ EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
+ .WillOnce(testing::Return(kImplThreadScrollState));
+ }
EXPECT_CALL(
mock_input_handler_,
ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0))))
@@ -1969,7 +2153,8 @@ TEST_P(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) {
overscroll.unused_scroll_delta,
testing::Property(&gfx::Vector2dF::y, testing::Lt(0)),
testing::_));
- EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
+ if (!touchpad_and_wheel_scroll_latching_enabled_)
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
time += base::TimeDelta::FromMilliseconds(100);
Animate(time);
@@ -1980,17 +2165,27 @@ TEST_P(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) {
EXPECT_CALL(mock_input_handler_,
GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
.WillOnce(testing::Return(cc::EventListenerProperties::kNone));
- EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
- .WillOnce(testing::Return(kImplThreadScrollState));
+ if (!touchpad_and_wheel_scroll_latching_enabled_) {
+ EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
+ .WillOnce(testing::Return(kImplThreadScrollState));
+ }
EXPECT_CALL(
mock_input_handler_,
ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Eq(0))))
.WillOnce(testing::Return(scroll_result_did_scroll_));
- EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
+ if (!touchpad_and_wheel_scroll_latching_enabled_)
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
time += base::TimeDelta::FromMilliseconds(100);
Animate(time);
VERIFY_AND_RESET_MOCKS();
}
+TEST_P(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) {
+ GestureFlingStopsAtContentEdge();
+}
+TEST_P(InputHandlerProxyWithoutWheelScrollLatchingTest,
+ GestureFlingStopsAtContentEdge) {
+ GestureFlingStopsAtContentEdge();
+}
TEST_P(InputHandlerProxyTest, GestureFlingNotCancelledBySmallTimeDelta) {
// We shouldn't send any events to the widget for this gesture.
@@ -2930,12 +3125,12 @@ TEST_P(InputHandlerProxyTest, FlingBoostTerminatedDuringScrollSequence) {
VERIFY_AND_RESET_MOCKS();
}
-
-TEST_P(InputHandlerProxyTest, DidReceiveInputEvent_ForFling) {
+void InputHandlerProxyTest::DidReceiveInputEvent_ForFling() {
testing::StrictMock<MockInputHandlerProxyClientWithDidAnimateForInput>
mock_client;
input_handler_.reset(
- new TestInputHandlerProxy(&mock_input_handler_, &mock_client, false));
+ new TestInputHandlerProxy(&mock_input_handler_, &mock_client,
+ touchpad_and_wheel_scroll_latching_enabled_));
if (install_synchronous_handler_) {
EXPECT_CALL(mock_input_handler_, RequestUpdateForSynchronousInputHandler())
.Times(1);
@@ -2951,7 +3146,8 @@ TEST_P(InputHandlerProxyTest, DidReceiveInputEvent_ForFling) {
EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
+ if (!touchpad_and_wheel_scroll_latching_enabled_)
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
EXPECT_EQ(InputHandlerProxy::DID_HANDLE,
input_handler_->HandleInputEvent(gesture_));
VERIFY_AND_RESET_MOCKS();
@@ -2963,6 +3159,13 @@ TEST_P(InputHandlerProxyTest, DidReceiveInputEvent_ForFling) {
VERIFY_AND_RESET_MOCKS();
}
+TEST_P(InputHandlerProxyTest, DidReceiveInputEvent_ForFling) {
+ DidReceiveInputEvent_ForFling();
+}
+TEST_P(InputHandlerProxyWithoutWheelScrollLatchingTest,
+ DidReceiveInputEvent_ForFling) {
+ DidReceiveInputEvent_ForFling();
+}
TEST(SynchronousInputHandlerProxyTest, StartupShutdown) {
testing::StrictMock<MockInputHandler> mock_input_handler;
@@ -3630,5 +3833,9 @@ INSTANTIATE_TEST_CASE_P(AnimateInput,
InputHandlerProxyTest,
testing::ValuesIn(test_types));
+INSTANTIATE_TEST_CASE_P(AnimateInput,
+ InputHandlerProxyWithoutWheelScrollLatchingTest,
+ testing::ValuesIn(test_types));
+
} // namespace test
} // namespace ui
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698