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

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

Issue 252023005: Revert 266470 "Implement async touchmove dispatch during scroll" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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
Index: trunk/src/content/browser/renderer_host/input/touch_event_queue_unittest.cc
===================================================================
--- trunk/src/content/browser/renderer_host/input/touch_event_queue_unittest.cc (revision 266575)
+++ trunk/src/content/browser/renderer_host/input/touch_event_queue_unittest.cc (working copy)
@@ -19,9 +19,6 @@
namespace content {
namespace {
-
-const double kMinSecondsBetweenThrottledTouchmoves = 0.2;
-
base::TimeDelta DefaultTouchTimeoutDelay() {
return base::TimeDelta::FromMilliseconds(1);
}
@@ -159,10 +156,6 @@
SendTouchEvent();
}
- void AdvanceTouchTime(double seconds) {
- touch_event_.timeStampSeconds += seconds;
- }
-
size_t GetAndResetAckedEventCount() {
size_t count = acked_event_count_;
acked_event_count_ = 0;
@@ -187,12 +180,12 @@
queue_->SetAckTimeoutEnabled(false, base::TimeDelta());
}
- bool IsTimeoutEnabled() const { return queue_->ack_timeout_enabled(); }
+ bool IsTimeoutEnabled() {
+ return queue_->ack_timeout_enabled();
+ }
- bool IsTimeoutRunning() const { return queue_->IsTimeoutRunningForTesting(); }
-
- bool HasPendingAsyncTouchMove() const {
- return queue_->HasPendingAsyncTouchMoveForTesting();
+ bool IsTimeoutRunning() {
+ return queue_->IsTimeoutRunningForTesting();
}
size_t queued_event_count() const {
@@ -1544,8 +1537,8 @@
EXPECT_EQ(0U, queued_event_count());
}
-TEST_F(TouchEventQueueTest, AsyncTouch) {
- SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE);
+TEST_F(TouchEventQueueTest, TouchAbsorption) {
+ SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_ABSORB_TOUCHMOVE);
// Queue a TouchStart.
PressTouchPoint(0, 1);
@@ -1557,28 +1550,24 @@
SendGestureEventAck(WebInputEvent::GestureScrollUpdate,
INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
- MoveTouchPoint(0, 10, 5);
+ MoveTouchPoint(0, 20, 5);
SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
- EXPECT_FALSE(HasPendingAsyncTouchMove());
- EXPECT_TRUE(sent_event().cancelable);
EXPECT_EQ(0U, queued_event_count());
EXPECT_EQ(1U, GetAndResetSentEventCount());
- // Consuming a scroll event will throttle subsequent touchmoves.
+ // Consuming a scroll event prevents the next touch moves from being
+ // dispatched.
SendGestureEventAck(WebInputEvent::GestureScrollUpdate,
INPUT_EVENT_ACK_STATE_CONSUMED);
- MoveTouchPoint(0, 10, 5);
+ MoveTouchPoint(0, 20, 5);
SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
- EXPECT_TRUE(HasPendingAsyncTouchMove());
EXPECT_EQ(0U, queued_event_count());
EXPECT_EQ(0U, GetAndResetSentEventCount());
}
}
-// Ensure that touchmove's are appropriately throttled during a typical
-// scroll sequences that transitions between scrolls consumed and unconsumed.
-TEST_F(TouchEventQueueTest, AsyncTouchThrottledAfterScroll) {
- SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE);
+TEST_F(TouchEventQueueTest, TouchAbsorptionNoTouchAfterScroll) {
+ SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_ABSORB_TOUCHMOVE);
// Process a TouchStart
PressTouchPoint(0, 1);
@@ -1596,45 +1585,30 @@
EXPECT_EQ(1U, GetAndResetSentEventCount());
EXPECT_EQ(1U, GetAndResetAckedEventCount());
- // Now queue a second touchmove and verify it's not (yet) dispatched.
+ // Now queue a second touchmove and verify it's not dispatched.
MoveTouchPoint(0, 0, 10);
SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
- 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.
+ // But a final touchend is sent (even before any gesture events
+ // have been ACKed).
ReleaseTouchPoint(0);
- EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type);
- EXPECT_FALSE(HasPendingAsyncTouchMove());
- EXPECT_FALSE(sent_event().cancelable);
- EXPECT_EQ(1U, GetAndResetSentEventCount());
- EXPECT_EQ(2U, queued_event_count());
-
- // Ack the flushed, async touchmove. The ack should not reach the client, but
- // it should trigger sending of the (now non-cancelable) touchend.
SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
- EXPECT_EQ(WebInputEvent::TouchEnd, sent_event().type);
- EXPECT_FALSE(sent_event().cancelable);
+ EXPECT_EQ(0U, queued_event_count());
EXPECT_EQ(1U, GetAndResetSentEventCount());
- EXPECT_EQ(0U, GetAndResetAckedEventCount());
- EXPECT_EQ(1U, queued_event_count());
-
- // Ack the touchend.
- SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
- EXPECT_EQ(0U, queued_event_count());
- EXPECT_EQ(0U, GetAndResetSentEventCount());
EXPECT_EQ(1U, GetAndResetAckedEventCount());
+ EXPECT_EQ(WebInputEvent::TouchEnd, sent_event().type);
// 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,
INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
- // Start a new touch sequence and verify that throttling has been reset.
- // Touch moves after the start of scrolling will again be throttled.
- PressTouchPoint(0, 0);
+ // Start a new touch sequence and verify that absorption has been
+ // reset so that moves after the start of scrolling are not sent.
+ PressTouchPoint(0, 1);
EXPECT_EQ(1U, GetAndResetSentEventCount());
SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
EXPECT_EQ(1U, GetAndResetAckedEventCount());
@@ -1645,195 +1619,8 @@
EXPECT_EQ(1U, GetAndResetAckedEventCount());
MoveTouchPoint(0, 0, 10);
SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
- EXPECT_TRUE(HasPendingAsyncTouchMove());
EXPECT_EQ(0U, queued_event_count());
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());
- EXPECT_EQ(0U, queued_event_count());
- EXPECT_EQ(0U, GetAndResetSentEventCount());
- EXPECT_EQ(1U, GetAndResetAckedEventCount());
-
- // The pending touchmove should be flushed with the the new touchmove if
- // sufficient time has passed.
- AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1);
- MoveTouchPoint(0, 0, 15);
- EXPECT_FALSE(HasPendingAsyncTouchMove());
- EXPECT_FALSE(sent_event().cancelable);
- EXPECT_EQ(1U, queued_event_count());
- EXPECT_EQ(1U, GetAndResetSentEventCount());
- EXPECT_EQ(0U, GetAndResetAckedEventCount());
- SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
- EXPECT_EQ(0U, queued_event_count());
- EXPECT_EQ(0U, GetAndResetSentEventCount());
- EXPECT_EQ(1U, GetAndResetAckedEventCount());
-
- // Non-touchmove events should always flush any pending touchmove events.
- MoveTouchPoint(0, 0, 25);
- EXPECT_TRUE(HasPendingAsyncTouchMove());
- EXPECT_EQ(0U, queued_event_count());
- EXPECT_EQ(0U, GetAndResetSentEventCount());
- EXPECT_EQ(1U, GetAndResetAckedEventCount());
- PressTouchPoint(30, 30);
- EXPECT_FALSE(HasPendingAsyncTouchMove());
- EXPECT_FALSE(sent_event().cancelable);
- EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type);
- EXPECT_EQ(1U, GetAndResetSentEventCount());
- EXPECT_EQ(2U, queued_event_count());
-
- // Ack'ing the flushed, async touchmove will dispatch the touchstart. Note
- // that the flushed touchmove's ack will not reach the client (its
- // constituent events have already been ack'ed).
- SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
- EXPECT_FALSE(sent_event().cancelable);
- EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type);
- EXPECT_EQ(1U, queued_event_count());
- EXPECT_EQ(1U, GetAndResetSentEventCount());
- EXPECT_EQ(0U, GetAndResetAckedEventCount());
-
- // Ack the touchstart.
- SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
- EXPECT_EQ(0U, queued_event_count());
- EXPECT_EQ(0U, GetAndResetSentEventCount());
- EXPECT_EQ(1U, GetAndResetAckedEventCount());
-
- // Send a secondary touchmove.
- MoveTouchPoint(1, 0, 25);
- EXPECT_TRUE(HasPendingAsyncTouchMove());
- EXPECT_EQ(0U, queued_event_count());
- EXPECT_EQ(0U, GetAndResetSentEventCount());
- EXPECT_EQ(1U, GetAndResetAckedEventCount());
-
- // An unconsumed scroll should resume synchronous touch handling.
- SendGestureEventAck(WebInputEvent::GestureScrollUpdate,
- INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
-
- // The pending touchmove should be coalesced with the next (now synchronous)
- // touchmove.
- MoveTouchPoint(0, 0, 25);
- EXPECT_TRUE(sent_event().cancelable);
- EXPECT_FALSE(HasPendingAsyncTouchMove());
- EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type);
- EXPECT_EQ(WebTouchPoint::StateMoved, sent_event().touches[0].state);
- EXPECT_EQ(WebTouchPoint::StateMoved, sent_event().touches[1].state);
- EXPECT_EQ(1U, queued_event_count());
- EXPECT_EQ(1U, GetAndResetSentEventCount());
- EXPECT_EQ(0U, GetAndResetAckedEventCount());
-
- // Subsequent touches will queue until the preceding, synchronous touches are
- // ack'ed.
- ReleaseTouchPoint(1);
- EXPECT_EQ(2U, queued_event_count());
- ReleaseTouchPoint(0);
- EXPECT_EQ(3U, queued_event_count());
- SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
- EXPECT_TRUE(sent_event().cancelable);
- EXPECT_EQ(WebInputEvent::TouchEnd, sent_event().type);
- EXPECT_EQ(2U, queued_event_count());
- EXPECT_EQ(1U, GetAndResetSentEventCount());
- EXPECT_EQ(1U, GetAndResetAckedEventCount());
-
- SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
- EXPECT_TRUE(sent_event().cancelable);
- EXPECT_EQ(WebInputEvent::TouchEnd, sent_event().type);
- EXPECT_EQ(1U, queued_event_count());
- EXPECT_EQ(1U, GetAndResetSentEventCount());
- EXPECT_EQ(1U, GetAndResetAckedEventCount());
-
- SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
- EXPECT_EQ(0U, queued_event_count());
- EXPECT_EQ(0U, GetAndResetSentEventCount());
- EXPECT_EQ(1U, GetAndResetAckedEventCount());
}
-// Ensure that async touch dispatch and touch ack timeout interactions work
-// appropriately.
-TEST_F(TouchEventQueueTest, AsyncTouchWithAckTimeout) {
- SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE);
- SetUpForTimeoutTesting(DefaultTouchTimeoutDelay());
-
- // The touchstart should start the timeout.
- PressTouchPoint(0, 0);
- EXPECT_EQ(1U, GetAndResetSentEventCount());
- EXPECT_TRUE(IsTimeoutRunning());
-
- // The start of a scroll gesture should triger async touch event dispatch.
- WebGestureEvent followup_scroll;
- followup_scroll.type = WebInputEvent::GestureScrollBegin;
- SetFollowupEvent(followup_scroll);
- SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
- EXPECT_FALSE(IsTimeoutRunning());
- EXPECT_EQ(1U, GetAndResetAckedEventCount());
-
- SendGestureEventAck(WebInputEvent::GestureScrollUpdate,
- INPUT_EVENT_ACK_STATE_CONSUMED);
-
- // An async touch should fire after the throttling interval has expired, but
- // it should not start the touch ack timeout.
- MoveTouchPoint(0, 5, 5);
- EXPECT_TRUE(HasPendingAsyncTouchMove());
- EXPECT_EQ(1U, GetAndResetAckedEventCount());
-
- AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1);
- MoveTouchPoint(0, 5, 5);
- EXPECT_FALSE(IsTimeoutRunning());
- EXPECT_FALSE(HasPendingAsyncTouchMove());
- EXPECT_FALSE(sent_event().cancelable);
- SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
- EXPECT_EQ(1U, GetAndResetAckedEventCount());
- EXPECT_EQ(1U, GetAndResetSentEventCount());
-
- // An unconsumed scroll event will resume synchronous touchmoves, which are
- // subject to the ack timeout.
- SendGestureEventAck(WebInputEvent::GestureScrollUpdate,
- INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
- MoveTouchPoint(0, 20, 5);
- EXPECT_TRUE(IsTimeoutRunning());
- EXPECT_TRUE(sent_event().cancelable);
- EXPECT_EQ(1U, GetAndResetSentEventCount());
-
- // The timeout should fire, disabling touch forwarding until both acks are
- // received and acking the timed out event.
- RunTasksAndWait(DefaultTouchTimeoutDelay() * 2);
- EXPECT_FALSE(IsTimeoutRunning());
- EXPECT_EQ(1U, GetAndResetAckedEventCount());
- EXPECT_EQ(0U, GetAndResetSentEventCount());
-
- // Ack'ing the original event should trigger a cancel event.
- SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
- SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
- EXPECT_FALSE(sent_event().cancelable);
- EXPECT_EQ(0U, GetAndResetAckedEventCount());
- EXPECT_EQ(1U, GetAndResetSentEventCount());
-
- // Subsequent touchmove's should not be forwarded, even as the scroll gesture
- // goes from unconsumed to consumed.
- SendGestureEventAck(WebInputEvent::GestureScrollUpdate,
- INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
- MoveTouchPoint(0, 20, 5);
- EXPECT_FALSE(HasPendingAsyncTouchMove());
- EXPECT_EQ(1U, GetAndResetAckedEventCount());
- EXPECT_EQ(0U, GetAndResetSentEventCount());
-
- SendGestureEventAck(WebInputEvent::GestureScrollUpdate,
- INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
- MoveTouchPoint(0, 25, 5);
- EXPECT_FALSE(HasPendingAsyncTouchMove());
- EXPECT_EQ(1U, GetAndResetAckedEventCount());
- EXPECT_EQ(0U, GetAndResetSentEventCount());
-}
-
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698