Index: content/browser/renderer_host/input/touch_event_queue_unittest.cc |
diff --git a/content/browser/renderer_host/input/touch_event_queue_unittest.cc b/content/browser/renderer_host/input/touch_event_queue_unittest.cc |
index 06a3a9f40f3e1113a1341b17228683afe45f76b6..719258fa02ee987a2234803d5c2e1c6226ac3777 100644 |
--- a/content/browser/renderer_host/input/touch_event_queue_unittest.cc |
+++ b/content/browser/renderer_host/input/touch_event_queue_unittest.cc |
@@ -1717,8 +1717,7 @@ TEST_F(TouchEventQueueTest, AsyncTouchThrottledAfterScroll) { |
SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
- // Now send the first touch move and associated GestureScrollBegin, |
- // but don't ACK the gesture event yet. |
+ // Now send the first touch move and associated GestureScrollBegin. |
MoveTouchPoint(0, 0, 5); |
WebGestureEvent followup_scroll; |
followup_scroll.type = WebInputEvent::GestureScrollBegin; |
@@ -1726,6 +1725,17 @@ TEST_F(TouchEventQueueTest, AsyncTouchThrottledAfterScroll) { |
SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
EXPECT_EQ(1U, GetAndResetSentEventCount()); |
EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
+ SendGestureEventAck(WebInputEvent::GestureScrollBegin, |
+ INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
+ |
+ // Send the second touch move and associated GestureScrollUpdate, but don't |
+ // ACK the gesture event yet. |
+ MoveTouchPoint(0, 0, 5); |
+ followup_scroll.type = WebInputEvent::GestureScrollUpdate; |
+ SetFollowupEvent(followup_scroll); |
+ SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
+ EXPECT_EQ(1U, GetAndResetSentEventCount()); |
+ EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
// Now queue a second touchmove and verify it's not (yet) dispatched. |
MoveTouchPoint(0, 0, 10); |
@@ -1760,7 +1770,7 @@ TEST_F(TouchEventQueueTest, AsyncTouchThrottledAfterScroll) { |
// Now mark the scroll as not consumed (which would cause future |
// touchmoves in the active sequence to be sent if there was one). |
- SendGestureEventAck(WebInputEvent::GestureScrollBegin, |
+ SendGestureEventAck(WebInputEvent::GestureScrollUpdate, |
INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
// Start a new touch sequence and verify that throttling has been reset. |
@@ -1770,10 +1780,19 @@ TEST_F(TouchEventQueueTest, AsyncTouchThrottledAfterScroll) { |
SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
MoveTouchPoint(0, 0, 5); |
+ followup_scroll.type = WebInputEvent::GestureScrollBegin; |
SetFollowupEvent(followup_scroll); |
SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
EXPECT_EQ(1U, GetAndResetSentEventCount()); |
EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
+ |
+ MoveTouchPoint(0, 0, 5); |
+ followup_scroll.type = WebInputEvent::GestureScrollUpdate; |
+ SetFollowupEvent(followup_scroll); |
+ SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
+ EXPECT_EQ(1U, GetAndResetSentEventCount()); |
+ EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
+ |
MoveTouchPoint(0, 0, 10); |
SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
EXPECT_TRUE(HasPendingAsyncTouchMove()); |
@@ -1993,6 +2012,8 @@ TEST_F(TouchEventQueueTest, AsyncTouchWithTouchCancelAfterAck) { |
EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
EXPECT_EQ(0U, queued_event_count()); |
+ SendGestureEvent(WebInputEvent::GestureScrollUpdate); |
+ |
// The async touchmove should be ack'ed immediately, but not forwarded. |
// However, because the ack triggers a touchcancel, both the pending touch and |
// the queued touchcancel should be flushed. |
@@ -2010,7 +2031,7 @@ TEST_F(TouchEventQueueTest, AsyncTouchWithTouchCancelAfterAck) { |
EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
EXPECT_EQ(1U, GetAndResetSentEventCount()); |
- // The ack for the asnc touchmove should not reach the client, as it has |
+ // The ack for the async touchmove should not reach the client, as it has |
// already been ack'ed. |
SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
EXPECT_FALSE(sent_event().cancelable); |
@@ -2026,4 +2047,27 @@ TEST_F(TouchEventQueueTest, AsyncTouchWithTouchCancelAfterAck) { |
EXPECT_EQ(0U, GetAndResetSentEventCount()); |
} |
+TEST_F(TouchEventQueueTest, TouchAbsorptionWithConsumedFirstMove) { |
+ SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE); |
+ |
+ // Queue a TouchStart. |
+ PressTouchPoint(0, 1); |
+ SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
+ EXPECT_EQ(0U, queued_event_count()); |
+ EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
+ |
+ MoveTouchPoint(0, 20, 5); |
+ SendGestureEvent(blink::WebInputEvent::GestureScrollBegin); |
+ SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
+ EXPECT_EQ(0U, queued_event_count()); |
+ EXPECT_EQ(2U, GetAndResetSentEventCount()); |
+ |
+ // Even if the first touchmove event was consumed, we should be able to |
+ // scroll if we receive unconsumed touchmove events. |
+ MoveTouchPoint(0, 60, 5); |
+ SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
+ EXPECT_EQ(0U, queued_event_count()); |
+ EXPECT_EQ(1U, GetAndResetSentEventCount()); |
+} |
+ |
} // namespace content |