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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 } | 143 } |
| 144 | 144 |
| 145 bool IsPendingAckTouchStart() const { | 145 bool IsPendingAckTouchStart() const { |
| 146 return queue_->IsPendingAckTouchStart(); | 146 return queue_->IsPendingAckTouchStart(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void OnHasTouchEventHandlers(bool has_handlers) { | 149 void OnHasTouchEventHandlers(bool has_handlers) { |
| 150 queue_->OnHasTouchEventHandlers(has_handlers); | 150 queue_->OnHasTouchEventHandlers(has_handlers); |
| 151 } | 151 } |
| 152 | 152 |
| 153 bool WillForwardTouchEvents() { | 153 bool WillForwardTouchEvents() { |
|
tdresser
2014/01/17 14:33:40
Something's wrong here...
jdduke (slow)
2014/01/17 18:29:07
lol, yeah this whole method needs to die... We sho
| |
| 154 return queue_->has_handlers_ && | 154 return queue_->touch_handling_state_ != |
| 155 !queue_->scroll_in_progress_ && | 155 TouchEventQueue::NO_TOUCH_HANDLER_FOR_GESTURE && |
| 156 !queue_->HasTimeoutEvent(); | 156 queue_->touch_handling_state_ != |
| 157 TouchEventQueue::NO_TOUCH_HANDLER_FOR_GESTURE; | |
| 157 } | 158 } |
| 158 | 159 |
| 159 bool IsTimeoutRunning() { | 160 bool IsTimeoutRunning() { |
| 160 return queue_->IsTimeoutRunningForTesting(); | 161 return queue_->IsTimeoutRunningForTesting(); |
| 161 } | 162 } |
| 162 | 163 |
| 163 size_t queued_event_count() const { | 164 size_t queued_event_count() const { |
| 164 return queue_->size(); | 165 return queue_->size(); |
| 165 } | 166 } |
| 166 | 167 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 257 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type); | 258 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type); |
| 258 | 259 |
| 259 // Flush the queue. The touch-event queue should now be emptied, but none of | 260 // Flush the queue. The touch-event queue should now be emptied, but none of |
| 260 // the queued touch-events should be sent to the renderer. | 261 // the queued touch-events should be sent to the renderer. |
| 261 OnHasTouchEventHandlers(false); | 262 OnHasTouchEventHandlers(false); |
| 262 EXPECT_EQ(0U, queued_event_count()); | 263 EXPECT_EQ(0U, queued_event_count()); |
| 263 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 264 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 264 EXPECT_EQ(31U, GetAndResetAckedEventCount()); | 265 EXPECT_EQ(31U, GetAndResetAckedEventCount()); |
| 265 } | 266 } |
| 266 | 267 |
| 268 // Tests that addition of a touch handler during a touch sequence will not cause | |
| 269 // the remaining sequence to be forwarded. | |
| 270 TEST_F(TouchEventQueueTest, ActiveSequenceNotForwardedWhenHandlersAdded) { | |
| 271 OnHasTouchEventHandlers(false); | |
| 272 | |
| 273 // Send a touch-press event while there is no handler. | |
| 274 PressTouchPoint(1, 1); | |
| 275 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 276 EXPECT_EQ(0U, GetAndResetSentEventCount()); | |
| 277 EXPECT_EQ(0U, queued_event_count()); | |
| 278 | |
| 279 OnHasTouchEventHandlers(true); | |
| 280 | |
| 281 // The remaining touch sequence should not be forwarded. | |
| 282 MoveTouchPoint(0, 5, 5); | |
| 283 ReleaseTouchPoint(0); | |
| 284 EXPECT_EQ(2U, GetAndResetAckedEventCount()); | |
| 285 EXPECT_EQ(0U, GetAndResetSentEventCount()); | |
| 286 EXPECT_EQ(0U, queued_event_count()); | |
| 287 | |
| 288 // A new touch sequence should resume forwarding. | |
| 289 PressTouchPoint(1, 1); | |
| 290 EXPECT_EQ(1U, queued_event_count()); | |
| 291 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 292 } | |
| 293 | |
| 267 // Tests that removal of a touch handler during a touch sequence will prevent | 294 // Tests that removal of a touch handler during a touch sequence will prevent |
| 268 // the remaining sequence from being forwarded, even if another touch handler is | 295 // the remaining sequence from being forwarded, even if another touch handler is |
| 269 // registered during the same touch sequence. | 296 // registered during the same touch sequence. |
| 270 TEST_F(TouchEventQueueTest, ActiveSequenceDroppedWhenHandlersRemoved) { | 297 TEST_F(TouchEventQueueTest, ActiveSequenceDroppedWhenHandlersRemoved) { |
| 271 // Send a touch-press event. | 298 // Send a touch-press event. |
| 272 PressTouchPoint(1, 1); | 299 PressTouchPoint(1, 1); |
| 273 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 300 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 274 EXPECT_EQ(1U, queued_event_count()); | 301 EXPECT_EQ(1U, queued_event_count()); |
| 275 | 302 |
| 276 // Queue a touch-move event. | 303 // Queue a touch-move event. |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 716 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 743 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 717 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 744 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 718 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); | 745 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); |
| 719 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type); | 746 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type); |
| 720 } | 747 } |
| 721 | 748 |
| 722 // Tests basic TouchEvent forwarding suppression. | 749 // Tests basic TouchEvent forwarding suppression. |
| 723 TEST_F(TouchEventQueueTest, NoTouchBasic) { | 750 TEST_F(TouchEventQueueTest, NoTouchBasic) { |
| 724 // Disable TouchEvent forwarding. | 751 // Disable TouchEvent forwarding. |
| 725 OnHasTouchEventHandlers(false); | 752 OnHasTouchEventHandlers(false); |
| 726 MoveTouchPoint(0, 30, 5); | 753 PressTouchPoint(30, 5); |
| 727 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 754 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 728 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 755 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 729 | 756 |
| 730 // TouchMove should not be sent to renderer. | 757 // TouchMove should not be sent to renderer. |
| 731 MoveTouchPoint(0, 65, 10); | 758 MoveTouchPoint(0, 65, 10); |
| 732 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 759 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 733 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 760 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 734 | 761 |
| 735 // TouchEnd should not be sent to renderer. | 762 // TouchEnd should not be sent to renderer. |
| 736 ReleaseTouchPoint(0); | 763 ReleaseTouchPoint(0); |
| 737 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 764 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 738 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 765 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 739 | 766 |
| 740 // TouchStart should not be sent to renderer. | |
| 741 PressTouchPoint(5, 5); | |
| 742 EXPECT_EQ(0U, GetAndResetSentEventCount()); | |
| 743 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 744 | |
| 745 // Enable TouchEvent forwarding. | 767 // Enable TouchEvent forwarding. |
| 746 OnHasTouchEventHandlers(true); | 768 OnHasTouchEventHandlers(true); |
| 747 | 769 |
| 748 PressTouchPoint(80, 10); | 770 PressTouchPoint(80, 10); |
| 749 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 771 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 750 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 772 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 751 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 773 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 752 | 774 |
| 753 MoveTouchPoint(0, 80, 20); | 775 MoveTouchPoint(0, 80, 20); |
| 754 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 776 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 808 // GestureScrollUpdates should not change affect touch forwarding. | 830 // GestureScrollUpdates should not change affect touch forwarding. |
| 809 SendGestureEvent(WebInputEvent::GestureScrollUpdate); | 831 SendGestureEvent(WebInputEvent::GestureScrollUpdate); |
| 810 EXPECT_FALSE(WillForwardTouchEvents()); | 832 EXPECT_FALSE(WillForwardTouchEvents()); |
| 811 | 833 |
| 812 // TouchEnd should not be sent to the renderer. | 834 // TouchEnd should not be sent to the renderer. |
| 813 ReleaseTouchPoint(0); | 835 ReleaseTouchPoint(0); |
| 814 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 836 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 815 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 837 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 816 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); | 838 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); |
| 817 | 839 |
| 818 // GestureScrollEnd will resume the sending of TouchEvents to renderer. | 840 ReleaseTouchPoint(0); |
| 819 SendGestureEvent(blink::WebInputEvent::GestureScrollEnd); | 841 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 820 EXPECT_TRUE(WillForwardTouchEvents()); | 842 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 843 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); | |
| 821 | 844 |
| 822 // Now TouchEvents should be forwarded normally. | 845 // Touch events from a new gesture sequence should be forwarded normally. |
| 823 PressTouchPoint(80, 10); | 846 PressTouchPoint(80, 10); |
| 824 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 847 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 825 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 848 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 826 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 849 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 827 | 850 |
| 828 MoveTouchPoint(0, 80, 20); | 851 MoveTouchPoint(0, 80, 20); |
| 829 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 852 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 830 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 853 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 831 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 854 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 832 | 855 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 945 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 968 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 946 | 969 |
| 947 // Ack'ing the original event should trigger a cancel event. | 970 // Ack'ing the original event should trigger a cancel event. |
| 948 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 971 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 949 EXPECT_FALSE(IsTimeoutRunning()); | 972 EXPECT_FALSE(IsTimeoutRunning()); |
| 950 EXPECT_FALSE(WillForwardTouchEvents()); | 973 EXPECT_FALSE(WillForwardTouchEvents()); |
| 951 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 974 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
| 952 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 975 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 953 | 976 |
| 954 // Touch events should not be forwarded until we receive the cancel acks. | 977 // Touch events should not be forwarded until we receive the cancel acks. |
| 955 PressTouchPoint(0, 1); | 978 MoveTouchPoint(0, 1, 1); |
| 956 ASSERT_EQ(0U, GetAndResetSentEventCount()); | 979 ASSERT_EQ(0U, GetAndResetSentEventCount()); |
| 957 ASSERT_EQ(1U, GetAndResetAckedEventCount()); | 980 ASSERT_EQ(1U, GetAndResetAckedEventCount()); |
| 958 | 981 |
| 982 ReleaseTouchPoint(0); | |
| 983 ASSERT_EQ(0U, GetAndResetSentEventCount()); | |
| 984 ASSERT_EQ(1U, GetAndResetAckedEventCount()); | |
| 985 | |
| 959 // The synthetic TouchCancel ack should not reach the client, but should | 986 // The synthetic TouchCancel ack should not reach the client, but should |
| 960 // resume touch forwarding. | 987 // resume touch forwarding. |
| 961 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 988 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 962 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 989 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 963 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 990 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
| 964 EXPECT_TRUE(WillForwardTouchEvents()); | |
| 965 | 991 |
| 966 // Subsequent events should be handled normally. | 992 // Subsequent events should be handled normally. |
| 967 PressTouchPoint(0, 1); | 993 PressTouchPoint(0, 1); |
| 968 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 994 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 969 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 995 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
| 996 EXPECT_TRUE(WillForwardTouchEvents()); | |
| 970 } | 997 } |
| 971 | 998 |
| 972 // Tests that the timeout is never started if the renderer consumes | 999 // Tests that the timeout is never started if the renderer consumes |
| 973 // a TouchEvent from the current touch sequence. | 1000 // a TouchEvent from the current touch sequence. |
| 974 TEST_F(TouchEventQueueTest, NoTouchTimeoutIfRendererIsConsumingGesture) { | 1001 TEST_F(TouchEventQueueTest, NoTouchTimeoutIfRendererIsConsumingGesture) { |
| 975 SetUpForTimeoutTesting(kDefaultTouchTimeoutDelayMs); | 1002 SetUpForTimeoutTesting(kDefaultTouchTimeoutDelayMs); |
| 976 | 1003 |
| 977 // Queue a TouchStart. | 1004 // Queue a TouchStart. |
| 978 PressTouchPoint(0, 1); | 1005 PressTouchPoint(0, 1); |
| 979 ASSERT_TRUE(IsTimeoutRunning()); | 1006 ASSERT_TRUE(IsTimeoutRunning()); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1065 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 1092 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
| 1066 | 1093 |
| 1067 // Ack the cancel event. Normally, this would resume touch forwarding, | 1094 // Ack the cancel event. Normally, this would resume touch forwarding, |
| 1068 // but we're still within a scroll gesture so it remains disabled. | 1095 // but we're still within a scroll gesture so it remains disabled. |
| 1069 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); | 1096 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); |
| 1070 EXPECT_FALSE(IsTimeoutRunning()); | 1097 EXPECT_FALSE(IsTimeoutRunning()); |
| 1071 EXPECT_FALSE(WillForwardTouchEvents()); | 1098 EXPECT_FALSE(WillForwardTouchEvents()); |
| 1072 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1099 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1073 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 1100 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
| 1074 | 1101 |
| 1075 // Try to forward a touch event. | 1102 // Try to forward touch events for the current sequence. |
| 1076 GetAndResetSentEventCount(); | 1103 GetAndResetSentEventCount(); |
| 1077 GetAndResetAckedEventCount(); | 1104 GetAndResetAckedEventCount(); |
| 1078 PressTouchPoint(0, 1); | 1105 MoveTouchPoint(0, 1, 1); |
| 1106 ReleaseTouchPoint(0); | |
| 1079 EXPECT_FALSE(IsTimeoutRunning()); | 1107 EXPECT_FALSE(IsTimeoutRunning()); |
| 1080 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1108 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1081 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1109 EXPECT_EQ(2U, GetAndResetAckedEventCount()); |
| 1082 | 1110 |
| 1083 // Now end the scroll sequence, resuming touch handling. | 1111 // Now end the scroll sequence, resuming touch handling. |
| 1084 SendGestureEvent(blink::WebInputEvent::GestureScrollEnd); | 1112 SendGestureEvent(blink::WebInputEvent::GestureScrollEnd); |
| 1085 EXPECT_TRUE(WillForwardTouchEvents()); | |
| 1086 PressTouchPoint(0, 1); | 1113 PressTouchPoint(0, 1); |
| 1087 EXPECT_TRUE(IsTimeoutRunning()); | 1114 EXPECT_TRUE(IsTimeoutRunning()); |
| 1115 EXPECT_TRUE(WillForwardTouchEvents()); | |
| 1088 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1116 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1089 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 1117 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
| 1090 } | 1118 } |
| 1091 | 1119 |
| 1092 // Tests that a TouchCancel timeout plays nice when the timed out touch stream | 1120 // Tests that a TouchCancel timeout plays nice when the timed out touch stream |
| 1093 // turns into a scroll gesture sequence, but the original event acks are | 1121 // turns into a scroll gesture sequence, but the original event acks are |
| 1094 // significantly delayed. | 1122 // significantly delayed. |
| 1095 TEST_F(TouchEventQueueTest, TouchTimeoutWithFollowupGestureAndDelayedAck) { | 1123 TEST_F(TouchEventQueueTest, TouchTimeoutWithFollowupGestureAndDelayedAck) { |
| 1096 SetUpForTimeoutTesting(kDefaultTouchTimeoutDelayMs); | 1124 SetUpForTimeoutTesting(kDefaultTouchTimeoutDelayMs); |
| 1097 | 1125 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1116 // The timeout should have fired, disabling touch forwarding until both acks | 1144 // The timeout should have fired, disabling touch forwarding until both acks |
| 1117 // are received and acking the timed out event. | 1145 // are received and acking the timed out event. |
| 1118 EXPECT_FALSE(IsTimeoutRunning()); | 1146 EXPECT_FALSE(IsTimeoutRunning()); |
| 1119 EXPECT_FALSE(WillForwardTouchEvents()); | 1147 EXPECT_FALSE(WillForwardTouchEvents()); |
| 1120 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1148 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1121 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1149 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1122 | 1150 |
| 1123 // Try to forward a touch event. | 1151 // Try to forward a touch event. |
| 1124 GetAndResetSentEventCount(); | 1152 GetAndResetSentEventCount(); |
| 1125 GetAndResetAckedEventCount(); | 1153 GetAndResetAckedEventCount(); |
| 1126 PressTouchPoint(0, 1); | 1154 MoveTouchPoint(0, 1, 1); |
| 1127 EXPECT_FALSE(IsTimeoutRunning()); | 1155 EXPECT_FALSE(IsTimeoutRunning()); |
| 1128 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1156 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1129 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1157 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1130 | 1158 |
| 1131 // Now end the scroll sequence. Events will not be forwarded until the two | 1159 // Now end the scroll sequence. Events will not be forwarded until the two |
| 1132 // outstanding touch acks are received. | 1160 // outstanding touch acks are received. |
| 1133 SendGestureEvent(blink::WebInputEvent::GestureScrollEnd); | 1161 SendGestureEvent(blink::WebInputEvent::GestureScrollEnd); |
| 1134 PressTouchPoint(0, 1); | 1162 MoveTouchPoint(0, 2, 2); |
| 1163 ReleaseTouchPoint(0); | |
| 1135 EXPECT_FALSE(IsTimeoutRunning()); | 1164 EXPECT_FALSE(IsTimeoutRunning()); |
| 1136 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1165 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1137 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1166 EXPECT_EQ(2U, GetAndResetAckedEventCount()); |
| 1138 | 1167 |
| 1139 // Ack the original event, triggering a cancel. | 1168 // Ack the original event, triggering a cancel. |
| 1140 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); | 1169 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); |
| 1141 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1170 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1142 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 1171 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
| 1143 | 1172 |
| 1144 // Ack the cancel event, resuming touch forwarding. | 1173 // Ack the cancel event, resuming touch forwarding. |
| 1145 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); | 1174 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); |
| 1146 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1175 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1147 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 1176 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 1171 base::MessageLoop::current()->Run(); | 1200 base::MessageLoop::current()->Run(); |
| 1172 | 1201 |
| 1173 // The timeout should have fired, synthetically ack'ing the timed out event. | 1202 // The timeout should have fired, synthetically ack'ing the timed out event. |
| 1174 // TouchEvent forwarding is disabled until the original ack is received. | 1203 // TouchEvent forwarding is disabled until the original ack is received. |
| 1175 EXPECT_FALSE(IsTimeoutRunning()); | 1204 EXPECT_FALSE(IsTimeoutRunning()); |
| 1176 EXPECT_FALSE(WillForwardTouchEvents()); | 1205 EXPECT_FALSE(WillForwardTouchEvents()); |
| 1177 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1206 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1178 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1207 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1179 | 1208 |
| 1180 // Touch events should not be forwarded until we receive the original ack. | 1209 // Touch events should not be forwarded until we receive the original ack. |
| 1181 PressTouchPoint(0, 1); | 1210 MoveTouchPoint(0, 1, 1); |
| 1211 ReleaseTouchPoint(0); | |
| 1182 ASSERT_EQ(0U, GetAndResetSentEventCount()); | 1212 ASSERT_EQ(0U, GetAndResetSentEventCount()); |
| 1183 ASSERT_EQ(1U, GetAndResetAckedEventCount()); | 1213 ASSERT_EQ(2U, GetAndResetAckedEventCount()); |
| 1184 | 1214 |
| 1185 // Ack'ing the original event should not trigger a cancel event, as the | 1215 // Ack'ing the original event should not trigger a cancel event, as the |
| 1186 // TouchStart had no consumer. However, it should re-enable touch forwarding. | 1216 // TouchStart had no consumer. However, it should re-enable touch forwarding. |
| 1187 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); | 1217 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); |
| 1188 EXPECT_FALSE(IsTimeoutRunning()); | 1218 EXPECT_FALSE(IsTimeoutRunning()); |
| 1189 EXPECT_TRUE(WillForwardTouchEvents()); | |
| 1190 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 1219 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
| 1191 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1220 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1192 | 1221 |
| 1193 // Subsequent events should be handled normally. | 1222 // Subsequent events should be handled normally. |
| 1194 PressTouchPoint(0, 1); | 1223 PressTouchPoint(0, 1); |
| 1224 EXPECT_TRUE(WillForwardTouchEvents()); | |
| 1195 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1225 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1196 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 1226 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
| 1197 } | 1227 } |
| 1198 } // namespace content | 1228 } // namespace content |
| OLD | NEW |