OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 public TouchpadTapSuppressionControllerClient { | 27 public TouchpadTapSuppressionControllerClient { |
28 public: | 28 public: |
29 GestureEventQueueTest() | 29 GestureEventQueueTest() |
30 : acked_gesture_event_count_(0), | 30 : acked_gesture_event_count_(0), |
31 sent_gesture_event_count_(0) {} | 31 sent_gesture_event_count_(0) {} |
32 | 32 |
33 virtual ~GestureEventQueueTest() {} | 33 virtual ~GestureEventQueueTest() {} |
34 | 34 |
35 // testing::Test | 35 // testing::Test |
36 virtual void SetUp() OVERRIDE { | 36 virtual void SetUp() OVERRIDE { |
37 queue_.reset(new GestureEventQueue(this, this)); | 37 queue_.reset(new GestureEventQueue(this, this, DefaultConfig())); |
38 } | 38 } |
39 | 39 |
40 virtual void TearDown() OVERRIDE { | 40 virtual void TearDown() OVERRIDE { |
41 // Process all pending tasks to avoid leaks. | 41 // Process all pending tasks to avoid leaks. |
42 RunUntilIdle(); | 42 RunUntilIdle(); |
43 queue_.reset(); | 43 queue_.reset(); |
44 } | 44 } |
45 | 45 |
46 // GestureEventQueueClient | 46 // GestureEventQueueClient |
47 virtual void SendGestureEventImmediately( | 47 virtual void SendGestureEventImmediately( |
(...skipping 13 matching lines...) Expand all Loading... |
61 if (sync_followup_event_) | 61 if (sync_followup_event_) |
62 SimulateGestureEvent(*sync_followup_event_.Pass()); | 62 SimulateGestureEvent(*sync_followup_event_.Pass()); |
63 } | 63 } |
64 | 64 |
65 // TouchpadTapSuppressionControllerClient | 65 // TouchpadTapSuppressionControllerClient |
66 virtual void SendMouseEventImmediately( | 66 virtual void SendMouseEventImmediately( |
67 const MouseEventWithLatencyInfo& event) OVERRIDE { | 67 const MouseEventWithLatencyInfo& event) OVERRIDE { |
68 } | 68 } |
69 | 69 |
70 protected: | 70 protected: |
| 71 static GestureEventQueue::Config DefaultConfig() { |
| 72 return GestureEventQueue::Config(); |
| 73 } |
| 74 |
| 75 void SetUpForDebounce(int interval_ms) { |
| 76 GestureEventQueue::Config config = DefaultConfig(); |
| 77 config.enable_debounce_during_scroll = true; |
| 78 config.debounce_interval = base::TimeDelta::FromMilliseconds(interval_ms); |
| 79 queue_.reset(new GestureEventQueue(this, this, config)); |
| 80 } |
71 | 81 |
72 // Returns the result of |GestureEventQueue::ShouldForward()|. | 82 // Returns the result of |GestureEventQueue::ShouldForward()|. |
73 bool SimulateGestureEvent(const WebGestureEvent& gesture) { | 83 bool SimulateGestureEvent(const WebGestureEvent& gesture) { |
74 GestureEventWithLatencyInfo gesture_with_latency(gesture, | 84 GestureEventWithLatencyInfo gesture_with_latency(gesture, |
75 ui::LatencyInfo()); | 85 ui::LatencyInfo()); |
76 if (queue()->ShouldForward(gesture_with_latency)) { | 86 if (queue()->ShouldForward(gesture_with_latency)) { |
77 SendGestureEventImmediately(gesture_with_latency); | 87 SendGestureEventImmediately(gesture_with_latency); |
78 return true; | 88 return true; |
79 } | 89 } |
80 return false; | 90 return false; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 size_t GetAndResetAckedGestureEventCount() { | 140 size_t GetAndResetAckedGestureEventCount() { |
131 size_t count = acked_gesture_event_count_; | 141 size_t count = acked_gesture_event_count_; |
132 acked_gesture_event_count_ = 0; | 142 acked_gesture_event_count_ = 0; |
133 return count; | 143 return count; |
134 } | 144 } |
135 | 145 |
136 const WebGestureEvent& last_acked_event() const { | 146 const WebGestureEvent& last_acked_event() const { |
137 return last_acked_event_; | 147 return last_acked_event_; |
138 } | 148 } |
139 | 149 |
140 void DisableDebounce() { | |
141 queue()->set_debounce_enabled_for_testing(false); | |
142 } | |
143 | |
144 void set_debounce_interval_time_ms(int ms) { | |
145 queue()->set_debounce_interval_time_ms_for_testing(ms); | |
146 } | |
147 | |
148 void set_synchronous_ack(InputEventAckState ack_result) { | 150 void set_synchronous_ack(InputEventAckState ack_result) { |
149 sync_ack_result_.reset(new InputEventAckState(ack_result)); | 151 sync_ack_result_.reset(new InputEventAckState(ack_result)); |
150 } | 152 } |
151 | 153 |
152 void set_sync_followup_event(WebInputEvent::Type type, | 154 void set_sync_followup_event(WebInputEvent::Type type, |
153 WebGestureEvent::SourceDevice sourceDevice) { | 155 WebGestureEvent::SourceDevice sourceDevice) { |
154 sync_followup_event_.reset(new WebGestureEvent( | 156 sync_followup_event_.reset(new WebGestureEvent( |
155 SyntheticWebGestureEventBuilder::Build(type, sourceDevice))); | 157 SyntheticWebGestureEventBuilder::Build(type, sourceDevice))); |
156 } | 158 } |
157 | 159 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 | 206 |
205 #if GTEST_HAS_PARAM_TEST | 207 #if GTEST_HAS_PARAM_TEST |
206 // This is for tests that are to be run for all source devices. | 208 // This is for tests that are to be run for all source devices. |
207 class GestureEventQueueWithSourceTest | 209 class GestureEventQueueWithSourceTest |
208 : public GestureEventQueueTest, | 210 : public GestureEventQueueTest, |
209 public testing::WithParamInterface<WebGestureEvent::SourceDevice> { | 211 public testing::WithParamInterface<WebGestureEvent::SourceDevice> { |
210 }; | 212 }; |
211 #endif // GTEST_HAS_PARAM_TEST | 213 #endif // GTEST_HAS_PARAM_TEST |
212 | 214 |
213 TEST_F(GestureEventQueueTest, CoalescesScrollGestureEvents) { | 215 TEST_F(GestureEventQueueTest, CoalescesScrollGestureEvents) { |
214 // Turn off debounce handling for test isolation. | |
215 DisableDebounce(); | |
216 | |
217 // Test coalescing of only GestureScrollUpdate events. | 216 // Test coalescing of only GestureScrollUpdate events. |
218 // Simulate gesture events. | 217 // Simulate gesture events. |
219 | 218 |
220 // Sent. | 219 // Sent. |
221 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 220 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
222 WebGestureEvent::Touchscreen); | 221 WebGestureEvent::Touchscreen); |
223 EXPECT_EQ(1U, GetAndResetSentGestureEventCount()); | 222 EXPECT_EQ(1U, GetAndResetSentGestureEventCount()); |
224 | 223 |
225 // Enqueued. | 224 // Enqueued. |
226 SimulateGestureScrollUpdateEvent(8, -5, 0); | 225 SimulateGestureScrollUpdateEvent(8, -5, 0); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 // After the final ack, the queue should be empty. | 281 // After the final ack, the queue should be empty. |
283 SendInputEventACK(WebInputEvent::GestureScrollEnd, | 282 SendInputEventACK(WebInputEvent::GestureScrollEnd, |
284 INPUT_EVENT_ACK_STATE_CONSUMED); | 283 INPUT_EVENT_ACK_STATE_CONSUMED); |
285 RunUntilIdle(); | 284 RunUntilIdle(); |
286 EXPECT_EQ(1U, GetAndResetAckedGestureEventCount()); | 285 EXPECT_EQ(1U, GetAndResetAckedGestureEventCount()); |
287 EXPECT_EQ(0U, GetAndResetSentGestureEventCount()); | 286 EXPECT_EQ(0U, GetAndResetSentGestureEventCount()); |
288 } | 287 } |
289 | 288 |
290 TEST_F(GestureEventQueueTest, | 289 TEST_F(GestureEventQueueTest, |
291 DoesNotCoalesceScrollGestureEventsFromDifferentDevices) { | 290 DoesNotCoalesceScrollGestureEventsFromDifferentDevices) { |
292 // Turn off debounce handling for test isolation. | |
293 DisableDebounce(); | |
294 | |
295 // Test that GestureScrollUpdate events from Touchscreen and Touchpad do not | 291 // Test that GestureScrollUpdate events from Touchscreen and Touchpad do not |
296 // coalesce. | 292 // coalesce. |
297 | 293 |
298 // Sent. | 294 // Sent. |
299 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 295 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
300 WebGestureEvent::Touchscreen); | 296 WebGestureEvent::Touchscreen); |
301 EXPECT_EQ(1U, GetAndResetSentGestureEventCount()); | 297 EXPECT_EQ(1U, GetAndResetSentGestureEventCount()); |
302 | 298 |
303 // Enqueued. | 299 // Enqueued. |
304 SimulateGestureScrollUpdateEvent(8, -5, 0); | 300 SimulateGestureScrollUpdateEvent(8, -5, 0); |
(...skipping 24 matching lines...) Expand all Loading... |
329 GestureEventLastQueueEvent().sourceDevice); | 325 GestureEventLastQueueEvent().sourceDevice); |
330 | 326 |
331 // Enqueued. | 327 // Enqueued. |
332 SimulateGestureScrollUpdateEvent(8, -7, 0); | 328 SimulateGestureScrollUpdateEvent(8, -7, 0); |
333 EXPECT_EQ(4U, GestureEventQueueSize()); | 329 EXPECT_EQ(4U, GestureEventQueueSize()); |
334 EXPECT_EQ(WebGestureEvent::Touchscreen, | 330 EXPECT_EQ(WebGestureEvent::Touchscreen, |
335 GestureEventLastQueueEvent().sourceDevice); | 331 GestureEventLastQueueEvent().sourceDevice); |
336 } | 332 } |
337 | 333 |
338 TEST_F(GestureEventQueueTest, CoalescesScrollAndPinchEvents) { | 334 TEST_F(GestureEventQueueTest, CoalescesScrollAndPinchEvents) { |
339 // Turn off debounce handling for test isolation. | |
340 DisableDebounce(); | |
341 | |
342 // Test coalescing of only GestureScrollUpdate events. | 335 // Test coalescing of only GestureScrollUpdate events. |
343 // Simulate gesture events. | 336 // Simulate gesture events. |
344 | 337 |
345 // Sent. | 338 // Sent. |
346 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 339 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
347 WebGestureEvent::Touchscreen); | 340 WebGestureEvent::Touchscreen); |
348 | 341 |
349 // Sent. | 342 // Sent. |
350 SimulateGestureEvent(WebInputEvent::GesturePinchBegin, | 343 SimulateGestureEvent(WebInputEvent::GesturePinchBegin, |
351 WebGestureEvent::Touchscreen); | 344 WebGestureEvent::Touchscreen); |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 // Check that the queue is empty after ACK and no events get sent. | 557 // Check that the queue is empty after ACK and no events get sent. |
565 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 558 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
566 INPUT_EVENT_ACK_STATE_CONSUMED); | 559 INPUT_EVENT_ACK_STATE_CONSUMED); |
567 EXPECT_EQ(WebInputEvent::GestureScrollUpdate, last_acked_event().type); | 560 EXPECT_EQ(WebInputEvent::GestureScrollUpdate, last_acked_event().type); |
568 RunUntilIdle(); | 561 RunUntilIdle(); |
569 EXPECT_EQ(0U, GetAndResetSentGestureEventCount()); | 562 EXPECT_EQ(0U, GetAndResetSentGestureEventCount()); |
570 EXPECT_EQ(0U, GestureEventQueueSize()); | 563 EXPECT_EQ(0U, GestureEventQueueSize()); |
571 } | 564 } |
572 | 565 |
573 TEST_F(GestureEventQueueTest, CoalescesMultiplePinchEventSequences) { | 566 TEST_F(GestureEventQueueTest, CoalescesMultiplePinchEventSequences) { |
574 // Turn off debounce handling for test isolation. | |
575 DisableDebounce(); | |
576 | |
577 // Simulate a pinch sequence. | 567 // Simulate a pinch sequence. |
578 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 568 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
579 WebGestureEvent::Touchscreen); | 569 WebGestureEvent::Touchscreen); |
580 SimulateGestureEvent(WebInputEvent::GesturePinchBegin, | 570 SimulateGestureEvent(WebInputEvent::GesturePinchBegin, |
581 WebGestureEvent::Touchscreen); | 571 WebGestureEvent::Touchscreen); |
582 | 572 |
583 SimulateGestureScrollUpdateEvent(8, -4, 1); | 573 SimulateGestureScrollUpdateEvent(8, -4, 1); |
584 // Make sure that the queue contains what we think it should. | 574 // Make sure that the queue contains what we think it should. |
585 WebGestureEvent merged_event = GestureEventLastQueueEvent(); | 575 WebGestureEvent merged_event = GestureEventLastQueueEvent(); |
586 size_t expected_events_in_queue = 3; | 576 size_t expected_events_in_queue = 3; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 EXPECT_EQ(1.5, merged_event.data.pinchUpdate.scale); | 647 EXPECT_EQ(1.5, merged_event.data.pinchUpdate.scale); |
658 EXPECT_EQ(1, merged_event.modifiers); | 648 EXPECT_EQ(1, merged_event.modifiers); |
659 merged_event = GestureEventSecondFromLastQueueEvent(); | 649 merged_event = GestureEventSecondFromLastQueueEvent(); |
660 EXPECT_EQ(WebInputEvent::GestureScrollUpdate, merged_event.type); | 650 EXPECT_EQ(WebInputEvent::GestureScrollUpdate, merged_event.type); |
661 EXPECT_EQ(12, merged_event.data.scrollUpdate.deltaX); | 651 EXPECT_EQ(12, merged_event.data.scrollUpdate.deltaX); |
662 EXPECT_EQ(-6, merged_event.data.scrollUpdate.deltaY); | 652 EXPECT_EQ(-6, merged_event.data.scrollUpdate.deltaY); |
663 EXPECT_EQ(1, merged_event.modifiers); | 653 EXPECT_EQ(1, merged_event.modifiers); |
664 } | 654 } |
665 | 655 |
666 TEST_F(GestureEventQueueTest, CoalescesPinchSequencesWithEarlyAck) { | 656 TEST_F(GestureEventQueueTest, CoalescesPinchSequencesWithEarlyAck) { |
667 // Turn off debounce handling for test isolation. | |
668 DisableDebounce(); | |
669 | |
670 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 657 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
671 WebGestureEvent::Touchscreen); | 658 WebGestureEvent::Touchscreen); |
672 SendInputEventACK(WebInputEvent::GestureScrollBegin, | 659 SendInputEventACK(WebInputEvent::GestureScrollBegin, |
673 INPUT_EVENT_ACK_STATE_CONSUMED); | 660 INPUT_EVENT_ACK_STATE_CONSUMED); |
674 | 661 |
675 SimulateGestureEvent(WebInputEvent::GesturePinchBegin, | 662 SimulateGestureEvent(WebInputEvent::GesturePinchBegin, |
676 WebGestureEvent::Touchscreen); | 663 WebGestureEvent::Touchscreen); |
677 SendInputEventACK(WebInputEvent::GesturePinchBegin, | 664 SendInputEventACK(WebInputEvent::GesturePinchBegin, |
678 INPUT_EVENT_ACK_STATE_CONSUMED); | 665 INPUT_EVENT_ACK_STATE_CONSUMED); |
679 // ScrollBegin and PinchBegin have been sent | 666 // ScrollBegin and PinchBegin have been sent |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 SendInputEventACK(WebInputEvent::GesturePinchUpdate, | 710 SendInputEventACK(WebInputEvent::GesturePinchUpdate, |
724 INPUT_EVENT_ACK_STATE_CONSUMED); | 711 INPUT_EVENT_ACK_STATE_CONSUMED); |
725 EXPECT_EQ(WebInputEvent::GesturePinchUpdate, last_acked_event().type); | 712 EXPECT_EQ(WebInputEvent::GesturePinchUpdate, last_acked_event().type); |
726 EXPECT_EQ(2.f * 3.f * 4.f, last_acked_event().data.pinchUpdate.scale); | 713 EXPECT_EQ(2.f * 3.f * 4.f, last_acked_event().data.pinchUpdate.scale); |
727 | 714 |
728 EXPECT_EQ(0U, GestureEventQueueSize()); | 715 EXPECT_EQ(0U, GestureEventQueueSize()); |
729 } | 716 } |
730 | 717 |
731 TEST_F(GestureEventQueueTest, | 718 TEST_F(GestureEventQueueTest, |
732 DoesNotCoalescePinchGestureEventsWithDifferentModifiers) { | 719 DoesNotCoalescePinchGestureEventsWithDifferentModifiers) { |
733 // Turn off debounce handling for test isolation. | |
734 DisableDebounce(); | |
735 | |
736 // Insert an event to force queueing of gestures. | 720 // Insert an event to force queueing of gestures. |
737 SimulateGestureEvent(WebInputEvent::GestureTapCancel, | 721 SimulateGestureEvent(WebInputEvent::GestureTapCancel, |
738 WebGestureEvent::Touchscreen); | 722 WebGestureEvent::Touchscreen); |
739 EXPECT_EQ(1U, GetAndResetSentGestureEventCount()); | 723 EXPECT_EQ(1U, GetAndResetSentGestureEventCount()); |
740 EXPECT_EQ(1U, GestureEventQueueSize()); | 724 EXPECT_EQ(1U, GestureEventQueueSize()); |
741 | 725 |
742 SimulateGestureScrollUpdateEvent(5, 5, 1); | 726 SimulateGestureScrollUpdateEvent(5, 5, 1); |
743 EXPECT_EQ(0U, GetAndResetSentGestureEventCount()); | 727 EXPECT_EQ(0U, GetAndResetSentGestureEventCount()); |
744 EXPECT_EQ(2U, GestureEventQueueSize()); | 728 EXPECT_EQ(2U, GestureEventQueueSize()); |
745 | 729 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 EXPECT_EQ(1U, GetAndResetSentGestureEventCount()); | 773 EXPECT_EQ(1U, GetAndResetSentGestureEventCount()); |
790 | 774 |
791 SendInputEventACK(WebInputEvent::GesturePinchUpdate, | 775 SendInputEventACK(WebInputEvent::GesturePinchUpdate, |
792 INPUT_EVENT_ACK_STATE_CONSUMED); | 776 INPUT_EVENT_ACK_STATE_CONSUMED); |
793 EXPECT_EQ(WebInputEvent::GesturePinchUpdate, last_acked_event().type); | 777 EXPECT_EQ(WebInputEvent::GesturePinchUpdate, last_acked_event().type); |
794 EXPECT_EQ(6.f, last_acked_event().data.pinchUpdate.scale); | 778 EXPECT_EQ(6.f, last_acked_event().data.pinchUpdate.scale); |
795 EXPECT_EQ(0U, GestureEventQueueSize()); | 779 EXPECT_EQ(0U, GestureEventQueueSize()); |
796 } | 780 } |
797 | 781 |
798 TEST_F(GestureEventQueueTest, CoalescesScrollAndPinchEventsIdentity) { | 782 TEST_F(GestureEventQueueTest, CoalescesScrollAndPinchEventsIdentity) { |
799 // Turn off debounce handling for test isolation. | |
800 DisableDebounce(); | |
801 | |
802 // Insert an event to force queueing of gestures. | 783 // Insert an event to force queueing of gestures. |
803 SimulateGestureEvent(WebInputEvent::GestureTapCancel, | 784 SimulateGestureEvent(WebInputEvent::GestureTapCancel, |
804 WebGestureEvent::Touchscreen); | 785 WebGestureEvent::Touchscreen); |
805 EXPECT_EQ(1U, GetAndResetSentGestureEventCount()); | 786 EXPECT_EQ(1U, GetAndResetSentGestureEventCount()); |
806 EXPECT_EQ(1U, GestureEventQueueSize()); | 787 EXPECT_EQ(1U, GestureEventQueueSize()); |
807 | 788 |
808 // Ensure that coalescing yields an identity transform for any pinch/scroll | 789 // Ensure that coalescing yields an identity transform for any pinch/scroll |
809 // pair combined with its inverse. | 790 // pair combined with its inverse. |
810 SimulateGestureScrollUpdateEvent(5, 5, 1); | 791 SimulateGestureScrollUpdateEvent(5, 5, 1); |
811 EXPECT_EQ(0U, GetAndResetSentGestureEventCount()); | 792 EXPECT_EQ(0U, GetAndResetSentGestureEventCount()); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 | 887 |
907 SendInputEventACK(WebInputEvent::GestureShowPress, | 888 SendInputEventACK(WebInputEvent::GestureShowPress, |
908 INPUT_EVENT_ACK_STATE_CONSUMED); | 889 INPUT_EVENT_ACK_STATE_CONSUMED); |
909 EXPECT_EQ(0U, GetAndResetSentGestureEventCount()); | 890 EXPECT_EQ(0U, GetAndResetSentGestureEventCount()); |
910 EXPECT_EQ(0U, GestureEventQueueSize()); | 891 EXPECT_EQ(0U, GestureEventQueueSize()); |
911 EXPECT_EQ(1U, GetAndResetAckedGestureEventCount()); | 892 EXPECT_EQ(1U, GetAndResetAckedGestureEventCount()); |
912 } | 893 } |
913 | 894 |
914 // Tests an event with an async ack followed by an event with a sync ack. | 895 // Tests an event with an async ack followed by an event with a sync ack. |
915 TEST_F(GestureEventQueueTest, AsyncThenSyncAck) { | 896 TEST_F(GestureEventQueueTest, AsyncThenSyncAck) { |
916 // Turn off debounce handling for test isolation. | |
917 DisableDebounce(); | |
918 | |
919 SimulateGestureEvent(WebInputEvent::GestureTapDown, | 897 SimulateGestureEvent(WebInputEvent::GestureTapDown, |
920 WebGestureEvent::Touchscreen); | 898 WebGestureEvent::Touchscreen); |
921 | 899 |
922 EXPECT_EQ(1U, GetAndResetSentGestureEventCount()); | 900 EXPECT_EQ(1U, GetAndResetSentGestureEventCount()); |
923 EXPECT_EQ(1U, GestureEventQueueSize()); | 901 EXPECT_EQ(1U, GestureEventQueueSize()); |
924 EXPECT_EQ(0U, GetAndResetAckedGestureEventCount()); | 902 EXPECT_EQ(0U, GetAndResetAckedGestureEventCount()); |
925 | 903 |
926 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 904 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
927 WebGestureEvent::Touchscreen); | 905 WebGestureEvent::Touchscreen); |
928 set_synchronous_ack(INPUT_EVENT_ACK_STATE_CONSUMED); | 906 set_synchronous_ack(INPUT_EVENT_ACK_STATE_CONSUMED); |
929 EXPECT_EQ(0U, GetAndResetSentGestureEventCount()); | 907 EXPECT_EQ(0U, GetAndResetSentGestureEventCount()); |
930 EXPECT_EQ(2U, GestureEventQueueSize()); | 908 EXPECT_EQ(2U, GestureEventQueueSize()); |
931 EXPECT_EQ(0U, GetAndResetAckedGestureEventCount()); | 909 EXPECT_EQ(0U, GetAndResetAckedGestureEventCount()); |
932 | 910 |
933 SendInputEventACK(WebInputEvent::GestureTapDown, | 911 SendInputEventACK(WebInputEvent::GestureTapDown, |
934 INPUT_EVENT_ACK_STATE_CONSUMED); | 912 INPUT_EVENT_ACK_STATE_CONSUMED); |
935 EXPECT_EQ(1U, GetAndResetSentGestureEventCount()); | 913 EXPECT_EQ(1U, GetAndResetSentGestureEventCount()); |
936 EXPECT_EQ(0U, GestureEventQueueSize()); | 914 EXPECT_EQ(0U, GestureEventQueueSize()); |
937 EXPECT_EQ(2U, GetAndResetAckedGestureEventCount()); | 915 EXPECT_EQ(2U, GetAndResetAckedGestureEventCount()); |
938 } | 916 } |
939 | 917 |
940 TEST_F(GestureEventQueueTest, CoalescesScrollAndPinchEventWithSyncAck) { | 918 TEST_F(GestureEventQueueTest, CoalescesScrollAndPinchEventWithSyncAck) { |
941 // Turn off debounce handling for test isolation. | |
942 DisableDebounce(); | |
943 | |
944 // Simulate a pinch sequence. | 919 // Simulate a pinch sequence. |
945 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 920 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
946 WebGestureEvent::Touchscreen); | 921 WebGestureEvent::Touchscreen); |
947 EXPECT_EQ(1U, GetAndResetSentGestureEventCount()); | 922 EXPECT_EQ(1U, GetAndResetSentGestureEventCount()); |
948 SimulateGestureEvent(WebInputEvent::GesturePinchBegin, | 923 SimulateGestureEvent(WebInputEvent::GesturePinchBegin, |
949 WebGestureEvent::Touchscreen); | 924 WebGestureEvent::Touchscreen); |
950 EXPECT_EQ(0U, GetAndResetSentGestureEventCount()); | 925 EXPECT_EQ(0U, GetAndResetSentGestureEventCount()); |
951 | 926 |
952 SimulateGestureScrollUpdateEvent(8, -4, 1); | 927 SimulateGestureScrollUpdateEvent(8, -4, 1); |
953 // Make sure that the queue contains what we think it should. | 928 // Make sure that the queue contains what we think it should. |
(...skipping 26 matching lines...) Expand all Loading... |
980 INPUT_EVENT_ACK_STATE_CONSUMED); | 955 INPUT_EVENT_ACK_STATE_CONSUMED); |
981 EXPECT_EQ(WebInputEvent::GesturePinchUpdate, last_acked_event().type); | 956 EXPECT_EQ(WebInputEvent::GesturePinchUpdate, last_acked_event().type); |
982 EXPECT_EQ(0U, GestureEventQueueSize()); | 957 EXPECT_EQ(0U, GestureEventQueueSize()); |
983 EXPECT_EQ(0U, GetAndResetSentGestureEventCount()); | 958 EXPECT_EQ(0U, GetAndResetSentGestureEventCount()); |
984 } | 959 } |
985 | 960 |
986 #if GTEST_HAS_PARAM_TEST | 961 #if GTEST_HAS_PARAM_TEST |
987 TEST_P(GestureEventQueueWithSourceTest, GestureFlingCancelsFiltered) { | 962 TEST_P(GestureEventQueueWithSourceTest, GestureFlingCancelsFiltered) { |
988 WebGestureEvent::SourceDevice source_device = GetParam(); | 963 WebGestureEvent::SourceDevice source_device = GetParam(); |
989 | 964 |
990 // Turn off debounce handling for test isolation. | |
991 DisableDebounce(); | |
992 // GFC without previous GFS is dropped. | 965 // GFC without previous GFS is dropped. |
993 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, source_device); | 966 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, source_device); |
994 EXPECT_EQ(0U, GetAndResetSentGestureEventCount()); | 967 EXPECT_EQ(0U, GetAndResetSentGestureEventCount()); |
995 EXPECT_EQ(0U, GestureEventQueueSize()); | 968 EXPECT_EQ(0U, GestureEventQueueSize()); |
996 | 969 |
997 // GFC after previous GFS is dispatched and acked. | 970 // GFC after previous GFS is dispatched and acked. |
998 SimulateGestureFlingStartEvent(0, -10, source_device); | 971 SimulateGestureFlingStartEvent(0, -10, source_device); |
999 EXPECT_TRUE(FlingInProgress()); | 972 EXPECT_TRUE(FlingInProgress()); |
1000 SendInputEventACK(WebInputEvent::GestureFlingStart, | 973 SendInputEventACK(WebInputEvent::GestureFlingStart, |
1001 INPUT_EVENT_ACK_STATE_CONSUMED); | 974 INPUT_EVENT_ACK_STATE_CONSUMED); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 INSTANTIATE_TEST_CASE_P(AllSources, | 1050 INSTANTIATE_TEST_CASE_P(AllSources, |
1078 GestureEventQueueWithSourceTest, | 1051 GestureEventQueueWithSourceTest, |
1079 testing::Values(WebGestureEvent::Touchscreen, | 1052 testing::Values(WebGestureEvent::Touchscreen, |
1080 WebGestureEvent::Touchpad)); | 1053 WebGestureEvent::Touchpad)); |
1081 #endif // GTEST_HAS_PARAM_TEST | 1054 #endif // GTEST_HAS_PARAM_TEST |
1082 | 1055 |
1083 // Test that a GestureScrollEnd | GestureFlingStart are deferred during the | 1056 // Test that a GestureScrollEnd | GestureFlingStart are deferred during the |
1084 // debounce interval, that Scrolls are not and that the deferred events are | 1057 // debounce interval, that Scrolls are not and that the deferred events are |
1085 // sent after that timer fires. | 1058 // sent after that timer fires. |
1086 TEST_F(GestureEventQueueTest, DebounceDefersFollowingGestureEvents) { | 1059 TEST_F(GestureEventQueueTest, DebounceDefersFollowingGestureEvents) { |
1087 set_debounce_interval_time_ms(3); | 1060 SetUpForDebounce(3); |
1088 | 1061 |
1089 SimulateGestureEvent(WebInputEvent::GestureScrollUpdate, | 1062 SimulateGestureEvent(WebInputEvent::GestureScrollUpdate, |
1090 WebGestureEvent::Touchscreen); | 1063 WebGestureEvent::Touchscreen); |
1091 EXPECT_EQ(1U, GetAndResetSentGestureEventCount()); | 1064 EXPECT_EQ(1U, GetAndResetSentGestureEventCount()); |
1092 EXPECT_EQ(1U, GestureEventQueueSize()); | 1065 EXPECT_EQ(1U, GestureEventQueueSize()); |
1093 EXPECT_EQ(0U, GestureEventDebouncingQueueSize()); | 1066 EXPECT_EQ(0U, GestureEventDebouncingQueueSize()); |
1094 EXPECT_TRUE(ScrollingInProgress()); | 1067 EXPECT_TRUE(ScrollingInProgress()); |
1095 | 1068 |
1096 SimulateGestureEvent(WebInputEvent::GestureScrollUpdate, | 1069 SimulateGestureEvent(WebInputEvent::GestureScrollUpdate, |
1097 WebGestureEvent::Touchscreen); | 1070 WebGestureEvent::Touchscreen); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1140 i++) { | 1113 i++) { |
1141 WebGestureEvent merged_event = GestureEventQueueEventAt(i); | 1114 WebGestureEvent merged_event = GestureEventQueueEventAt(i); |
1142 EXPECT_EQ(expected[i], merged_event.type); | 1115 EXPECT_EQ(expected[i], merged_event.type); |
1143 } | 1116 } |
1144 } | 1117 } |
1145 | 1118 |
1146 // Test that non-scroll events are deferred while scrolling during the debounce | 1119 // Test that non-scroll events are deferred while scrolling during the debounce |
1147 // interval and are discarded if a GestureScrollUpdate event arrives before the | 1120 // interval and are discarded if a GestureScrollUpdate event arrives before the |
1148 // interval end. | 1121 // interval end. |
1149 TEST_F(GestureEventQueueTest, DebounceDropsDeferredEvents) { | 1122 TEST_F(GestureEventQueueTest, DebounceDropsDeferredEvents) { |
1150 set_debounce_interval_time_ms(3); | 1123 SetUpForDebounce(3); |
| 1124 |
1151 EXPECT_FALSE(ScrollingInProgress()); | 1125 EXPECT_FALSE(ScrollingInProgress()); |
1152 | 1126 |
1153 SimulateGestureEvent(WebInputEvent::GestureScrollUpdate, | 1127 SimulateGestureEvent(WebInputEvent::GestureScrollUpdate, |
1154 WebGestureEvent::Touchscreen); | 1128 WebGestureEvent::Touchscreen); |
1155 EXPECT_EQ(1U, GetAndResetSentGestureEventCount()); | 1129 EXPECT_EQ(1U, GetAndResetSentGestureEventCount()); |
1156 EXPECT_EQ(1U, GestureEventQueueSize()); | 1130 EXPECT_EQ(1U, GestureEventQueueSize()); |
1157 EXPECT_EQ(0U, GestureEventDebouncingQueueSize()); | 1131 EXPECT_EQ(0U, GestureEventDebouncingQueueSize()); |
1158 EXPECT_TRUE(ScrollingInProgress()); | 1132 EXPECT_TRUE(ScrollingInProgress()); |
1159 | 1133 |
1160 // This event should get discarded. | 1134 // This event should get discarded. |
(...skipping 29 matching lines...) Expand all Loading... |
1190 gesture_event.data.flingStart.velocityX = 0.f; | 1164 gesture_event.data.flingStart.velocityX = 0.f; |
1191 gesture_event.data.flingStart.velocityY = 0.f; | 1165 gesture_event.data.flingStart.velocityY = 0.f; |
1192 ASSERT_EQ(0U, GetAndResetSentGestureEventCount()); | 1166 ASSERT_EQ(0U, GetAndResetSentGestureEventCount()); |
1193 ASSERT_EQ(0U, GestureEventQueueSize()); | 1167 ASSERT_EQ(0U, GestureEventQueueSize()); |
1194 EXPECT_FALSE(SimulateGestureEvent(gesture_event)); | 1168 EXPECT_FALSE(SimulateGestureEvent(gesture_event)); |
1195 EXPECT_EQ(0U, GetAndResetSentGestureEventCount()); | 1169 EXPECT_EQ(0U, GetAndResetSentGestureEventCount()); |
1196 EXPECT_EQ(0U, GestureEventQueueSize()); | 1170 EXPECT_EQ(0U, GestureEventQueueSize()); |
1197 } | 1171 } |
1198 | 1172 |
1199 } // namespace content | 1173 } // namespace content |
OLD | NEW |