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

Unified Diff: content/browser/renderer_host/input/touch_event_queue_unittest.cc

Issue 259763010: Forward secondary touch points even if the first had no consumer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clarify comment Created 6 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 | « content/browser/renderer_host/input/touch_event_queue.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8c6d68fc90804f28633ec97bea9df4a8dcf540ca..779cf25f34c77321ed0e118788515377fabeb187 100644
--- a/content/browser/renderer_host/input/touch_event_queue_unittest.cc
+++ b/content/browser/renderer_host/input/touch_event_queue_unittest.cc
@@ -576,13 +576,14 @@ TEST_F(TouchEventQueueTest, NoConsumer) {
EXPECT_EQ(1U, GetAndResetAckedEventCount());
EXPECT_EQ(0U, queued_event_count());
- // Send a second press event. As the first touch press had NO_CONSUMER, this
- // press event should not reach the renderer.
+ // Send a second press event. Even though the first touch press had
+ // NO_CONSUMER, this press event should reach the renderer.
PressTouchPoint(1, 1);
- EXPECT_EQ(0U, GetAndResetSentEventCount());
+ EXPECT_EQ(1U, GetAndResetSentEventCount());
+ EXPECT_EQ(1U, queued_event_count());
+ SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type);
EXPECT_EQ(1U, GetAndResetAckedEventCount());
- EXPECT_EQ(0U, queued_event_count());
}
TEST_F(TouchEventQueueTest, ConsumerIgnoreMultiFinger) {
@@ -1522,6 +1523,65 @@ TEST_F(TouchEventQueueTest, NoTouchMoveSuppressionAfterMultiTouch) {
EXPECT_EQ(0U, GetAndResetAckedEventCount());
}
+// Tests that secondary touch points can be forwarded even if the primary touch
+// point had no consumer.
+TEST_F(TouchEventQueueTest, SecondaryTouchForwardedAfterPrimaryHadNoConsumer) {
+ // Queue a TouchStart.
+ PressTouchPoint(0, 0);
+ SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
+ ASSERT_EQ(1U, GetAndResetSentEventCount());
+ ASSERT_EQ(1U, GetAndResetAckedEventCount());
+
+ // Events should not be forwarded, as the point had no consumer.
+ MoveTouchPoint(0, 0, 15);
+ EXPECT_EQ(0U, queued_event_count());
+ EXPECT_EQ(0U, GetAndResetSentEventCount());
+ EXPECT_EQ(1U, GetAndResetAckedEventCount());
+
+ // Simulate a secondary pointer press.
+ PressTouchPoint(20, 0);
+ SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_EQ(1U, GetAndResetSentEventCount());
+ EXPECT_EQ(1U, GetAndResetAckedEventCount());
+
+ // TouchMove with a secondary pointer should not be suppressed.
+ MoveTouchPoint(1, 25, 0);
+ EXPECT_EQ(1U, queued_event_count());
+ EXPECT_EQ(1U, GetAndResetSentEventCount());
+ SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_EQ(1U, GetAndResetAckedEventCount());
+}
+
+// Tests that no touch points will be forwarded after scrolling begins while no
+// touch points have a consumer.
+TEST_F(TouchEventQueueTest, NoForwardingAfterScrollWithNoTouchConsumers) {
+ // Queue a TouchStart.
+ PressTouchPoint(0, 0);
+ SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
+ ASSERT_EQ(1U, GetAndResetSentEventCount());
+ ASSERT_EQ(1U, GetAndResetAckedEventCount());
+
+ WebGestureEvent followup_scroll;
+ followup_scroll.type = WebInputEvent::GestureScrollBegin;
+ SetFollowupEvent(followup_scroll);
+ MoveTouchPoint(0, 20, 5);
+ EXPECT_EQ(0U, GetAndResetSentEventCount());
+ EXPECT_EQ(1U, GetAndResetAckedEventCount());
+ EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state());
+
+ // The secondary pointer press should not be forwarded.
+ PressTouchPoint(20, 0);
+ EXPECT_EQ(0U, GetAndResetSentEventCount());
+ EXPECT_EQ(1U, GetAndResetAckedEventCount());
+ EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state());
+
+ // Neither should any further touchmoves be forwarded.
+ MoveTouchPoint(1, 25, 0);
+ EXPECT_EQ(0U, GetAndResetSentEventCount());
+ EXPECT_EQ(1U, GetAndResetAckedEventCount());
+ EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state());
+}
+
TEST_F(TouchEventQueueTest, SyncTouchMoveDoesntCancelTouchOnScroll) {
SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_SYNC_TOUCHMOVE);
// Queue a TouchStart.
@@ -1770,7 +1830,7 @@ TEST_F(TouchEventQueueTest, AsyncTouchWithAckTimeout) {
EXPECT_EQ(1U, GetAndResetSentEventCount());
EXPECT_TRUE(IsTimeoutRunning());
- // The start of a scroll gesture should triger async touch event dispatch.
+ // The start of a scroll gesture should trigger async touch event dispatch.
WebGestureEvent followup_scroll;
followup_scroll.type = WebInputEvent::GestureScrollBegin;
SetFollowupEvent(followup_scroll);
@@ -1836,4 +1896,53 @@ TEST_F(TouchEventQueueTest, AsyncTouchWithAckTimeout) {
EXPECT_EQ(0U, GetAndResetSentEventCount());
}
+// Ensure that if the touch ack for an async touchmove triggers a follow-up
+// touch event, that follow-up touch will be forwarded appropriately.
+TEST_F(TouchEventQueueTest, AsyncTouchWithTouchCancelAfterAck) {
+ SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE);
+
+ PressTouchPoint(0, 0);
+ EXPECT_EQ(1U, GetAndResetSentEventCount());
+
+ // The start of a scroll gesture should trigger async touch event dispatch.
+ WebGestureEvent followup_scroll;
+ followup_scroll.type = WebInputEvent::GestureScrollBegin;
+ SetFollowupEvent(followup_scroll);
+ SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_EQ(1U, GetAndResetAckedEventCount());
+ EXPECT_EQ(0U, queued_event_count());
+
+ // 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.
+ WebTouchEvent followup_cancel;
+ followup_cancel.type = WebInputEvent::TouchCancel;
+ followup_cancel.touchesLength = 1;
+ followup_cancel.touches[0].state = WebTouchPoint::StateCancelled;
+ SetFollowupEvent(followup_cancel);
+ MoveTouchPoint(0, 5, 5);
+ EXPECT_EQ(2U, queued_event_count());
+ EXPECT_FALSE(sent_event().cancelable);
+ EXPECT_FALSE(HasPendingAsyncTouchMove());
+ EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type);
+ EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type);
+ EXPECT_EQ(1U, GetAndResetAckedEventCount());
+ EXPECT_EQ(1U, GetAndResetSentEventCount());
+
+ // The ack for the asnc 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);
+ EXPECT_EQ(1U, queued_event_count());
+ EXPECT_EQ(WebInputEvent::TouchCancel, sent_event().type);
+ EXPECT_EQ(0U, GetAndResetAckedEventCount());
+ EXPECT_EQ(1U, GetAndResetSentEventCount());
+
+ SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_EQ(0U, queued_event_count());
+ EXPECT_EQ(WebInputEvent::TouchCancel, acked_event().type);
+ EXPECT_EQ(1U, GetAndResetAckedEventCount());
+ EXPECT_EQ(0U, GetAndResetSentEventCount());
+}
+
} // namespace content
« no previous file with comments | « content/browser/renderer_host/input/touch_event_queue.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698