| Index: content/browser/renderer_host/input/passthrough_touch_event_queue_unittest.cc
|
| diff --git a/content/browser/renderer_host/input/touch_event_queue_unittest.cc b/content/browser/renderer_host/input/passthrough_touch_event_queue_unittest.cc
|
| similarity index 56%
|
| rename from content/browser/renderer_host/input/touch_event_queue_unittest.cc
|
| rename to content/browser/renderer_host/input/passthrough_touch_event_queue_unittest.cc
|
| index b20f692127df31e16d458d601004a5bfbefca442..6b708cced1d4c833ffee577d1bcfbb2fd79b3709 100644
|
| --- a/content/browser/renderer_host/input/touch_event_queue_unittest.cc
|
| +++ b/content/browser/renderer_host/input/passthrough_touch_event_queue_unittest.cc
|
| @@ -1,8 +1,8 @@
|
| -// Copyright 2013 The Chromium Authors. All rights reserved.
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "content/browser/renderer_host/input/touch_event_queue.h"
|
| +#include "content/browser/renderer_host/input/passthrough_touch_event_queue.h"
|
|
|
| #include <stddef.h>
|
|
|
| @@ -15,7 +15,6 @@
|
| #include "base/run_loop.h"
|
| #include "base/single_thread_task_runner.h"
|
| #include "base/threading/thread_task_runner_handle.h"
|
| -#include "content/browser/renderer_host/input/legacy_touch_event_queue.h"
|
| #include "content/browser/renderer_host/input/timeout_monitor.h"
|
| #include "content/common/input/synthetic_web_input_event_builders.h"
|
| #include "content/common/input/web_touch_event_traits.h"
|
| @@ -40,15 +39,15 @@ base::TimeDelta DefaultTouchTimeoutDelay() {
|
| }
|
| } // namespace
|
|
|
| -class TouchEventQueueTest : public testing::Test,
|
| - public TouchEventQueueClient {
|
| +class PassthroughTouchEventQueueTest : public testing::Test,
|
| + public TouchEventQueueClient {
|
| public:
|
| - TouchEventQueueTest()
|
| + PassthroughTouchEventQueueTest()
|
| : acked_event_count_(0),
|
| last_acked_event_state_(INPUT_EVENT_ACK_STATE_UNKNOWN),
|
| slop_length_dips_(0) {}
|
|
|
| - ~TouchEventQueueTest() override {}
|
| + ~PassthroughTouchEventQueueTest() override {}
|
|
|
| // testing::Test
|
| void SetUp() override {
|
| @@ -82,9 +81,8 @@ class TouchEventQueueTest : public testing::Test,
|
| if (followup_gesture_event_) {
|
| std::unique_ptr<WebGestureEvent> followup_gesture_event =
|
| std::move(followup_gesture_event_);
|
| - queue_->OnGestureScrollEvent(
|
| - GestureEventWithLatencyInfo(*followup_gesture_event,
|
| - ui::LatencyInfo()));
|
| + queue_->OnGestureScrollEvent(GestureEventWithLatencyInfo(
|
| + *followup_gesture_event, ui::LatencyInfo()));
|
| }
|
| }
|
|
|
| @@ -140,6 +138,13 @@ class TouchEventQueueTest : public testing::Test,
|
| sent_events_ids_.pop_front();
|
| }
|
|
|
| + void SendTouchEventAckLast(InputEventAckState ack_result) {
|
| + DCHECK(!sent_events_ids_.empty());
|
| + queue_->ProcessTouchAck(ack_result, ui::LatencyInfo(),
|
| + sent_events_ids_.back());
|
| + sent_events_ids_.pop_back();
|
| + }
|
| +
|
| void SendTouchEventAckWithID(InputEventAckState ack_result,
|
| int unique_event_id) {
|
| queue_->ProcessTouchAck(ack_result, ui::LatencyInfo(), unique_event_id);
|
| @@ -247,9 +252,7 @@ class TouchEventQueueTest : public testing::Test,
|
| touch_event_.setTimeStampSeconds(touch_event_.timeStampSeconds() + seconds);
|
| }
|
|
|
| - void ResetTouchEvent() {
|
| - touch_event_ = SyntheticWebTouchEvent();
|
| - }
|
| + void ResetTouchEvent() { touch_event_ = SyntheticWebTouchEvent(); }
|
|
|
| size_t GetAndResetAckedEventCount() {
|
| size_t count = acked_event_count_;
|
| @@ -279,21 +282,13 @@ class TouchEventQueueTest : public testing::Test,
|
|
|
| bool IsTimeoutRunning() const { return queue_->IsTimeoutRunningForTesting(); }
|
|
|
| - bool HasPendingAsyncTouchMove() const {
|
| - return queue_->HasPendingAsyncTouchMoveForTesting();
|
| - }
|
| -
|
| - size_t queued_event_count() const {
|
| - return queue_->size();
|
| - }
|
| + size_t queued_event_count() const { return queue_->SizeForTesting(); }
|
|
|
| const WebTouchEvent& latest_event() const {
|
| return queue_->GetLatestEventForTesting().event;
|
| }
|
|
|
| - const WebTouchEvent& acked_event() const {
|
| - return last_acked_event_;
|
| - }
|
| + const WebTouchEvent& acked_event() const { return last_acked_event_; }
|
|
|
| const WebTouchEvent& sent_event() const {
|
| DCHECK(!sent_events_.empty());
|
| @@ -314,10 +309,6 @@ class TouchEventQueueTest : public testing::Test,
|
| base::RunLoop().Run();
|
| }
|
|
|
| - size_t uncancelable_touch_moves_pending_ack_count() const {
|
| - return queue_->uncancelable_touch_moves_pending_ack_count();
|
| - }
|
| -
|
| int GetUniqueTouchEventID() { return sent_events_ids_.back(); }
|
|
|
| private:
|
| @@ -327,11 +318,11 @@ class TouchEventQueueTest : public testing::Test,
|
| }
|
|
|
| void ResetQueueWithConfig(const TouchEventQueue::Config& config) {
|
| - queue_.reset(new LegacyTouchEventQueue(this, config));
|
| + queue_.reset(new PassthroughTouchEventQueue(this, config));
|
| queue_->OnHasTouchEventHandlers(true);
|
| }
|
|
|
| - std::unique_ptr<LegacyTouchEventQueue> queue_;
|
| + std::unique_ptr<PassthroughTouchEventQueue> queue_;
|
| size_t acked_event_count_;
|
| WebTouchEvent last_acked_event_;
|
| std::vector<WebTouchEvent> sent_events_;
|
| @@ -346,22 +337,22 @@ class TouchEventQueueTest : public testing::Test,
|
| std::deque<int> sent_events_ids_;
|
| };
|
|
|
| -
|
| // Tests that touch-events are queued properly.
|
| -TEST_F(TouchEventQueueTest, Basic) {
|
| +TEST_F(PassthroughTouchEventQueueTest, Basic) {
|
| PressTouchPoint(1, 1);
|
| EXPECT_EQ(1U, queued_event_count());
|
| EXPECT_EQ(1U, GetAndResetSentEventCount());
|
|
|
| - // The second touch should not be sent since one is already in queue.
|
| + // The second touch should be sent right away even though
|
| + // we haven't received an ack for the touch start.
|
| MoveTouchPoint(0, 5, 5);
|
| EXPECT_EQ(2U, queued_event_count());
|
| - EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| + EXPECT_EQ(1U, GetAndResetSentEventCount());
|
|
|
| // Receive an ACK for the first touch-event.
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| EXPECT_EQ(1U, queued_event_count());
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| + EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type());
|
| EXPECT_EQ(WebInputEvent::Blocking, acked_event().dispatchType);
|
| @@ -376,53 +367,55 @@ TEST_F(TouchEventQueueTest, Basic) {
|
| }
|
|
|
| // Tests that touch-events with multiple points are queued properly.
|
| -TEST_F(TouchEventQueueTest, BasicMultiTouch) {
|
| +TEST_F(PassthroughTouchEventQueueTest, BasicMultiTouch) {
|
| const size_t kPointerCount = 10;
|
| for (float i = 0; i < kPointerCount; ++i)
|
| PressTouchPoint(i, i);
|
|
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| + EXPECT_EQ(kPointerCount, GetAndResetSentEventCount());
|
| EXPECT_EQ(0U, GetAndResetAckedEventCount());
|
| EXPECT_EQ(kPointerCount, queued_event_count());
|
|
|
| for (int i = 0; i < static_cast<int>(kPointerCount); ++i)
|
| MoveTouchPoint(i, 1.f + i, 2.f + i);
|
|
|
| - EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| + EXPECT_EQ(kPointerCount, GetAndResetSentEventCount());
|
| EXPECT_EQ(0U, GetAndResetAckedEventCount());
|
| - // All moves should coalesce.
|
| - EXPECT_EQ(kPointerCount + 1, queued_event_count());
|
| + // No coalescing happens in the queue since they are all sent immediately.
|
| + EXPECT_EQ(2 * kPointerCount, queued_event_count());
|
|
|
| for (int i = 0; i < static_cast<int>(kPointerCount); ++i)
|
| ReleaseTouchPoint(kPointerCount - 1 - i);
|
|
|
| - EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| + EXPECT_EQ(kPointerCount, GetAndResetSentEventCount());
|
| EXPECT_EQ(0U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(kPointerCount * 2 + 1, queued_event_count());
|
| + EXPECT_EQ(kPointerCount * 3, queued_event_count());
|
|
|
| // Ack all presses.
|
| for (size_t i = 0; i < kPointerCount; ++i)
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
|
|
| EXPECT_EQ(kPointerCount, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(kPointerCount, GetAndResetSentEventCount());
|
| + EXPECT_EQ(0U, GetAndResetSentEventCount());
|
|
|
| - // Ack the coalesced move.
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| + // Ack the touch moves.
|
| + for (size_t i = 0; i < kPointerCount; ++i)
|
| + SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| EXPECT_EQ(kPointerCount, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| + EXPECT_EQ(0U, GetAndResetSentEventCount());
|
|
|
| // Ack all releases.
|
| for (size_t i = 0; i < kPointerCount; ++i)
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
|
|
| EXPECT_EQ(kPointerCount, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(kPointerCount - 1, GetAndResetSentEventCount());
|
| + EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| }
|
|
|
| // Tests that the touch-queue continues delivering events for an active touch
|
| // sequence after all handlers are removed.
|
| -TEST_F(TouchEventQueueTest, TouchesForwardedIfHandlerRemovedDuringSequence) {
|
| +TEST_F(PassthroughTouchEventQueueTest,
|
| + TouchesForwardedIfHandlerRemovedDuringSequence) {
|
| OnHasTouchEventHandlers(true);
|
| EXPECT_EQ(0U, queued_event_count());
|
| EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| @@ -455,10 +448,10 @@ TEST_F(TouchEventQueueTest, TouchesForwardedIfHandlerRemovedDuringSequence) {
|
| // reported no consumer.
|
| MoveTouchPoint(1, 3, 3);
|
| ReleaseTouchPoint(1);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| + EXPECT_EQ(2U, GetAndResetSentEventCount());
|
| EXPECT_EQ(0U, GetAndResetAckedEventCount());
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| + EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
|
| EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| @@ -467,12 +460,12 @@ TEST_F(TouchEventQueueTest, TouchesForwardedIfHandlerRemovedDuringSequence) {
|
| // Events for the first pointer, that had a handler, should be forwarded.
|
| MoveTouchPoint(0, 4, 4);
|
| ReleaseTouchPoint(0);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| + EXPECT_EQ(2U, GetAndResetSentEventCount());
|
| EXPECT_EQ(2U, queued_event_count());
|
|
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| + EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| EXPECT_EQ(1U, queued_event_count());
|
| EXPECT_EQ(INPUT_EVENT_ACK_STATE_CONSUMED, acked_event_state());
|
|
|
| @@ -485,7 +478,8 @@ TEST_F(TouchEventQueueTest, TouchesForwardedIfHandlerRemovedDuringSequence) {
|
|
|
| // Tests that addition of a touch handler during a touch sequence will not cause
|
| // the remaining sequence to be forwarded.
|
| -TEST_F(TouchEventQueueTest, ActiveSequenceNotForwardedWhenHandlersAdded) {
|
| +TEST_F(PassthroughTouchEventQueueTest,
|
| + ActiveSequenceNotForwardedWhenHandlersAdded) {
|
| OnHasTouchEventHandlers(false);
|
|
|
| // Send a touch-press event while there is no handler.
|
| @@ -512,7 +506,8 @@ TEST_F(TouchEventQueueTest, ActiveSequenceNotForwardedWhenHandlersAdded) {
|
| // Tests that removal of a touch handler during a touch sequence will prevent
|
| // the remaining sequence from being forwarded, even if another touch handler is
|
| // registered during the same touch sequence.
|
| -TEST_F(TouchEventQueueTest, ActiveSequenceDroppedWhenHandlersRemoved) {
|
| +TEST_F(PassthroughTouchEventQueueTest,
|
| + ActiveSequenceDroppedWhenHandlersRemoved) {
|
| // Send a touch-press event.
|
| PressTouchPoint(1, 1);
|
| EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| @@ -522,7 +517,7 @@ TEST_F(TouchEventQueueTest, ActiveSequenceDroppedWhenHandlersRemoved) {
|
| MoveTouchPoint(0, 5, 5);
|
| EXPECT_EQ(2U, queued_event_count());
|
| EXPECT_EQ(0U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| + EXPECT_EQ(1U, GetAndResetSentEventCount());
|
|
|
| // Unregister all touch handlers.
|
| OnHasTouchEventHandlers(false);
|
| @@ -538,7 +533,8 @@ TEST_F(TouchEventQueueTest, ActiveSequenceDroppedWhenHandlersRemoved) {
|
| EXPECT_EQ(0U, GetAndResetAckedEventCount());
|
| EXPECT_EQ(2U, queued_event_count());
|
|
|
| - // The ack should be flush the queue.
|
| + // clear the queue .
|
| + SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
|
| EXPECT_EQ(2U, GetAndResetAckedEventCount());
|
| EXPECT_EQ(0U, queued_event_count());
|
| @@ -566,7 +562,7 @@ TEST_F(TouchEventQueueTest, ActiveSequenceDroppedWhenHandlersRemoved) {
|
|
|
| // Tests that removal/addition of a touch handler without any intervening
|
| // touch activity has no affect on touch forwarding.
|
| -TEST_F(TouchEventQueueTest,
|
| +TEST_F(PassthroughTouchEventQueueTest,
|
| ActiveSequenceUnaffectedByRepeatedHandlerRemovalAndAddition) {
|
| // Send a touch-press event.
|
| PressTouchPoint(1, 1);
|
| @@ -578,123 +574,22 @@ TEST_F(TouchEventQueueTest,
|
| OnHasTouchEventHandlers(false);
|
| OnHasTouchEventHandlers(true);
|
|
|
| - // Queue a touch-move event.
|
| + // Queue a touch-move event, should be sent right away.
|
| MoveTouchPoint(0, 5, 5);
|
| EXPECT_EQ(2U, queued_event_count());
|
| EXPECT_EQ(0U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| + EXPECT_EQ(1U, GetAndResetSentEventCount());
|
|
|
| // The ack should trigger forwarding of the touchmove, as if no touch
|
| // handler registration changes have occurred.
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, queued_event_count());
|
| -}
|
| -
|
| -// Tests that touch-events are coalesced properly in the queue.
|
| -TEST_F(TouchEventQueueTest, Coalesce) {
|
| - // Send a touch-press event.
|
| - PressTouchPoint(1, 1);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| -
|
| - // Send a few touch-move events, followed by a touch-release event. All the
|
| - // touch-move events should be coalesced into a single event.
|
| - for (float i = 5; i < 15; ++i)
|
| - MoveTouchPoint(0, i, i);
|
| -
|
| - EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| - ReleaseTouchPoint(0);
|
| - EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(3U, queued_event_count());
|
| -
|
| - // ACK the press. Coalesced touch-move events should be sent.
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| - EXPECT_EQ(2U, queued_event_count());
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type());
|
| - EXPECT_EQ(INPUT_EVENT_ACK_STATE_CONSUMED, acked_event_state());
|
| -
|
| - // ACK the moves.
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| - EXPECT_EQ(1U, queued_event_count());
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(10U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type());
|
| -
|
| - // ACK the release.
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(WebInputEvent::TouchEnd, acked_event().type());
|
| -}
|
| -
|
| -// Tests that an event that has already been sent but hasn't been ack'ed yet
|
| -// doesn't get coalesced with newer events.
|
| -TEST_F(TouchEventQueueTest, SentTouchEventDoesNotCoalesce) {
|
| - // Send a touch-press event.
|
| - PressTouchPoint(1, 1);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| -
|
| - // Send a few touch-move events, followed by a touch-release event. All the
|
| - // touch-move events should be coalesced into a single event.
|
| - for (float i = 5; i < 15; ++i)
|
| - MoveTouchPoint(0, i, i);
|
| -
|
| EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(2U, queued_event_count());
|
| -
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| EXPECT_EQ(1U, queued_event_count());
|
| -
|
| - // The coalesced touch-move event has been sent to the renderer. Any new
|
| - // touch-move event should not be coalesced with the sent event.
|
| - MoveTouchPoint(0, 5, 5);
|
| - EXPECT_EQ(2U, queued_event_count());
|
| -
|
| - MoveTouchPoint(0, 7, 7);
|
| - EXPECT_EQ(2U, queued_event_count());
|
| -}
|
| -
|
| -// Tests that coalescing works correctly for multi-touch events.
|
| -TEST_F(TouchEventQueueTest, MultiTouch) {
|
| - // Press the first finger.
|
| - PressTouchPoint(1, 1);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| -
|
| - // Move the finger.
|
| - MoveTouchPoint(0, 5, 5);
|
| - EXPECT_EQ(2U, queued_event_count());
|
| -
|
| - // Now press a second finger.
|
| - PressTouchPoint(2, 2);
|
| - EXPECT_EQ(3U, queued_event_count());
|
| -
|
| - // Move both fingers.
|
| - MoveTouchPoints(0, 10, 10, 1, 20, 20);
|
| - MoveTouchPoint(1, 20, 20);
|
| - EXPECT_EQ(4U, queued_event_count());
|
| -
|
| - // Move only one finger now.
|
| - MoveTouchPoint(0, 15, 15);
|
| - EXPECT_EQ(4U, queued_event_count());
|
| -
|
| - // Move the other finger.
|
| - MoveTouchPoint(1, 25, 25);
|
| - EXPECT_EQ(4U, queued_event_count());
|
| -
|
| - // Make sure both fingers are marked as having been moved in the coalesced
|
| - // event.
|
| - const WebTouchEvent& event = latest_event();
|
| - EXPECT_EQ(WebTouchPoint::StateMoved, event.touches[0].state);
|
| - EXPECT_EQ(WebTouchPoint::StateMoved, event.touches[1].state);
|
| }
|
|
|
| // Tests that the touch-event queue is robust to redundant acks.
|
| -TEST_F(TouchEventQueueTest, SpuriousAcksIgnored) {
|
| +TEST_F(PassthroughTouchEventQueueTest, SpuriousAcksIgnored) {
|
| // Trigger a spurious ack.
|
| SendTouchEventAckWithID(INPUT_EVENT_ACK_STATE_CONSUMED, 0);
|
| EXPECT_EQ(0U, GetAndResetAckedEventCount());
|
| @@ -714,24 +609,22 @@ TEST_F(TouchEventQueueTest, SpuriousAcksIgnored) {
|
|
|
| // Tests that touch-move events are not sent to the renderer if the preceding
|
| // touch-press event did not have a consumer (and consequently, did not hit the
|
| -// main thread in the renderer). Also tests that all queued/coalesced touch
|
| -// events are flushed immediately when the ACK for the touch-press comes back
|
| -// with NO_CONSUMER status.
|
| -TEST_F(TouchEventQueueTest, NoConsumer) {
|
| +// main thread in the renderer).
|
| +TEST_F(PassthroughTouchEventQueueTest, NoConsumer) {
|
| // The first touch-press should reach the renderer.
|
| PressTouchPoint(1, 1);
|
| EXPECT_EQ(1U, GetAndResetSentEventCount());
|
|
|
| - // The second touch should not be sent since one is already in queue.
|
| + // The second touch should be sent since we don't know if there is
|
| + // a consumer or not.
|
| MoveTouchPoint(0, 5, 5);
|
| - EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| + EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| EXPECT_EQ(2U, queued_event_count());
|
|
|
| - // Receive an ACK for the first touch-event. This should release the queued
|
| - // touch-event, but it should not be sent to the renderer.
|
| + // Receive an ACK for the first touch-event and the first touch-move
|
| + SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
|
| EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type());
|
| EXPECT_EQ(2U, GetAndResetAckedEventCount());
|
| EXPECT_EQ(0U, GetAndResetSentEventCount());
|
|
|
| @@ -741,101 +634,53 @@ TEST_F(TouchEventQueueTest, NoConsumer) {
|
| EXPECT_EQ(WebInputEvent::TouchEnd, acked_event().type());
|
| EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
|
|
| - // Send a press-event, followed by move and release events, and another press
|
| - // event, before the ACK for the first press event comes back. All of the
|
| - // events should be queued first. After the NO_CONSUMER ack for the first
|
| - // touch-press, all events upto the second touch-press should be flushed.
|
| + // Send a press-event, followed by move a following move should not
|
| + // be sent but held in the queue.
|
| PressTouchPoint(10, 10);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| -
|
| MoveTouchPoint(0, 5, 5);
|
| - MoveTouchPoint(0, 6, 5);
|
| - ReleaseTouchPoint(0);
|
| -
|
| - PressTouchPoint(6, 5);
|
| - EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| - // The queue should hold the first sent touch-press event, the coalesced
|
| - // touch-move event, the touch-end event and the second touch-press event.
|
| - EXPECT_EQ(4U, queued_event_count());
|
|
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(WebInputEvent::TouchEnd, acked_event().type());
|
| - EXPECT_EQ(4U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(1U, queued_event_count());
|
| -
|
| - // ACK the second press event as NO_CONSUMER too.
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
|
| - EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type());
|
| + EXPECT_EQ(2U, GetAndResetSentEventCount());
|
| EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(0U, queued_event_count());
|
|
|
| - // 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(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, queued_event_count());
|
| + MoveTouchPoint(0, 6, 5);
|
| + EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| + EXPECT_EQ(0U, GetAndResetAckedEventCount());
|
| + EXPECT_EQ(2U, queued_event_count());
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| - EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| + EXPECT_EQ(2U, GetAndResetAckedEventCount());
|
| }
|
|
|
| -TEST_F(TouchEventQueueTest, ConsumerIgnoreMultiFinger) {
|
| - // Interleave three pointer press, move and release events.
|
| +TEST_F(PassthroughTouchEventQueueTest, AckTouchEventInReverse) {
|
| PressTouchPoint(1, 1);
|
| MoveTouchPoint(0, 5, 5);
|
| - PressTouchPoint(10, 10);
|
| - MoveTouchPoint(1, 15, 15);
|
| - PressTouchPoint(20, 20);
|
| - MoveTouchPoint(2, 25, 25);
|
| - ReleaseTouchPoint(2);
|
| - MoveTouchPoint(1, 20, 20);
|
| - ReleaseTouchPoint(1);
|
| - MoveTouchPoint(0, 10, 10);
|
| + MoveTouchPoint(0, 15, 15);
|
| ReleaseTouchPoint(0);
|
|
|
| - // Since the first touch-press is still pending ACK, no other event should
|
| - // have been sent to the renderer.
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(11U, queued_event_count());
|
| + EXPECT_EQ(4U, GetAndResetSentEventCount());
|
| + EXPECT_EQ(4U, queued_event_count());
|
|
|
| - // ACK the first press as CONSUMED. This should cause the first touch-move of
|
| - // the first touch-point to be dispatched.
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(10U, queued_event_count());
|
| + SendTouchEventAckLast(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| + EXPECT_EQ(0U, GetAndResetAckedEventCount());
|
| + EXPECT_EQ(4U, queued_event_count());
|
|
|
| - // ACK the first move as CONSUMED.
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(9U, queued_event_count());
|
| -
|
| - // ACK the second press as NO_CONSUMER_EXISTS. The second pointer's touchmove
|
| - // should still be forwarded, despite lacking a direct consumer.
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(8U, queued_event_count());
|
| -
|
| - // ACK the coalesced move as NOT_CONSUMED.
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(7U, queued_event_count());
|
| -
|
| - // All remaining touch events should be forwarded, even if the third pointer
|
| - // press also reports no consumer.
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
|
| - EXPECT_EQ(6U, queued_event_count());
|
| + EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type());
|
| + EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| + EXPECT_EQ(3U, queued_event_count());
|
|
|
| - while (queued_event_count())
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| + SendTouchEventAckLast(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| + EXPECT_EQ(0U, GetAndResetAckedEventCount());
|
| + EXPECT_EQ(3U, queued_event_count());
|
|
|
| - EXPECT_EQ(6U, GetAndResetSentEventCount());
|
| + SendTouchEventAckLast(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| + EXPECT_EQ(WebInputEvent::TouchEnd, acked_event().type());
|
| + EXPECT_EQ(3U, GetAndResetAckedEventCount());
|
| + EXPECT_EQ(0U, queued_event_count());
|
| }
|
|
|
| // Tests that touch-event's enqueued via a touch ack are properly handled.
|
| -TEST_F(TouchEventQueueTest, AckWithFollowupEvents) {
|
| +TEST_F(PassthroughTouchEventQueueTest, AckWithFollowupEvents) {
|
| // Queue a touch down.
|
| PressTouchPoint(1, 1);
|
| EXPECT_EQ(1U, queued_event_count());
|
| @@ -874,7 +719,7 @@ TEST_F(TouchEventQueueTest, AckWithFollowupEvents) {
|
| }
|
|
|
| // Tests that touch-events can be synchronously ack'ed.
|
| -TEST_F(TouchEventQueueTest, SynchronousAcks) {
|
| +TEST_F(PassthroughTouchEventQueueTest, SynchronousAcks) {
|
| // TouchStart
|
| SetSyncAckResult(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| PressTouchPoint(1, 1);
|
| @@ -912,7 +757,7 @@ TEST_F(TouchEventQueueTest, SynchronousAcks) {
|
|
|
| // Tests that followup events triggered by an immediate ack from
|
| // TouchEventQueue::QueueEvent() are properly handled.
|
| -TEST_F(TouchEventQueueTest, ImmediateAckWithFollowupEvents) {
|
| +TEST_F(PassthroughTouchEventQueueTest, ImmediateAckWithFollowupEvents) {
|
| // Create a touch event that will be queued synchronously by a touch ack.
|
| WebTouchEvent followup_event(
|
| WebInputEvent::TouchStart, WebInputEvent::NoModifiers,
|
| @@ -942,7 +787,7 @@ TEST_F(TouchEventQueueTest, ImmediateAckWithFollowupEvents) {
|
| }
|
|
|
| // Tests basic TouchEvent forwarding suppression.
|
| -TEST_F(TouchEventQueueTest, NoTouchBasic) {
|
| +TEST_F(PassthroughTouchEventQueueTest, NoTouchBasic) {
|
| // Disable TouchEvent forwarding.
|
| OnHasTouchEventHandlers(false);
|
| PressTouchPoint(30, 5);
|
| @@ -979,8 +824,7 @@ TEST_F(TouchEventQueueTest, NoTouchBasic) {
|
| }
|
|
|
| // Tests that IsTouchStartPendingAck works correctly.
|
| -TEST_F(TouchEventQueueTest, PendingStart) {
|
| -
|
| +TEST_F(PassthroughTouchEventQueueTest, PendingStart) {
|
| EXPECT_FALSE(IsPendingAckTouchStart());
|
|
|
| // Send the touchstart for one point (#1).
|
| @@ -1001,7 +845,7 @@ TEST_F(TouchEventQueueTest, PendingStart) {
|
| // Send a touchstart for another point (#3).
|
| PressTouchPoint(10, 10);
|
| EXPECT_EQ(2U, queued_event_count());
|
| - EXPECT_FALSE(IsPendingAckTouchStart());
|
| + EXPECT_TRUE(IsPendingAckTouchStart());
|
|
|
| // Ack the touchmove (#2).
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| @@ -1025,7 +869,7 @@ TEST_F(TouchEventQueueTest, PendingStart) {
|
| }
|
|
|
| // Tests that the touch timeout is started when sending certain touch types.
|
| -TEST_F(TouchEventQueueTest, TouchTimeoutTypes) {
|
| +TEST_F(PassthroughTouchEventQueueTest, TouchTimeoutTypes) {
|
| SetUpForTimeoutTesting();
|
|
|
| // Sending a TouchStart will start the timeout.
|
| @@ -1059,7 +903,7 @@ TEST_F(TouchEventQueueTest, TouchTimeoutTypes) {
|
| // Tests that a delayed TouchEvent ack will trigger a TouchCancel timeout,
|
| // disabling touch forwarding until the next TouchStart is received after
|
| // the timeout events are ack'ed.
|
| -TEST_F(TouchEventQueueTest, TouchTimeoutBasic) {
|
| +TEST_F(PassthroughTouchEventQueueTest, TouchTimeoutBasic) {
|
| SetUpForTimeoutTesting();
|
|
|
| // Queue a TouchStart.
|
| @@ -1113,7 +957,8 @@ TEST_F(TouchEventQueueTest, TouchTimeoutBasic) {
|
|
|
| // Tests that the timeout is never started if the renderer consumes
|
| // a TouchEvent from the current touch sequence.
|
| -TEST_F(TouchEventQueueTest, NoTouchTimeoutIfRendererIsConsumingGesture) {
|
| +TEST_F(PassthroughTouchEventQueueTest,
|
| + NoTouchTimeoutIfRendererIsConsumingGesture) {
|
| SetUpForTimeoutTesting();
|
|
|
| // Queue a TouchStart.
|
| @@ -1147,7 +992,8 @@ TEST_F(TouchEventQueueTest, NoTouchTimeoutIfRendererIsConsumingGesture) {
|
|
|
| // Tests that the timeout is never started if the renderer consumes
|
| // a TouchEvent from the current touch sequence.
|
| -TEST_F(TouchEventQueueTest, NoTouchTimeoutIfDisabledAfterTouchStart) {
|
| +TEST_F(PassthroughTouchEventQueueTest,
|
| + NoTouchTimeoutIfDisabledAfterTouchStart) {
|
| SetUpForTimeoutTesting();
|
|
|
| // Queue a TouchStart.
|
| @@ -1173,7 +1019,7 @@ TEST_F(TouchEventQueueTest, NoTouchTimeoutIfDisabledAfterTouchStart) {
|
| }
|
|
|
| // Tests that the timeout is never started if the ack is synchronous.
|
| -TEST_F(TouchEventQueueTest, NoTouchTimeoutIfAckIsSynchronous) {
|
| +TEST_F(PassthroughTouchEventQueueTest, NoTouchTimeoutIfAckIsSynchronous) {
|
| SetUpForTimeoutTesting();
|
|
|
| // Queue a TouchStart.
|
| @@ -1185,7 +1031,8 @@ TEST_F(TouchEventQueueTest, NoTouchTimeoutIfAckIsSynchronous) {
|
|
|
| // Tests that the timeout does not fire if explicitly disabled while an event
|
| // is in-flight.
|
| -TEST_F(TouchEventQueueTest, NoTouchTimeoutIfDisabledWhileTimerIsActive) {
|
| +TEST_F(PassthroughTouchEventQueueTest,
|
| + NoTouchTimeoutIfDisabledWhileTimerIsActive) {
|
| SetUpForTimeoutTesting();
|
|
|
| // Queue a TouchStart.
|
| @@ -1200,7 +1047,7 @@ TEST_F(TouchEventQueueTest, NoTouchTimeoutIfDisabledWhileTimerIsActive) {
|
| }
|
|
|
| // Tests that the timeout does not fire if the delay is zero.
|
| -TEST_F(TouchEventQueueTest, NoTouchTimeoutIfTimeoutDelayIsZero) {
|
| +TEST_F(PassthroughTouchEventQueueTest, NoTouchTimeoutIfTimeoutDelayIsZero) {
|
| SetUpForTimeoutTesting(base::TimeDelta(), base::TimeDelta());
|
|
|
| // As the delay is zero, timeout behavior should be disabled.
|
| @@ -1211,7 +1058,7 @@ TEST_F(TouchEventQueueTest, NoTouchTimeoutIfTimeoutDelayIsZero) {
|
| }
|
|
|
| // Tests that timeout delays for mobile sites take effect when appropriate.
|
| -TEST_F(TouchEventQueueTest, TouchTimeoutConfiguredForMobile) {
|
| +TEST_F(PassthroughTouchEventQueueTest, TouchTimeoutConfiguredForMobile) {
|
| base::TimeDelta desktop_delay = DefaultTouchTimeoutDelay();
|
| base::TimeDelta mobile_delay = base::TimeDelta();
|
| SetUpForTimeoutTesting(desktop_delay, mobile_delay);
|
| @@ -1238,7 +1085,7 @@ TEST_F(TouchEventQueueTest, TouchTimeoutConfiguredForMobile) {
|
|
|
| // Tests that a TouchCancel timeout plays nice when the timed out touch stream
|
| // turns into a scroll gesture sequence.
|
| -TEST_F(TouchEventQueueTest, TouchTimeoutWithFollowupGesture) {
|
| +TEST_F(PassthroughTouchEventQueueTest, TouchTimeoutWithFollowupGesture) {
|
| SetUpForTimeoutTesting();
|
|
|
| // Queue a TouchStart.
|
| @@ -1294,7 +1141,8 @@ TEST_F(TouchEventQueueTest, TouchTimeoutWithFollowupGesture) {
|
| // Tests that a TouchCancel timeout plays nice when the timed out touch stream
|
| // turns into a scroll gesture sequence, but the original event acks are
|
| // significantly delayed.
|
| -TEST_F(TouchEventQueueTest, TouchTimeoutWithFollowupGestureAndDelayedAck) {
|
| +TEST_F(PassthroughTouchEventQueueTest,
|
| + TouchTimeoutWithFollowupGestureAndDelayedAck) {
|
| SetUpForTimeoutTesting();
|
|
|
| // Queue a TouchStart.
|
| @@ -1351,7 +1199,7 @@ TEST_F(TouchEventQueueTest, TouchTimeoutWithFollowupGestureAndDelayedAck) {
|
|
|
| // Tests that a delayed TouchEvent ack will not trigger a TouchCancel timeout if
|
| // the timed-out event had no consumer.
|
| -TEST_F(TouchEventQueueTest, NoCancelOnTouchTimeoutWithoutConsumer) {
|
| +TEST_F(PassthroughTouchEventQueueTest, NoCancelOnTouchTimeoutWithoutConsumer) {
|
| SetUpForTimeoutTesting();
|
|
|
| // Queue a TouchStart.
|
| @@ -1390,7 +1238,7 @@ TEST_F(TouchEventQueueTest, NoCancelOnTouchTimeoutWithoutConsumer) {
|
|
|
| // Tests that TouchMove's movedBeyondSlopRegion is set to false if within the
|
| // boundary-inclusive slop region for an unconsumed TouchStart.
|
| -TEST_F(TouchEventQueueTest, TouchMovedBeyondSlopRegionCheck) {
|
| +TEST_F(PassthroughTouchEventQueueTest, TouchMovedBeyondSlopRegionCheck) {
|
| SetUpForTouchMoveSlopTesting(kSlopLengthDips);
|
|
|
| // Queue a TouchStart.
|
| @@ -1440,7 +1288,7 @@ TEST_F(TouchEventQueueTest, TouchMovedBeyondSlopRegionCheck) {
|
| const float kFortyFiveDegreeSlopLengthXY =
|
| kSlopLengthDips * std::sqrt(2.f) / 2;
|
| MoveTouchPoint(0, kFortyFiveDegreeSlopLengthXY + .2f,
|
| - kFortyFiveDegreeSlopLengthXY + .2f);
|
| + kFortyFiveDegreeSlopLengthXY + .2f);
|
| EXPECT_EQ(1U, queued_event_count());
|
| EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| EXPECT_EQ(0U, GetAndResetAckedEventCount());
|
| @@ -1451,7 +1299,8 @@ TEST_F(TouchEventQueueTest, TouchMovedBeyondSlopRegionCheck) {
|
|
|
| // Tests that even very small TouchMove's movedBeyondSlopRegion is set to true
|
| // when the slop region's dimension is 0.
|
| -TEST_F(TouchEventQueueTest, MovedBeyondSlopRegionAlwaysTrueIfDimensionZero) {
|
| +TEST_F(PassthroughTouchEventQueueTest,
|
| + MovedBeyondSlopRegionAlwaysTrueIfDimensionZero) {
|
| // Queue a TouchStart.
|
| PressTouchPoint(0, 0);
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| @@ -1470,7 +1319,8 @@ TEST_F(TouchEventQueueTest, MovedBeyondSlopRegionAlwaysTrueIfDimensionZero) {
|
|
|
| // Tests that secondary touch points can be forwarded even if the primary touch
|
| // point had no consumer.
|
| -TEST_F(TouchEventQueueTest, SecondaryTouchForwardedAfterPrimaryHadNoConsumer) {
|
| +TEST_F(PassthroughTouchEventQueueTest,
|
| + SecondaryTouchForwardedAfterPrimaryHadNoConsumer) {
|
| // Queue a TouchStart.
|
| PressTouchPoint(0, 0);
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
|
| @@ -1499,7 +1349,8 @@ TEST_F(TouchEventQueueTest, SecondaryTouchForwardedAfterPrimaryHadNoConsumer) {
|
|
|
| // Tests that secondary touch points can be forwarded after scrolling begins
|
| // while first touch point has no consumer.
|
| -TEST_F(TouchEventQueueTest, NoForwardingAfterScrollWithNoTouchConsumers) {
|
| +TEST_F(PassthroughTouchEventQueueTest,
|
| + NoForwardingAfterScrollWithNoTouchConsumers) {
|
| // Queue a TouchStart.
|
| PressTouchPoint(0, 0);
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
|
| @@ -1529,812 +1380,67 @@ TEST_F(TouchEventQueueTest, NoForwardingAfterScrollWithNoTouchConsumers) {
|
| EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| }
|
|
|
| -TEST_F(TouchEventQueueTest, AsyncTouch) {
|
| +TEST_F(PassthroughTouchEventQueueTest, TouchAbsorptionWithConsumedFirstMove) {
|
| // Queue a TouchStart.
|
| PressTouchPoint(0, 1);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| + EXPECT_EQ(0U, queued_event_count());
|
| EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
|
|
| - for (int i = 0; i < 3; ++i) {
|
| - SendGestureEventAck(WebInputEvent::GestureScrollUpdate,
|
| - INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| -
|
| - MoveTouchPoint(0, 10, 5+i);
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_FALSE(HasPendingAsyncTouchMove());
|
| - EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType);
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| -
|
| - // Consuming a scroll event will throttle subsequent touchmoves.
|
| - SendGestureEventAck(WebInputEvent::GestureScrollUpdate,
|
| - INPUT_EVENT_ACK_STATE_CONSUMED);
|
| - MoveTouchPoint(0, 10, 7+i);
|
| - EXPECT_TRUE(HasPendingAsyncTouchMove());
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| - }
|
| -}
|
| + MoveTouchPoint(0, 20, 5);
|
| + SendGestureEvent(blink::WebInputEvent::GestureScrollBegin);
|
| + SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| + EXPECT_EQ(0U, queued_event_count());
|
| + EXPECT_EQ(2U, GetAndResetSentEventCount());
|
|
|
| -// Ensure that touchmove's are appropriately throttled during a typical
|
| -// scroll sequences that transitions between scrolls consumed and unconsumed.
|
| -TEST_F(TouchEventQueueTest, AsyncTouchThrottledAfterScroll) {
|
| - // Process a TouchStart
|
| - PressTouchPoint(0, 1);
|
| + // Even if the first touchmove event was consumed, subsequent unconsumed
|
| + // touchmove events should trigger scrolling.
|
| + MoveTouchPoint(0, 60, 5);
|
| + SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| + EXPECT_EQ(0U, queued_event_count());
|
| + EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType);
|
| EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
|
|
| - // Now send the first touch move and associated GestureScrollBegin.
|
| - MoveTouchPoint(0, 0, 5);
|
| - WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin,
|
| + MoveTouchPoint(0, 20, 5);
|
| + WebGestureEvent followup_scroll(WebInputEvent::GestureScrollUpdate,
|
| WebInputEvent::NoModifiers,
|
| WebInputEvent::TimeStampForTesting);
|
| SetFollowupEvent(followup_scroll);
|
| 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, 50);
|
| - followup_scroll.setType(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);
|
| - SetFollowupEvent(followup_scroll);
|
| - EXPECT_TRUE(HasPendingAsyncTouchMove());
|
| + SendGestureEventAck(WebInputEvent::GestureScrollUpdate,
|
| + INPUT_EVENT_ACK_STATE_CONSUMED);
|
| EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| + EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType);
|
| + EXPECT_EQ(1U, GetAndResetSentEventCount());
|
|
|
| - // Queuing the final touchend should flush the pending async touchmove. In
|
| - // this case, we will first dispatch an async touchmove and then a touchend.
|
| - // For the async touchmove, we will not send ack again.
|
| - ReleaseTouchPoint(0);
|
| - followup_scroll.setType(WebInputEvent::GestureScrollEnd);
|
| - SetFollowupEvent(followup_scroll);
|
| - EXPECT_FALSE(HasPendingAsyncTouchMove());
|
| - EXPECT_EQ(2U, all_sent_events().size());
|
| - EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[0].type());
|
| - EXPECT_NE(WebInputEvent::Blocking, all_sent_events()[0].dispatchType);
|
| - EXPECT_EQ(WebInputEvent::TouchEnd, all_sent_events()[1].type());
|
| - EXPECT_NE(WebInputEvent::Blocking, all_sent_events()[1].dispatchType);
|
| - EXPECT_EQ(2U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(0U, GetAndResetAckedEventCount());
|
| + // Touch moves are sent right away.
|
| + MoveTouchPoint(0, 60, 5);
|
| EXPECT_EQ(1U, queued_event_count());
|
| -
|
| - // Ack the touchend.
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| -
|
| - // Now mark the scrolls as not consumed (which would cause future touchmoves
|
| - // in the active sequence to be sent if there was one).
|
| - SendGestureEventAck(WebInputEvent::GestureScrollUpdate,
|
| - INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - SendGestureEventAck(WebInputEvent::GestureScrollUpdate,
|
| - 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);
|
| EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| +}
|
| +
|
| +TEST_F(PassthroughTouchEventQueueTest, TouchStartCancelableDuringScroll) {
|
| + // Queue a touchstart and touchmove that go unconsumed, transitioning to an
|
| + // active scroll sequence.
|
| + PressTouchPoint(0, 1);
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| - MoveTouchPoint(0, 0, 5);
|
| - followup_scroll.setType(WebInputEvent::GestureScrollBegin);
|
| - SetFollowupEvent(followup_scroll);
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| + EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType);
|
| + ASSERT_EQ(1U, GetAndResetSentEventCount());
|
|
|
| - MoveTouchPoint(0, 0, 6);
|
| - followup_scroll.setType(WebInputEvent::GestureScrollUpdate);
|
| - SetFollowupEvent(followup_scroll);
|
| + MoveTouchPoint(0, 20, 5);
|
| + EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType);
|
| + SendGestureEvent(blink::WebInputEvent::GestureScrollBegin);
|
| + SendGestureEvent(blink::WebInputEvent::GestureScrollUpdate);
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_FALSE(HasPendingAsyncTouchMove());
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| + EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType);
|
| + ASSERT_EQ(1U, GetAndResetSentEventCount());
|
|
|
| - MoveTouchPoint(0, 0, 10);
|
| - EXPECT_TRUE(HasPendingAsyncTouchMove());
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_EQ(0U, 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());
|
| - EXPECT_EQ(0U, uncancelable_touch_moves_pending_ack_count());
|
| -
|
| - // The pending touchmove should be flushed with the the new touchmove if
|
| - // sufficient time has passed and ack to the client.
|
| - AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1);
|
| - MoveTouchPoint(0, 0, 15);
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_FALSE(HasPendingAsyncTouchMove());
|
| - EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType);
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| -
|
| - // Non-touchmove events should always flush any pending touchmove events. In
|
| - // this case, we will first dispatch an async touchmove and then a
|
| - // touchstart. For the async touchmove, we will not send ack again.
|
| - 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_EQ(2U, all_sent_events().size());
|
| - EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[0].type());
|
| - EXPECT_NE(WebInputEvent::Blocking, all_sent_events()[0].dispatchType);
|
| - EXPECT_EQ(WebInputEvent::TouchStart, all_sent_events()[1].type());
|
| - EXPECT_EQ(WebInputEvent::Blocking, all_sent_events()[1].dispatchType);
|
| - EXPECT_EQ(2U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(0U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(1U, queued_event_count());
|
| -
|
| - // Ack the touchstart.
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - 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, 26);
|
| - EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType);
|
| - 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_EQ(WebInputEvent::Blocking, sent_event().dispatchType);
|
| - 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_EQ(WebInputEvent::Blocking, sent_event().dispatchType);
|
| - 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());
|
| -}
|
| -
|
| -TEST_F(TouchEventQueueTest, AsyncTouchFlushedByTouchEnd) {
|
| - 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(WebInputEvent::GestureScrollBegin,
|
| - WebInputEvent::NoModifiers,
|
| - WebInputEvent::TimeStampForTesting);
|
| - SetFollowupEvent(followup_scroll);
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| -
|
| - MoveTouchPoint(0, 0, 10);
|
| - followup_scroll.setType(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. Note that
|
| - // this (0, 0) touchmove will coalesce with the previous (0, 100) touchmove.
|
| - 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. In
|
| - // this case, we will first dispatch an async touchmove and then a touchend.
|
| - // For the async touchmove, we will not send ack again.
|
| - ReleaseTouchPoint(0);
|
| - EXPECT_FALSE(HasPendingAsyncTouchMove());
|
| - EXPECT_EQ(2U, all_sent_events().size());
|
| - EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[0].type());
|
| - EXPECT_NE(WebInputEvent::Blocking, all_sent_events()[0].dispatchType);
|
| - EXPECT_EQ(0, all_sent_events()[0].touches[0].position.x);
|
| - EXPECT_EQ(0, all_sent_events()[0].touches[0].position.y);
|
| - EXPECT_EQ(WebInputEvent::TouchEnd, all_sent_events()[1].type());
|
| - EXPECT_NE(WebInputEvent::Blocking, all_sent_events()[1].dispatchType);
|
| - EXPECT_EQ(2U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(0U, GetAndResetAckedEventCount());
|
| -}
|
| -
|
| -// Ensure that async touch dispatch and touch ack timeout interactions work
|
| -// appropriately.
|
| -TEST_F(TouchEventQueueTest, AsyncTouchWithAckTimeout) {
|
| - SetUpForTimeoutTesting();
|
| -
|
| - // The touchstart should start the timeout.
|
| - PressTouchPoint(0, 0);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_TRUE(IsTimeoutRunning());
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| - EXPECT_FALSE(IsTimeoutRunning());
|
| -
|
| - // The start of a scroll gesture should trigger async touch event dispatch.
|
| - MoveTouchPoint(0, 1, 1);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_TRUE(IsTimeoutRunning());
|
| - WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin,
|
| - WebInputEvent::NoModifiers,
|
| - WebInputEvent::TimeStampForTesting);
|
| - 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_NE(WebInputEvent::Blocking, sent_event().dispatchType);
|
| - 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_EQ(WebInputEvent::Blocking, sent_event().dispatchType);
|
| - 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_NE(WebInputEvent::Blocking, sent_event().dispatchType);
|
| - 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());
|
| -}
|
| -
|
| -// 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) {
|
| - PressTouchPoint(0, 0);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| -
|
| - // The start of a scroll gesture should trigger async touch event dispatch.
|
| - MoveTouchPoint(0, 1, 1);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin,
|
| - WebInputEvent::NoModifiers,
|
| - WebInputEvent::TimeStampForTesting);
|
| - SetFollowupEvent(followup_scroll);
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - 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.
|
| - WebTouchEvent followup_cancel(WebInputEvent::TouchCancel,
|
| - WebInputEvent::NoModifiers,
|
| - WebInputEvent::TimeStampForTesting);
|
| - followup_cancel.touchesLength = 1;
|
| - followup_cancel.touches[0].state = WebTouchPoint::StateCancelled;
|
| - SetFollowupEvent(followup_cancel);
|
| - MoveTouchPoint(0, 5, 5);
|
| - EXPECT_EQ(1U, queued_event_count());
|
| - EXPECT_EQ(2U, all_sent_events().size());
|
| - EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[0].type());
|
| - EXPECT_NE(WebInputEvent::Blocking, all_sent_events()[0].dispatchType);
|
| - EXPECT_EQ(WebInputEvent::TouchCancel, all_sent_events()[1].type());
|
| - EXPECT_NE(WebInputEvent::Blocking, all_sent_events()[1].dispatchType);
|
| - EXPECT_EQ(2U, GetAndResetSentEventCount());
|
| - // Sending the ack is because the async touchmove is not ready for
|
| - // dispatching send the ack immediately.
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type());
|
| -
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - 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());
|
| -}
|
| -
|
| -// Ensure that the async touch is fully reset if the touch sequence restarts
|
| -// without properly terminating.
|
| -TEST_F(TouchEventQueueTest, AsyncTouchWithHardTouchStartReset) {
|
| - PressTouchPoint(0, 0);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| -
|
| - // Trigger async touchmove dispatch.
|
| - MoveTouchPoint(0, 1, 1);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin,
|
| - WebInputEvent::NoModifiers,
|
| - WebInputEvent::TimeStampForTesting);
|
| - SetFollowupEvent(followup_scroll);
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - SendGestureEvent(WebInputEvent::GestureScrollUpdate);
|
| -
|
| - // The async touchmove should be immediately ack'ed but delivery is deferred.
|
| - MoveTouchPoint(0, 2, 2);
|
| - EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type());
|
| -
|
| - // The queue should be robust to hard touch restarts with a new touch
|
| - // sequence. In this case, the deferred async touch should not be flushed
|
| - // by the new touch sequence.
|
| - SendGestureEvent(WebInputEvent::GestureScrollEnd);
|
| - ResetTouchEvent();
|
| -
|
| - PressTouchPoint(0, 0);
|
| - EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type());
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| -}
|
| -
|
| -// Ensure that even when the interval expires, we still need to wait for the
|
| -// ack sent back from render to send the next async touchmove once the scroll
|
| -// starts.
|
| -TEST_F(TouchEventQueueTest, SendNextThrottledAsyncTouchMoveAfterAck) {
|
| - // Process a TouchStart
|
| - PressTouchPoint(0, 1);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| -
|
| - // Initiate async touchmove dispatch after the start of a scroll sequence.
|
| - MoveTouchPoint(0, 0, 5);
|
| - WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin,
|
| - WebInputEvent::NoModifiers,
|
| - WebInputEvent::TimeStampForTesting);
|
| - SetFollowupEvent(followup_scroll);
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| -
|
| - MoveTouchPoint(0, 0, 10);
|
| - followup_scroll.setType(WebInputEvent::GestureScrollUpdate);
|
| - SetFollowupEvent(followup_scroll);
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_FALSE(HasPendingAsyncTouchMove());
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| -
|
| - // We set the next touch event time to be after the throttled interval.
|
| - AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1);
|
| - // Dispatch the touch move event when sufficient time has passed.
|
| - MoveTouchPoint(0, 0, 40);
|
| - EXPECT_FALSE(HasPendingAsyncTouchMove());
|
| - EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType);
|
| - // When we dispatch an async touchmove, we do not put it back to the queue
|
| - // any more and we will ack to client right away.
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count());
|
| -
|
| - // Do not dispatch the event until throttledTouchmoves intervals expires and
|
| - // receive an ack from render.
|
| - AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1);
|
| - MoveTouchPoint(0, 0, 50);
|
| - EXPECT_TRUE(HasPendingAsyncTouchMove());
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count());
|
| -
|
| - // Send pending_async_touch_move_ when we receive an ack back from render,
|
| - // but we will not send an ack for pending_async_touch_move_ becasue it is
|
| - // been acked before.
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_FALSE(HasPendingAsyncTouchMove());
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(0U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count());
|
| -}
|
| -
|
| -// Ensure that even when we receive the ack from render, we still need to wait
|
| -// for the interval expires to send the next async touchmove once the scroll
|
| -// starts.
|
| -TEST_F(TouchEventQueueTest, SendNextAsyncTouchMoveAfterAckAndTimeExpire) {
|
| - // Process a TouchStart
|
| - PressTouchPoint(0, 1);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| -
|
| - // Initiate async touchmove dispatch after the start of a scroll sequence.
|
| - MoveTouchPoint(0, 0, 5);
|
| - WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin,
|
| - WebInputEvent::NoModifiers,
|
| - WebInputEvent::TimeStampForTesting);
|
| - SetFollowupEvent(followup_scroll);
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| -
|
| - MoveTouchPoint(0, 0, 10);
|
| - followup_scroll.setType(WebInputEvent::GestureScrollUpdate);
|
| - SetFollowupEvent(followup_scroll);
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_FALSE(HasPendingAsyncTouchMove());
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| -
|
| - // Dispatch the touch move event when sufficient time has passed.
|
| - AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1);
|
| - MoveTouchPoint(0, 0, 40);
|
| - EXPECT_FALSE(HasPendingAsyncTouchMove());
|
| - EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType);
|
| - // When we dispatch an async touchmove, we do not put it back to the queue
|
| - // any more and we will ack to client right away.
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count());
|
| -
|
| - // We receive an ack back from render but the time interval is not expired,
|
| - // so we do not dispatch the touch move event.
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(0U, uncancelable_touch_moves_pending_ack_count());
|
| - MoveTouchPoint(0, 0, 50);
|
| - EXPECT_TRUE(HasPendingAsyncTouchMove());
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| -
|
| - // Dispatch the touch move when sufficient time has passed.
|
| - AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1);
|
| - MoveTouchPoint(0, 0, 50);
|
| - EXPECT_FALSE(HasPendingAsyncTouchMove());
|
| - EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type());
|
| - EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType);
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count());
|
| -}
|
| -
|
| -TEST_F(TouchEventQueueTest, AsyncTouchFlushedByNonTouchMove) {
|
| - // Process a TouchStart
|
| - PressTouchPoint(0, 1);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| -
|
| - // Initiate async touchmove dispatch after the start of a scroll sequence.
|
| - MoveTouchPoint(0, 0, 5);
|
| - WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin,
|
| - WebInputEvent::NoModifiers,
|
| - WebInputEvent::TimeStampForTesting);
|
| - SetFollowupEvent(followup_scroll);
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| -
|
| - MoveTouchPoint(0, 0, 10);
|
| - followup_scroll.setType(WebInputEvent::GestureScrollUpdate);
|
| - SetFollowupEvent(followup_scroll);
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_FALSE(HasPendingAsyncTouchMove());
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| -
|
| - // Dispatch the touch move when sufficient time has passed.
|
| - AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1);
|
| - MoveTouchPoint(0, 0, 40);
|
| - EXPECT_FALSE(HasPendingAsyncTouchMove());
|
| - EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType);
|
| - // When we dispatch an async touchmove, we do not put it back to the queue
|
| - // any more and we will ack to client right away.
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count());
|
| -
|
| - for (int i = 0; i < 3; ++i) {
|
| - // We throttle the touchmoves, put it in the pending_async_touch_move_,
|
| - // do not dispatch it.
|
| - MoveTouchPoint(0, 10 + 10 * i, 10 + 10 * i);
|
| - EXPECT_TRUE(HasPendingAsyncTouchMove());
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(static_cast<size_t>(i + 1),
|
| - uncancelable_touch_moves_pending_ack_count());
|
| -
|
| - // Send touchstart will flush pending_async_touch_move_, and increase the
|
| - // count. In this case, we will first dispatch an async touchmove and
|
| - // then a touchstart. For the async touchmove, we will not send ack again.
|
| - PressTouchPoint(30, 30);
|
| - EXPECT_FALSE(HasPendingAsyncTouchMove());
|
| - EXPECT_EQ(2U, all_sent_events().size());
|
| - EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[0].type());
|
| - EXPECT_NE(WebInputEvent::Blocking, all_sent_events()[0].dispatchType);
|
| - EXPECT_EQ(10 + 10 * i, all_sent_events()[0].touches[0].position.x);
|
| - EXPECT_EQ(10 + 10 * i, all_sent_events()[0].touches[0].position.y);
|
| - EXPECT_EQ(static_cast<size_t>(i + 2),
|
| - uncancelable_touch_moves_pending_ack_count());
|
| - EXPECT_EQ(WebInputEvent::TouchStart, all_sent_events()[1].type());
|
| - EXPECT_EQ(WebInputEvent::Blocking, all_sent_events()[1].dispatchType);
|
| - EXPECT_EQ(2U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(0U, GetAndResetAckedEventCount());
|
| -
|
| - SendTouchEventAckWithID(INPUT_EVENT_ACK_STATE_NOT_CONSUMED,
|
| - GetUniqueTouchEventID());
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_FALSE(HasPendingAsyncTouchMove());
|
| - EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| - }
|
| -
|
| - EXPECT_EQ(4U, uncancelable_touch_moves_pending_ack_count());
|
| -
|
| - // When we receive an ack from render we decrease the count.
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(3U, uncancelable_touch_moves_pending_ack_count());
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_FALSE(HasPendingAsyncTouchMove());
|
| -
|
| - // Do not dispatch the next uncancelable touchmove when we have not received
|
| - // all the acks back from render.
|
| - AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1);
|
| - MoveTouchPoint(0, 20, 30);
|
| - EXPECT_TRUE(HasPendingAsyncTouchMove());
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(3U, uncancelable_touch_moves_pending_ack_count());
|
| -
|
| - // Once we receive the ack from render, we do not dispatch the
|
| - // pending_async_touchmove_ until the count is 0.
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(2U, uncancelable_touch_moves_pending_ack_count());
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_TRUE(HasPendingAsyncTouchMove());
|
| -
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| -
|
| - // When we receive this ack from render, and the count is 0, so we can
|
| - // dispatch the pending_async_touchmove_.
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count());
|
| - EXPECT_FALSE(HasPendingAsyncTouchMove());
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type());
|
| - EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(0U, GetAndResetAckedEventCount());
|
| -}
|
| -
|
| -// Ensure that even when we receive the ack from render, we still need to wait
|
| -// for the interval expires to send the next async touchmove once the scroll
|
| -// starts.
|
| -TEST_F(TouchEventQueueTest, DoNotIncreaseIfClientConsumeAsyncTouchMove) {
|
| - // Process a TouchStart
|
| - PressTouchPoint(0, 1);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| -
|
| - // Initiate async touchmove dispatch after the start of a scroll sequence.
|
| - MoveTouchPoint(0, 0, 5);
|
| - WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin,
|
| - WebInputEvent::NoModifiers,
|
| - WebInputEvent::TimeStampForTesting);
|
| - SetFollowupEvent(followup_scroll);
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| -
|
| - MoveTouchPoint(0, 0, 10);
|
| - followup_scroll.setType(WebInputEvent::GestureScrollUpdate);
|
| - SetFollowupEvent(followup_scroll);
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_FALSE(HasPendingAsyncTouchMove());
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| -
|
| - // Dispatch the touch move event when sufficient time has passed.
|
| - AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1);
|
| - MoveTouchPoint(0, 0, 40);
|
| - EXPECT_FALSE(HasPendingAsyncTouchMove());
|
| - EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType);
|
| - // When we dispatch an async touchmove, we do not put it back to the queue
|
| - // any more and we will ack to client right away.
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count());
|
| -
|
| - // We receive an ack back from render but the time interval is not expired,
|
| - // so we do not dispatch the touch move event.
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(0U, uncancelable_touch_moves_pending_ack_count());
|
| - MoveTouchPoint(0, 0, 50);
|
| - EXPECT_TRUE(HasPendingAsyncTouchMove());
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| -
|
| - // Dispatch the touch move when sufficient time has passed. Becasue the event
|
| - // is consumed by client already, we would not increase the count and ack to
|
| - // client again.
|
| - AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1);
|
| - SetSyncAckResult(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| - MoveTouchPoint(0, 0, 50);
|
| - EXPECT_FALSE(HasPendingAsyncTouchMove());
|
| - EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type());
|
| - EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType);
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(0U, uncancelable_touch_moves_pending_ack_count());
|
| -}
|
| -
|
| -TEST_F(TouchEventQueueTest, TouchAbsorptionWithConsumedFirstMove) {
|
| - // 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, subsequent unconsumed
|
| - // touchmove events should trigger scrolling.
|
| - MoveTouchPoint(0, 60, 5);
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| -
|
| - MoveTouchPoint(0, 20, 5);
|
| - WebGestureEvent followup_scroll(WebInputEvent::GestureScrollUpdate,
|
| - WebInputEvent::NoModifiers,
|
| - WebInputEvent::TimeStampForTesting);
|
| - SetFollowupEvent(followup_scroll);
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - SendGestureEventAck(WebInputEvent::GestureScrollUpdate,
|
| - INPUT_EVENT_ACK_STATE_CONSUMED);
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| -
|
| - // Touch move event is throttled.
|
| - MoveTouchPoint(0, 60, 5);
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| -}
|
| -
|
| -TEST_F(TouchEventQueueTest, TouchStartCancelableDuringScroll) {
|
| - // Queue a touchstart and touchmove that go unconsumed, transitioning to an
|
| - // active scroll sequence.
|
| - PressTouchPoint(0, 1);
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType);
|
| - ASSERT_EQ(1U, GetAndResetSentEventCount());
|
| -
|
| - MoveTouchPoint(0, 20, 5);
|
| - EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType);
|
| - SendGestureEvent(blink::WebInputEvent::GestureScrollBegin);
|
| - SendGestureEvent(blink::WebInputEvent::GestureScrollUpdate);
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
|
| - EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType);
|
| - ASSERT_EQ(1U, GetAndResetSentEventCount());
|
| -
|
| - // Even though scrolling has begun, touchstart events should be cancelable,
|
| - // allowing, for example, customized pinch processing.
|
| - PressTouchPoint(10, 11);
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| - EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType);
|
| - ASSERT_EQ(1U, GetAndResetSentEventCount());
|
| + // Even though scrolling has begun, touchstart events should be cancelable,
|
| + // allowing, for example, customized pinch processing.
|
| + PressTouchPoint(10, 11);
|
| + SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| + EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType);
|
| + ASSERT_EQ(1U, GetAndResetSentEventCount());
|
|
|
| // As the touch start was consumed, touchmoves should no longer be throttled.
|
| MoveTouchPoint(1, 11, 11);
|
| @@ -2372,7 +1478,7 @@ TEST_F(TouchEventQueueTest, TouchStartCancelableDuringScroll) {
|
| ASSERT_EQ(1U, GetAndResetSentEventCount());
|
| }
|
|
|
| -TEST_F(TouchEventQueueTest, UnseenTouchPointerIdsNotForwarded) {
|
| +TEST_F(PassthroughTouchEventQueueTest, UnseenTouchPointerIdsNotForwarded) {
|
| SyntheticWebTouchEvent event;
|
| event.PressPoint(0, 0);
|
| SendTouchEvent(event);
|
| @@ -2402,22 +1508,21 @@ TEST_F(TouchEventQueueTest, UnseenTouchPointerIdsNotForwarded) {
|
| EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
|
|
| - // Give the touchmove a valid id; it should be sent.
|
| + // Give the touchmove a valid id after release it shouldn't be sent.
|
| event.touches[0].id = press_id;
|
| SendTouchEvent(event);
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| + EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| }
|
|
|
| // Tests that touch points states are correct in TouchMove events.
|
| -TEST_F(TouchEventQueueTest, PointerStatesInTouchMove) {
|
| +TEST_F(PassthroughTouchEventQueueTest, PointerStatesInTouchMove) {
|
| PressTouchPoint(1, 1);
|
| PressTouchPoint(2, 2);
|
| PressTouchPoint(3, 3);
|
| + EXPECT_EQ(3U, queued_event_count());
|
| + EXPECT_EQ(3U, GetAndResetSentEventCount());
|
| PressTouchPoint(4, 4);
|
| - EXPECT_EQ(4U, queued_event_count());
|
| - EXPECT_EQ(1U, GetAndResetSentEventCount());
|
|
|
| // Receive ACK for the first three touch-events.
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| @@ -2437,7 +1542,7 @@ TEST_F(TouchEventQueueTest, PointerStatesInTouchMove) {
|
| // and do not move other touches.
|
| MoveTouchPoints(0, 1.1f, 1.f, 1, 2.f, 20.001f);
|
| MoveTouchPoints(2, 3.f, 3.f, 3, 4.f, 4.f);
|
| - EXPECT_EQ(2U, queued_event_count());
|
| + EXPECT_EQ(3U, queued_event_count());
|
|
|
| // Receive an ACK for the last TouchPress event.
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| @@ -2468,7 +1573,8 @@ TEST_F(TouchEventQueueTest, PointerStatesInTouchMove) {
|
|
|
| // Tests that touch point state is correct in TouchMove events
|
| // when point properties other than position changed.
|
| -TEST_F(TouchEventQueueTest, PointerStatesWhenOtherThanPositionChanged) {
|
| +TEST_F(PassthroughTouchEventQueueTest,
|
| + PointerStatesWhenOtherThanPositionChanged) {
|
| PressTouchPoint(1, 1);
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
|
|
| @@ -2509,7 +1615,7 @@ TEST_F(TouchEventQueueTest, PointerStatesWhenOtherThanPositionChanged) {
|
| }
|
|
|
| // Tests that TouchMoves are filtered when none of the points are changed.
|
| -TEST_F(TouchEventQueueTest, FilterTouchMovesWhenNoPointerChanged) {
|
| +TEST_F(PassthroughTouchEventQueueTest, FilterTouchMovesWhenNoPointerChanged) {
|
| PressTouchPoint(1, 1);
|
| PressTouchPoint(2, 2);
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| @@ -2534,14 +1640,15 @@ TEST_F(TouchEventQueueTest, FilterTouchMovesWhenNoPointerChanged) {
|
| MoveTouchPoint(0, 10, 10);
|
| ChangeTouchPointRadius(1, 1, 1);
|
| MoveTouchPoint(1, 2, 2);
|
| - EXPECT_EQ(2U, queued_event_count());
|
| + EXPECT_EQ(4U, queued_event_count());
|
| EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| + // The TouchMove but should be filtered when none of the touch points have
|
| + // changed but don't get acked right away.
|
| + EXPECT_EQ(0U, GetAndResetAckedEventCount());
|
|
|
| // Receive an ACK for 1st TouchMove.
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
|
|
| - // Tries to forward TouchMove but should be filtered
|
| - // when none of the touch points have changed.
|
| EXPECT_EQ(0U, queued_event_count());
|
| EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| EXPECT_EQ(4U, GetAndResetAckedEventCount());
|
| @@ -2561,18 +1668,20 @@ TEST_F(TouchEventQueueTest, FilterTouchMovesWhenNoPointerChanged) {
|
| EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| }
|
|
|
| -// Tests that touch-scroll-notification is not pushed into an empty queue.
|
| -TEST_F(TouchEventQueueTest, TouchScrollNotificationOrder_EmptyQueue) {
|
| +// Tests that touch-scroll-notification is queued normally.
|
| +TEST_F(PassthroughTouchEventQueueTest,
|
| + TouchScrollNotificationOrder_EmptyQueue) {
|
| PrependTouchScrollNotification();
|
|
|
| EXPECT_EQ(0U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(0U, queued_event_count());
|
| - EXPECT_EQ(0U, GetAndResetSentEventCount());
|
| + EXPECT_EQ(1U, queued_event_count());
|
| + EXPECT_EQ(1U, GetAndResetSentEventCount());
|
| }
|
|
|
| -// Tests touch-scroll-notification firing order when the event is placed at the
|
| -// end of touch queue because of a pending ack for the head of the queue.
|
| -TEST_F(TouchEventQueueTest, TouchScrollNotificationOrder_EndOfQueue) {
|
| +// Tests touch-scroll-notification firing is appended to the tail of sent
|
| +// events since all events are sent right away.
|
| +TEST_F(PassthroughTouchEventQueueTest,
|
| + TouchScrollNotificationOrder_EndOfQueue) {
|
| PressTouchPoint(1, 1);
|
|
|
| EXPECT_EQ(0U, GetAndResetAckedEventCount());
|
| @@ -2584,77 +1693,22 @@ TEST_F(TouchEventQueueTest, TouchScrollNotificationOrder_EndOfQueue) {
|
| EXPECT_EQ(0U, GetAndResetAckedEventCount());
|
| EXPECT_EQ(2U, queued_event_count());
|
|
|
| - // Receive an ACK for the touchstart.
|
| + // Send ACKs.
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| -
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type());
|
| - EXPECT_EQ(1U, queued_event_count());
|
| -
|
| - // Receive an ACK for the touch-scroll-notification.
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_IGNORED);
|
|
|
| - EXPECT_EQ(0U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(0U, queued_event_count());
|
| -
|
| - EXPECT_EQ(WebInputEvent::TouchStart, all_sent_events()[0].type());
|
| - EXPECT_EQ(WebInputEvent::TouchScrollStarted, all_sent_events()[1].type());
|
| - EXPECT_EQ(2U, GetAndResetSentEventCount());
|
| -}
|
| -
|
| -// Tests touch-scroll-notification firing order when the event is placed in the
|
| -// 2nd position in the touch queue between two events.
|
| -TEST_F(TouchEventQueueTest, TouchScrollNotificationOrder_SecondPosition) {
|
| - PressTouchPoint(1, 1);
|
| - MoveTouchPoint(0, 5, 5);
|
| - ReleaseTouchPoint(0);
|
| -
|
| - EXPECT_EQ(0U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(3U, queued_event_count());
|
| -
|
| - // Send the touch-scroll-notification when 3 events are in the queue.
|
| - PrependTouchScrollNotification();
|
| -
|
| - EXPECT_EQ(0U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(4U, queued_event_count());
|
| -
|
| - // Receive an ACK for the touchstart.
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| -
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type());
|
| - EXPECT_EQ(3U, queued_event_count());
|
| -
|
| - // Receive an ACK for the touch-scroll-notification.
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_IGNORED);
|
| -
|
| - EXPECT_EQ(0U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(2U, queued_event_count());
|
| -
|
| - // Receive an ACK for the touchmove.
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| -
|
| + // Touch-scroll-start Ack is not reported to client.
|
| EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type());
|
| - EXPECT_EQ(1U, queued_event_count());
|
| -
|
| - // Receive an ACK for the touchend.
|
| - SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| -
|
| - EXPECT_EQ(1U, GetAndResetAckedEventCount());
|
| - EXPECT_EQ(WebInputEvent::TouchEnd, acked_event().type());
|
| EXPECT_EQ(0U, queued_event_count());
|
|
|
| EXPECT_EQ(WebInputEvent::TouchStart, all_sent_events()[0].type());
|
| EXPECT_EQ(WebInputEvent::TouchScrollStarted, all_sent_events()[1].type());
|
| - EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[2].type());
|
| - EXPECT_EQ(WebInputEvent::TouchEnd, all_sent_events()[3].type());
|
| - EXPECT_EQ(4U, GetAndResetSentEventCount());
|
| + EXPECT_EQ(2U, GetAndResetSentEventCount());
|
| }
|
|
|
| // Tests that if touchStartOrFirstTouchMove is correctly set up for touch
|
| // events.
|
| -TEST_F(TouchEventQueueTest, TouchStartOrFirstTouchMove) {
|
| +TEST_F(PassthroughTouchEventQueueTest, TouchStartOrFirstTouchMove) {
|
| PressTouchPoint(1, 1);
|
| SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
|
| EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type());
|
|
|