Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "content/browser/renderer_host/input/timeout_monitor.h" | 9 #include "content/browser/renderer_host/input/timeout_monitor.h" |
| 10 #include "content/browser/renderer_host/input/touch_event_queue.h" | 10 #include "content/browser/renderer_host/input/touch_event_queue.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 | 27 |
| 28 base::TimeDelta DefaultTouchTimeoutDelay() { | 28 base::TimeDelta DefaultTouchTimeoutDelay() { |
| 29 return base::TimeDelta::FromMilliseconds(1); | 29 return base::TimeDelta::FromMilliseconds(1); |
| 30 } | 30 } |
| 31 } // namespace | 31 } // namespace |
| 32 | 32 |
| 33 class TouchEventQueueTest : public testing::Test, | 33 class TouchEventQueueTest : public testing::Test, |
| 34 public TouchEventQueueClient { | 34 public TouchEventQueueClient { |
| 35 public: | 35 public: |
| 36 TouchEventQueueTest() | 36 TouchEventQueueTest() |
| 37 : sent_event_count_(0), | 37 : acked_event_count_(0), |
| 38 acked_event_count_(0), | |
| 39 last_acked_event_state_(INPUT_EVENT_ACK_STATE_UNKNOWN), | 38 last_acked_event_state_(INPUT_EVENT_ACK_STATE_UNKNOWN), |
| 40 slop_length_dips_(0) {} | 39 slop_length_dips_(0) {} |
| 41 | 40 |
| 42 ~TouchEventQueueTest() override {} | 41 ~TouchEventQueueTest() override {} |
| 43 | 42 |
| 44 // testing::Test | 43 // testing::Test |
| 45 void SetUp() override { | 44 void SetUp() override { |
| 46 ResetQueueWithConfig(TouchEventQueue::Config()); | 45 ResetQueueWithConfig(TouchEventQueue::Config()); |
| 47 } | 46 } |
| 48 | 47 |
| 49 void TearDown() override { queue_.reset(); } | 48 void TearDown() override { queue_.reset(); } |
| 50 | 49 |
| 51 // TouchEventQueueClient | 50 // TouchEventQueueClient |
| 52 void SendTouchEventImmediately( | 51 void SendTouchEventImmediately( |
| 53 const TouchEventWithLatencyInfo& event) override { | 52 const TouchEventWithLatencyInfo& event) override { |
| 54 ++sent_event_count_; | 53 sent_events_.push_back(event.event); |
| 55 last_sent_event_ = event.event; | |
| 56 if (sync_ack_result_) { | 54 if (sync_ack_result_) { |
| 57 auto sync_ack_result = sync_ack_result_.Pass(); | 55 auto sync_ack_result = sync_ack_result_.Pass(); |
| 58 SendTouchEventAck(*sync_ack_result); | 56 SendTouchEventAck(*sync_ack_result); |
| 59 } | 57 } |
| 60 } | 58 } |
| 61 | 59 |
| 62 void OnTouchEventAck(const TouchEventWithLatencyInfo& event, | 60 void OnTouchEventAck(const TouchEventWithLatencyInfo& event, |
| 63 InputEventAckState ack_result) override { | 61 InputEventAckState ack_result) override { |
| 64 ++acked_event_count_; | 62 ++acked_event_count_; |
| 65 last_acked_event_ = event.event; | 63 last_acked_event_ = event.event; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 WebGestureEvent event; | 109 WebGestureEvent event; |
| 112 event.type = type; | 110 event.type = type; |
| 113 queue_->OnGestureScrollEvent( | 111 queue_->OnGestureScrollEvent( |
| 114 GestureEventWithLatencyInfo(event, ui::LatencyInfo())); | 112 GestureEventWithLatencyInfo(event, ui::LatencyInfo())); |
| 115 } | 113 } |
| 116 | 114 |
| 117 void SendTouchEventAck(InputEventAckState ack_result) { | 115 void SendTouchEventAck(InputEventAckState ack_result) { |
| 118 queue_->ProcessTouchAck(ack_result, ui::LatencyInfo()); | 116 queue_->ProcessTouchAck(ack_result, ui::LatencyInfo()); |
| 119 } | 117 } |
| 120 | 118 |
| 119 void SendUncancelableTouchMoveEventAck() { | |
| 120 queue_->ProcessUncancelableTouchMoveAck(); | |
| 121 } | |
| 122 | |
| 121 void SendGestureEventAck(WebInputEvent::Type type, | 123 void SendGestureEventAck(WebInputEvent::Type type, |
| 122 InputEventAckState ack_result) { | 124 InputEventAckState ack_result) { |
| 123 blink::WebGestureEvent gesture_event; | 125 blink::WebGestureEvent gesture_event; |
| 124 gesture_event.type = type; | 126 gesture_event.type = type; |
| 125 GestureEventWithLatencyInfo event(gesture_event, ui::LatencyInfo()); | 127 GestureEventWithLatencyInfo event(gesture_event, ui::LatencyInfo()); |
| 126 queue_->OnGestureEventAck(event, ack_result); | 128 queue_->OnGestureEventAck(event, ack_result); |
| 127 } | 129 } |
| 128 | 130 |
| 129 void SetFollowupEvent(const WebTouchEvent& event) { | 131 void SetFollowupEvent(const WebTouchEvent& event) { |
| 130 followup_touch_event_.reset(new WebTouchEvent(event)); | 132 followup_touch_event_.reset(new WebTouchEvent(event)); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 touch_event_ = SyntheticWebTouchEvent(); | 219 touch_event_ = SyntheticWebTouchEvent(); |
| 218 } | 220 } |
| 219 | 221 |
| 220 size_t GetAndResetAckedEventCount() { | 222 size_t GetAndResetAckedEventCount() { |
| 221 size_t count = acked_event_count_; | 223 size_t count = acked_event_count_; |
| 222 acked_event_count_ = 0; | 224 acked_event_count_ = 0; |
| 223 return count; | 225 return count; |
| 224 } | 226 } |
| 225 | 227 |
| 226 size_t GetAndResetSentEventCount() { | 228 size_t GetAndResetSentEventCount() { |
| 227 size_t count = sent_event_count_; | 229 size_t count = sent_events_.size(); |
| 228 sent_event_count_ = 0; | 230 sent_events_.clear(); |
| 229 return count; | 231 return count; |
| 230 } | 232 } |
| 231 | 233 |
| 232 bool IsPendingAckTouchStart() const { | 234 bool IsPendingAckTouchStart() const { |
| 233 return queue_->IsPendingAckTouchStart(); | 235 return queue_->IsPendingAckTouchStart(); |
| 234 } | 236 } |
| 235 | 237 |
| 236 void OnHasTouchEventHandlers(bool has_handlers) { | 238 void OnHasTouchEventHandlers(bool has_handlers) { |
| 237 queue_->OnHasTouchEventHandlers(has_handlers); | 239 queue_->OnHasTouchEventHandlers(has_handlers); |
| 238 } | 240 } |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 251 | 253 |
| 252 const WebTouchEvent& latest_event() const { | 254 const WebTouchEvent& latest_event() const { |
| 253 return queue_->GetLatestEventForTesting().event; | 255 return queue_->GetLatestEventForTesting().event; |
| 254 } | 256 } |
| 255 | 257 |
| 256 const WebTouchEvent& acked_event() const { | 258 const WebTouchEvent& acked_event() const { |
| 257 return last_acked_event_; | 259 return last_acked_event_; |
| 258 } | 260 } |
| 259 | 261 |
| 260 const WebTouchEvent& sent_event() const { | 262 const WebTouchEvent& sent_event() const { |
| 261 return last_sent_event_; | 263 DCHECK(!sent_events_.empty()); |
| 264 return sent_events_.back(); | |
| 265 } | |
| 266 | |
| 267 const std::vector<WebTouchEvent> sent_all_events() const { | |
|
jdduke (slow)
2015/04/15 17:14:53
maybe |all_sent_events|, and you can return by con
lanwei
2015/04/17 20:49:00
Done.
| |
| 268 return sent_events_; | |
| 262 } | 269 } |
| 263 | 270 |
| 264 InputEventAckState acked_event_state() const { | 271 InputEventAckState acked_event_state() const { |
| 265 return last_acked_event_state_; | 272 return last_acked_event_state_; |
| 266 } | 273 } |
| 267 | 274 |
| 268 static void RunTasksAndWait(base::TimeDelta delay) { | 275 static void RunTasksAndWait(base::TimeDelta delay) { |
| 269 base::MessageLoop::current()->PostDelayedTask( | 276 base::MessageLoop::current()->PostDelayedTask( |
| 270 FROM_HERE, base::MessageLoop::QuitClosure(), delay); | 277 FROM_HERE, base::MessageLoop::QuitClosure(), delay); |
| 271 base::MessageLoop::current()->Run(); | 278 base::MessageLoop::current()->Run(); |
| 272 } | 279 } |
| 273 | 280 |
| 281 size_t uncancelable_touch_moves_pending_ack_count() const { | |
| 282 return queue_->uncancelable_touch_moves_pending_ack_count(); | |
| 283 } | |
| 284 | |
| 274 private: | 285 private: |
| 275 void SendTouchEvent() { | 286 void SendTouchEvent() { |
| 276 SendTouchEvent(touch_event_); | 287 SendTouchEvent(touch_event_); |
| 277 touch_event_.ResetPoints(); | 288 touch_event_.ResetPoints(); |
| 278 } | 289 } |
| 279 | 290 |
| 280 void ResetQueueWithConfig(const TouchEventQueue::Config& config) { | 291 void ResetQueueWithConfig(const TouchEventQueue::Config& config) { |
| 281 queue_.reset(new TouchEventQueue(this, config)); | 292 queue_.reset(new TouchEventQueue(this, config)); |
| 282 queue_->OnHasTouchEventHandlers(true); | 293 queue_->OnHasTouchEventHandlers(true); |
| 283 } | 294 } |
| 284 | 295 |
| 285 scoped_ptr<TouchEventQueue> queue_; | 296 scoped_ptr<TouchEventQueue> queue_; |
| 286 size_t sent_event_count_; | |
| 287 size_t acked_event_count_; | 297 size_t acked_event_count_; |
| 288 WebTouchEvent last_sent_event_; | |
| 289 WebTouchEvent last_acked_event_; | 298 WebTouchEvent last_acked_event_; |
| 299 std::vector<WebTouchEvent> sent_events_; | |
| 290 InputEventAckState last_acked_event_state_; | 300 InputEventAckState last_acked_event_state_; |
| 291 SyntheticWebTouchEvent touch_event_; | 301 SyntheticWebTouchEvent touch_event_; |
| 292 scoped_ptr<WebTouchEvent> followup_touch_event_; | 302 scoped_ptr<WebTouchEvent> followup_touch_event_; |
| 293 scoped_ptr<WebGestureEvent> followup_gesture_event_; | 303 scoped_ptr<WebGestureEvent> followup_gesture_event_; |
| 294 scoped_ptr<InputEventAckState> sync_ack_result_; | 304 scoped_ptr<InputEventAckState> sync_ack_result_; |
| 295 double slop_length_dips_; | 305 double slop_length_dips_; |
| 296 gfx::PointF anchor_; | 306 gfx::PointF anchor_; |
| 297 base::MessageLoopForUI message_loop_; | 307 base::MessageLoopForUI message_loop_; |
| 298 }; | 308 }; |
| 299 | 309 |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1023 // The timeout should have fired, synthetically ack'ing the timed-out event. | 1033 // The timeout should have fired, synthetically ack'ing the timed-out event. |
| 1024 // TouchEvent forwarding is disabled until the ack is received for the | 1034 // TouchEvent forwarding is disabled until the ack is received for the |
| 1025 // timed-out event and the future cancel event. | 1035 // timed-out event and the future cancel event. |
| 1026 EXPECT_FALSE(IsTimeoutRunning()); | 1036 EXPECT_FALSE(IsTimeoutRunning()); |
| 1027 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1037 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1028 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1038 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1029 | 1039 |
| 1030 // Ack'ing the original event should trigger a cancel event. | 1040 // Ack'ing the original event should trigger a cancel event. |
| 1031 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1041 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1032 EXPECT_FALSE(IsTimeoutRunning()); | 1042 EXPECT_FALSE(IsTimeoutRunning()); |
| 1043 EXPECT_EQ(WebInputEvent::TouchCancel, sent_event().type); | |
| 1044 EXPECT_FALSE(sent_event().cancelable); | |
| 1033 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 1045 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
| 1034 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1046 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1035 EXPECT_EQ(WebInputEvent::TouchCancel, sent_event().type); | |
| 1036 EXPECT_FALSE(sent_event().cancelable); | |
| 1037 | 1047 |
| 1038 // Touch events should not be forwarded until we receive the cancel acks. | 1048 // Touch events should not be forwarded until we receive the cancel acks. |
| 1039 MoveTouchPoint(0, 1, 1); | 1049 MoveTouchPoint(0, 1, 1); |
| 1040 ASSERT_EQ(0U, GetAndResetSentEventCount()); | 1050 ASSERT_EQ(0U, GetAndResetSentEventCount()); |
| 1041 ASSERT_EQ(1U, GetAndResetAckedEventCount()); | 1051 ASSERT_EQ(1U, GetAndResetAckedEventCount()); |
| 1042 | 1052 |
| 1043 ReleaseTouchPoint(0); | 1053 ReleaseTouchPoint(0); |
| 1044 ASSERT_EQ(0U, GetAndResetSentEventCount()); | 1054 ASSERT_EQ(0U, GetAndResetSentEventCount()); |
| 1045 ASSERT_EQ(1U, GetAndResetAckedEventCount()); | 1055 ASSERT_EQ(1U, GetAndResetAckedEventCount()); |
| 1046 | 1056 |
| 1047 // The synthetic TouchCancel ack should not reach the client, but should | 1057 // The synthetic TouchCancel ack should not reach the client, but should |
| 1048 // resume touch forwarding. | 1058 // resume touch forwarding. |
| 1049 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1059 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1050 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1060 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1051 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 1061 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
| 1052 | 1062 |
| 1053 // Subsequent events should be handled normally. | 1063 // Subsequent events should be handled normally. |
| 1054 PressTouchPoint(0, 1); | 1064 PressTouchPoint(0, 1); |
| 1065 EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type); | |
| 1066 EXPECT_TRUE(sent_event().cancelable); | |
| 1055 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1067 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1056 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 1068 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
| 1057 EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type); | |
| 1058 EXPECT_TRUE(sent_event().cancelable); | |
| 1059 } | 1069 } |
| 1060 | 1070 |
| 1061 // Tests that the timeout is never started if the renderer consumes | 1071 // Tests that the timeout is never started if the renderer consumes |
| 1062 // a TouchEvent from the current touch sequence. | 1072 // a TouchEvent from the current touch sequence. |
| 1063 TEST_F(TouchEventQueueTest, NoTouchTimeoutIfRendererIsConsumingGesture) { | 1073 TEST_F(TouchEventQueueTest, NoTouchTimeoutIfRendererIsConsumingGesture) { |
| 1064 SetUpForTimeoutTesting(DefaultTouchTimeoutDelay()); | 1074 SetUpForTimeoutTesting(DefaultTouchTimeoutDelay()); |
| 1065 | 1075 |
| 1066 // Queue a TouchStart. | 1076 // Queue a TouchStart. |
| 1067 PressTouchPoint(0, 1); | 1077 PressTouchPoint(0, 1); |
| 1068 ASSERT_TRUE(IsTimeoutRunning()); | 1078 ASSERT_TRUE(IsTimeoutRunning()); |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1578 | 1588 |
| 1579 // Now queue a second touchmove and verify it's not (yet) dispatched. | 1589 // Now queue a second touchmove and verify it's not (yet) dispatched. |
| 1580 MoveTouchPoint(0, 0, 100); | 1590 MoveTouchPoint(0, 0, 100); |
| 1581 SetFollowupEvent(followup_scroll); | 1591 SetFollowupEvent(followup_scroll); |
| 1582 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1592 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1583 EXPECT_TRUE(HasPendingAsyncTouchMove()); | 1593 EXPECT_TRUE(HasPendingAsyncTouchMove()); |
| 1584 EXPECT_EQ(0U, queued_event_count()); | 1594 EXPECT_EQ(0U, queued_event_count()); |
| 1585 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1595 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1586 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1596 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1587 | 1597 |
| 1588 // Queuing the final touchend should flush the pending, async touchmove. | 1598 // Queuing the final touchend should flush the pending async touchmove. In |
| 1599 // this case, we will first dispatch an async touchmove and then a touchend. | |
| 1600 // For the async touchmove, we will only ack the client. | |
| 1589 ReleaseTouchPoint(0); | 1601 ReleaseTouchPoint(0); |
| 1590 followup_scroll.type = WebInputEvent::GestureScrollEnd; | 1602 followup_scroll.type = WebInputEvent::GestureScrollEnd; |
| 1591 SetFollowupEvent(followup_scroll); | 1603 SetFollowupEvent(followup_scroll); |
| 1592 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type); | |
| 1593 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 1604 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
| 1594 EXPECT_FALSE(sent_event().cancelable); | 1605 EXPECT_EQ(2U, sent_all_events().size()); |
| 1595 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1606 EXPECT_EQ(WebInputEvent::TouchMove, sent_all_events()[0].type); |
| 1596 EXPECT_EQ(2U, queued_event_count()); | 1607 EXPECT_FALSE(sent_all_events()[0].cancelable); |
| 1597 | 1608 EXPECT_EQ(WebInputEvent::TouchEnd, sent_all_events()[1].type); |
| 1598 // Ack the flushed, async touchmove. The ack should not reach the client, but | 1609 EXPECT_FALSE(sent_all_events()[1].cancelable); |
| 1599 // it should trigger sending of the (now non-cancelable) touchend. | 1610 EXPECT_EQ(2U, GetAndResetSentEventCount()); |
| 1600 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1611 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1601 EXPECT_EQ(WebInputEvent::TouchEnd, sent_event().type); | |
| 1602 EXPECT_FALSE(sent_event().cancelable); | |
| 1603 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 1604 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | |
| 1605 EXPECT_EQ(1U, queued_event_count()); | 1612 EXPECT_EQ(1U, queued_event_count()); |
| 1606 | 1613 |
| 1607 // Ack the touchend. | 1614 // Ack the touchend. |
| 1608 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1615 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1609 EXPECT_EQ(0U, queued_event_count()); | 1616 EXPECT_EQ(0U, queued_event_count()); |
| 1610 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1617 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1611 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1618 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1612 | 1619 |
| 1613 // Now mark the scrolls as not consumed (which would cause future touchmoves | 1620 // Now mark the scrolls as not consumed (which would cause future touchmoves |
| 1614 // in the active sequence to be sent if there was one). | 1621 // in the active sequence to be sent if there was one). |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1627 followup_scroll.type = WebInputEvent::GestureScrollBegin; | 1634 followup_scroll.type = WebInputEvent::GestureScrollBegin; |
| 1628 SetFollowupEvent(followup_scroll); | 1635 SetFollowupEvent(followup_scroll); |
| 1629 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1636 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1630 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1637 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1631 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1638 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1632 | 1639 |
| 1633 MoveTouchPoint(0, 0, 6); | 1640 MoveTouchPoint(0, 0, 6); |
| 1634 followup_scroll.type = WebInputEvent::GestureScrollUpdate; | 1641 followup_scroll.type = WebInputEvent::GestureScrollUpdate; |
| 1635 SetFollowupEvent(followup_scroll); | 1642 SetFollowupEvent(followup_scroll); |
| 1636 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1643 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1644 SendUncancelableTouchMoveEventAck(); | |
| 1637 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 1645 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
| 1638 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1646 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1639 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1647 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1640 | 1648 |
| 1641 MoveTouchPoint(0, 0, 10); | 1649 MoveTouchPoint(0, 0, 10); |
| 1642 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1650 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1643 EXPECT_TRUE(HasPendingAsyncTouchMove()); | 1651 EXPECT_TRUE(HasPendingAsyncTouchMove()); |
| 1644 EXPECT_EQ(0U, queued_event_count()); | 1652 EXPECT_EQ(0U, queued_event_count()); |
| 1645 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1653 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1646 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1654 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1647 | 1655 |
| 1648 // Subsequent touchmove's should be deferred. | 1656 // Subsequent touchmove's should be deferred. |
| 1649 MoveTouchPoint(0, 0, 25); | 1657 MoveTouchPoint(0, 0, 25); |
| 1650 EXPECT_TRUE(HasPendingAsyncTouchMove()); | 1658 EXPECT_TRUE(HasPendingAsyncTouchMove()); |
| 1651 EXPECT_EQ(0U, queued_event_count()); | 1659 EXPECT_EQ(0U, queued_event_count()); |
| 1652 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1660 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1653 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1661 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1654 | 1662 |
| 1655 // The pending touchmove should be flushed with the the new touchmove if | 1663 // The pending touchmove should be flushed with the the new touchmove if |
| 1656 // sufficient time has passed. | 1664 // sufficient time has passed and ack to the client. |
| 1657 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); | 1665 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); |
| 1658 MoveTouchPoint(0, 0, 15); | 1666 MoveTouchPoint(0, 0, 15); |
| 1659 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 1667 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
| 1660 EXPECT_FALSE(sent_event().cancelable); | 1668 EXPECT_FALSE(sent_event().cancelable); |
| 1661 EXPECT_EQ(1U, queued_event_count()); | 1669 EXPECT_EQ(0U, queued_event_count()); |
| 1662 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1670 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1663 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | |
| 1664 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1665 EXPECT_EQ(0U, queued_event_count()); | |
| 1666 EXPECT_EQ(0U, GetAndResetSentEventCount()); | |
| 1667 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1671 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1668 | 1672 |
| 1669 // Non-touchmove events should always flush any pending touchmove events. | 1673 // Non-touchmove events should always flush any pending touchmove events. In |
| 1674 // this case, we will first dispatch an async touchmove and then a | |
| 1675 // touchstart. For the async touchmove, we will only ack the client. | |
| 1670 MoveTouchPoint(0, 0, 25); | 1676 MoveTouchPoint(0, 0, 25); |
| 1671 EXPECT_TRUE(HasPendingAsyncTouchMove()); | 1677 EXPECT_TRUE(HasPendingAsyncTouchMove()); |
| 1672 EXPECT_EQ(0U, queued_event_count()); | 1678 EXPECT_EQ(0U, queued_event_count()); |
| 1673 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1679 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1674 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1680 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1675 PressTouchPoint(30, 30); | 1681 PressTouchPoint(30, 30); |
| 1676 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 1682 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
| 1677 EXPECT_FALSE(sent_event().cancelable); | 1683 EXPECT_EQ(2U, sent_all_events().size()); |
| 1678 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type); | 1684 EXPECT_EQ(WebInputEvent::TouchMove, sent_all_events()[0].type); |
| 1679 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1685 EXPECT_FALSE(sent_all_events()[0].cancelable); |
| 1680 EXPECT_EQ(2U, queued_event_count()); | 1686 EXPECT_EQ(WebInputEvent::TouchStart, sent_all_events()[1].type); |
| 1681 | 1687 EXPECT_TRUE(sent_all_events()[1].cancelable); |
| 1682 // Ack'ing the flushed, async touchmove will dispatch the touchstart. Note | 1688 EXPECT_EQ(2U, GetAndResetSentEventCount()); |
| 1683 // that the flushed touchmove's ack will not reach the client (its | 1689 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1684 // constituent events have already been ack'ed). | |
| 1685 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1686 EXPECT_TRUE(sent_event().cancelable); | |
| 1687 EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type); | |
| 1688 EXPECT_EQ(1U, queued_event_count()); | 1690 EXPECT_EQ(1U, queued_event_count()); |
| 1689 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 1690 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | |
| 1691 | 1691 |
| 1692 // Ack the touchstart. | 1692 // Ack the touchstart. |
| 1693 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1693 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1694 EXPECT_EQ(0U, queued_event_count()); | 1694 EXPECT_EQ(0U, queued_event_count()); |
| 1695 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1695 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1696 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1696 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1697 | 1697 |
| 1698 // Send a secondary touchmove. | 1698 // Send a secondary touchmove. |
| 1699 MoveTouchPoint(1, 0, 25); | 1699 MoveTouchPoint(1, 0, 25); |
| 1700 EXPECT_TRUE(HasPendingAsyncTouchMove()); | 1700 EXPECT_TRUE(HasPendingAsyncTouchMove()); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1774 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1774 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1775 | 1775 |
| 1776 // Return the touch sequence to the original touchstart position. Note that | 1776 // Return the touch sequence to the original touchstart position. Note that |
| 1777 // this (0, 0) touchmove will coalesce with the previous (0, 100) touchmove. | 1777 // this (0, 0) touchmove will coalesce with the previous (0, 100) touchmove. |
| 1778 MoveTouchPoint(0, 0, 0); | 1778 MoveTouchPoint(0, 0, 0); |
| 1779 EXPECT_TRUE(HasPendingAsyncTouchMove()); | 1779 EXPECT_TRUE(HasPendingAsyncTouchMove()); |
| 1780 EXPECT_EQ(0U, queued_event_count()); | 1780 EXPECT_EQ(0U, queued_event_count()); |
| 1781 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1781 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1782 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1782 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1783 | 1783 |
| 1784 // Queuing the final touchend should flush the pending, async touchmove. | 1784 // Queuing the final touchend should flush the pending, async touchmove. In |
| 1785 // this case, we will first dispatch an async touchmove and then a touchend. | |
| 1786 // For the async touchmove, we will only ack the client. | |
| 1785 ReleaseTouchPoint(0); | 1787 ReleaseTouchPoint(0); |
| 1786 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 1788 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
| 1787 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type); | 1789 EXPECT_EQ(2U, sent_all_events().size()); |
| 1788 EXPECT_FALSE(sent_event().cancelable); | 1790 EXPECT_EQ(WebInputEvent::TouchMove, sent_all_events()[0].type); |
| 1789 EXPECT_EQ(0, sent_event().touches[0].position.x); | 1791 EXPECT_FALSE(sent_all_events()[0].cancelable); |
| 1790 EXPECT_EQ(0, sent_event().touches[0].position.y); | 1792 EXPECT_EQ(0, sent_all_events()[0].touches[0].position.x); |
| 1791 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1793 EXPECT_EQ(0, sent_all_events()[0].touches[0].position.y); |
| 1792 | 1794 EXPECT_EQ(WebInputEvent::TouchEnd, sent_all_events()[1].type); |
| 1793 // Touchend is not cancelable during async touch dispatch. | 1795 EXPECT_FALSE(sent_all_events()[1].cancelable); |
| 1794 SendTouchEventAck(INPUT_EVENT_ACK_STATE_IGNORED); | 1796 EXPECT_EQ(2U, GetAndResetSentEventCount()); |
| 1795 EXPECT_EQ(WebInputEvent::TouchEnd, sent_event().type); | 1797 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1796 EXPECT_FALSE(sent_event().cancelable); | |
| 1797 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 1798 } | 1798 } |
| 1799 | 1799 |
| 1800 // Ensure that async touch dispatch and touch ack timeout interactions work | 1800 // Ensure that async touch dispatch and touch ack timeout interactions work |
| 1801 // appropriately. | 1801 // appropriately. |
| 1802 TEST_F(TouchEventQueueTest, AsyncTouchWithAckTimeout) { | 1802 TEST_F(TouchEventQueueTest, AsyncTouchWithAckTimeout) { |
| 1803 SetUpForTimeoutTesting(DefaultTouchTimeoutDelay()); | 1803 SetUpForTimeoutTesting(DefaultTouchTimeoutDelay()); |
| 1804 | 1804 |
| 1805 // The touchstart should start the timeout. | 1805 // The touchstart should start the timeout. |
| 1806 PressTouchPoint(0, 0); | 1806 PressTouchPoint(0, 0); |
| 1807 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1807 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 1828 // it should not start the touch ack timeout. | 1828 // it should not start the touch ack timeout. |
| 1829 MoveTouchPoint(0, 5, 5); | 1829 MoveTouchPoint(0, 5, 5); |
| 1830 EXPECT_TRUE(HasPendingAsyncTouchMove()); | 1830 EXPECT_TRUE(HasPendingAsyncTouchMove()); |
| 1831 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1831 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1832 | 1832 |
| 1833 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); | 1833 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); |
| 1834 MoveTouchPoint(0, 5, 5); | 1834 MoveTouchPoint(0, 5, 5); |
| 1835 EXPECT_FALSE(IsTimeoutRunning()); | 1835 EXPECT_FALSE(IsTimeoutRunning()); |
| 1836 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 1836 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
| 1837 EXPECT_FALSE(sent_event().cancelable); | 1837 EXPECT_FALSE(sent_event().cancelable); |
| 1838 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1839 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1838 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1840 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1839 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1841 | 1840 |
| 1842 // An unconsumed scroll event will resume synchronous touchmoves, which are | 1841 // An unconsumed scroll event will resume synchronous touchmoves, which are |
| 1843 // subject to the ack timeout. | 1842 // subject to the ack timeout. |
| 1844 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, | 1843 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, |
| 1845 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1844 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1846 MoveTouchPoint(0, 20, 5); | 1845 MoveTouchPoint(0, 20, 5); |
| 1847 EXPECT_TRUE(IsTimeoutRunning()); | 1846 EXPECT_TRUE(IsTimeoutRunning()); |
| 1848 EXPECT_TRUE(sent_event().cancelable); | 1847 EXPECT_TRUE(sent_event().cancelable); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1901 | 1900 |
| 1902 // The async touchmove should be ack'ed immediately, but not forwarded. | 1901 // The async touchmove should be ack'ed immediately, but not forwarded. |
| 1903 // However, because the ack triggers a touchcancel, both the pending touch and | 1902 // However, because the ack triggers a touchcancel, both the pending touch and |
| 1904 // the queued touchcancel should be flushed. | 1903 // the queued touchcancel should be flushed. |
| 1905 WebTouchEvent followup_cancel; | 1904 WebTouchEvent followup_cancel; |
| 1906 followup_cancel.type = WebInputEvent::TouchCancel; | 1905 followup_cancel.type = WebInputEvent::TouchCancel; |
| 1907 followup_cancel.touchesLength = 1; | 1906 followup_cancel.touchesLength = 1; |
| 1908 followup_cancel.touches[0].state = WebTouchPoint::StateCancelled; | 1907 followup_cancel.touches[0].state = WebTouchPoint::StateCancelled; |
| 1909 SetFollowupEvent(followup_cancel); | 1908 SetFollowupEvent(followup_cancel); |
| 1910 MoveTouchPoint(0, 5, 5); | 1909 MoveTouchPoint(0, 5, 5); |
| 1911 EXPECT_EQ(2U, queued_event_count()); | 1910 EXPECT_EQ(1U, queued_event_count()); |
| 1912 EXPECT_FALSE(sent_event().cancelable); | 1911 EXPECT_EQ(2U, sent_all_events().size()); |
| 1913 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 1912 EXPECT_EQ(WebInputEvent::TouchMove, sent_all_events()[0].type); |
| 1913 EXPECT_FALSE(sent_all_events()[0].cancelable); | |
| 1914 EXPECT_EQ(WebInputEvent::TouchCancel, sent_all_events()[1].type); | |
| 1915 EXPECT_FALSE(sent_all_events()[1].cancelable); | |
| 1916 EXPECT_EQ(2U, GetAndResetSentEventCount()); | |
| 1917 // The first ack is because the async touchmove is not ready for dispatching | |
| 1918 // send the ack immediately, the second ack is when flushing the async | |
| 1919 // touchmove, ack to client right away. | |
| 1920 EXPECT_EQ(2U, GetAndResetAckedEventCount()); | |
| 1914 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type); | 1921 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type); |
| 1915 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type); | |
| 1916 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 1917 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 1918 | |
| 1919 // The ack for the async touchmove should not reach the client, as it has | |
| 1920 // already been ack'ed. | |
| 1921 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1922 EXPECT_FALSE(sent_event().cancelable); | |
| 1923 EXPECT_EQ(1U, queued_event_count()); | |
| 1924 EXPECT_EQ(WebInputEvent::TouchCancel, sent_event().type); | |
| 1925 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | |
| 1926 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 1927 | 1922 |
| 1928 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1923 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1929 EXPECT_EQ(0U, queued_event_count()); | 1924 EXPECT_EQ(0U, queued_event_count()); |
| 1930 EXPECT_EQ(WebInputEvent::TouchCancel, acked_event().type); | 1925 EXPECT_EQ(WebInputEvent::TouchCancel, acked_event().type); |
| 1931 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1926 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1932 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1927 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1933 } | 1928 } |
| 1934 | 1929 |
| 1935 // Ensure that the async touch is fully reset if the touch sequence restarts | 1930 // Ensure that the async touch is fully reset if the touch sequence restarts |
| 1936 // without properly terminating. | 1931 // without properly terminating. |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 1958 EXPECT_EQ(0U, queued_event_count()); | 1953 EXPECT_EQ(0U, queued_event_count()); |
| 1959 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type); | 1954 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type); |
| 1960 | 1955 |
| 1961 // The queue should be robust to hard touch restarts with a new touch | 1956 // The queue should be robust to hard touch restarts with a new touch |
| 1962 // sequence. In this case, the deferred async touch should not be flushed | 1957 // sequence. In this case, the deferred async touch should not be flushed |
| 1963 // by the new touch sequence. | 1958 // by the new touch sequence. |
| 1964 SendGestureEvent(WebInputEvent::GestureScrollEnd); | 1959 SendGestureEvent(WebInputEvent::GestureScrollEnd); |
| 1965 ResetTouchEvent(); | 1960 ResetTouchEvent(); |
| 1966 | 1961 |
| 1967 PressTouchPoint(0, 0); | 1962 PressTouchPoint(0, 0); |
| 1968 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 1969 EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type); | 1963 EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type); |
| 1970 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1964 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1965 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1966 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 1967 } | |
| 1968 | |
| 1969 // Ensure that even when the interval expires, we still need to wait for the | |
| 1970 // ack sent back from render to send the next async touchmove once the scroll | |
| 1971 // starts. | |
| 1972 TEST_F(TouchEventQueueTest, SendNextThrottledAsyncTouchMoveAfterAck) { | |
| 1973 // Process a TouchStart | |
| 1974 PressTouchPoint(0, 1); | |
| 1975 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 1976 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1977 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 1978 | |
| 1979 // Initiate async touchmove dispatch after the start of a scroll sequence. | |
| 1980 MoveTouchPoint(0, 0, 5); | |
| 1981 WebGestureEvent followup_scroll; | |
| 1982 followup_scroll.type = WebInputEvent::GestureScrollBegin; | |
| 1983 SetFollowupEvent(followup_scroll); | |
| 1984 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1985 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 1986 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 1987 | |
| 1988 MoveTouchPoint(0, 0, 10); | |
| 1989 followup_scroll.type = WebInputEvent::GestureScrollUpdate; | |
| 1990 SetFollowupEvent(followup_scroll); | |
| 1991 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1992 EXPECT_FALSE(HasPendingAsyncTouchMove()); | |
| 1993 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 1994 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 1995 | |
| 1996 // We set the next touch event time to be after the throttled interval. | |
| 1997 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); | |
| 1998 // Dispatch the touch move event when sufficient time has passed. | |
| 1999 MoveTouchPoint(0, 0, 40); | |
| 2000 EXPECT_FALSE(HasPendingAsyncTouchMove()); | |
| 2001 EXPECT_FALSE(sent_event().cancelable); | |
| 2002 // When we dispatch an async touchmove, we do not put it back to the queue | |
| 2003 // any more and we will ack to client right away. | |
| 2004 EXPECT_EQ(0U, queued_event_count()); | |
| 2005 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 2006 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 2007 EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count()); | |
| 2008 | |
| 2009 // Do not dispatch the event until throttledTouchmoves intervals expires and | |
| 2010 // receive an ack from render. | |
| 2011 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); | |
| 2012 MoveTouchPoint(0, 0, 50); | |
| 2013 EXPECT_TRUE(HasPendingAsyncTouchMove()); | |
| 2014 EXPECT_EQ(0U, queued_event_count()); | |
| 2015 EXPECT_EQ(0U, GetAndResetSentEventCount()); | |
| 2016 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 2017 EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count()); | |
| 2018 | |
| 2019 // Send pending_async_touch_move_ when we receive an ack back from render. | |
| 2020 SendUncancelableTouchMoveEventAck(); | |
| 2021 EXPECT_FALSE(HasPendingAsyncTouchMove()); | |
| 2022 EXPECT_EQ(0U, queued_event_count()); | |
| 2023 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 2024 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 2025 EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count()); | |
| 2026 } | |
| 2027 | |
| 2028 // Ensure that even when we receive the ack from render, we still need to wait | |
| 2029 // for the interval expires to send the next async touchmove once the scroll | |
| 2030 // starts. | |
| 2031 TEST_F(TouchEventQueueTest, SendNextAsyncTouchMoveAfterAckAndTimeExpire) { | |
| 2032 // Process a TouchStart | |
| 2033 PressTouchPoint(0, 1); | |
| 2034 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 2035 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 2036 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 2037 | |
| 2038 // Initiate async touchmove dispatch after the start of a scroll sequence. | |
| 2039 MoveTouchPoint(0, 0, 5); | |
| 2040 WebGestureEvent followup_scroll; | |
| 2041 followup_scroll.type = WebInputEvent::GestureScrollBegin; | |
| 2042 SetFollowupEvent(followup_scroll); | |
| 2043 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 2044 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 2045 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 2046 | |
| 2047 MoveTouchPoint(0, 0, 10); | |
| 2048 followup_scroll.type = WebInputEvent::GestureScrollUpdate; | |
| 2049 SetFollowupEvent(followup_scroll); | |
| 2050 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 2051 EXPECT_FALSE(HasPendingAsyncTouchMove()); | |
| 2052 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 2053 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 2054 | |
| 2055 // Dispatch the touch move event when sufficient time has passed. | |
| 2056 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); | |
| 2057 MoveTouchPoint(0, 0, 40); | |
| 2058 EXPECT_FALSE(HasPendingAsyncTouchMove()); | |
| 2059 EXPECT_FALSE(sent_event().cancelable); | |
| 2060 // When we dispatch an async touchmove, we do not put it back to the queue | |
| 2061 // any more and we will ack to client right away. | |
| 2062 EXPECT_EQ(0U, queued_event_count()); | |
| 2063 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 2064 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 2065 EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count()); | |
| 2066 | |
| 2067 // We receive an ack back from render but the time interval is not expired, | |
| 2068 // so we do not dispatch the touch move event. | |
| 2069 SendUncancelableTouchMoveEventAck(); | |
| 2070 EXPECT_EQ(0U, uncancelable_touch_moves_pending_ack_count()); | |
| 2071 MoveTouchPoint(0, 0, 50); | |
| 2072 EXPECT_TRUE(HasPendingAsyncTouchMove()); | |
| 2073 EXPECT_EQ(0U, queued_event_count()); | |
| 2074 EXPECT_EQ(0U, GetAndResetSentEventCount()); | |
| 2075 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 2076 | |
| 2077 // Dispatch the touch move when sufficient time has passed. | |
| 2078 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); | |
| 2079 MoveTouchPoint(0, 0, 50); | |
| 2080 EXPECT_FALSE(HasPendingAsyncTouchMove()); | |
| 2081 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type); | |
| 2082 EXPECT_FALSE(sent_event().cancelable); | |
| 2083 EXPECT_EQ(0U, queued_event_count()); | |
| 2084 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 2085 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 2086 EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count()); | |
| 2087 } | |
| 2088 | |
| 2089 TEST_F(TouchEventQueueTest, AsyncTouchFlushedByNonTouchMove) { | |
| 2090 // Process a TouchStart | |
| 2091 PressTouchPoint(0, 1); | |
| 2092 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 2093 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 2094 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 2095 | |
| 2096 // Initiate async touchmove dispatch after the start of a scroll sequence. | |
| 2097 MoveTouchPoint(0, 0, 5); | |
| 2098 WebGestureEvent followup_scroll; | |
| 2099 followup_scroll.type = WebInputEvent::GestureScrollBegin; | |
| 2100 SetFollowupEvent(followup_scroll); | |
| 2101 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 2102 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 2103 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 2104 | |
| 2105 MoveTouchPoint(0, 0, 10); | |
| 2106 followup_scroll.type = WebInputEvent::GestureScrollUpdate; | |
| 2107 SetFollowupEvent(followup_scroll); | |
| 2108 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 2109 EXPECT_FALSE(HasPendingAsyncTouchMove()); | |
| 2110 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 2111 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 2112 | |
| 2113 // Dispatch the touch move when sufficient time has passed. | |
| 2114 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); | |
| 2115 MoveTouchPoint(0, 0, 40); | |
| 2116 EXPECT_FALSE(HasPendingAsyncTouchMove()); | |
| 2117 EXPECT_FALSE(sent_event().cancelable); | |
| 2118 // When we dispatch an async touchmove, we do not put it back to the queue | |
| 2119 // any more and we will ack to client right away. | |
| 2120 EXPECT_EQ(0U, queued_event_count()); | |
| 2121 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 2122 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 2123 EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count()); | |
| 2124 | |
| 2125 for (int i = 0; i < 3; ++i) { | |
| 2126 // We throttle the touchmoves, put it in the pending_async_touch_move_, | |
| 2127 // do not dispatch it. | |
| 2128 MoveTouchPoint(0, 10 + 10 * i, 10 + 10 * i); | |
| 2129 EXPECT_TRUE(HasPendingAsyncTouchMove()); | |
| 2130 EXPECT_EQ(0U, queued_event_count()); | |
| 2131 EXPECT_EQ(0U, GetAndResetSentEventCount()); | |
| 2132 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 2133 EXPECT_EQ(static_cast<size_t>(i + 1), | |
| 2134 uncancelable_touch_moves_pending_ack_count()); | |
| 2135 | |
| 2136 // Send touchstart will flush pending_async_touch_move_, and increase the | |
| 2137 // count. In this case, we will first dispatch an async touchmove and | |
| 2138 // then a touchstart. For the async touchmove, we will only ack the client. | |
| 2139 PressTouchPoint(30, 30); | |
| 2140 EXPECT_FALSE(HasPendingAsyncTouchMove()); | |
| 2141 EXPECT_EQ(2U, sent_all_events().size()); | |
| 2142 EXPECT_EQ(WebInputEvent::TouchMove, sent_all_events()[0].type); | |
| 2143 EXPECT_FALSE(sent_all_events()[0].cancelable); | |
| 2144 EXPECT_EQ(10 + 10 * i, sent_all_events()[0].touches[0].position.x); | |
| 2145 EXPECT_EQ(10 + 10 * i, sent_all_events()[0].touches[0].position.y); | |
| 2146 EXPECT_EQ(static_cast<size_t>(i + 2), | |
| 2147 uncancelable_touch_moves_pending_ack_count()); | |
| 2148 EXPECT_EQ(WebInputEvent::TouchStart, sent_all_events()[1].type); | |
| 2149 EXPECT_TRUE(sent_all_events()[1].cancelable); | |
| 2150 EXPECT_EQ(2U, GetAndResetSentEventCount()); | |
| 2151 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 2152 | |
| 2153 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 2154 EXPECT_EQ(0U, queued_event_count()); | |
| 2155 EXPECT_FALSE(HasPendingAsyncTouchMove()); | |
| 2156 EXPECT_EQ(0U, GetAndResetSentEventCount()); | |
| 2157 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 2158 } | |
| 2159 | |
| 2160 EXPECT_EQ(4U, uncancelable_touch_moves_pending_ack_count()); | |
| 2161 // When we receive an ack from render we decrease the count. | |
| 2162 SendUncancelableTouchMoveEventAck(); | |
| 2163 EXPECT_EQ(3U, uncancelable_touch_moves_pending_ack_count()); | |
| 2164 EXPECT_EQ(0U, queued_event_count()); | |
| 2165 EXPECT_FALSE(HasPendingAsyncTouchMove()); | |
| 2166 | |
| 2167 // Do not dispatch the next uncancelable touchmove when we have not received | |
| 2168 // all the acks back from render. | |
| 2169 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); | |
| 2170 MoveTouchPoint(0, 20, 30); | |
| 2171 EXPECT_TRUE(HasPendingAsyncTouchMove()); | |
| 2172 EXPECT_EQ(0U, queued_event_count()); | |
| 2173 EXPECT_EQ(0U, GetAndResetSentEventCount()); | |
| 2174 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 2175 EXPECT_EQ(3U, uncancelable_touch_moves_pending_ack_count()); | |
| 2176 | |
| 2177 // Once we receive the ack from render, we do not dispatch the | |
| 2178 // pending_async_touchmove_ until the count is 0. | |
| 2179 SendUncancelableTouchMoveEventAck(); | |
| 2180 EXPECT_EQ(2U, uncancelable_touch_moves_pending_ack_count()); | |
| 2181 EXPECT_EQ(0U, queued_event_count()); | |
| 2182 EXPECT_TRUE(HasPendingAsyncTouchMove()); | |
| 2183 | |
| 2184 SendUncancelableTouchMoveEventAck(); | |
| 2185 | |
| 2186 // When we receive this ack from render, and the count is 0, so we can | |
| 2187 // dispatch the pending_async_touchmove_. | |
| 2188 SendUncancelableTouchMoveEventAck(); | |
| 2189 EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count()); | |
| 2190 EXPECT_FALSE(HasPendingAsyncTouchMove()); | |
| 2191 EXPECT_EQ(0U, queued_event_count()); | |
| 2192 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type); | |
| 2193 EXPECT_FALSE(sent_event().cancelable); | |
| 2194 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 1971 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2195 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1972 } | 2196 } |
| 1973 | 2197 |
| 1974 TEST_F(TouchEventQueueTest, TouchAbsorptionWithConsumedFirstMove) { | 2198 TEST_F(TouchEventQueueTest, TouchAbsorptionWithConsumedFirstMove) { |
| 1975 // Queue a TouchStart. | 2199 // Queue a TouchStart. |
| 1976 PressTouchPoint(0, 1); | 2200 PressTouchPoint(0, 1); |
| 1977 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2201 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1978 EXPECT_EQ(0U, queued_event_count()); | 2202 EXPECT_EQ(0U, queued_event_count()); |
| 1979 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2203 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1980 | 2204 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 2008 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 2232 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2009 EXPECT_EQ(0U, queued_event_count()); | 2233 EXPECT_EQ(0U, queued_event_count()); |
| 2010 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 2234 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 2011 } | 2235 } |
| 2012 | 2236 |
| 2013 TEST_F(TouchEventQueueTest, TouchStartCancelableDuringScroll) { | 2237 TEST_F(TouchEventQueueTest, TouchStartCancelableDuringScroll) { |
| 2014 // Queue a touchstart and touchmove that go unconsumed, transitioning to an | 2238 // Queue a touchstart and touchmove that go unconsumed, transitioning to an |
| 2015 // active scroll sequence. | 2239 // active scroll sequence. |
| 2016 PressTouchPoint(0, 1); | 2240 PressTouchPoint(0, 1); |
| 2017 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2241 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2242 EXPECT_TRUE(sent_event().cancelable); | |
| 2018 ASSERT_EQ(1U, GetAndResetSentEventCount()); | 2243 ASSERT_EQ(1U, GetAndResetSentEventCount()); |
| 2019 EXPECT_TRUE(sent_event().cancelable); | |
| 2020 | 2244 |
| 2021 MoveTouchPoint(0, 20, 5); | 2245 MoveTouchPoint(0, 20, 5); |
| 2022 EXPECT_TRUE(sent_event().cancelable); | 2246 EXPECT_TRUE(sent_event().cancelable); |
| 2023 SendGestureEvent(blink::WebInputEvent::GestureScrollBegin); | 2247 SendGestureEvent(blink::WebInputEvent::GestureScrollBegin); |
| 2024 SendGestureEvent(blink::WebInputEvent::GestureScrollUpdate); | 2248 SendGestureEvent(blink::WebInputEvent::GestureScrollUpdate); |
| 2025 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2249 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2250 EXPECT_TRUE(sent_event().cancelable); | |
| 2026 ASSERT_EQ(1U, GetAndResetSentEventCount()); | 2251 ASSERT_EQ(1U, GetAndResetSentEventCount()); |
| 2027 EXPECT_TRUE(sent_event().cancelable); | |
| 2028 | 2252 |
| 2029 // Even though scrolling has begun, touchstart events should be cancelable, | 2253 // Even though scrolling has begun, touchstart events should be cancelable, |
| 2030 // allowing, for example, customized pinch processing. | 2254 // allowing, for example, customized pinch processing. |
| 2031 PressTouchPoint(10, 11); | 2255 PressTouchPoint(10, 11); |
| 2032 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 2256 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2257 EXPECT_TRUE(sent_event().cancelable); | |
| 2033 ASSERT_EQ(1U, GetAndResetSentEventCount()); | 2258 ASSERT_EQ(1U, GetAndResetSentEventCount()); |
| 2034 EXPECT_TRUE(sent_event().cancelable); | |
| 2035 | 2259 |
| 2036 // As the touch start was consumed, touchmoves should no longer be throttled. | 2260 // As the touch start was consumed, touchmoves should no longer be throttled. |
| 2037 MoveTouchPoint(1, 11, 11); | 2261 MoveTouchPoint(1, 11, 11); |
| 2038 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 2262 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2263 EXPECT_TRUE(sent_event().cancelable); | |
| 2039 ASSERT_EQ(1U, GetAndResetSentEventCount()); | 2264 ASSERT_EQ(1U, GetAndResetSentEventCount()); |
| 2040 EXPECT_TRUE(sent_event().cancelable); | |
| 2041 | 2265 |
| 2042 // With throttling disabled, touchend and touchmove events should also be | 2266 // With throttling disabled, touchend and touchmove events should also be |
| 2043 // cancelable. | 2267 // cancelable. |
| 2044 MoveTouchPoint(1, 12, 12); | 2268 MoveTouchPoint(1, 12, 12); |
| 2045 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 2269 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2270 EXPECT_TRUE(sent_event().cancelable); | |
| 2046 ASSERT_EQ(1U, GetAndResetSentEventCount()); | 2271 ASSERT_EQ(1U, GetAndResetSentEventCount()); |
| 2047 EXPECT_TRUE(sent_event().cancelable); | |
| 2048 ReleaseTouchPoint(1); | 2272 ReleaseTouchPoint(1); |
| 2049 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 2273 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2274 EXPECT_TRUE(sent_event().cancelable); | |
| 2050 ASSERT_EQ(1U, GetAndResetSentEventCount()); | 2275 ASSERT_EQ(1U, GetAndResetSentEventCount()); |
| 2051 EXPECT_TRUE(sent_event().cancelable); | |
| 2052 | 2276 |
| 2053 // If subsequent touchmoves aren't consumed, the generated scroll events | 2277 // If subsequent touchmoves aren't consumed, the generated scroll events |
| 2054 // will restore async touch dispatch. | 2278 // will restore async touch dispatch. |
| 2055 MoveTouchPoint(0, 25, 5); | 2279 MoveTouchPoint(0, 25, 5); |
| 2056 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2280 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2057 SendGestureEvent(blink::WebInputEvent::GestureScrollUpdate); | 2281 SendGestureEvent(blink::WebInputEvent::GestureScrollUpdate); |
| 2282 EXPECT_TRUE(sent_event().cancelable); | |
| 2058 ASSERT_EQ(1U, GetAndResetSentEventCount()); | 2283 ASSERT_EQ(1U, GetAndResetSentEventCount()); |
| 2059 EXPECT_TRUE(sent_event().cancelable); | |
| 2060 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); | 2284 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); |
| 2061 MoveTouchPoint(0, 30, 5); | 2285 MoveTouchPoint(0, 30, 5); |
| 2286 SendUncancelableTouchMoveEventAck(); | |
| 2287 EXPECT_FALSE(sent_event().cancelable); | |
| 2062 ASSERT_EQ(1U, GetAndResetSentEventCount()); | 2288 ASSERT_EQ(1U, GetAndResetSentEventCount()); |
| 2063 SendTouchEventAck(INPUT_EVENT_ACK_STATE_IGNORED); | |
| 2064 EXPECT_FALSE(sent_event().cancelable); | |
| 2065 | 2289 |
| 2066 // The touchend will be uncancelable during an active scroll sequence. | 2290 // The touchend will be uncancelable during an active scroll sequence. |
| 2067 ReleaseTouchPoint(0); | 2291 ReleaseTouchPoint(0); |
| 2292 EXPECT_FALSE(sent_event().cancelable); | |
| 2068 ASSERT_EQ(1U, GetAndResetSentEventCount()); | 2293 ASSERT_EQ(1U, GetAndResetSentEventCount()); |
| 2069 EXPECT_FALSE(sent_event().cancelable); | |
| 2070 } | 2294 } |
| 2071 | 2295 |
| 2072 TEST_F(TouchEventQueueTest, UnseenTouchPointerIdsNotForwarded) { | 2296 TEST_F(TouchEventQueueTest, UnseenTouchPointerIdsNotForwarded) { |
| 2073 SyntheticWebTouchEvent event; | 2297 SyntheticWebTouchEvent event; |
| 2074 event.PressPoint(0, 0); | 2298 event.PressPoint(0, 0); |
| 2075 SendTouchEvent(event); | 2299 SendTouchEvent(event); |
| 2076 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2300 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 2077 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 2301 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2078 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2302 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2079 | 2303 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2211 PressTouchPoint(2, 2); | 2435 PressTouchPoint(2, 2); |
| 2212 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 2436 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2213 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 2437 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2214 EXPECT_EQ(0U, queued_event_count()); | 2438 EXPECT_EQ(0U, queued_event_count()); |
| 2215 EXPECT_EQ(2U, GetAndResetSentEventCount()); | 2439 EXPECT_EQ(2U, GetAndResetSentEventCount()); |
| 2216 EXPECT_EQ(2U, GetAndResetAckedEventCount()); | 2440 EXPECT_EQ(2U, GetAndResetAckedEventCount()); |
| 2217 | 2441 |
| 2218 // Move 1st touch point. | 2442 // Move 1st touch point. |
| 2219 MoveTouchPoint(0, 10, 10); | 2443 MoveTouchPoint(0, 10, 10); |
| 2220 EXPECT_EQ(1U, queued_event_count()); | 2444 EXPECT_EQ(1U, queued_event_count()); |
| 2221 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 2222 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | |
| 2223 | 2445 |
| 2224 // TouchMove should be allowed and test for touches state. | 2446 // TouchMove should be allowed and test for touches state. |
| 2225 const WebTouchEvent& event1 = sent_event(); | 2447 const WebTouchEvent& event1 = sent_event(); |
| 2226 EXPECT_EQ(WebInputEvent::TouchMove, event1.type); | 2448 EXPECT_EQ(WebInputEvent::TouchMove, event1.type); |
| 2227 EXPECT_EQ(WebTouchPoint::StateMoved, event1.touches[0].state); | 2449 EXPECT_EQ(WebTouchPoint::StateMoved, event1.touches[0].state); |
| 2228 EXPECT_EQ(WebTouchPoint::StateStationary, event1.touches[1].state); | 2450 EXPECT_EQ(WebTouchPoint::StateStationary, event1.touches[1].state); |
| 2451 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 2452 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | |
| 2229 | 2453 |
| 2230 // Do not really move any touch points, but use previous values. | 2454 // Do not really move any touch points, but use previous values. |
| 2231 MoveTouchPoint(0, 10, 10); | 2455 MoveTouchPoint(0, 10, 10); |
| 2232 ChangeTouchPointRadius(1, 1, 1); | 2456 ChangeTouchPointRadius(1, 1, 1); |
| 2233 MoveTouchPoint(1, 2, 2); | 2457 MoveTouchPoint(1, 2, 2); |
| 2234 EXPECT_EQ(2U, queued_event_count()); | 2458 EXPECT_EQ(2U, queued_event_count()); |
| 2235 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 2459 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 2236 | 2460 |
| 2237 // Receive an ACK for 1st TouchMove. | 2461 // Receive an ACK for 1st TouchMove. |
| 2238 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 2462 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2239 | 2463 |
| 2240 // Tries to forward TouchMove but should be filtered | 2464 // Tries to forward TouchMove but should be filtered |
| 2241 // when none of the touch points have changed. | 2465 // when none of the touch points have changed. |
| 2242 EXPECT_EQ(0U, queued_event_count()); | 2466 EXPECT_EQ(0U, queued_event_count()); |
| 2243 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 2467 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 2244 EXPECT_EQ(4U, GetAndResetAckedEventCount()); | 2468 EXPECT_EQ(4U, GetAndResetAckedEventCount()); |
| 2245 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); | 2469 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); |
| 2246 | 2470 |
| 2247 // Move 2nd touch point. | 2471 // Move 2nd touch point. |
| 2248 MoveTouchPoint(1, 3, 3); | 2472 MoveTouchPoint(1, 3, 3); |
| 2249 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 2473 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2250 EXPECT_EQ(0U, queued_event_count()); | 2474 EXPECT_EQ(0U, queued_event_count()); |
| 2251 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 2252 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 2253 | 2475 |
| 2254 // TouchMove should be allowed and test for touches state. | 2476 // TouchMove should be allowed and test for touches state. |
| 2255 const WebTouchEvent& event2 = sent_event(); | 2477 const WebTouchEvent& event2 = sent_event(); |
| 2256 EXPECT_EQ(WebInputEvent::TouchMove, event2.type); | 2478 EXPECT_EQ(WebInputEvent::TouchMove, event2.type); |
| 2257 EXPECT_EQ(WebTouchPoint::StateStationary, event2.touches[0].state); | 2479 EXPECT_EQ(WebTouchPoint::StateStationary, event2.touches[0].state); |
| 2258 EXPECT_EQ(WebTouchPoint::StateMoved, event2.touches[1].state); | 2480 EXPECT_EQ(WebTouchPoint::StateMoved, event2.touches[1].state); |
| 2481 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 2482 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 2259 } | 2483 } |
| 2260 | 2484 |
| 2261 } // namespace content | 2485 } // namespace content |
| OLD | NEW |