Commit 8a5b4060 authored by sahel's avatar sahel Committed by Commit bot

Event unittests cover both wheel scroll latching and propagating cases.

BUG=526463

Review-Url: https://codereview.chromium.org/2802993003
Cr-Commit-Position: refs/heads/master@{#462972}
parent 365c1380
...@@ -181,6 +181,7 @@ class MockInputHandler : public cc::InputHandler { ...@@ -181,6 +181,7 @@ class MockInputHandler : public cc::InputHandler {
MOCK_METHOD1(ScrollBy, cc::InputHandlerScrollResult(cc::ScrollState*)); MOCK_METHOD1(ScrollBy, cc::InputHandlerScrollResult(cc::ScrollState*));
MOCK_METHOD1(ScrollEnd, void(cc::ScrollState*)); MOCK_METHOD1(ScrollEnd, void(cc::ScrollState*));
MOCK_METHOD0(FlingScrollBegin, cc::InputHandler::ScrollStatus()); MOCK_METHOD0(FlingScrollBegin, cc::InputHandler::ScrollStatus());
MOCK_METHOD0(ScrollingShouldSwitchtoMainThread, bool());
std::unique_ptr<cc::SwapPromiseMonitor> CreateLatencyInfoSwapPromiseMonitor( std::unique_ptr<cc::SwapPromiseMonitor> CreateLatencyInfoSwapPromiseMonitor(
ui::LatencyInfo* latency) override { ui::LatencyInfo* latency) override {
...@@ -198,8 +199,6 @@ class MockInputHandler : public cc::InputHandler { ...@@ -198,8 +199,6 @@ class MockInputHandler : public cc::InputHandler {
return false; return false;
} }
bool ScrollingShouldSwitchtoMainThread() override { return false; }
void BindToClient(cc::InputHandlerClient* client, void BindToClient(cc::InputHandlerClient* client,
bool touchpad_and_wheel_scroll_latching_enabled) override {} bool touchpad_and_wheel_scroll_latching_enabled) override {}
...@@ -371,14 +370,17 @@ class InputHandlerProxyTest ...@@ -371,14 +370,17 @@ class InputHandlerProxyTest
: public testing::Test, : public testing::Test,
public testing::WithParamInterface<InputHandlerProxyTestType> { public testing::WithParamInterface<InputHandlerProxyTestType> {
public: public:
InputHandlerProxyTest() InputHandlerProxyTest(bool touchpad_and_wheel_scroll_latching_enabled = true)
: synchronous_root_scroll_(GetParam() == ROOT_SCROLL_SYNCHRONOUS_HANDLER), : synchronous_root_scroll_(GetParam() == ROOT_SCROLL_SYNCHRONOUS_HANDLER),
install_synchronous_handler_( install_synchronous_handler_(
GetParam() == ROOT_SCROLL_SYNCHRONOUS_HANDLER || GetParam() == ROOT_SCROLL_SYNCHRONOUS_HANDLER ||
GetParam() == CHILD_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( 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_scroll_.did_scroll = true;
scroll_result_did_not_scroll_.did_scroll = false; scroll_result_did_not_scroll_.did_scroll = false;
...@@ -396,9 +398,7 @@ class InputHandlerProxyTest ...@@ -396,9 +398,7 @@ class InputHandlerProxyTest
gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; gesture_.sourceDevice = blink::WebGestureDeviceTouchpad;
} }
~InputHandlerProxyTest() { virtual ~InputHandlerProxyTest() { input_handler_.reset(); }
input_handler_.reset();
}
// This is defined as a macro so the line numbers can be traced back to the // This is defined as a macro so the line numbers can be traced back to the
// correct spot when it fails. // correct spot when it fails.
...@@ -481,6 +481,14 @@ class InputHandlerProxyTest ...@@ -481,6 +481,14 @@ class InputHandlerProxyTest
} }
protected: protected:
void GestureFlingAnimatesTouchpad();
void DidReceiveInputEvent_ForFling();
void GestureScrollStarted();
void GestureFlingPassiveListener();
void GestureFlingStartedTouchpad();
void GestureFlingStopsAtContentEdge();
void GestureFlingTransferResetsTouchpad();
const bool synchronous_root_scroll_; const bool synchronous_root_scroll_;
const bool install_synchronous_handler_; const bool install_synchronous_handler_;
testing::StrictMock<MockInputHandler> mock_input_handler_; testing::StrictMock<MockInputHandler> mock_input_handler_;
...@@ -493,9 +501,17 @@ class InputHandlerProxyTest ...@@ -493,9 +501,17 @@ class InputHandlerProxyTest
base::HistogramTester histogram_tester_; base::HistogramTester histogram_tester_;
cc::InputHandlerScrollResult scroll_result_did_scroll_; cc::InputHandlerScrollResult scroll_result_did_scroll_;
cc::InputHandlerScrollResult scroll_result_did_not_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 { class InputHandlerProxyEventQueueTest : public testing::TestWithParam<bool> {
public: public:
InputHandlerProxyEventQueueTest() : weak_ptr_factory_(this) { InputHandlerProxyEventQueueTest() : weak_ptr_factory_(this) {
feature_list_.InitAndEnableFeature(features::kVsyncAlignedInputEvents); feature_list_.InitAndEnableFeature(features::kVsyncAlignedInputEvents);
...@@ -504,9 +520,10 @@ class InputHandlerProxyEventQueueTest : public testing::Test { ...@@ -504,9 +520,10 @@ class InputHandlerProxyEventQueueTest : public testing::Test {
~InputHandlerProxyEventQueueTest() { input_handler_proxy_.reset(); } ~InputHandlerProxyEventQueueTest() { input_handler_proxy_.reset(); }
void SetUp() override { void SetUp() override {
bool wheel_scroll_latching_enabled = GetParam();
event_disposition_recorder_.clear(); event_disposition_recorder_.clear();
input_handler_proxy_ = base::MakeUnique<TestInputHandlerProxy>( input_handler_proxy_ = base::MakeUnique<TestInputHandlerProxy>(
&mock_input_handler_, &mock_client_, false); &mock_input_handler_, &mock_client_, wheel_scroll_latching_enabled);
if (input_handler_proxy_->compositor_event_queue_) if (input_handler_proxy_->compositor_event_queue_)
input_handler_proxy_->compositor_event_queue_ = input_handler_proxy_->compositor_event_queue_ =
base::MakeUnique<CompositorThreadEventQueue>(); base::MakeUnique<CompositorThreadEventQueue>();
...@@ -627,7 +644,7 @@ TEST_P(InputHandlerProxyTest, MouseWheelBlockingAndPassiveListener) { ...@@ -627,7 +644,7 @@ TEST_P(InputHandlerProxyTest, MouseWheelBlockingAndPassiveListener) {
VERIFY_AND_RESET_MOCKS(); VERIFY_AND_RESET_MOCKS();
} }
TEST_P(InputHandlerProxyTest, GestureScrollStarted) { void InputHandlerProxyTest::GestureScrollStarted() {
// We shouldn't send any events to the widget for this gesture. // We shouldn't send any events to the widget for this gesture.
expected_disposition_ = InputHandlerProxy::DID_HANDLE; expected_disposition_ = InputHandlerProxy::DID_HANDLE;
VERIFY_AND_RESET_MOCKS(); VERIFY_AND_RESET_MOCKS();
...@@ -649,6 +666,8 @@ TEST_P(InputHandlerProxyTest, GestureScrollStarted) { ...@@ -649,6 +666,8 @@ TEST_P(InputHandlerProxyTest, GestureScrollStarted) {
mock_input_handler_, mock_input_handler_,
ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)))) ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0))))
.WillOnce(testing::Return(scroll_result_did_not_scroll_)); .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_)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
// Mark the event as handled if scroll happens. // Mark the event as handled if scroll happens.
...@@ -673,6 +692,12 @@ TEST_P(InputHandlerProxyTest, GestureScrollStarted) { ...@@ -673,6 +692,12 @@ TEST_P(InputHandlerProxyTest, GestureScrollStarted) {
VERIFY_AND_RESET_MOCKS(); VERIFY_AND_RESET_MOCKS();
} }
TEST_P(InputHandlerProxyTest, GestureScrollStarted) {
GestureScrollStarted();
}
TEST_P(InputHandlerProxyWithoutWheelScrollLatchingTest, GestureScrollStarted) {
GestureScrollStarted();
}
TEST_P(InputHandlerProxyTest, GestureScrollOnMainThread) { TEST_P(InputHandlerProxyTest, GestureScrollOnMainThread) {
// We should send all events to the widget for this gesture. // We should send all events to the widget for this gesture.
...@@ -957,14 +982,25 @@ TEST_P(InputHandlerProxyTest, GesturePinchAfterScrollOnMainThread) { ...@@ -957,14 +982,25 @@ TEST_P(InputHandlerProxyTest, GesturePinchAfterScrollOnMainThread) {
VERIFY_AND_RESET_MOCKS(); VERIFY_AND_RESET_MOCKS();
} }
TEST_P(InputHandlerProxyTest, GestureFlingStartedTouchpad) { void InputHandlerProxyTest::GestureFlingStartedTouchpad() {
// We shouldn't send any events to the widget for this gesture. // We shouldn't send any events to the widget for this gesture.
expected_disposition_ = InputHandlerProxy::DID_HANDLE; expected_disposition_ = InputHandlerProxy::DID_HANDLE;
VERIFY_AND_RESET_MOCKS(); 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::_)) EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(kImplThreadScrollState)); .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_SET_NEEDS_ANIMATE_INPUT(1);
gesture_.setType(WebInputEvent::GestureFlingStart); gesture_.setType(WebInputEvent::GestureFlingStart);
...@@ -974,10 +1010,24 @@ TEST_P(InputHandlerProxyTest, GestureFlingStartedTouchpad) { ...@@ -974,10 +1010,24 @@ TEST_P(InputHandlerProxyTest, GestureFlingStartedTouchpad) {
VERIFY_AND_RESET_MOCKS(); 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. // Verify that a GestureFlingCancel during an animation cancels it.
gesture_.setType(WebInputEvent::GestureFlingCancel); gesture_.setType(WebInputEvent::GestureFlingCancel);
gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; gesture_.sourceDevice = blink::WebGestureDeviceTouchpad;
EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 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) { TEST_P(InputHandlerProxyTest, GestureFlingTouchpadScrollLatchingEnabled) {
...@@ -1070,6 +1120,8 @@ TEST_P(InputHandlerProxyTest, GestureFlingTouchpadScrollLatchingEnabled) { ...@@ -1070,6 +1120,8 @@ TEST_P(InputHandlerProxyTest, GestureFlingTouchpadScrollLatchingEnabled) {
mock_input_handler_, mock_input_handler_,
ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
.WillOnce(testing::Return(scroll_result_did_not_scroll_)); .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 // When scroll latching is enabled, ScrollEnd gets called when the last
// ScrollBy did not scroll. // ScrollBy did not scroll.
...@@ -1133,11 +1185,21 @@ TEST_P(InputHandlerProxyTest, GestureFlingIgnoredTouchpad) { ...@@ -1133,11 +1185,21 @@ TEST_P(InputHandlerProxyTest, GestureFlingIgnoredTouchpad) {
EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 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. // We shouldn't send any events to the widget for this gesture.
expected_disposition_ = InputHandlerProxy::DID_HANDLE; expected_disposition_ = InputHandlerProxy::DID_HANDLE;
VERIFY_AND_RESET_MOCKS(); 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 // On the fling start, we should schedule an animation but not actually start
// scrolling. // scrolling.
gesture_.setType(WebInputEvent::GestureFlingStart); gesture_.setType(WebInputEvent::GestureFlingStart);
...@@ -1155,7 +1217,8 @@ TEST_P(InputHandlerProxyTest, GestureFlingAnimatesTouchpad) { ...@@ -1155,7 +1217,8 @@ TEST_P(InputHandlerProxyTest, GestureFlingAnimatesTouchpad) {
EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(kImplThreadScrollState)); .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_)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
VERIFY_AND_RESET_MOCKS(); VERIFY_AND_RESET_MOCKS();
...@@ -1178,13 +1241,16 @@ TEST_P(InputHandlerProxyTest, GestureFlingAnimatesTouchpad) { ...@@ -1178,13 +1241,16 @@ TEST_P(InputHandlerProxyTest, GestureFlingAnimatesTouchpad) {
EXPECT_CALL(mock_input_handler_, EXPECT_CALL(mock_input_handler_,
GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
.WillOnce(testing::Return(cc::EventListenerProperties::kNone)); .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) if (!touchpad_and_wheel_scroll_latching_enabled_) {
.WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(kImplThreadScrollState));
}
EXPECT_CALL( EXPECT_CALL(
mock_input_handler_, mock_input_handler_,
ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
.WillOnce(testing::Return(scroll_result_did_scroll_)); .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); time += base::TimeDelta::FromMilliseconds(100);
Animate(time); Animate(time);
...@@ -1198,10 +1264,20 @@ TEST_P(InputHandlerProxyTest, GestureFlingAnimatesTouchpad) { ...@@ -1198,10 +1264,20 @@ TEST_P(InputHandlerProxyTest, GestureFlingAnimatesTouchpad) {
EXPECT_CALL(mock_input_handler_, EXPECT_CALL(mock_input_handler_,
GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
.WillOnce(testing::Return(cc::EventListenerProperties::kNone)); .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) if (!touchpad_and_wheel_scroll_latching_enabled_) {
.WillOnce(testing::Return(kMainThreadScrollState)); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); .WillOnce(testing::Return(kMainThreadScrollState));
EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0); 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: // Expected wheel fling animation parameters:
// *) fling_delta and fling_point should match the original GestureFlingStart // *) fling_delta and fling_point should match the original GestureFlingStart
// event // event
...@@ -1247,12 +1323,29 @@ TEST_P(InputHandlerProxyTest, GestureFlingAnimatesTouchpad) { ...@@ -1247,12 +1323,29 @@ TEST_P(InputHandlerProxyTest, GestureFlingAnimatesTouchpad) {
VERIFY_AND_RESET_MOCKS(); 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. // We shouldn't send any events to the widget for this gesture.
expected_disposition_ = InputHandlerProxy::DID_HANDLE; expected_disposition_ = InputHandlerProxy::DID_HANDLE;
VERIFY_AND_RESET_MOCKS(); 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 // On the fling start, we should schedule an animation but not actually start
// scrolling. // scrolling.
gesture_.setType(WebInputEvent::GestureFlingStart); gesture_.setType(WebInputEvent::GestureFlingStart);
...@@ -1267,7 +1360,8 @@ TEST_P(InputHandlerProxyTest, GestureFlingPassiveListener) { ...@@ -1267,7 +1360,8 @@ TEST_P(InputHandlerProxyTest, GestureFlingPassiveListener) {
EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(kImplThreadScrollState)); .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_)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
VERIFY_AND_RESET_MOCKS(); VERIFY_AND_RESET_MOCKS();
...@@ -1291,8 +1385,10 @@ TEST_P(InputHandlerProxyTest, GestureFlingPassiveListener) { ...@@ -1291,8 +1385,10 @@ TEST_P(InputHandlerProxyTest, GestureFlingPassiveListener) {
EXPECT_CALL(mock_input_handler_, EXPECT_CALL(mock_input_handler_,
GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
.WillOnce(testing::Return(cc::EventListenerProperties::kPassive)); .WillOnce(testing::Return(cc::EventListenerProperties::kPassive));
EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) if (!touchpad_and_wheel_scroll_latching_enabled_) {
.WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(kImplThreadScrollState));
}
EXPECT_CALL( EXPECT_CALL(
mock_input_handler_, mock_input_handler_,
ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
...@@ -1308,7 +1404,8 @@ TEST_P(InputHandlerProxyTest, GestureFlingPassiveListener) { ...@@ -1308,7 +1404,8 @@ TEST_P(InputHandlerProxyTest, GestureFlingPassiveListener) {
EXPECT_CALL(mock_client_, DispatchNonBlockingEventToMainThread_( EXPECT_CALL(mock_client_, DispatchNonBlockingEventToMainThread_(
WheelEventsMatch(expected_wheel))) WheelEventsMatch(expected_wheel)))
.Times(1); .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); time += base::TimeDelta::FromMilliseconds(100);
Animate(time); Animate(time);
...@@ -1319,15 +1416,36 @@ TEST_P(InputHandlerProxyTest, GestureFlingPassiveListener) { ...@@ -1319,15 +1416,36 @@ TEST_P(InputHandlerProxyTest, GestureFlingPassiveListener) {
expected_disposition_ = InputHandlerProxy::DID_HANDLE; expected_disposition_ = InputHandlerProxy::DID_HANDLE;
gesture_.setType(WebInputEvent::GestureFlingCancel); gesture_.setType(WebInputEvent::GestureFlingCancel);
EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 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(); 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. // We shouldn't send any events to the widget for this gesture.
expected_disposition_ = InputHandlerProxy::DID_HANDLE; expected_disposition_ = InputHandlerProxy::DID_HANDLE;
VERIFY_AND_RESET_MOCKS(); 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. // Start a gesture fling in the -X direction with zero Y movement.
WebFloatPoint fling_delta = WebFloatPoint(1000, 0); WebFloatPoint fling_delta = WebFloatPoint(1000, 0);
WebPoint fling_point = WebPoint(7, 13); WebPoint fling_point = WebPoint(7, 13);
...@@ -1343,7 +1461,8 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) { ...@@ -1343,7 +1461,8 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) {
EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(kImplThreadScrollState)); .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_)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
VERIFY_AND_RESET_MOCKS(); VERIFY_AND_RESET_MOCKS();
...@@ -1362,13 +1481,16 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) { ...@@ -1362,13 +1481,16 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) {
EXPECT_CALL(mock_input_handler_, EXPECT_CALL(mock_input_handler_,
GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
.WillOnce(testing::Return(cc::EventListenerProperties::kNone)); .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) if (!touchpad_and_wheel_scroll_latching_enabled_) {
.WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(kImplThreadScrollState));
}
EXPECT_CALL( EXPECT_CALL(
mock_input_handler_, mock_input_handler_,
ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
.WillOnce(testing::Return(scroll_result_did_scroll_)); .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); time += base::TimeDelta::FromMilliseconds(100);
Animate(time); Animate(time);
...@@ -1382,11 +1504,19 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) { ...@@ -1382,11 +1504,19 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) {
EXPECT_CALL(mock_input_handler_, EXPECT_CALL(mock_input_handler_,
GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
.WillOnce(testing::Return(cc::EventListenerProperties::kNone)); .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) if (!touchpad_and_wheel_scroll_latching_enabled_) {
.WillOnce(testing::Return(kMainThreadScrollState)); 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_, ScrollBy(testing::_)).Times(0);
EXPECT_CALL(mock_input_handler_, ScrollEnd(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: // Expected wheel fling animation parameters:
// *) fling_delta and fling_point should match the original GestureFlingStart // *) fling_delta and fling_point should match the original GestureFlingStart
...@@ -1410,6 +1540,9 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) { ...@@ -1410,6 +1540,9 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) {
testing::Eq(10)), testing::Eq(10)),
testing::Field(&WebActiveWheelFlingParameters::cumulativeScroll, testing::Field(&WebActiveWheelFlingParameters::cumulativeScroll,
testing::Field(&WebSize::width, testing::Gt(0)))))); 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); time += base::TimeDelta::FromMilliseconds(100);
Animate(time); Animate(time);
...@@ -1436,6 +1569,17 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) { ...@@ -1436,6 +1569,17 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) {
VERIFY_AND_RESET_MOCKS(); VERIFY_AND_RESET_MOCKS();
input_handler_->MainThreadHasStoppedFlinging(); 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. // Start a second gesture fling, this time in the +Y direction with no X.
fling_delta = WebFloatPoint(0, -1000); fling_delta = WebFloatPoint(0, -1000);
fling_point = WebPoint(95, 87); fling_point = WebPoint(95, 87);
...@@ -1449,7 +1593,8 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) { ...@@ -1449,7 +1593,8 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) {
EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(kImplThreadScrollState)); .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; expected_disposition_ = InputHandlerProxy::DID_HANDLE;
EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
...@@ -1469,13 +1614,16 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) { ...@@ -1469,13 +1614,16 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) {
EXPECT_CALL(mock_input_handler_, EXPECT_CALL(mock_input_handler_,
GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
.WillOnce(testing::Return(cc::EventListenerProperties::kNone)); .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) if (!touchpad_and_wheel_scroll_latching_enabled_) {
.WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(kImplThreadScrollState));
}
EXPECT_CALL( EXPECT_CALL(
mock_input_handler_, mock_input_handler_,
ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)))) ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0))))
.WillOnce(testing::Return(scroll_result_did_scroll_)); .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); time += base::TimeDelta::FromMilliseconds(100);
Animate(time); Animate(time);
...@@ -1485,10 +1633,19 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) { ...@@ -1485,10 +1633,19 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) {
EXPECT_CALL(mock_input_handler_, EXPECT_CALL(mock_input_handler_,
GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
.WillOnce(testing::Return(cc::EventListenerProperties::kNone)); .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) if (!touchpad_and_wheel_scroll_latching_enabled_) {
.WillOnce(testing::Return(kMainThreadScrollState)); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); .WillOnce(testing::Return(kMainThreadScrollState));
EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0); 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 // We should get parameters from the second fling, nothing from the first
// fling should "leak". // fling should "leak".
...@@ -1507,11 +1664,22 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) { ...@@ -1507,11 +1664,22 @@ TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) {
testing::Eq(30)), testing::Eq(30)),
testing::Field(&WebActiveWheelFlingParameters::cumulativeScroll, testing::Field(&WebActiveWheelFlingParameters::cumulativeScroll,
testing::Field(&WebSize::height, testing::Lt(0)))))); 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); time += base::TimeDelta::FromMilliseconds(100);
Animate(time); Animate(time);
VERIFY_AND_RESET_MOCKS(); VERIFY_AND_RESET_MOCKS();
} }
TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) {
GestureFlingTransferResetsTouchpad();
}
TEST_P(InputHandlerProxyWithoutWheelScrollLatchingTest,
GestureFlingTransferResetsTouchpad) {
GestureFlingTransferResetsTouchpad();
}
TEST_P(InputHandlerProxyTest, GestureFlingStartedTouchscreen) { TEST_P(InputHandlerProxyTest, GestureFlingStartedTouchscreen) {
// We shouldn't send any events to the widget for this gesture. // We shouldn't send any events to the widget for this gesture.
...@@ -1919,11 +2087,21 @@ TEST_P(InputHandlerProxyTest, ...@@ -1919,11 +2087,21 @@ TEST_P(InputHandlerProxyTest,
VERIFY_AND_RESET_MOCKS(); VERIFY_AND_RESET_MOCKS();
} }
TEST_P(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) { void InputHandlerProxyTest::GestureFlingStopsAtContentEdge() {
// We shouldn't send any events to the widget for this gesture. // We shouldn't send any events to the widget for this gesture.
expected_disposition_ = InputHandlerProxy::DID_HANDLE; expected_disposition_ = InputHandlerProxy::DID_HANDLE;
VERIFY_AND_RESET_MOCKS(); 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 // On the fling start, we should schedule an animation but not actually start
// scrolling. // scrolling.
gesture_.setType(WebInputEvent::GestureFlingStart); gesture_.setType(WebInputEvent::GestureFlingStart);
...@@ -1932,7 +2110,8 @@ TEST_P(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) { ...@@ -1932,7 +2110,8 @@ TEST_P(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) {
gesture_.data.flingStart.velocityY = fling_delta.y; gesture_.data.flingStart.velocityY = fling_delta.y;
EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(kImplThreadScrollState)); .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_SET_NEEDS_ANIMATE_INPUT(1);
EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
VERIFY_AND_RESET_MOCKS(); VERIFY_AND_RESET_MOCKS();
...@@ -1947,13 +2126,16 @@ TEST_P(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) { ...@@ -1947,13 +2126,16 @@ TEST_P(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) {
EXPECT_CALL(mock_input_handler_, EXPECT_CALL(mock_input_handler_,
GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
.WillOnce(testing::Return(cc::EventListenerProperties::kNone)); .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) if (!touchpad_and_wheel_scroll_latching_enabled_) {
.WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(kImplThreadScrollState));
}
EXPECT_CALL( EXPECT_CALL(
mock_input_handler_, mock_input_handler_,
ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0))))
.WillOnce(testing::Return(scroll_result_did_scroll_)); .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); EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
time += base::TimeDelta::FromMilliseconds(100); time += base::TimeDelta::FromMilliseconds(100);
Animate(time); Animate(time);
...@@ -1969,8 +2151,10 @@ TEST_P(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) { ...@@ -1969,8 +2151,10 @@ TEST_P(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) {
EXPECT_CALL(mock_input_handler_, EXPECT_CALL(mock_input_handler_,
GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
.WillOnce(testing::Return(cc::EventListenerProperties::kNone)); .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) if (!touchpad_and_wheel_scroll_latching_enabled_) {
.WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(kImplThreadScrollState));
}
EXPECT_CALL( EXPECT_CALL(
mock_input_handler_, mock_input_handler_,
ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0))))
...@@ -1982,7 +2166,8 @@ TEST_P(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) { ...@@ -1982,7 +2166,8 @@ TEST_P(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) {
overscroll.unused_scroll_delta, overscroll.unused_scroll_delta,
testing::Property(&gfx::Vector2dF::y, testing::Lt(0)), testing::Property(&gfx::Vector2dF::y, testing::Lt(0)),
testing::_)); 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); EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
time += base::TimeDelta::FromMilliseconds(100); time += base::TimeDelta::FromMilliseconds(100);
Animate(time); Animate(time);
...@@ -1993,17 +2178,27 @@ TEST_P(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) { ...@@ -1993,17 +2178,27 @@ TEST_P(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) {
EXPECT_CALL(mock_input_handler_, EXPECT_CALL(mock_input_handler_,
GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
.WillOnce(testing::Return(cc::EventListenerProperties::kNone)); .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) if (!touchpad_and_wheel_scroll_latching_enabled_) {
.WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(kImplThreadScrollState));
}
EXPECT_CALL( EXPECT_CALL(
mock_input_handler_, mock_input_handler_,
ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Eq(0)))) ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Eq(0))))
.WillOnce(testing::Return(scroll_result_did_scroll_)); .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); time += base::TimeDelta::FromMilliseconds(100);
Animate(time); Animate(time);
VERIFY_AND_RESET_MOCKS(); VERIFY_AND_RESET_MOCKS();
} }
TEST_P(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) {
GestureFlingStopsAtContentEdge();
}
TEST_P(InputHandlerProxyWithoutWheelScrollLatchingTest,
GestureFlingStopsAtContentEdge) {
GestureFlingStopsAtContentEdge();
}
TEST_P(InputHandlerProxyTest, GestureFlingNotCancelledBySmallTimeDelta) { TEST_P(InputHandlerProxyTest, GestureFlingNotCancelledBySmallTimeDelta) {
// We shouldn't send any events to the widget for this gesture. // We shouldn't send any events to the widget for this gesture.
...@@ -2943,12 +3138,12 @@ TEST_P(InputHandlerProxyTest, FlingBoostTerminatedDuringScrollSequence) { ...@@ -2943,12 +3138,12 @@ TEST_P(InputHandlerProxyTest, FlingBoostTerminatedDuringScrollSequence) {
VERIFY_AND_RESET_MOCKS(); VERIFY_AND_RESET_MOCKS();
} }
void InputHandlerProxyTest::DidReceiveInputEvent_ForFling() {
TEST_P(InputHandlerProxyTest, DidReceiveInputEvent_ForFling) {
testing::StrictMock<MockInputHandlerProxyClientWithDidAnimateForInput> testing::StrictMock<MockInputHandlerProxyClientWithDidAnimateForInput>
mock_client; mock_client;
input_handler_.reset( 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_) { if (install_synchronous_handler_) {
EXPECT_CALL(mock_input_handler_, RequestUpdateForSynchronousInputHandler()) EXPECT_CALL(mock_input_handler_, RequestUpdateForSynchronousInputHandler())
.Times(1); .Times(1);
...@@ -2964,7 +3159,8 @@ TEST_P(InputHandlerProxyTest, DidReceiveInputEvent_ForFling) { ...@@ -2964,7 +3159,8 @@ TEST_P(InputHandlerProxyTest, DidReceiveInputEvent_ForFling) {
EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(kImplThreadScrollState)); .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, EXPECT_EQ(InputHandlerProxy::DID_HANDLE,
input_handler_->HandleInputEvent(gesture_)); input_handler_->HandleInputEvent(gesture_));
VERIFY_AND_RESET_MOCKS(); VERIFY_AND_RESET_MOCKS();
...@@ -2976,6 +3172,13 @@ TEST_P(InputHandlerProxyTest, DidReceiveInputEvent_ForFling) { ...@@ -2976,6 +3172,13 @@ TEST_P(InputHandlerProxyTest, DidReceiveInputEvent_ForFling) {
VERIFY_AND_RESET_MOCKS(); VERIFY_AND_RESET_MOCKS();
} }
TEST_P(InputHandlerProxyTest, DidReceiveInputEvent_ForFling) {
DidReceiveInputEvent_ForFling();
}
TEST_P(InputHandlerProxyWithoutWheelScrollLatchingTest,
DidReceiveInputEvent_ForFling) {
DidReceiveInputEvent_ForFling();
}
TEST(SynchronousInputHandlerProxyTest, StartupShutdown) { TEST(SynchronousInputHandlerProxyTest, StartupShutdown) {
testing::StrictMock<MockInputHandler> mock_input_handler; testing::StrictMock<MockInputHandler> mock_input_handler;
...@@ -3254,7 +3457,7 @@ TEST_P(InputHandlerProxyTest, WheelScrollingThreadStatusHistogram) { ...@@ -3254,7 +3457,7 @@ TEST_P(InputHandlerProxyTest, WheelScrollingThreadStatusHistogram) {
VERIFY_AND_RESET_MOCKS(); VERIFY_AND_RESET_MOCKS();
} }
TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedGestureScroll) { TEST_P(InputHandlerProxyEventQueueTest, VSyncAlignedGestureScroll) {
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
// Handle scroll on compositor. // Handle scroll on compositor.
...@@ -3317,7 +3520,7 @@ TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedGestureScroll) { ...@@ -3317,7 +3520,7 @@ TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedGestureScroll) {
histogram_tester.ExpectUniqueSample(kCoalescedCountHistogram, 2, 1); histogram_tester.ExpectUniqueSample(kCoalescedCountHistogram, 2, 1);
} }
TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedGestureScrollPinchScroll) { TEST_P(InputHandlerProxyEventQueueTest, VSyncAlignedGestureScrollPinchScroll) {
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
// Handle scroll on compositor. // Handle scroll on compositor.
...@@ -3386,7 +3589,7 @@ TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedGestureScrollPinchScroll) { ...@@ -3386,7 +3589,7 @@ TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedGestureScrollPinchScroll) {
histogram_tester.ExpectBucketCount(kCoalescedCountHistogram, 2, 2); histogram_tester.ExpectBucketCount(kCoalescedCountHistogram, 2, 2);
} }
TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedQueueingTime) { TEST_P(InputHandlerProxyEventQueueTest, VSyncAlignedQueueingTime) {
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
std::unique_ptr<base::SimpleTestTickClock> tick_clock = std::unique_ptr<base::SimpleTestTickClock> tick_clock =
base::MakeUnique<base::SimpleTestTickClock>(); base::MakeUnique<base::SimpleTestTickClock>();
...@@ -3432,7 +3635,7 @@ TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedQueueingTime) { ...@@ -3432,7 +3635,7 @@ TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedQueueingTime) {
1); 1);
} }
TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedCoalesceScrollAndPinch) { TEST_P(InputHandlerProxyEventQueueTest, VSyncAlignedCoalesceScrollAndPinch) {
// Start scroll in the first frame. // Start scroll in the first frame.
EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
.WillOnce(testing::Return(kImplThreadScrollState)); .WillOnce(testing::Return(kImplThreadScrollState));
...@@ -3484,7 +3687,7 @@ TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedCoalesceScrollAndPinch) { ...@@ -3484,7 +3687,7 @@ TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedCoalesceScrollAndPinch) {
testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
} }
TEST_F(InputHandlerProxyEventQueueTest, OriginalEventsTracing) { TEST_P(InputHandlerProxyEventQueueTest, OriginalEventsTracing) {
// Handle scroll on compositor. // Handle scroll on compositor.
cc::InputHandlerScrollResult scroll_result_did_scroll_; cc::InputHandlerScrollResult scroll_result_did_scroll_;
scroll_result_did_scroll_.did_scroll = true; scroll_result_did_scroll_.did_scroll = true;
...@@ -3555,7 +3758,7 @@ TEST_F(InputHandlerProxyEventQueueTest, OriginalEventsTracing) { ...@@ -3555,7 +3758,7 @@ TEST_F(InputHandlerProxyEventQueueTest, OriginalEventsTracing) {
testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
} }
TEST_F(InputHandlerProxyEventQueueTest, GestureScrollFlingOrder) { TEST_P(InputHandlerProxyEventQueueTest, GestureScrollFlingOrder) {
// Handle scroll on compositor. // Handle scroll on compositor.
cc::InputHandlerScrollResult scroll_result_did_scroll_; cc::InputHandlerScrollResult scroll_result_did_scroll_;
scroll_result_did_scroll_.did_scroll = true; scroll_result_did_scroll_.did_scroll = true;
...@@ -3604,7 +3807,7 @@ TEST_F(InputHandlerProxyEventQueueTest, GestureScrollFlingOrder) { ...@@ -3604,7 +3807,7 @@ TEST_F(InputHandlerProxyEventQueueTest, GestureScrollFlingOrder) {
!input_handler_proxy_->gesture_scroll_on_impl_thread_for_testing()); !input_handler_proxy_->gesture_scroll_on_impl_thread_for_testing());
} }
TEST_F(InputHandlerProxyEventQueueTest, GestureScrollAfterFling) { TEST_P(InputHandlerProxyEventQueueTest, GestureScrollAfterFling) {
// Handle scroll on compositor. // Handle scroll on compositor.
cc::InputHandlerScrollResult scroll_result_did_scroll_; cc::InputHandlerScrollResult scroll_result_did_scroll_;
scroll_result_did_scroll_.did_scroll = true; scroll_result_did_scroll_.did_scroll = true;
...@@ -3643,5 +3846,13 @@ INSTANTIATE_TEST_CASE_P(AnimateInput, ...@@ -3643,5 +3846,13 @@ INSTANTIATE_TEST_CASE_P(AnimateInput,
InputHandlerProxyTest, InputHandlerProxyTest,
testing::ValuesIn(test_types)); testing::ValuesIn(test_types));
INSTANTIATE_TEST_CASE_P(AnimateInput,
InputHandlerProxyWithoutWheelScrollLatchingTest,
testing::ValuesIn(test_types));
INSTANTIATE_TEST_CASE_P(InputHandlerProxyEventQueueTests,
InputHandlerProxyEventQueueTest,
testing::Bool());
} // namespace test } // namespace test
} // namespace ui } // namespace ui
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment