| 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 "content/browser/renderer_host/input/touch_event_queue.h" | 5 #include "content/browser/renderer_host/input/touch_event_queue.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
| 17 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
| 18 #include "content/browser/renderer_host/input/timeout_monitor.h" | 18 #include "content/browser/renderer_host/input/timeout_monitor.h" |
| 19 #include "content/common/input/synthetic_web_input_event_builders.h" | 19 #include "content/common/input/synthetic_web_input_event_builders.h" |
| 20 #include "content/common/input/web_touch_event_traits.h" | 20 #include "content/common/input/web_touch_event_traits.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 22 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 22 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
| 23 #include "ui/events/base_event_utils.h" |
| 23 | 24 |
| 24 using blink::WebGestureEvent; | 25 using blink::WebGestureEvent; |
| 25 using blink::WebInputEvent; | 26 using blink::WebInputEvent; |
| 26 using blink::WebTouchEvent; | 27 using blink::WebTouchEvent; |
| 27 using blink::WebTouchPoint; | 28 using blink::WebTouchPoint; |
| 28 | 29 |
| 29 namespace content { | 30 namespace content { |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 const double kMinSecondsBetweenThrottledTouchmoves = 0.2; | 33 const double kMinSecondsBetweenThrottledTouchmoves = 0.2; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 if (delta.LengthSquared() > slop_length_dips_ * slop_length_dips_) | 119 if (delta.LengthSquared() > slop_length_dips_ * slop_length_dips_) |
| 119 event.movedBeyondSlopRegion = true; | 120 event.movedBeyondSlopRegion = true; |
| 120 } | 121 } |
| 121 } else { | 122 } else { |
| 122 event.movedBeyondSlopRegion = event.type == WebInputEvent::TouchMove; | 123 event.movedBeyondSlopRegion = event.type == WebInputEvent::TouchMove; |
| 123 } | 124 } |
| 124 queue_->QueueEvent(TouchEventWithLatencyInfo(event, ui::LatencyInfo())); | 125 queue_->QueueEvent(TouchEventWithLatencyInfo(event, ui::LatencyInfo())); |
| 125 } | 126 } |
| 126 | 127 |
| 127 void SendGestureEvent(WebInputEvent::Type type) { | 128 void SendGestureEvent(WebInputEvent::Type type) { |
| 128 WebGestureEvent event; | 129 WebGestureEvent event(type, WebInputEvent::NoModifiers, |
| 129 event.type = type; | 130 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); |
| 130 queue_->OnGestureScrollEvent( | 131 queue_->OnGestureScrollEvent( |
| 131 GestureEventWithLatencyInfo(event, ui::LatencyInfo())); | 132 GestureEventWithLatencyInfo(event, ui::LatencyInfo())); |
| 132 } | 133 } |
| 133 | 134 |
| 134 void SendTouchEventAck(InputEventAckState ack_result) { | 135 void SendTouchEventAck(InputEventAckState ack_result) { |
| 135 DCHECK(!sent_events_ids_.empty()); | 136 DCHECK(!sent_events_ids_.empty()); |
| 136 queue_->ProcessTouchAck(ack_result, ui::LatencyInfo(), | 137 queue_->ProcessTouchAck(ack_result, ui::LatencyInfo(), |
| 137 sent_events_ids_.front()); | 138 sent_events_ids_.front()); |
| 138 sent_events_ids_.pop_front(); | 139 sent_events_ids_.pop_front(); |
| 139 } | 140 } |
| 140 | 141 |
| 141 void SendTouchEventAckWithID(InputEventAckState ack_result, | 142 void SendTouchEventAckWithID(InputEventAckState ack_result, |
| 142 int unique_event_id) { | 143 int unique_event_id) { |
| 143 queue_->ProcessTouchAck(ack_result, ui::LatencyInfo(), unique_event_id); | 144 queue_->ProcessTouchAck(ack_result, ui::LatencyInfo(), unique_event_id); |
| 144 sent_events_ids_.erase(std::remove(sent_events_ids_.begin(), | 145 sent_events_ids_.erase(std::remove(sent_events_ids_.begin(), |
| 145 sent_events_ids_.end(), unique_event_id), | 146 sent_events_ids_.end(), unique_event_id), |
| 146 sent_events_ids_.end()); | 147 sent_events_ids_.end()); |
| 147 } | 148 } |
| 148 | 149 |
| 149 void SendGestureEventAck(WebInputEvent::Type type, | 150 void SendGestureEventAck(WebInputEvent::Type type, |
| 150 InputEventAckState ack_result) { | 151 InputEventAckState ack_result) { |
| 151 blink::WebGestureEvent gesture_event; | 152 GestureEventWithLatencyInfo event( |
| 152 gesture_event.type = type; | 153 type, blink::WebInputEvent::NoModifiers, |
| 153 GestureEventWithLatencyInfo event(gesture_event, ui::LatencyInfo()); | 154 ui::EventTimeStampToSeconds(ui::EventTimeForNow()), ui::LatencyInfo()); |
| 154 queue_->OnGestureEventAck(event, ack_result); | 155 queue_->OnGestureEventAck(event, ack_result); |
| 155 } | 156 } |
| 156 | 157 |
| 157 void SetFollowupEvent(const WebTouchEvent& event) { | 158 void SetFollowupEvent(const WebTouchEvent& event) { |
| 158 followup_touch_event_.reset(new WebTouchEvent(event)); | 159 followup_touch_event_.reset(new WebTouchEvent(event)); |
| 159 } | 160 } |
| 160 | 161 |
| 161 void SetFollowupEvent(const WebGestureEvent& event) { | 162 void SetFollowupEvent(const WebGestureEvent& event) { |
| 162 followup_gesture_event_.reset(new WebGestureEvent(event)); | 163 followup_gesture_event_.reset(new WebGestureEvent(event)); |
| 163 } | 164 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 void CancelTouchPoint(int index) { | 236 void CancelTouchPoint(int index) { |
| 236 touch_event_.CancelPoint(index); | 237 touch_event_.CancelPoint(index); |
| 237 SendTouchEvent(); | 238 SendTouchEvent(); |
| 238 } | 239 } |
| 239 | 240 |
| 240 void PrependTouchScrollNotification() { | 241 void PrependTouchScrollNotification() { |
| 241 queue_->PrependTouchScrollNotification(); | 242 queue_->PrependTouchScrollNotification(); |
| 242 } | 243 } |
| 243 | 244 |
| 244 void AdvanceTouchTime(double seconds) { | 245 void AdvanceTouchTime(double seconds) { |
| 245 touch_event_.timeStampSeconds += seconds; | 246 touch_event_.setTimeStampSeconds(touch_event_.timeStampSeconds + seconds); |
| 246 } | 247 } |
| 247 | 248 |
| 248 void ResetTouchEvent() { | 249 void ResetTouchEvent() { |
| 249 touch_event_ = SyntheticWebTouchEvent(); | 250 touch_event_ = SyntheticWebTouchEvent(); |
| 250 } | 251 } |
| 251 | 252 |
| 252 size_t GetAndResetAckedEventCount() { | 253 size_t GetAndResetAckedEventCount() { |
| 253 size_t count = acked_event_count_; | 254 size_t count = acked_event_count_; |
| 254 acked_event_count_ = 0; | 255 acked_event_count_ = 0; |
| 255 return count; | 256 return count; |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 // Tests that touch-event's enqueued via a touch ack are properly handled. | 836 // Tests that touch-event's enqueued via a touch ack are properly handled. |
| 836 TEST_F(TouchEventQueueTest, AckWithFollowupEvents) { | 837 TEST_F(TouchEventQueueTest, AckWithFollowupEvents) { |
| 837 // Queue a touch down. | 838 // Queue a touch down. |
| 838 PressTouchPoint(1, 1); | 839 PressTouchPoint(1, 1); |
| 839 EXPECT_EQ(1U, queued_event_count()); | 840 EXPECT_EQ(1U, queued_event_count()); |
| 840 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 841 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 841 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 842 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
| 842 | 843 |
| 843 // Create a touch event that will be queued synchronously by a touch ack. | 844 // Create a touch event that will be queued synchronously by a touch ack. |
| 844 // Note, this will be triggered by all subsequent touch acks. | 845 // Note, this will be triggered by all subsequent touch acks. |
| 845 WebTouchEvent followup_event; | 846 WebTouchEvent followup_event( |
| 846 followup_event.type = WebInputEvent::TouchMove; | 847 WebInputEvent::TouchMove, WebInputEvent::NoModifiers, |
| 848 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); |
| 847 followup_event.touchesLength = 1; | 849 followup_event.touchesLength = 1; |
| 848 followup_event.touches[0].id = 0; | 850 followup_event.touches[0].id = 0; |
| 849 followup_event.touches[0].state = WebTouchPoint::StateMoved; | 851 followup_event.touches[0].state = WebTouchPoint::StateMoved; |
| 850 SetFollowupEvent(followup_event); | 852 SetFollowupEvent(followup_event); |
| 851 | 853 |
| 852 // Receive an ACK for the press. This should cause the followup touch-move to | 854 // Receive an ACK for the press. This should cause the followup touch-move to |
| 853 // be sent to the renderer. | 855 // be sent to the renderer. |
| 854 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 856 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
| 855 EXPECT_EQ(1U, queued_event_count()); | 857 EXPECT_EQ(1U, queued_event_count()); |
| 856 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 858 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 CancelTouchPoint(0); | 906 CancelTouchPoint(0); |
| 905 EXPECT_EQ(0U, queued_event_count()); | 907 EXPECT_EQ(0U, queued_event_count()); |
| 906 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 908 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 907 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 909 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 908 } | 910 } |
| 909 | 911 |
| 910 // Tests that followup events triggered by an immediate ack from | 912 // Tests that followup events triggered by an immediate ack from |
| 911 // TouchEventQueue::QueueEvent() are properly handled. | 913 // TouchEventQueue::QueueEvent() are properly handled. |
| 912 TEST_F(TouchEventQueueTest, ImmediateAckWithFollowupEvents) { | 914 TEST_F(TouchEventQueueTest, ImmediateAckWithFollowupEvents) { |
| 913 // Create a touch event that will be queued synchronously by a touch ack. | 915 // Create a touch event that will be queued synchronously by a touch ack. |
| 914 WebTouchEvent followup_event; | 916 WebTouchEvent followup_event( |
| 915 followup_event.type = WebInputEvent::TouchStart; | 917 WebInputEvent::TouchStart, WebInputEvent::NoModifiers, |
| 918 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); |
| 916 followup_event.touchesLength = 1; | 919 followup_event.touchesLength = 1; |
| 917 followup_event.touches[0].id = 1; | 920 followup_event.touches[0].id = 1; |
| 918 followup_event.touches[0].state = WebTouchPoint::StatePressed; | 921 followup_event.touches[0].state = WebTouchPoint::StatePressed; |
| 919 SetFollowupEvent(followup_event); | 922 SetFollowupEvent(followup_event); |
| 920 | 923 |
| 921 // Now, enqueue a stationary touch that will not be forwarded. This should be | 924 // Now, enqueue a stationary touch that will not be forwarded. This should be |
| 922 // immediately ack'ed with "NO_CONSUMER_EXISTS". The followup event should | 925 // immediately ack'ed with "NO_CONSUMER_EXISTS". The followup event should |
| 923 // then be enqueued and immediately sent to the renderer. | 926 // then be enqueued and immediately sent to the renderer. |
| 924 WebTouchEvent stationary_event; | 927 WebTouchEvent stationary_event( |
| 928 WebInputEvent::TouchMove, WebInputEvent::NoModifiers, |
| 929 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); |
| 930 ; |
| 925 stationary_event.touchesLength = 1; | 931 stationary_event.touchesLength = 1; |
| 926 stationary_event.type = WebInputEvent::TouchMove; | |
| 927 stationary_event.touches[0].id = 1; | 932 stationary_event.touches[0].id = 1; |
| 928 stationary_event.touches[0].state = WebTouchPoint::StateStationary; | 933 stationary_event.touches[0].state = WebTouchPoint::StateStationary; |
| 929 SendTouchEvent(stationary_event); | 934 SendTouchEvent(stationary_event); |
| 930 | 935 |
| 931 EXPECT_EQ(1U, queued_event_count()); | 936 EXPECT_EQ(1U, queued_event_count()); |
| 932 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 937 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 933 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 938 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 934 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); | 939 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); |
| 935 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type); | 940 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type); |
| 936 } | 941 } |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1234 // turns into a scroll gesture sequence. | 1239 // turns into a scroll gesture sequence. |
| 1235 TEST_F(TouchEventQueueTest, TouchTimeoutWithFollowupGesture) { | 1240 TEST_F(TouchEventQueueTest, TouchTimeoutWithFollowupGesture) { |
| 1236 SetUpForTimeoutTesting(); | 1241 SetUpForTimeoutTesting(); |
| 1237 | 1242 |
| 1238 // Queue a TouchStart. | 1243 // Queue a TouchStart. |
| 1239 PressTouchPoint(0, 1); | 1244 PressTouchPoint(0, 1); |
| 1240 EXPECT_TRUE(IsTimeoutRunning()); | 1245 EXPECT_TRUE(IsTimeoutRunning()); |
| 1241 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1246 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1242 | 1247 |
| 1243 // The cancelled sequence may turn into a scroll gesture. | 1248 // The cancelled sequence may turn into a scroll gesture. |
| 1244 WebGestureEvent followup_scroll; | 1249 WebGestureEvent followup_scroll( |
| 1245 followup_scroll.type = WebInputEvent::GestureScrollBegin; | 1250 WebInputEvent::GestureScrollBegin, WebInputEvent::NoModifiers, |
| 1251 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); |
| 1246 SetFollowupEvent(followup_scroll); | 1252 SetFollowupEvent(followup_scroll); |
| 1247 | 1253 |
| 1248 // Delay the ack. | 1254 // Delay the ack. |
| 1249 RunTasksAndWait(DefaultTouchTimeoutDelay() * 2); | 1255 RunTasksAndWait(DefaultTouchTimeoutDelay() * 2); |
| 1250 | 1256 |
| 1251 // The timeout should have fired, disabling touch forwarding until both acks | 1257 // The timeout should have fired, disabling touch forwarding until both acks |
| 1252 // are received, acking the timed out event. | 1258 // are received, acking the timed out event. |
| 1253 EXPECT_FALSE(IsTimeoutRunning()); | 1259 EXPECT_FALSE(IsTimeoutRunning()); |
| 1254 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1260 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1255 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1261 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1289 // significantly delayed. | 1295 // significantly delayed. |
| 1290 TEST_F(TouchEventQueueTest, TouchTimeoutWithFollowupGestureAndDelayedAck) { | 1296 TEST_F(TouchEventQueueTest, TouchTimeoutWithFollowupGestureAndDelayedAck) { |
| 1291 SetUpForTimeoutTesting(); | 1297 SetUpForTimeoutTesting(); |
| 1292 | 1298 |
| 1293 // Queue a TouchStart. | 1299 // Queue a TouchStart. |
| 1294 PressTouchPoint(0, 1); | 1300 PressTouchPoint(0, 1); |
| 1295 EXPECT_TRUE(IsTimeoutRunning()); | 1301 EXPECT_TRUE(IsTimeoutRunning()); |
| 1296 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1302 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1297 | 1303 |
| 1298 // The cancelled sequence may turn into a scroll gesture. | 1304 // The cancelled sequence may turn into a scroll gesture. |
| 1299 WebGestureEvent followup_scroll; | 1305 WebGestureEvent followup_scroll( |
| 1300 followup_scroll.type = WebInputEvent::GestureScrollBegin; | 1306 WebInputEvent::GestureScrollBegin, WebInputEvent::NoModifiers, |
| 1307 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); |
| 1301 SetFollowupEvent(followup_scroll); | 1308 SetFollowupEvent(followup_scroll); |
| 1302 | 1309 |
| 1303 // Delay the ack. | 1310 // Delay the ack. |
| 1304 RunTasksAndWait(DefaultTouchTimeoutDelay() * 2); | 1311 RunTasksAndWait(DefaultTouchTimeoutDelay() * 2); |
| 1305 | 1312 |
| 1306 // The timeout should have fired, disabling touch forwarding until both acks | 1313 // The timeout should have fired, disabling touch forwarding until both acks |
| 1307 // are received and acking the timed out event. | 1314 // are received and acking the timed out event. |
| 1308 EXPECT_FALSE(IsTimeoutRunning()); | 1315 EXPECT_FALSE(IsTimeoutRunning()); |
| 1309 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1316 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1310 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1317 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1573 | 1580 |
| 1574 // Tests that secondary touch points can be forwarded after scrolling begins | 1581 // Tests that secondary touch points can be forwarded after scrolling begins |
| 1575 // while first touch point has no consumer. | 1582 // while first touch point has no consumer. |
| 1576 TEST_F(TouchEventQueueTest, NoForwardingAfterScrollWithNoTouchConsumers) { | 1583 TEST_F(TouchEventQueueTest, NoForwardingAfterScrollWithNoTouchConsumers) { |
| 1577 // Queue a TouchStart. | 1584 // Queue a TouchStart. |
| 1578 PressTouchPoint(0, 0); | 1585 PressTouchPoint(0, 0); |
| 1579 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); | 1586 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); |
| 1580 ASSERT_EQ(1U, GetAndResetSentEventCount()); | 1587 ASSERT_EQ(1U, GetAndResetSentEventCount()); |
| 1581 ASSERT_EQ(1U, GetAndResetAckedEventCount()); | 1588 ASSERT_EQ(1U, GetAndResetAckedEventCount()); |
| 1582 | 1589 |
| 1583 WebGestureEvent followup_scroll; | 1590 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin, |
| 1584 followup_scroll.type = WebInputEvent::GestureScrollBegin; | 1591 WebInputEvent::NoModifiers, |
| 1592 WebInputEvent::TimeStampForTesting); |
| 1585 SetFollowupEvent(followup_scroll); | 1593 SetFollowupEvent(followup_scroll); |
| 1586 MoveTouchPoint(0, 20, 5); | 1594 MoveTouchPoint(0, 20, 5); |
| 1587 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1595 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1588 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1596 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1589 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); | 1597 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); |
| 1590 | 1598 |
| 1591 // The secondary pointer press should be forwarded. | 1599 // The secondary pointer press should be forwarded. |
| 1592 PressTouchPoint(20, 0); | 1600 PressTouchPoint(20, 0); |
| 1593 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 1601 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
| 1594 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1602 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1634 // scroll sequences that transitions between scrolls consumed and unconsumed. | 1642 // scroll sequences that transitions between scrolls consumed and unconsumed. |
| 1635 TEST_F(TouchEventQueueTest, AsyncTouchThrottledAfterScroll) { | 1643 TEST_F(TouchEventQueueTest, AsyncTouchThrottledAfterScroll) { |
| 1636 // Process a TouchStart | 1644 // Process a TouchStart |
| 1637 PressTouchPoint(0, 1); | 1645 PressTouchPoint(0, 1); |
| 1638 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1646 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1639 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1647 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1640 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1648 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1641 | 1649 |
| 1642 // Now send the first touch move and associated GestureScrollBegin. | 1650 // Now send the first touch move and associated GestureScrollBegin. |
| 1643 MoveTouchPoint(0, 0, 5); | 1651 MoveTouchPoint(0, 0, 5); |
| 1644 WebGestureEvent followup_scroll; | 1652 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin, |
| 1645 followup_scroll.type = WebInputEvent::GestureScrollBegin; | 1653 WebInputEvent::NoModifiers, |
| 1654 WebInputEvent::TimeStampForTesting); |
| 1646 SetFollowupEvent(followup_scroll); | 1655 SetFollowupEvent(followup_scroll); |
| 1647 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1656 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1648 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1657 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1649 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1658 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1650 SendGestureEventAck(WebInputEvent::GestureScrollBegin, | 1659 SendGestureEventAck(WebInputEvent::GestureScrollBegin, |
| 1651 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1660 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1652 | 1661 |
| 1653 // Send the second touch move and associated GestureScrollUpdate, but don't | 1662 // Send the second touch move and associated GestureScrollUpdate, but don't |
| 1654 // ACK the gesture event yet. | 1663 // ACK the gesture event yet. |
| 1655 MoveTouchPoint(0, 0, 50); | 1664 MoveTouchPoint(0, 0, 50); |
| 1656 followup_scroll.type = WebInputEvent::GestureScrollUpdate; | 1665 followup_scroll.setType(WebInputEvent::GestureScrollUpdate); |
| 1657 SetFollowupEvent(followup_scroll); | 1666 SetFollowupEvent(followup_scroll); |
| 1658 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1667 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1659 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1668 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1660 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1669 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1661 | 1670 |
| 1662 // Now queue a second touchmove and verify it's not (yet) dispatched. | 1671 // Now queue a second touchmove and verify it's not (yet) dispatched. |
| 1663 MoveTouchPoint(0, 0, 100); | 1672 MoveTouchPoint(0, 0, 100); |
| 1664 SetFollowupEvent(followup_scroll); | 1673 SetFollowupEvent(followup_scroll); |
| 1665 EXPECT_TRUE(HasPendingAsyncTouchMove()); | 1674 EXPECT_TRUE(HasPendingAsyncTouchMove()); |
| 1666 EXPECT_EQ(0U, queued_event_count()); | 1675 EXPECT_EQ(0U, queued_event_count()); |
| 1667 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1676 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1668 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1677 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1669 | 1678 |
| 1670 // Queuing the final touchend should flush the pending async touchmove. In | 1679 // Queuing the final touchend should flush the pending async touchmove. In |
| 1671 // this case, we will first dispatch an async touchmove and then a touchend. | 1680 // this case, we will first dispatch an async touchmove and then a touchend. |
| 1672 // For the async touchmove, we will not send ack again. | 1681 // For the async touchmove, we will not send ack again. |
| 1673 ReleaseTouchPoint(0); | 1682 ReleaseTouchPoint(0); |
| 1674 followup_scroll.type = WebInputEvent::GestureScrollEnd; | 1683 followup_scroll.setType(WebInputEvent::GestureScrollEnd); |
| 1675 SetFollowupEvent(followup_scroll); | 1684 SetFollowupEvent(followup_scroll); |
| 1676 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 1685 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
| 1677 EXPECT_EQ(2U, all_sent_events().size()); | 1686 EXPECT_EQ(2U, all_sent_events().size()); |
| 1678 EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[0].type); | 1687 EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[0].type); |
| 1679 EXPECT_NE(WebInputEvent::Blocking, all_sent_events()[0].dispatchType); | 1688 EXPECT_NE(WebInputEvent::Blocking, all_sent_events()[0].dispatchType); |
| 1680 EXPECT_EQ(WebInputEvent::TouchEnd, all_sent_events()[1].type); | 1689 EXPECT_EQ(WebInputEvent::TouchEnd, all_sent_events()[1].type); |
| 1681 EXPECT_NE(WebInputEvent::Blocking, all_sent_events()[1].dispatchType); | 1690 EXPECT_NE(WebInputEvent::Blocking, all_sent_events()[1].dispatchType); |
| 1682 EXPECT_EQ(2U, GetAndResetSentEventCount()); | 1691 EXPECT_EQ(2U, GetAndResetSentEventCount()); |
| 1683 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 1692 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
| 1684 EXPECT_EQ(1U, queued_event_count()); | 1693 EXPECT_EQ(1U, queued_event_count()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1697 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, | 1706 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, |
| 1698 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1707 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1699 | 1708 |
| 1700 // Start a new touch sequence and verify that throttling has been reset. | 1709 // Start a new touch sequence and verify that throttling has been reset. |
| 1701 // Touch moves after the start of scrolling will again be throttled. | 1710 // Touch moves after the start of scrolling will again be throttled. |
| 1702 PressTouchPoint(0, 0); | 1711 PressTouchPoint(0, 0); |
| 1703 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1712 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1704 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1713 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1705 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1714 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1706 MoveTouchPoint(0, 0, 5); | 1715 MoveTouchPoint(0, 0, 5); |
| 1707 followup_scroll.type = WebInputEvent::GestureScrollBegin; | 1716 followup_scroll.setType(WebInputEvent::GestureScrollBegin); |
| 1708 SetFollowupEvent(followup_scroll); | 1717 SetFollowupEvent(followup_scroll); |
| 1709 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1718 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1710 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1719 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1711 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1720 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1712 | 1721 |
| 1713 MoveTouchPoint(0, 0, 6); | 1722 MoveTouchPoint(0, 0, 6); |
| 1714 followup_scroll.type = WebInputEvent::GestureScrollUpdate; | 1723 followup_scroll.setType(WebInputEvent::GestureScrollUpdate); |
| 1715 SetFollowupEvent(followup_scroll); | 1724 SetFollowupEvent(followup_scroll); |
| 1716 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1725 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1717 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 1726 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
| 1718 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1727 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1719 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1728 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1720 | 1729 |
| 1721 MoveTouchPoint(0, 0, 10); | 1730 MoveTouchPoint(0, 0, 10); |
| 1722 EXPECT_TRUE(HasPendingAsyncTouchMove()); | 1731 EXPECT_TRUE(HasPendingAsyncTouchMove()); |
| 1723 EXPECT_EQ(0U, queued_event_count()); | 1732 EXPECT_EQ(0U, queued_event_count()); |
| 1724 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1733 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1819 } | 1828 } |
| 1820 | 1829 |
| 1821 TEST_F(TouchEventQueueTest, AsyncTouchFlushedByTouchEnd) { | 1830 TEST_F(TouchEventQueueTest, AsyncTouchFlushedByTouchEnd) { |
| 1822 PressTouchPoint(0, 0); | 1831 PressTouchPoint(0, 0); |
| 1823 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1832 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1824 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1833 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1825 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1834 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1826 | 1835 |
| 1827 // Initiate async touchmove dispatch after the start of a scroll sequence. | 1836 // Initiate async touchmove dispatch after the start of a scroll sequence. |
| 1828 MoveTouchPoint(0, 0, 5); | 1837 MoveTouchPoint(0, 0, 5); |
| 1829 WebGestureEvent followup_scroll; | 1838 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin, |
| 1830 followup_scroll.type = WebInputEvent::GestureScrollBegin; | 1839 WebInputEvent::NoModifiers, |
| 1840 WebInputEvent::TimeStampForTesting); |
| 1831 SetFollowupEvent(followup_scroll); | 1841 SetFollowupEvent(followup_scroll); |
| 1832 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1842 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1833 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1843 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1834 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1844 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1835 | 1845 |
| 1836 MoveTouchPoint(0, 0, 10); | 1846 MoveTouchPoint(0, 0, 10); |
| 1837 followup_scroll.type = WebInputEvent::GestureScrollUpdate; | 1847 followup_scroll.setType(WebInputEvent::GestureScrollUpdate); |
| 1838 SetFollowupEvent(followup_scroll); | 1848 SetFollowupEvent(followup_scroll); |
| 1839 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1849 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1840 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1850 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1841 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1851 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1842 | 1852 |
| 1843 // Now queue a second touchmove and verify it's not (yet) dispatched. | 1853 // Now queue a second touchmove and verify it's not (yet) dispatched. |
| 1844 MoveTouchPoint(0, 0, 100); | 1854 MoveTouchPoint(0, 0, 100); |
| 1845 EXPECT_TRUE(HasPendingAsyncTouchMove()); | 1855 EXPECT_TRUE(HasPendingAsyncTouchMove()); |
| 1846 EXPECT_EQ(0U, queued_event_count()); | 1856 EXPECT_EQ(0U, queued_event_count()); |
| 1847 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1857 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1881 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1891 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1882 EXPECT_TRUE(IsTimeoutRunning()); | 1892 EXPECT_TRUE(IsTimeoutRunning()); |
| 1883 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1893 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1884 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1894 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1885 EXPECT_FALSE(IsTimeoutRunning()); | 1895 EXPECT_FALSE(IsTimeoutRunning()); |
| 1886 | 1896 |
| 1887 // The start of a scroll gesture should trigger async touch event dispatch. | 1897 // The start of a scroll gesture should trigger async touch event dispatch. |
| 1888 MoveTouchPoint(0, 1, 1); | 1898 MoveTouchPoint(0, 1, 1); |
| 1889 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1899 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1890 EXPECT_TRUE(IsTimeoutRunning()); | 1900 EXPECT_TRUE(IsTimeoutRunning()); |
| 1891 WebGestureEvent followup_scroll; | 1901 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin, |
| 1892 followup_scroll.type = WebInputEvent::GestureScrollBegin; | 1902 WebInputEvent::NoModifiers, |
| 1903 WebInputEvent::TimeStampForTesting); |
| 1893 SetFollowupEvent(followup_scroll); | 1904 SetFollowupEvent(followup_scroll); |
| 1894 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1905 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1895 EXPECT_FALSE(IsTimeoutRunning()); | 1906 EXPECT_FALSE(IsTimeoutRunning()); |
| 1896 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1907 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1897 | 1908 |
| 1898 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, | 1909 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, |
| 1899 INPUT_EVENT_ACK_STATE_CONSUMED); | 1910 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 1900 | 1911 |
| 1901 // An async touch should fire after the throttling interval has expired, but | 1912 // An async touch should fire after the throttling interval has expired, but |
| 1902 // it should not start the touch ack timeout. | 1913 // it should not start the touch ack timeout. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1956 // touch event, that follow-up touch will be forwarded appropriately. | 1967 // touch event, that follow-up touch will be forwarded appropriately. |
| 1957 TEST_F(TouchEventQueueTest, AsyncTouchWithTouchCancelAfterAck) { | 1968 TEST_F(TouchEventQueueTest, AsyncTouchWithTouchCancelAfterAck) { |
| 1958 PressTouchPoint(0, 0); | 1969 PressTouchPoint(0, 0); |
| 1959 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1970 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1960 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1971 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1961 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1972 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1962 | 1973 |
| 1963 // The start of a scroll gesture should trigger async touch event dispatch. | 1974 // The start of a scroll gesture should trigger async touch event dispatch. |
| 1964 MoveTouchPoint(0, 1, 1); | 1975 MoveTouchPoint(0, 1, 1); |
| 1965 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1976 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1966 WebGestureEvent followup_scroll; | 1977 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin, |
| 1967 followup_scroll.type = WebInputEvent::GestureScrollBegin; | 1978 WebInputEvent::NoModifiers, |
| 1979 WebInputEvent::TimeStampForTesting); |
| 1968 SetFollowupEvent(followup_scroll); | 1980 SetFollowupEvent(followup_scroll); |
| 1969 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1981 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1970 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1982 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1971 EXPECT_EQ(0U, queued_event_count()); | 1983 EXPECT_EQ(0U, queued_event_count()); |
| 1972 | 1984 |
| 1973 SendGestureEvent(WebInputEvent::GestureScrollUpdate); | 1985 SendGestureEvent(WebInputEvent::GestureScrollUpdate); |
| 1974 | 1986 |
| 1975 // The async touchmove should be ack'ed immediately, but not forwarded. | 1987 // The async touchmove should be ack'ed immediately, but not forwarded. |
| 1976 // However, because the ack triggers a touchcancel, both the pending touch and | 1988 // However, because the ack triggers a touchcancel, both the pending touch and |
| 1977 // the queued touchcancel should be flushed. | 1989 // the queued touchcancel should be flushed. |
| 1978 WebTouchEvent followup_cancel; | 1990 WebTouchEvent followup_cancel(WebInputEvent::TouchCancel, |
| 1979 followup_cancel.type = WebInputEvent::TouchCancel; | 1991 WebInputEvent::NoModifiers, |
| 1992 WebInputEvent::TimeStampForTesting); |
| 1980 followup_cancel.touchesLength = 1; | 1993 followup_cancel.touchesLength = 1; |
| 1981 followup_cancel.touches[0].state = WebTouchPoint::StateCancelled; | 1994 followup_cancel.touches[0].state = WebTouchPoint::StateCancelled; |
| 1982 SetFollowupEvent(followup_cancel); | 1995 SetFollowupEvent(followup_cancel); |
| 1983 MoveTouchPoint(0, 5, 5); | 1996 MoveTouchPoint(0, 5, 5); |
| 1984 EXPECT_EQ(1U, queued_event_count()); | 1997 EXPECT_EQ(1U, queued_event_count()); |
| 1985 EXPECT_EQ(2U, all_sent_events().size()); | 1998 EXPECT_EQ(2U, all_sent_events().size()); |
| 1986 EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[0].type); | 1999 EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[0].type); |
| 1987 EXPECT_NE(WebInputEvent::Blocking, all_sent_events()[0].dispatchType); | 2000 EXPECT_NE(WebInputEvent::Blocking, all_sent_events()[0].dispatchType); |
| 1988 EXPECT_EQ(WebInputEvent::TouchCancel, all_sent_events()[1].type); | 2001 EXPECT_EQ(WebInputEvent::TouchCancel, all_sent_events()[1].type); |
| 1989 EXPECT_NE(WebInputEvent::Blocking, all_sent_events()[1].dispatchType); | 2002 EXPECT_NE(WebInputEvent::Blocking, all_sent_events()[1].dispatchType); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2005 // without properly terminating. | 2018 // without properly terminating. |
| 2006 TEST_F(TouchEventQueueTest, AsyncTouchWithHardTouchStartReset) { | 2019 TEST_F(TouchEventQueueTest, AsyncTouchWithHardTouchStartReset) { |
| 2007 PressTouchPoint(0, 0); | 2020 PressTouchPoint(0, 0); |
| 2008 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2021 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 2009 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2022 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2010 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2023 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2011 | 2024 |
| 2012 // Trigger async touchmove dispatch. | 2025 // Trigger async touchmove dispatch. |
| 2013 MoveTouchPoint(0, 1, 1); | 2026 MoveTouchPoint(0, 1, 1); |
| 2014 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2027 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 2015 WebGestureEvent followup_scroll; | 2028 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin, |
| 2016 followup_scroll.type = WebInputEvent::GestureScrollBegin; | 2029 WebInputEvent::NoModifiers, |
| 2030 WebInputEvent::TimeStampForTesting); |
| 2017 SetFollowupEvent(followup_scroll); | 2031 SetFollowupEvent(followup_scroll); |
| 2018 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2032 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2019 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2033 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2020 EXPECT_EQ(0U, queued_event_count()); | 2034 EXPECT_EQ(0U, queued_event_count()); |
| 2021 SendGestureEvent(WebInputEvent::GestureScrollUpdate); | 2035 SendGestureEvent(WebInputEvent::GestureScrollUpdate); |
| 2022 | 2036 |
| 2023 // The async touchmove should be immediately ack'ed but delivery is deferred. | 2037 // The async touchmove should be immediately ack'ed but delivery is deferred. |
| 2024 MoveTouchPoint(0, 2, 2); | 2038 MoveTouchPoint(0, 2, 2); |
| 2025 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 2039 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 2026 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2040 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2045 // starts. | 2059 // starts. |
| 2046 TEST_F(TouchEventQueueTest, SendNextThrottledAsyncTouchMoveAfterAck) { | 2060 TEST_F(TouchEventQueueTest, SendNextThrottledAsyncTouchMoveAfterAck) { |
| 2047 // Process a TouchStart | 2061 // Process a TouchStart |
| 2048 PressTouchPoint(0, 1); | 2062 PressTouchPoint(0, 1); |
| 2049 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2063 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 2050 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2064 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2051 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2065 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2052 | 2066 |
| 2053 // Initiate async touchmove dispatch after the start of a scroll sequence. | 2067 // Initiate async touchmove dispatch after the start of a scroll sequence. |
| 2054 MoveTouchPoint(0, 0, 5); | 2068 MoveTouchPoint(0, 0, 5); |
| 2055 WebGestureEvent followup_scroll; | 2069 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin, |
| 2056 followup_scroll.type = WebInputEvent::GestureScrollBegin; | 2070 WebInputEvent::NoModifiers, |
| 2071 WebInputEvent::TimeStampForTesting); |
| 2057 SetFollowupEvent(followup_scroll); | 2072 SetFollowupEvent(followup_scroll); |
| 2058 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2073 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2059 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2074 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 2060 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2075 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2061 | 2076 |
| 2062 MoveTouchPoint(0, 0, 10); | 2077 MoveTouchPoint(0, 0, 10); |
| 2063 followup_scroll.type = WebInputEvent::GestureScrollUpdate; | 2078 followup_scroll.setType(WebInputEvent::GestureScrollUpdate); |
| 2064 SetFollowupEvent(followup_scroll); | 2079 SetFollowupEvent(followup_scroll); |
| 2065 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2080 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2066 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 2081 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
| 2067 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2082 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 2068 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2083 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2069 | 2084 |
| 2070 // We set the next touch event time to be after the throttled interval. | 2085 // We set the next touch event time to be after the throttled interval. |
| 2071 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); | 2086 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); |
| 2072 // Dispatch the touch move event when sufficient time has passed. | 2087 // Dispatch the touch move event when sufficient time has passed. |
| 2073 MoveTouchPoint(0, 0, 40); | 2088 MoveTouchPoint(0, 0, 40); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2106 // starts. | 2121 // starts. |
| 2107 TEST_F(TouchEventQueueTest, SendNextAsyncTouchMoveAfterAckAndTimeExpire) { | 2122 TEST_F(TouchEventQueueTest, SendNextAsyncTouchMoveAfterAckAndTimeExpire) { |
| 2108 // Process a TouchStart | 2123 // Process a TouchStart |
| 2109 PressTouchPoint(0, 1); | 2124 PressTouchPoint(0, 1); |
| 2110 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2125 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 2111 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2126 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2112 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2127 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2113 | 2128 |
| 2114 // Initiate async touchmove dispatch after the start of a scroll sequence. | 2129 // Initiate async touchmove dispatch after the start of a scroll sequence. |
| 2115 MoveTouchPoint(0, 0, 5); | 2130 MoveTouchPoint(0, 0, 5); |
| 2116 WebGestureEvent followup_scroll; | 2131 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin, |
| 2117 followup_scroll.type = WebInputEvent::GestureScrollBegin; | 2132 WebInputEvent::NoModifiers, |
| 2133 WebInputEvent::TimeStampForTesting); |
| 2118 SetFollowupEvent(followup_scroll); | 2134 SetFollowupEvent(followup_scroll); |
| 2119 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2135 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2120 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2136 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 2121 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2137 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2122 | 2138 |
| 2123 MoveTouchPoint(0, 0, 10); | 2139 MoveTouchPoint(0, 0, 10); |
| 2124 followup_scroll.type = WebInputEvent::GestureScrollUpdate; | 2140 followup_scroll.setType(WebInputEvent::GestureScrollUpdate); |
| 2125 SetFollowupEvent(followup_scroll); | 2141 SetFollowupEvent(followup_scroll); |
| 2126 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2142 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2127 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 2143 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
| 2128 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2144 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 2129 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2145 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2130 | 2146 |
| 2131 // Dispatch the touch move event when sufficient time has passed. | 2147 // Dispatch the touch move event when sufficient time has passed. |
| 2132 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); | 2148 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); |
| 2133 MoveTouchPoint(0, 0, 40); | 2149 MoveTouchPoint(0, 0, 40); |
| 2134 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 2150 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2164 | 2180 |
| 2165 TEST_F(TouchEventQueueTest, AsyncTouchFlushedByNonTouchMove) { | 2181 TEST_F(TouchEventQueueTest, AsyncTouchFlushedByNonTouchMove) { |
| 2166 // Process a TouchStart | 2182 // Process a TouchStart |
| 2167 PressTouchPoint(0, 1); | 2183 PressTouchPoint(0, 1); |
| 2168 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2184 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 2169 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2185 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2170 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2186 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2171 | 2187 |
| 2172 // Initiate async touchmove dispatch after the start of a scroll sequence. | 2188 // Initiate async touchmove dispatch after the start of a scroll sequence. |
| 2173 MoveTouchPoint(0, 0, 5); | 2189 MoveTouchPoint(0, 0, 5); |
| 2174 WebGestureEvent followup_scroll; | 2190 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin, |
| 2175 followup_scroll.type = WebInputEvent::GestureScrollBegin; | 2191 WebInputEvent::NoModifiers, |
| 2192 WebInputEvent::TimeStampForTesting); |
| 2176 SetFollowupEvent(followup_scroll); | 2193 SetFollowupEvent(followup_scroll); |
| 2177 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2194 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2178 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2195 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 2179 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2196 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2180 | 2197 |
| 2181 MoveTouchPoint(0, 0, 10); | 2198 MoveTouchPoint(0, 0, 10); |
| 2182 followup_scroll.type = WebInputEvent::GestureScrollUpdate; | 2199 followup_scroll.setType(WebInputEvent::GestureScrollUpdate); |
| 2183 SetFollowupEvent(followup_scroll); | 2200 SetFollowupEvent(followup_scroll); |
| 2184 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2201 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2185 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 2202 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
| 2186 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2203 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 2187 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2204 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2188 | 2205 |
| 2189 // Dispatch the touch move when sufficient time has passed. | 2206 // Dispatch the touch move when sufficient time has passed. |
| 2190 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); | 2207 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); |
| 2191 MoveTouchPoint(0, 0, 40); | 2208 MoveTouchPoint(0, 0, 40); |
| 2192 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 2209 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2278 // starts. | 2295 // starts. |
| 2279 TEST_F(TouchEventQueueTest, DoNotIncreaseIfClientConsumeAsyncTouchMove) { | 2296 TEST_F(TouchEventQueueTest, DoNotIncreaseIfClientConsumeAsyncTouchMove) { |
| 2280 // Process a TouchStart | 2297 // Process a TouchStart |
| 2281 PressTouchPoint(0, 1); | 2298 PressTouchPoint(0, 1); |
| 2282 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2299 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 2283 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2300 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2284 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2301 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2285 | 2302 |
| 2286 // Initiate async touchmove dispatch after the start of a scroll sequence. | 2303 // Initiate async touchmove dispatch after the start of a scroll sequence. |
| 2287 MoveTouchPoint(0, 0, 5); | 2304 MoveTouchPoint(0, 0, 5); |
| 2288 WebGestureEvent followup_scroll; | 2305 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin, |
| 2289 followup_scroll.type = WebInputEvent::GestureScrollBegin; | 2306 WebInputEvent::NoModifiers, |
| 2307 WebInputEvent::TimeStampForTesting); |
| 2290 SetFollowupEvent(followup_scroll); | 2308 SetFollowupEvent(followup_scroll); |
| 2291 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2309 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2292 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2310 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 2293 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2311 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2294 | 2312 |
| 2295 MoveTouchPoint(0, 0, 10); | 2313 MoveTouchPoint(0, 0, 10); |
| 2296 followup_scroll.type = WebInputEvent::GestureScrollUpdate; | 2314 followup_scroll.setType(WebInputEvent::GestureScrollUpdate); |
| 2297 SetFollowupEvent(followup_scroll); | 2315 SetFollowupEvent(followup_scroll); |
| 2298 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2316 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2299 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 2317 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
| 2300 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2318 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 2301 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2319 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2302 | 2320 |
| 2303 // Dispatch the touch move event when sufficient time has passed. | 2321 // Dispatch the touch move event when sufficient time has passed. |
| 2304 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); | 2322 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); |
| 2305 MoveTouchPoint(0, 0, 40); | 2323 MoveTouchPoint(0, 0, 40); |
| 2306 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 2324 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2352 | 2370 |
| 2353 // Even if the first touchmove event was consumed, subsequent unconsumed | 2371 // Even if the first touchmove event was consumed, subsequent unconsumed |
| 2354 // touchmove events should trigger scrolling. | 2372 // touchmove events should trigger scrolling. |
| 2355 MoveTouchPoint(0, 60, 5); | 2373 MoveTouchPoint(0, 60, 5); |
| 2356 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 2374 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2357 EXPECT_EQ(0U, queued_event_count()); | 2375 EXPECT_EQ(0U, queued_event_count()); |
| 2358 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType); | 2376 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType); |
| 2359 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2377 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 2360 | 2378 |
| 2361 MoveTouchPoint(0, 20, 5); | 2379 MoveTouchPoint(0, 20, 5); |
| 2362 WebGestureEvent followup_scroll; | 2380 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollUpdate, |
| 2363 followup_scroll.type = WebInputEvent::GestureScrollUpdate; | 2381 WebInputEvent::NoModifiers, |
| 2382 WebInputEvent::TimeStampForTesting); |
| 2364 SetFollowupEvent(followup_scroll); | 2383 SetFollowupEvent(followup_scroll); |
| 2365 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2384 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2366 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, | 2385 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, |
| 2367 INPUT_EVENT_ACK_STATE_CONSUMED); | 2386 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2368 EXPECT_EQ(0U, queued_event_count()); | 2387 EXPECT_EQ(0U, queued_event_count()); |
| 2369 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType); | 2388 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType); |
| 2370 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2389 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 2371 | 2390 |
| 2372 // Touch move event is throttled. | 2391 // Touch move event is throttled. |
| 2373 MoveTouchPoint(0, 60, 5); | 2392 MoveTouchPoint(0, 60, 5); |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2732 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type); | 2751 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type); |
| 2733 EXPECT_FALSE(sent_event().touchStartOrFirstTouchMove); | 2752 EXPECT_FALSE(sent_event().touchStartOrFirstTouchMove); |
| 2734 | 2753 |
| 2735 ReleaseTouchPoint(0); | 2754 ReleaseTouchPoint(0); |
| 2736 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 2755 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2737 EXPECT_EQ(WebInputEvent::TouchEnd, sent_event().type); | 2756 EXPECT_EQ(WebInputEvent::TouchEnd, sent_event().type); |
| 2738 EXPECT_FALSE(sent_event().touchStartOrFirstTouchMove); | 2757 EXPECT_FALSE(sent_event().touchStartOrFirstTouchMove); |
| 2739 } | 2758 } |
| 2740 | 2759 |
| 2741 } // namespace content | 2760 } // namespace content |
| OLD | NEW |