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..618cac06f519ec676e8a079a53a85abd05042c50 100644 |
--- a/content/browser/renderer_host/input/touch_event_queue_unittest.cc |
+++ b/content/browser/renderer_host/input/touch_event_queue_unittest.cc |
@@ -859,13 +859,16 @@ TEST_F(TouchEventQueueTest, TouchCancelOnScroll) { |
EXPECT_EQ(1U, queued_event_count()); |
EXPECT_EQ(1U, GetAndResetSentEventCount()); |
+ MoveTouchPoint(0, 30, 15); |
+ EXPECT_EQ(2U, queued_event_count()); |
+ EXPECT_EQ(0U, GetAndResetSentEventCount()); |
+ |
// Queue another TouchStart. |
PressTouchPoint(20, 20); |
- EXPECT_EQ(2U, queued_event_count()); |
+ EXPECT_EQ(3U, queued_event_count()); |
EXPECT_EQ(0U, GetAndResetSentEventCount()); |
EXPECT_EQ(WebInputEvent::TouchStart, latest_event().type); |
- // GestureScrollBegin inserts a synthetic TouchCancel before the TouchStart. |
WebGestureEvent followup_scroll; |
followup_scroll.type = WebInputEvent::GestureScrollBegin; |
SetFollowupEvent(followup_scroll); |
@@ -873,6 +876,16 @@ TEST_F(TouchEventQueueTest, TouchCancelOnScroll) { |
EXPECT_EQ(1U, GetAndResetSentEventCount()); |
EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
EXPECT_EQ(2U, queued_event_count()); |
+ EXPECT_TRUE(sent_event().cancelable); |
+ EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type); |
+ |
+ // GestureScrollUpdate inserts a synthetic TouchCancel before the TouchStart. |
+ followup_scroll.type = WebInputEvent::GestureScrollUpdate; |
+ SetFollowupEvent(followup_scroll); |
+ SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
+ EXPECT_EQ(1U, GetAndResetSentEventCount()); |
+ EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
+ EXPECT_EQ(2U, queued_event_count()); |
EXPECT_EQ(WebInputEvent::TouchCancel, sent_event().type); |
EXPECT_FALSE(sent_event().cancelable); |
EXPECT_EQ(WebInputEvent::TouchStart, latest_event().type); |
@@ -890,9 +903,6 @@ TEST_F(TouchEventQueueTest, TouchCancelOnScroll) { |
EXPECT_EQ(0U, GetAndResetSentEventCount()); |
EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); |
- // GestureScrollUpdates should not change affect touch forwarding. |
- SendGestureEvent(WebInputEvent::GestureScrollUpdate); |
jdduke (slow)
2014/07/07 23:09:14
Why remove this?
tdresser
2014/07/08 15:56:41
I was thinking of it more as moving it upwards. Re
|
- |
// TouchEnd should not be sent to the renderer. |
ReleaseTouchPoint(0); |
EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
@@ -1717,8 +1727,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 +1735,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 +1780,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 +1790,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 +2022,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 +2041,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 +2057,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. |
jdduke (slow)
2014/07/07 23:09:14
Maybe change the comment to say:
// Even if the f
tdresser
2014/07/08 15:56:41
Done.
|
+ MoveTouchPoint(0, 60, 5); |
+ SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
+ EXPECT_EQ(0U, queued_event_count()); |
+ EXPECT_EQ(1U, GetAndResetSentEventCount()); |
+} |
+ |
} // namespace content |