Chromium Code Reviews| 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 21895d2935c7f0150262eba792821ee9be57ca4a..2664a4c21eacb6b61a4b40c82b3f75a826d3b0d8 100644 |
| --- a/content/browser/renderer_host/input/touch_event_queue_unittest.cc |
| +++ b/content/browser/renderer_host/input/touch_event_queue_unittest.cc |
| @@ -1827,16 +1827,6 @@ TEST_F(TouchEventQueueTest, AsyncTouchThrottledAfterScroll) { |
| EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| - // As soon as a touchmove exceeds the outer slop region it will be forwarded |
| - // immediately. |
| - MoveTouchPoint(0, 0, 20); |
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| - EXPECT_FALSE(HasPendingAsyncTouchMove()); |
| - EXPECT_FALSE(sent_event().cancelable); |
| - EXPECT_EQ(0U, queued_event_count()); |
| - EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| - EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| - |
| // Subsequent touchmove's should be deferred. |
| MoveTouchPoint(0, 0, 25); |
| EXPECT_TRUE(HasPendingAsyncTouchMove()); |
| @@ -1936,6 +1926,60 @@ TEST_F(TouchEventQueueTest, AsyncTouchThrottledAfterScroll) { |
| EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| } |
| +TEST_F(TouchEventQueueTest, AsyncTouchFlushedByTouchEnd) { |
|
Rick Byers
2015/01/28 20:00:09
thanks for adding this test
|
| + SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE); |
|
Rick Byers
2015/01/28 20:00:08
we don't need to explicitly set this (it's the def
jdduke (slow)
2015/01/28 20:10:07
Probably not, only did it for consistency with oth
|
| + |
| + PressTouchPoint(0, 0); |
| + SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| + EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| + EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| + |
| + // Initiate async touchmove dispatch after the start of a scroll sequence. |
| + MoveTouchPoint(0, 0, 5); |
| + WebGestureEvent followup_scroll; |
| + 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, 10); |
| + 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, 100); |
| + EXPECT_TRUE(HasPendingAsyncTouchMove()); |
| + EXPECT_EQ(0U, queued_event_count()); |
| + EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| + EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| + |
| + // Return the touch sequence to the original touchstart position. |
|
Rick Byers
2015/01/28 20:00:09
this gets coalesced into the above event, right?
jdduke (slow)
2015/01/28 20:10:07
yup, i'll make a note.
|
| + MoveTouchPoint(0, 0, 0); |
| + EXPECT_TRUE(HasPendingAsyncTouchMove()); |
| + EXPECT_EQ(0U, queued_event_count()); |
| + EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| + EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| + |
| + // Queuing the final touchend should flush the pending, async touchmove. |
| + ReleaseTouchPoint(0); |
| + EXPECT_FALSE(HasPendingAsyncTouchMove()); |
| + EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type); |
| + EXPECT_FALSE(sent_event().cancelable); |
| + EXPECT_EQ(0, sent_event().touches[0].position.x); |
| + EXPECT_EQ(0, sent_event().touches[0].position.y); |
| + EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| + |
| + // Touchend is not cancelable during async touch dispatch. |
| + SendTouchEventAck(INPUT_EVENT_ACK_STATE_IGNORED); |
| + EXPECT_EQ(WebInputEvent::TouchEnd, sent_event().type); |
| + EXPECT_FALSE(sent_event().cancelable); |
| + EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| +} |
| + |
| // Ensure that async touch dispatch and touch ack timeout interactions work |
| // appropriately. |
| TEST_F(TouchEventQueueTest, AsyncTouchWithAckTimeout) { |