| 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 19 matching lines...) Expand all Loading... |
| 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 : sent_event_count_(0), |
| 38 acked_event_count_(0), | 38 acked_event_count_(0), |
| 39 last_acked_event_state_(INPUT_EVENT_ACK_STATE_UNKNOWN), | 39 last_acked_event_state_(INPUT_EVENT_ACK_STATE_UNKNOWN), |
| 40 slop_length_dips_(0), | 40 slop_length_dips_(0) {} |
| 41 touch_scrolling_mode_(TouchEventQueue::TOUCH_SCROLLING_MODE_DEFAULT) {} | |
| 42 | 41 |
| 43 ~TouchEventQueueTest() override {} | 42 ~TouchEventQueueTest() override {} |
| 44 | 43 |
| 45 // testing::Test | 44 // testing::Test |
| 46 void SetUp() override { ResetQueueWithConfig(CreateConfig()); } | 45 void SetUp() override { |
| 46 ResetQueueWithConfig(TouchEventQueue::Config()); |
| 47 } |
| 47 | 48 |
| 48 void TearDown() override { queue_.reset(); } | 49 void TearDown() override { queue_.reset(); } |
| 49 | 50 |
| 50 // TouchEventQueueClient | 51 // TouchEventQueueClient |
| 51 void SendTouchEventImmediately( | 52 void SendTouchEventImmediately( |
| 52 const TouchEventWithLatencyInfo& event) override { | 53 const TouchEventWithLatencyInfo& event) override { |
| 53 ++sent_event_count_; | 54 ++sent_event_count_; |
| 54 last_sent_event_ = event.event; | 55 last_sent_event_ = event.event; |
| 55 if (sync_ack_result_) { | 56 if (sync_ack_result_) { |
| 56 auto sync_ack_result = sync_ack_result_.Pass(); | 57 auto sync_ack_result = sync_ack_result_.Pass(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 71 if (followup_gesture_event_) { | 72 if (followup_gesture_event_) { |
| 72 scoped_ptr<WebGestureEvent> followup_gesture_event = | 73 scoped_ptr<WebGestureEvent> followup_gesture_event = |
| 73 followup_gesture_event_.Pass(); | 74 followup_gesture_event_.Pass(); |
| 74 queue_->OnGestureScrollEvent( | 75 queue_->OnGestureScrollEvent( |
| 75 GestureEventWithLatencyInfo(*followup_gesture_event, | 76 GestureEventWithLatencyInfo(*followup_gesture_event, |
| 76 ui::LatencyInfo())); | 77 ui::LatencyInfo())); |
| 77 } | 78 } |
| 78 } | 79 } |
| 79 | 80 |
| 80 protected: | 81 protected: |
| 81 TouchEventQueue::Config CreateConfig() { | |
| 82 TouchEventQueue::Config config; | |
| 83 config.touch_scrolling_mode = touch_scrolling_mode_; | |
| 84 return config; | |
| 85 } | |
| 86 | |
| 87 void SetTouchScrollingMode(TouchEventQueue::TouchScrollingMode mode) { | |
| 88 touch_scrolling_mode_ = mode; | |
| 89 ResetQueueWithConfig(CreateConfig()); | |
| 90 } | |
| 91 | |
| 92 void SetUpForTouchMoveSlopTesting(double slop_length_dips) { | 82 void SetUpForTouchMoveSlopTesting(double slop_length_dips) { |
| 93 slop_length_dips_ = slop_length_dips; | 83 slop_length_dips_ = slop_length_dips; |
| 94 } | 84 } |
| 95 | 85 |
| 96 void SetUpForTimeoutTesting(base::TimeDelta timeout_delay) { | 86 void SetUpForTimeoutTesting(base::TimeDelta timeout_delay) { |
| 97 TouchEventQueue::Config config = CreateConfig(); | 87 TouchEventQueue::Config config; |
| 98 config.touch_ack_timeout_delay = timeout_delay; | 88 config.touch_ack_timeout_delay = timeout_delay; |
| 99 config.touch_ack_timeout_supported = true; | 89 config.touch_ack_timeout_supported = true; |
| 100 ResetQueueWithConfig(config); | 90 ResetQueueWithConfig(config); |
| 101 } | 91 } |
| 102 | 92 |
| 103 void SendTouchEvent(WebTouchEvent event) { | 93 void SendTouchEvent(WebTouchEvent event) { |
| 104 if (slop_length_dips_) { | 94 if (slop_length_dips_) { |
| 105 event.causesScrollingIfUncanceled = false; | 95 event.causesScrollingIfUncanceled = false; |
| 106 if (WebTouchEventTraits::IsTouchSequenceStart(event)) | 96 if (WebTouchEventTraits::IsTouchSequenceStart(event)) |
| 107 anchor_ = event.touches[0].position; | 97 anchor_ = event.touches[0].position; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 size_t acked_event_count_; | 287 size_t acked_event_count_; |
| 298 WebTouchEvent last_sent_event_; | 288 WebTouchEvent last_sent_event_; |
| 299 WebTouchEvent last_acked_event_; | 289 WebTouchEvent last_acked_event_; |
| 300 InputEventAckState last_acked_event_state_; | 290 InputEventAckState last_acked_event_state_; |
| 301 SyntheticWebTouchEvent touch_event_; | 291 SyntheticWebTouchEvent touch_event_; |
| 302 scoped_ptr<WebTouchEvent> followup_touch_event_; | 292 scoped_ptr<WebTouchEvent> followup_touch_event_; |
| 303 scoped_ptr<WebGestureEvent> followup_gesture_event_; | 293 scoped_ptr<WebGestureEvent> followup_gesture_event_; |
| 304 scoped_ptr<InputEventAckState> sync_ack_result_; | 294 scoped_ptr<InputEventAckState> sync_ack_result_; |
| 305 double slop_length_dips_; | 295 double slop_length_dips_; |
| 306 gfx::PointF anchor_; | 296 gfx::PointF anchor_; |
| 307 TouchEventQueue::TouchScrollingMode touch_scrolling_mode_; | |
| 308 base::MessageLoopForUI message_loop_; | 297 base::MessageLoopForUI message_loop_; |
| 309 }; | 298 }; |
| 310 | 299 |
| 311 | 300 |
| 312 // Tests that touch-events are queued properly. | 301 // Tests that touch-events are queued properly. |
| 313 TEST_F(TouchEventQueueTest, Basic) { | 302 TEST_F(TouchEventQueueTest, Basic) { |
| 314 PressTouchPoint(1, 1); | 303 PressTouchPoint(1, 1); |
| 315 EXPECT_EQ(1U, queued_event_count()); | 304 EXPECT_EQ(1U, queued_event_count()); |
| 316 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 305 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 317 | 306 |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 970 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 982 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 971 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 983 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 972 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 984 | 973 |
| 985 ReleaseTouchPoint(0); | 974 ReleaseTouchPoint(0); |
| 986 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 975 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 987 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 976 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 988 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 977 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 989 } | 978 } |
| 990 | 979 |
| 991 // Tests that no TouchEvents are sent to renderer during scrolling. | |
| 992 TEST_F(TouchEventQueueTest, TouchCancelOnScroll) { | |
| 993 SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_TOUCHCANCEL); | |
| 994 // Queue a TouchStart. | |
| 995 PressTouchPoint(0, 1); | |
| 996 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 997 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 998 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 999 | |
| 1000 MoveTouchPoint(0, 20, 5); | |
| 1001 EXPECT_EQ(1U, queued_event_count()); | |
| 1002 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 1003 | |
| 1004 MoveTouchPoint(0, 30, 15); | |
| 1005 EXPECT_EQ(2U, queued_event_count()); | |
| 1006 EXPECT_EQ(0U, GetAndResetSentEventCount()); | |
| 1007 | |
| 1008 // Queue another TouchStart. | |
| 1009 PressTouchPoint(20, 20); | |
| 1010 EXPECT_EQ(3U, queued_event_count()); | |
| 1011 EXPECT_EQ(0U, GetAndResetSentEventCount()); | |
| 1012 EXPECT_EQ(WebInputEvent::TouchStart, latest_event().type); | |
| 1013 | |
| 1014 WebGestureEvent followup_scroll; | |
| 1015 followup_scroll.type = WebInputEvent::GestureScrollBegin; | |
| 1016 SetFollowupEvent(followup_scroll); | |
| 1017 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1018 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 1019 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 1020 EXPECT_EQ(2U, queued_event_count()); | |
| 1021 EXPECT_TRUE(sent_event().cancelable); | |
| 1022 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type); | |
| 1023 | |
| 1024 // GestureScrollUpdate inserts a synthetic TouchCancel before the TouchStart. | |
| 1025 followup_scroll.type = WebInputEvent::GestureScrollUpdate; | |
| 1026 SetFollowupEvent(followup_scroll); | |
| 1027 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1028 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 1029 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 1030 EXPECT_EQ(2U, queued_event_count()); | |
| 1031 EXPECT_EQ(WebInputEvent::TouchCancel, sent_event().type); | |
| 1032 EXPECT_FALSE(sent_event().cancelable); | |
| 1033 EXPECT_EQ(WebInputEvent::TouchStart, latest_event().type); | |
| 1034 | |
| 1035 // Acking the TouchCancel will result in dispatch of the next TouchStart. | |
| 1036 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1037 // The synthetic TouchCancel should not reach client, only the TouchStart. | |
| 1038 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 1039 EXPECT_EQ(0U, GetAndResetSentEventCount()); | |
| 1040 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type); | |
| 1041 | |
| 1042 // TouchMove should not be sent to the renderer. | |
| 1043 MoveTouchPoint(0, 30, 5); | |
| 1044 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 1045 EXPECT_EQ(0U, GetAndResetSentEventCount()); | |
| 1046 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); | |
| 1047 | |
| 1048 // GestureScrollUpdates should not change affect touch forwarding. | |
| 1049 SendGestureEvent(WebInputEvent::GestureScrollUpdate); | |
| 1050 | |
| 1051 // TouchEnd should not be sent to the renderer. | |
| 1052 ReleaseTouchPoint(0); | |
| 1053 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 1054 EXPECT_EQ(0U, GetAndResetSentEventCount()); | |
| 1055 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); | |
| 1056 | |
| 1057 ReleaseTouchPoint(0); | |
| 1058 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 1059 EXPECT_EQ(0U, GetAndResetSentEventCount()); | |
| 1060 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); | |
| 1061 | |
| 1062 // Touch events from a new gesture sequence should be forwarded normally. | |
| 1063 PressTouchPoint(80, 10); | |
| 1064 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 1065 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1066 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 1067 | |
| 1068 MoveTouchPoint(0, 80, 20); | |
| 1069 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 1070 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1071 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 1072 | |
| 1073 ReleaseTouchPoint(0); | |
| 1074 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 1075 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1076 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 1077 } | |
| 1078 | |
| 1079 // Tests that a scroll event will not insert a synthetic TouchCancel if there | |
| 1080 // was no consumer for the current touch sequence. | |
| 1081 TEST_F(TouchEventQueueTest, NoTouchCancelOnScrollIfNoConsumer) { | |
| 1082 SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_TOUCHCANCEL); | |
| 1083 | |
| 1084 // Queue a TouchStart. | |
| 1085 PressTouchPoint(0, 1); | |
| 1086 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 1087 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); | |
| 1088 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 1089 EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type); | |
| 1090 | |
| 1091 // Queue a TouchMove that turns into a GestureScrollBegin. | |
| 1092 WebGestureEvent followup_scroll; | |
| 1093 followup_scroll.type = WebInputEvent::GestureScrollBegin; | |
| 1094 SetFollowupEvent(followup_scroll); | |
| 1095 MoveTouchPoint(0, 20, 5); | |
| 1096 | |
| 1097 // The TouchMove has no consumer, and should be ack'ed immediately. However, | |
| 1098 // *no* synthetic TouchCancel should be inserted as the touch sequence | |
| 1099 // had no consumer. | |
| 1100 EXPECT_EQ(0U, queued_event_count()); | |
| 1101 EXPECT_EQ(0U, GetAndResetSentEventCount()); | |
| 1102 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 1103 EXPECT_EQ(0U, queued_event_count()); | |
| 1104 EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type); | |
| 1105 | |
| 1106 // Subsequent TouchMove's should not be sent to the renderer. | |
| 1107 MoveTouchPoint(0, 30, 5); | |
| 1108 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 1109 EXPECT_EQ(0U, GetAndResetSentEventCount()); | |
| 1110 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); | |
| 1111 | |
| 1112 // TouchEnd should not be sent to the renderer. | |
| 1113 ReleaseTouchPoint(0); | |
| 1114 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 1115 EXPECT_EQ(0U, GetAndResetSentEventCount()); | |
| 1116 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); | |
| 1117 | |
| 1118 // Touch events from a new gesture sequence should be forwarded normally. | |
| 1119 PressTouchPoint(80, 10); | |
| 1120 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 1121 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1122 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 1123 } | |
| 1124 | |
| 1125 // Tests that IsTouchStartPendingAck works correctly. | 980 // Tests that IsTouchStartPendingAck works correctly. |
| 1126 TEST_F(TouchEventQueueTest, PendingStart) { | 981 TEST_F(TouchEventQueueTest, PendingStart) { |
| 1127 | 982 |
| 1128 EXPECT_FALSE(IsPendingAckTouchStart()); | 983 EXPECT_FALSE(IsPendingAckTouchStart()); |
| 1129 | 984 |
| 1130 // Send the touchstart for one point (#1). | 985 // Send the touchstart for one point (#1). |
| 1131 PressTouchPoint(1, 1); | 986 PressTouchPoint(1, 1); |
| 1132 EXPECT_EQ(1U, queued_event_count()); | 987 EXPECT_EQ(1U, queued_event_count()); |
| 1133 EXPECT_TRUE(IsPendingAckTouchStart()); | 988 EXPECT_TRUE(IsPendingAckTouchStart()); |
| 1134 | 989 |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1707 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1562 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1708 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); | 1563 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); |
| 1709 | 1564 |
| 1710 // Neither should any further touchmoves be forwarded. | 1565 // Neither should any further touchmoves be forwarded. |
| 1711 MoveTouchPoint(1, 25, 0); | 1566 MoveTouchPoint(1, 25, 0); |
| 1712 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1567 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1713 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1568 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1714 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); | 1569 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); |
| 1715 } | 1570 } |
| 1716 | 1571 |
| 1717 TEST_F(TouchEventQueueTest, SyncTouchMoveDoesntCancelTouchOnScroll) { | |
| 1718 SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_SYNC_TOUCHMOVE); | |
| 1719 // Queue a TouchStart. | |
| 1720 PressTouchPoint(0, 1); | |
| 1721 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 1722 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1723 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 1724 | |
| 1725 MoveTouchPoint(0, 20, 5); | |
| 1726 EXPECT_EQ(1U, queued_event_count()); | |
| 1727 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 1728 | |
| 1729 // GestureScrollBegin doesn't insert a synthetic TouchCancel. | |
| 1730 WebGestureEvent followup_scroll; | |
| 1731 followup_scroll.type = WebInputEvent::GestureScrollBegin; | |
| 1732 SetFollowupEvent(followup_scroll); | |
| 1733 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1734 EXPECT_EQ(0U, GetAndResetSentEventCount()); | |
| 1735 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 1736 EXPECT_EQ(0U, queued_event_count()); | |
| 1737 } | |
| 1738 | |
| 1739 TEST_F(TouchEventQueueTest, AsyncTouch) { | 1572 TEST_F(TouchEventQueueTest, AsyncTouch) { |
| 1740 SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE); | |
| 1741 | |
| 1742 // Queue a TouchStart. | 1573 // Queue a TouchStart. |
| 1743 PressTouchPoint(0, 1); | 1574 PressTouchPoint(0, 1); |
| 1744 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1575 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1745 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1576 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1746 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1577 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1747 | 1578 |
| 1748 for (int i = 0; i < 3; ++i) { | 1579 for (int i = 0; i < 3; ++i) { |
| 1749 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, | 1580 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, |
| 1750 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1581 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1751 | 1582 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1763 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1594 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1764 EXPECT_TRUE(HasPendingAsyncTouchMove()); | 1595 EXPECT_TRUE(HasPendingAsyncTouchMove()); |
| 1765 EXPECT_EQ(0U, queued_event_count()); | 1596 EXPECT_EQ(0U, queued_event_count()); |
| 1766 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1597 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1767 } | 1598 } |
| 1768 } | 1599 } |
| 1769 | 1600 |
| 1770 // Ensure that touchmove's are appropriately throttled during a typical | 1601 // Ensure that touchmove's are appropriately throttled during a typical |
| 1771 // scroll sequences that transitions between scrolls consumed and unconsumed. | 1602 // scroll sequences that transitions between scrolls consumed and unconsumed. |
| 1772 TEST_F(TouchEventQueueTest, AsyncTouchThrottledAfterScroll) { | 1603 TEST_F(TouchEventQueueTest, AsyncTouchThrottledAfterScroll) { |
| 1773 SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE); | |
| 1774 | |
| 1775 // Process a TouchStart | 1604 // Process a TouchStart |
| 1776 PressTouchPoint(0, 1); | 1605 PressTouchPoint(0, 1); |
| 1777 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1606 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1778 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1607 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1779 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1608 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1780 | 1609 |
| 1781 // Now send the first touch move and associated GestureScrollBegin. | 1610 // Now send the first touch move and associated GestureScrollBegin. |
| 1782 MoveTouchPoint(0, 0, 5); | 1611 MoveTouchPoint(0, 0, 5); |
| 1783 WebGestureEvent followup_scroll; | 1612 WebGestureEvent followup_scroll; |
| 1784 followup_scroll.type = WebInputEvent::GestureScrollBegin; | 1613 followup_scroll.type = WebInputEvent::GestureScrollBegin; |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1960 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1789 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1961 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1790 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1962 | 1791 |
| 1963 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1792 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1964 EXPECT_EQ(0U, queued_event_count()); | 1793 EXPECT_EQ(0U, queued_event_count()); |
| 1965 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1794 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1966 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1795 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1967 } | 1796 } |
| 1968 | 1797 |
| 1969 TEST_F(TouchEventQueueTest, AsyncTouchFlushedByTouchEnd) { | 1798 TEST_F(TouchEventQueueTest, AsyncTouchFlushedByTouchEnd) { |
| 1970 SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE); | |
| 1971 | |
| 1972 PressTouchPoint(0, 0); | 1799 PressTouchPoint(0, 0); |
| 1973 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1800 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1974 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1801 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1975 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1802 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1976 | 1803 |
| 1977 // Initiate async touchmove dispatch after the start of a scroll sequence. | 1804 // Initiate async touchmove dispatch after the start of a scroll sequence. |
| 1978 MoveTouchPoint(0, 0, 5); | 1805 MoveTouchPoint(0, 0, 5); |
| 1979 WebGestureEvent followup_scroll; | 1806 WebGestureEvent followup_scroll; |
| 1980 followup_scroll.type = WebInputEvent::GestureScrollBegin; | 1807 followup_scroll.type = WebInputEvent::GestureScrollBegin; |
| 1981 SetFollowupEvent(followup_scroll); | 1808 SetFollowupEvent(followup_scroll); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2017 // Touchend is not cancelable during async touch dispatch. | 1844 // Touchend is not cancelable during async touch dispatch. |
| 2018 SendTouchEventAck(INPUT_EVENT_ACK_STATE_IGNORED); | 1845 SendTouchEventAck(INPUT_EVENT_ACK_STATE_IGNORED); |
| 2019 EXPECT_EQ(WebInputEvent::TouchEnd, sent_event().type); | 1846 EXPECT_EQ(WebInputEvent::TouchEnd, sent_event().type); |
| 2020 EXPECT_FALSE(sent_event().cancelable); | 1847 EXPECT_FALSE(sent_event().cancelable); |
| 2021 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1848 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 2022 } | 1849 } |
| 2023 | 1850 |
| 2024 // Ensure that async touch dispatch and touch ack timeout interactions work | 1851 // Ensure that async touch dispatch and touch ack timeout interactions work |
| 2025 // appropriately. | 1852 // appropriately. |
| 2026 TEST_F(TouchEventQueueTest, AsyncTouchWithAckTimeout) { | 1853 TEST_F(TouchEventQueueTest, AsyncTouchWithAckTimeout) { |
| 2027 SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE); | |
| 2028 SetUpForTimeoutTesting(DefaultTouchTimeoutDelay()); | 1854 SetUpForTimeoutTesting(DefaultTouchTimeoutDelay()); |
| 2029 | 1855 |
| 2030 // The touchstart should start the timeout. | 1856 // The touchstart should start the timeout. |
| 2031 PressTouchPoint(0, 0); | 1857 PressTouchPoint(0, 0); |
| 2032 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1858 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 2033 EXPECT_TRUE(IsTimeoutRunning()); | 1859 EXPECT_TRUE(IsTimeoutRunning()); |
| 2034 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1860 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2035 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1861 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2036 EXPECT_FALSE(IsTimeoutRunning()); | 1862 EXPECT_FALSE(IsTimeoutRunning()); |
| 2037 | 1863 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2100 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1926 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2101 MoveTouchPoint(0, 25, 5); | 1927 MoveTouchPoint(0, 25, 5); |
| 2102 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 1928 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
| 2103 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1929 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2104 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1930 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 2105 } | 1931 } |
| 2106 | 1932 |
| 2107 // Ensure that if the touch ack for an async touchmove triggers a follow-up | 1933 // Ensure that if the touch ack for an async touchmove triggers a follow-up |
| 2108 // touch event, that follow-up touch will be forwarded appropriately. | 1934 // touch event, that follow-up touch will be forwarded appropriately. |
| 2109 TEST_F(TouchEventQueueTest, AsyncTouchWithTouchCancelAfterAck) { | 1935 TEST_F(TouchEventQueueTest, AsyncTouchWithTouchCancelAfterAck) { |
| 2110 SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE); | |
| 2111 | |
| 2112 PressTouchPoint(0, 0); | 1936 PressTouchPoint(0, 0); |
| 2113 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1937 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 2114 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1938 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2115 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1939 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2116 | 1940 |
| 2117 // The start of a scroll gesture should trigger async touch event dispatch. | 1941 // The start of a scroll gesture should trigger async touch event dispatch. |
| 2118 MoveTouchPoint(0, 1, 1); | 1942 MoveTouchPoint(0, 1, 1); |
| 2119 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1943 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 2120 WebGestureEvent followup_scroll; | 1944 WebGestureEvent followup_scroll; |
| 2121 followup_scroll.type = WebInputEvent::GestureScrollBegin; | 1945 followup_scroll.type = WebInputEvent::GestureScrollBegin; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2155 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1979 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2156 EXPECT_EQ(0U, queued_event_count()); | 1980 EXPECT_EQ(0U, queued_event_count()); |
| 2157 EXPECT_EQ(WebInputEvent::TouchCancel, acked_event().type); | 1981 EXPECT_EQ(WebInputEvent::TouchCancel, acked_event().type); |
| 2158 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1982 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2159 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1983 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 2160 } | 1984 } |
| 2161 | 1985 |
| 2162 // Ensure that the async touch is fully reset if the touch sequence restarts | 1986 // Ensure that the async touch is fully reset if the touch sequence restarts |
| 2163 // without properly terminating. | 1987 // without properly terminating. |
| 2164 TEST_F(TouchEventQueueTest, AsyncTouchWithHardTouchStartReset) { | 1988 TEST_F(TouchEventQueueTest, AsyncTouchWithHardTouchStartReset) { |
| 2165 SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE); | |
| 2166 | |
| 2167 PressTouchPoint(0, 0); | 1989 PressTouchPoint(0, 0); |
| 2168 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1990 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 2169 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1991 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2170 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1992 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2171 | 1993 |
| 2172 // Trigger async touchmove dispatch. | 1994 // Trigger async touchmove dispatch. |
| 2173 MoveTouchPoint(0, 1, 1); | 1995 MoveTouchPoint(0, 1, 1); |
| 2174 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1996 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 2175 WebGestureEvent followup_scroll; | 1997 WebGestureEvent followup_scroll; |
| 2176 followup_scroll.type = WebInputEvent::GestureScrollBegin; | 1998 followup_scroll.type = WebInputEvent::GestureScrollBegin; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2194 ResetTouchEvent(); | 2016 ResetTouchEvent(); |
| 2195 | 2017 |
| 2196 PressTouchPoint(0, 0); | 2018 PressTouchPoint(0, 0); |
| 2197 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2019 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 2198 EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type); | 2020 EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type); |
| 2199 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2021 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2200 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2022 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2201 } | 2023 } |
| 2202 | 2024 |
| 2203 TEST_F(TouchEventQueueTest, TouchAbsorptionWithConsumedFirstMove) { | 2025 TEST_F(TouchEventQueueTest, TouchAbsorptionWithConsumedFirstMove) { |
| 2204 SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE); | |
| 2205 | |
| 2206 // Queue a TouchStart. | 2026 // Queue a TouchStart. |
| 2207 PressTouchPoint(0, 1); | 2027 PressTouchPoint(0, 1); |
| 2208 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2028 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2209 EXPECT_EQ(0U, queued_event_count()); | 2029 EXPECT_EQ(0U, queued_event_count()); |
| 2210 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2030 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2211 | 2031 |
| 2212 MoveTouchPoint(0, 20, 5); | 2032 MoveTouchPoint(0, 20, 5); |
| 2213 SendGestureEvent(blink::WebInputEvent::GestureScrollBegin); | 2033 SendGestureEvent(blink::WebInputEvent::GestureScrollBegin); |
| 2214 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 2034 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2215 EXPECT_EQ(0U, queued_event_count()); | 2035 EXPECT_EQ(0U, queued_event_count()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2235 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2055 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 2236 | 2056 |
| 2237 // Touch move event is throttled. | 2057 // Touch move event is throttled. |
| 2238 MoveTouchPoint(0, 60, 5); | 2058 MoveTouchPoint(0, 60, 5); |
| 2239 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 2059 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2240 EXPECT_EQ(0U, queued_event_count()); | 2060 EXPECT_EQ(0U, queued_event_count()); |
| 2241 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 2061 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 2242 } | 2062 } |
| 2243 | 2063 |
| 2244 TEST_F(TouchEventQueueTest, TouchStartCancelableDuringScroll) { | 2064 TEST_F(TouchEventQueueTest, TouchStartCancelableDuringScroll) { |
| 2245 SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE); | |
| 2246 | |
| 2247 // Queue a touchstart and touchmove that go unconsumed, transitioning to an | 2065 // Queue a touchstart and touchmove that go unconsumed, transitioning to an |
| 2248 // active scroll sequence. | 2066 // active scroll sequence. |
| 2249 PressTouchPoint(0, 1); | 2067 PressTouchPoint(0, 1); |
| 2250 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2068 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2251 ASSERT_EQ(1U, GetAndResetSentEventCount()); | 2069 ASSERT_EQ(1U, GetAndResetSentEventCount()); |
| 2252 EXPECT_TRUE(sent_event().cancelable); | 2070 EXPECT_TRUE(sent_event().cancelable); |
| 2253 | 2071 |
| 2254 MoveTouchPoint(0, 20, 5); | 2072 MoveTouchPoint(0, 20, 5); |
| 2255 EXPECT_TRUE(sent_event().cancelable); | 2073 EXPECT_TRUE(sent_event().cancelable); |
| 2256 SendGestureEvent(blink::WebInputEvent::GestureScrollBegin); | 2074 SendGestureEvent(blink::WebInputEvent::GestureScrollBegin); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2444 // Receive an ACK for previous TouchMove. | 2262 // Receive an ACK for previous TouchMove. |
| 2445 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 2263 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2446 | 2264 |
| 2447 // TouchMove is sent, but pointer state should be StateStationary. | 2265 // TouchMove is sent, but pointer state should be StateStationary. |
| 2448 const WebTouchEvent& event4 = sent_event(); | 2266 const WebTouchEvent& event4 = sent_event(); |
| 2449 EXPECT_EQ(WebInputEvent::TouchMove, event4.type); | 2267 EXPECT_EQ(WebInputEvent::TouchMove, event4.type); |
| 2450 EXPECT_EQ(WebTouchPoint::StateStationary, event4.touches[0].state); | 2268 EXPECT_EQ(WebTouchPoint::StateStationary, event4.touches[0].state); |
| 2451 } | 2269 } |
| 2452 | 2270 |
| 2453 } // namespace content | 2271 } // namespace content |
| OLD | NEW |