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> |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 MoveTouchPoint(0, 5, 5); | 354 MoveTouchPoint(0, 5, 5); |
355 EXPECT_EQ(2U, queued_event_count()); | 355 EXPECT_EQ(2U, queued_event_count()); |
356 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 356 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
357 | 357 |
358 // Receive an ACK for the first touch-event. | 358 // Receive an ACK for the first touch-event. |
359 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 359 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
360 EXPECT_EQ(1U, queued_event_count()); | 360 EXPECT_EQ(1U, queued_event_count()); |
361 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 361 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
362 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 362 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
363 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type); | 363 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type); |
364 EXPECT_TRUE(acked_event().cancelable); | 364 EXPECT_EQ(WebInputEvent::Blocking, acked_event().dispatchType); |
365 | 365 |
366 // Receive an ACK for the second touch-event. | 366 // Receive an ACK for the second touch-event. |
367 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 367 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
368 EXPECT_EQ(0U, queued_event_count()); | 368 EXPECT_EQ(0U, queued_event_count()); |
369 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 369 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
370 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 370 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
371 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type); | 371 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type); |
372 EXPECT_TRUE(acked_event().cancelable); | 372 EXPECT_EQ(WebInputEvent::Blocking, acked_event().dispatchType); |
373 } | 373 } |
374 | 374 |
375 // Tests that touch-events with multiple points are queued properly. | 375 // Tests that touch-events with multiple points are queued properly. |
376 TEST_F(TouchEventQueueTest, BasicMultiTouch) { | 376 TEST_F(TouchEventQueueTest, BasicMultiTouch) { |
377 const size_t kPointerCount = 10; | 377 const size_t kPointerCount = 10; |
378 for (float i = 0; i < kPointerCount; ++i) | 378 for (float i = 0; i < kPointerCount; ++i) |
379 PressTouchPoint(i, i); | 379 PressTouchPoint(i, i); |
380 | 380 |
381 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 381 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
382 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 382 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1070 // TouchEvent forwarding is disabled until the ack is received for the | 1070 // TouchEvent forwarding is disabled until the ack is received for the |
1071 // timed-out event and the future cancel event. | 1071 // timed-out event and the future cancel event. |
1072 EXPECT_FALSE(IsTimeoutRunning()); | 1072 EXPECT_FALSE(IsTimeoutRunning()); |
1073 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1073 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
1074 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1074 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
1075 | 1075 |
1076 // Ack'ing the original event should trigger a cancel event. | 1076 // Ack'ing the original event should trigger a cancel event. |
1077 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1077 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1078 EXPECT_FALSE(IsTimeoutRunning()); | 1078 EXPECT_FALSE(IsTimeoutRunning()); |
1079 EXPECT_EQ(WebInputEvent::TouchCancel, sent_event().type); | 1079 EXPECT_EQ(WebInputEvent::TouchCancel, sent_event().type); |
1080 EXPECT_FALSE(sent_event().cancelable); | 1080 EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType); |
1081 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 1081 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
1082 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1082 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
1083 | 1083 |
1084 // Touch events should not be forwarded until we receive the cancel acks. | 1084 // Touch events should not be forwarded until we receive the cancel acks. |
1085 MoveTouchPoint(0, 1, 1); | 1085 MoveTouchPoint(0, 1, 1); |
1086 ASSERT_EQ(0U, GetAndResetSentEventCount()); | 1086 ASSERT_EQ(0U, GetAndResetSentEventCount()); |
1087 ASSERT_EQ(1U, GetAndResetAckedEventCount()); | 1087 ASSERT_EQ(1U, GetAndResetAckedEventCount()); |
1088 | 1088 |
1089 ReleaseTouchPoint(0); | 1089 ReleaseTouchPoint(0); |
1090 ASSERT_EQ(0U, GetAndResetSentEventCount()); | 1090 ASSERT_EQ(0U, GetAndResetSentEventCount()); |
1091 ASSERT_EQ(1U, GetAndResetAckedEventCount()); | 1091 ASSERT_EQ(1U, GetAndResetAckedEventCount()); |
1092 | 1092 |
1093 // The synthetic TouchCancel ack should not reach the client, but should | 1093 // The synthetic TouchCancel ack should not reach the client, but should |
1094 // resume touch forwarding. | 1094 // resume touch forwarding. |
1095 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1095 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1096 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1096 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
1097 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 1097 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
1098 | 1098 |
1099 // Subsequent events should be handled normally. | 1099 // Subsequent events should be handled normally. |
1100 PressTouchPoint(0, 1); | 1100 PressTouchPoint(0, 1); |
1101 EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type); | 1101 EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type); |
1102 EXPECT_TRUE(sent_event().cancelable); | 1102 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType); |
1103 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1103 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
1104 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 1104 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
1105 } | 1105 } |
1106 | 1106 |
1107 // Tests that the timeout is never started if the renderer consumes | 1107 // Tests that the timeout is never started if the renderer consumes |
1108 // a TouchEvent from the current touch sequence. | 1108 // a TouchEvent from the current touch sequence. |
1109 TEST_F(TouchEventQueueTest, NoTouchTimeoutIfRendererIsConsumingGesture) { | 1109 TEST_F(TouchEventQueueTest, NoTouchTimeoutIfRendererIsConsumingGesture) { |
1110 SetUpForTimeoutTesting(); | 1110 SetUpForTimeoutTesting(); |
1111 | 1111 |
1112 // Queue a TouchStart. | 1112 // Queue a TouchStart. |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1608 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1608 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1609 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1609 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
1610 | 1610 |
1611 for (int i = 0; i < 3; ++i) { | 1611 for (int i = 0; i < 3; ++i) { |
1612 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, | 1612 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, |
1613 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1613 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1614 | 1614 |
1615 MoveTouchPoint(0, 10, 5+i); | 1615 MoveTouchPoint(0, 10, 5+i); |
1616 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1616 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1617 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 1617 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
1618 EXPECT_TRUE(sent_event().cancelable); | 1618 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType); |
1619 EXPECT_EQ(0U, queued_event_count()); | 1619 EXPECT_EQ(0U, queued_event_count()); |
1620 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1620 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
1621 | 1621 |
1622 // Consuming a scroll event will throttle subsequent touchmoves. | 1622 // Consuming a scroll event will throttle subsequent touchmoves. |
1623 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, | 1623 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, |
1624 INPUT_EVENT_ACK_STATE_CONSUMED); | 1624 INPUT_EVENT_ACK_STATE_CONSUMED); |
1625 MoveTouchPoint(0, 10, 7+i); | 1625 MoveTouchPoint(0, 10, 7+i); |
1626 EXPECT_TRUE(HasPendingAsyncTouchMove()); | 1626 EXPECT_TRUE(HasPendingAsyncTouchMove()); |
1627 EXPECT_EQ(0U, queued_event_count()); | 1627 EXPECT_EQ(0U, queued_event_count()); |
1628 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1628 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1668 | 1668 |
1669 // Queuing the final touchend should flush the pending async touchmove. In | 1669 // Queuing the final touchend should flush the pending async touchmove. In |
1670 // this case, we will first dispatch an async touchmove and then a touchend. | 1670 // this case, we will first dispatch an async touchmove and then a touchend. |
1671 // For the async touchmove, we will not send ack again. | 1671 // For the async touchmove, we will not send ack again. |
1672 ReleaseTouchPoint(0); | 1672 ReleaseTouchPoint(0); |
1673 followup_scroll.type = WebInputEvent::GestureScrollEnd; | 1673 followup_scroll.type = WebInputEvent::GestureScrollEnd; |
1674 SetFollowupEvent(followup_scroll); | 1674 SetFollowupEvent(followup_scroll); |
1675 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 1675 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
1676 EXPECT_EQ(2U, all_sent_events().size()); | 1676 EXPECT_EQ(2U, all_sent_events().size()); |
1677 EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[0].type); | 1677 EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[0].type); |
1678 EXPECT_FALSE(all_sent_events()[0].cancelable); | 1678 EXPECT_NE(WebInputEvent::Blocking, all_sent_events()[0].dispatchType); |
1679 EXPECT_EQ(WebInputEvent::TouchEnd, all_sent_events()[1].type); | 1679 EXPECT_EQ(WebInputEvent::TouchEnd, all_sent_events()[1].type); |
1680 EXPECT_FALSE(all_sent_events()[1].cancelable); | 1680 EXPECT_NE(WebInputEvent::Blocking, all_sent_events()[1].dispatchType); |
1681 EXPECT_EQ(2U, GetAndResetSentEventCount()); | 1681 EXPECT_EQ(2U, GetAndResetSentEventCount()); |
1682 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 1682 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
1683 EXPECT_EQ(1U, queued_event_count()); | 1683 EXPECT_EQ(1U, queued_event_count()); |
1684 | 1684 |
1685 // Ack the touchend. | 1685 // Ack the touchend. |
1686 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1686 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1687 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1687 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1688 EXPECT_EQ(0U, queued_event_count()); | 1688 EXPECT_EQ(0U, queued_event_count()); |
1689 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1689 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
1690 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1690 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1730 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1730 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
1731 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1731 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
1732 EXPECT_EQ(0U, uncancelable_touch_moves_pending_ack_count()); | 1732 EXPECT_EQ(0U, uncancelable_touch_moves_pending_ack_count()); |
1733 | 1733 |
1734 // The pending touchmove should be flushed with the the new touchmove if | 1734 // The pending touchmove should be flushed with the the new touchmove if |
1735 // sufficient time has passed and ack to the client. | 1735 // sufficient time has passed and ack to the client. |
1736 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); | 1736 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); |
1737 MoveTouchPoint(0, 0, 15); | 1737 MoveTouchPoint(0, 0, 15); |
1738 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1738 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1739 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 1739 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
1740 EXPECT_FALSE(sent_event().cancelable); | 1740 EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType); |
1741 EXPECT_EQ(0U, queued_event_count()); | 1741 EXPECT_EQ(0U, queued_event_count()); |
1742 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1742 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
1743 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1743 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
1744 | 1744 |
1745 // Non-touchmove events should always flush any pending touchmove events. In | 1745 // Non-touchmove events should always flush any pending touchmove events. In |
1746 // this case, we will first dispatch an async touchmove and then a | 1746 // this case, we will first dispatch an async touchmove and then a |
1747 // touchstart. For the async touchmove, we will not send ack again. | 1747 // touchstart. For the async touchmove, we will not send ack again. |
1748 MoveTouchPoint(0, 0, 25); | 1748 MoveTouchPoint(0, 0, 25); |
1749 EXPECT_TRUE(HasPendingAsyncTouchMove()); | 1749 EXPECT_TRUE(HasPendingAsyncTouchMove()); |
1750 EXPECT_EQ(0U, queued_event_count()); | 1750 EXPECT_EQ(0U, queued_event_count()); |
1751 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1751 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
1752 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1752 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
1753 PressTouchPoint(30, 30); | 1753 PressTouchPoint(30, 30); |
1754 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 1754 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
1755 EXPECT_EQ(2U, all_sent_events().size()); | 1755 EXPECT_EQ(2U, all_sent_events().size()); |
1756 EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[0].type); | 1756 EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[0].type); |
1757 EXPECT_FALSE(all_sent_events()[0].cancelable); | 1757 EXPECT_NE(WebInputEvent::Blocking, all_sent_events()[0].dispatchType); |
1758 EXPECT_EQ(WebInputEvent::TouchStart, all_sent_events()[1].type); | 1758 EXPECT_EQ(WebInputEvent::TouchStart, all_sent_events()[1].type); |
1759 EXPECT_TRUE(all_sent_events()[1].cancelable); | 1759 EXPECT_EQ(WebInputEvent::Blocking, all_sent_events()[1].dispatchType); |
1760 EXPECT_EQ(2U, GetAndResetSentEventCount()); | 1760 EXPECT_EQ(2U, GetAndResetSentEventCount()); |
1761 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 1761 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
1762 EXPECT_EQ(1U, queued_event_count()); | 1762 EXPECT_EQ(1U, queued_event_count()); |
1763 | 1763 |
1764 // Ack the touchstart. | 1764 // Ack the touchstart. |
1765 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1765 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1766 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1766 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1767 EXPECT_EQ(0U, queued_event_count()); | 1767 EXPECT_EQ(0U, queued_event_count()); |
1768 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1768 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
1769 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1769 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
1770 | 1770 |
1771 // Send a secondary touchmove. | 1771 // Send a secondary touchmove. |
1772 MoveTouchPoint(1, 0, 25); | 1772 MoveTouchPoint(1, 0, 25); |
1773 EXPECT_TRUE(HasPendingAsyncTouchMove()); | 1773 EXPECT_TRUE(HasPendingAsyncTouchMove()); |
1774 EXPECT_EQ(0U, queued_event_count()); | 1774 EXPECT_EQ(0U, queued_event_count()); |
1775 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1775 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
1776 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1776 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
1777 | 1777 |
1778 // An unconsumed scroll should resume synchronous touch handling. | 1778 // An unconsumed scroll should resume synchronous touch handling. |
1779 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, | 1779 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, |
1780 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1780 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1781 | 1781 |
1782 // The pending touchmove should be coalesced with the next (now synchronous) | 1782 // The pending touchmove should be coalesced with the next (now synchronous) |
1783 // touchmove. | 1783 // touchmove. |
1784 MoveTouchPoint(0, 0, 26); | 1784 MoveTouchPoint(0, 0, 26); |
1785 EXPECT_TRUE(sent_event().cancelable); | 1785 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType); |
1786 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 1786 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
1787 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type); | 1787 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type); |
1788 EXPECT_EQ(WebTouchPoint::StateMoved, sent_event().touches[0].state); | 1788 EXPECT_EQ(WebTouchPoint::StateMoved, sent_event().touches[0].state); |
1789 EXPECT_EQ(WebTouchPoint::StateMoved, sent_event().touches[1].state); | 1789 EXPECT_EQ(WebTouchPoint::StateMoved, sent_event().touches[1].state); |
1790 EXPECT_EQ(1U, queued_event_count()); | 1790 EXPECT_EQ(1U, queued_event_count()); |
1791 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1791 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
1792 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 1792 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
1793 | 1793 |
1794 // Subsequent touches will queue until the preceding, synchronous touches are | 1794 // Subsequent touches will queue until the preceding, synchronous touches are |
1795 // ack'ed. | 1795 // ack'ed. |
1796 ReleaseTouchPoint(1); | 1796 ReleaseTouchPoint(1); |
1797 EXPECT_EQ(2U, queued_event_count()); | 1797 EXPECT_EQ(2U, queued_event_count()); |
1798 ReleaseTouchPoint(0); | 1798 ReleaseTouchPoint(0); |
1799 EXPECT_EQ(3U, queued_event_count()); | 1799 EXPECT_EQ(3U, queued_event_count()); |
1800 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1800 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1801 EXPECT_TRUE(sent_event().cancelable); | 1801 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType); |
1802 EXPECT_EQ(WebInputEvent::TouchEnd, sent_event().type); | 1802 EXPECT_EQ(WebInputEvent::TouchEnd, sent_event().type); |
1803 EXPECT_EQ(2U, queued_event_count()); | 1803 EXPECT_EQ(2U, queued_event_count()); |
1804 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1804 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
1805 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1805 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
1806 | 1806 |
1807 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1807 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1808 EXPECT_TRUE(sent_event().cancelable); | 1808 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType); |
1809 EXPECT_EQ(WebInputEvent::TouchEnd, sent_event().type); | 1809 EXPECT_EQ(WebInputEvent::TouchEnd, sent_event().type); |
1810 EXPECT_EQ(1U, queued_event_count()); | 1810 EXPECT_EQ(1U, queued_event_count()); |
1811 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1811 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
1812 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1812 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
1813 | 1813 |
1814 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1814 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1815 EXPECT_EQ(0U, queued_event_count()); | 1815 EXPECT_EQ(0U, queued_event_count()); |
1816 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1816 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
1817 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1817 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
1818 } | 1818 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1854 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1854 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
1855 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1855 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
1856 | 1856 |
1857 // Queuing the final touchend should flush the pending, async touchmove. In | 1857 // Queuing the final touchend should flush the pending, async touchmove. In |
1858 // this case, we will first dispatch an async touchmove and then a touchend. | 1858 // this case, we will first dispatch an async touchmove and then a touchend. |
1859 // For the async touchmove, we will not send ack again. | 1859 // For the async touchmove, we will not send ack again. |
1860 ReleaseTouchPoint(0); | 1860 ReleaseTouchPoint(0); |
1861 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 1861 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
1862 EXPECT_EQ(2U, all_sent_events().size()); | 1862 EXPECT_EQ(2U, all_sent_events().size()); |
1863 EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[0].type); | 1863 EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[0].type); |
1864 EXPECT_FALSE(all_sent_events()[0].cancelable); | 1864 EXPECT_NE(WebInputEvent::Blocking, all_sent_events()[0].dispatchType); |
1865 EXPECT_EQ(0, all_sent_events()[0].touches[0].position.x); | 1865 EXPECT_EQ(0, all_sent_events()[0].touches[0].position.x); |
1866 EXPECT_EQ(0, all_sent_events()[0].touches[0].position.y); | 1866 EXPECT_EQ(0, all_sent_events()[0].touches[0].position.y); |
1867 EXPECT_EQ(WebInputEvent::TouchEnd, all_sent_events()[1].type); | 1867 EXPECT_EQ(WebInputEvent::TouchEnd, all_sent_events()[1].type); |
1868 EXPECT_FALSE(all_sent_events()[1].cancelable); | 1868 EXPECT_NE(WebInputEvent::Blocking, all_sent_events()[1].dispatchType); |
1869 EXPECT_EQ(2U, GetAndResetSentEventCount()); | 1869 EXPECT_EQ(2U, GetAndResetSentEventCount()); |
1870 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 1870 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
1871 } | 1871 } |
1872 | 1872 |
1873 // Ensure that async touch dispatch and touch ack timeout interactions work | 1873 // Ensure that async touch dispatch and touch ack timeout interactions work |
1874 // appropriately. | 1874 // appropriately. |
1875 TEST_F(TouchEventQueueTest, AsyncTouchWithAckTimeout) { | 1875 TEST_F(TouchEventQueueTest, AsyncTouchWithAckTimeout) { |
1876 SetUpForTimeoutTesting(); | 1876 SetUpForTimeoutTesting(); |
1877 | 1877 |
1878 // The touchstart should start the timeout. | 1878 // The touchstart should start the timeout. |
(...skipping 21 matching lines...) Expand all Loading... |
1900 // An async touch should fire after the throttling interval has expired, but | 1900 // An async touch should fire after the throttling interval has expired, but |
1901 // it should not start the touch ack timeout. | 1901 // it should not start the touch ack timeout. |
1902 MoveTouchPoint(0, 5, 5); | 1902 MoveTouchPoint(0, 5, 5); |
1903 EXPECT_TRUE(HasPendingAsyncTouchMove()); | 1903 EXPECT_TRUE(HasPendingAsyncTouchMove()); |
1904 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1904 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
1905 | 1905 |
1906 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); | 1906 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); |
1907 MoveTouchPoint(0, 5, 5); | 1907 MoveTouchPoint(0, 5, 5); |
1908 EXPECT_FALSE(IsTimeoutRunning()); | 1908 EXPECT_FALSE(IsTimeoutRunning()); |
1909 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 1909 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
1910 EXPECT_FALSE(sent_event().cancelable); | 1910 EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType); |
1911 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1911 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
1912 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1912 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
1913 | 1913 |
1914 // An unconsumed scroll event will resume synchronous touchmoves, which are | 1914 // An unconsumed scroll event will resume synchronous touchmoves, which are |
1915 // subject to the ack timeout. | 1915 // subject to the ack timeout. |
1916 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, | 1916 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, |
1917 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1917 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1918 MoveTouchPoint(0, 20, 5); | 1918 MoveTouchPoint(0, 20, 5); |
1919 EXPECT_TRUE(IsTimeoutRunning()); | 1919 EXPECT_TRUE(IsTimeoutRunning()); |
1920 EXPECT_TRUE(sent_event().cancelable); | 1920 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType); |
1921 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1921 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
1922 | 1922 |
1923 // The timeout should fire, disabling touch forwarding until both acks are | 1923 // The timeout should fire, disabling touch forwarding until both acks are |
1924 // received and acking the timed out event. | 1924 // received and acking the timed out event. |
1925 RunTasksAndWait(DefaultTouchTimeoutDelay() * 2); | 1925 RunTasksAndWait(DefaultTouchTimeoutDelay() * 2); |
1926 EXPECT_FALSE(IsTimeoutRunning()); | 1926 EXPECT_FALSE(IsTimeoutRunning()); |
1927 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1927 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
1928 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1928 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
1929 | 1929 |
1930 // Ack'ing the original event should trigger a cancel event. | 1930 // Ack'ing the original event should trigger a cancel event. |
1931 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1931 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1932 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1932 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1933 EXPECT_FALSE(sent_event().cancelable); | 1933 EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType); |
1934 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 1934 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
1935 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1935 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
1936 | 1936 |
1937 // Subsequent touchmove's should not be forwarded, even as the scroll gesture | 1937 // Subsequent touchmove's should not be forwarded, even as the scroll gesture |
1938 // goes from unconsumed to consumed. | 1938 // goes from unconsumed to consumed. |
1939 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, | 1939 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, |
1940 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1940 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1941 MoveTouchPoint(0, 20, 5); | 1941 MoveTouchPoint(0, 20, 5); |
1942 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 1942 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
1943 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1943 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1976 // the queued touchcancel should be flushed. | 1976 // the queued touchcancel should be flushed. |
1977 WebTouchEvent followup_cancel; | 1977 WebTouchEvent followup_cancel; |
1978 followup_cancel.type = WebInputEvent::TouchCancel; | 1978 followup_cancel.type = WebInputEvent::TouchCancel; |
1979 followup_cancel.touchesLength = 1; | 1979 followup_cancel.touchesLength = 1; |
1980 followup_cancel.touches[0].state = WebTouchPoint::StateCancelled; | 1980 followup_cancel.touches[0].state = WebTouchPoint::StateCancelled; |
1981 SetFollowupEvent(followup_cancel); | 1981 SetFollowupEvent(followup_cancel); |
1982 MoveTouchPoint(0, 5, 5); | 1982 MoveTouchPoint(0, 5, 5); |
1983 EXPECT_EQ(1U, queued_event_count()); | 1983 EXPECT_EQ(1U, queued_event_count()); |
1984 EXPECT_EQ(2U, all_sent_events().size()); | 1984 EXPECT_EQ(2U, all_sent_events().size()); |
1985 EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[0].type); | 1985 EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[0].type); |
1986 EXPECT_FALSE(all_sent_events()[0].cancelable); | 1986 EXPECT_NE(WebInputEvent::Blocking, all_sent_events()[0].dispatchType); |
1987 EXPECT_EQ(WebInputEvent::TouchCancel, all_sent_events()[1].type); | 1987 EXPECT_EQ(WebInputEvent::TouchCancel, all_sent_events()[1].type); |
1988 EXPECT_FALSE(all_sent_events()[1].cancelable); | 1988 EXPECT_NE(WebInputEvent::Blocking, all_sent_events()[1].dispatchType); |
1989 EXPECT_EQ(2U, GetAndResetSentEventCount()); | 1989 EXPECT_EQ(2U, GetAndResetSentEventCount()); |
1990 // Sending the ack is because the async touchmove is not ready for | 1990 // Sending the ack is because the async touchmove is not ready for |
1991 // dispatching send the ack immediately. | 1991 // dispatching send the ack immediately. |
1992 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1992 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
1993 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type); | 1993 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type); |
1994 | 1994 |
1995 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1995 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1996 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1996 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1997 EXPECT_EQ(0U, queued_event_count()); | 1997 EXPECT_EQ(0U, queued_event_count()); |
1998 EXPECT_EQ(WebInputEvent::TouchCancel, acked_event().type); | 1998 EXPECT_EQ(WebInputEvent::TouchCancel, acked_event().type); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2064 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2064 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2065 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 2065 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
2066 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2066 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
2067 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2067 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
2068 | 2068 |
2069 // We set the next touch event time to be after the throttled interval. | 2069 // We set the next touch event time to be after the throttled interval. |
2070 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); | 2070 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); |
2071 // Dispatch the touch move event when sufficient time has passed. | 2071 // Dispatch the touch move event when sufficient time has passed. |
2072 MoveTouchPoint(0, 0, 40); | 2072 MoveTouchPoint(0, 0, 40); |
2073 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 2073 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
2074 EXPECT_FALSE(sent_event().cancelable); | 2074 EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType); |
2075 // When we dispatch an async touchmove, we do not put it back to the queue | 2075 // When we dispatch an async touchmove, we do not put it back to the queue |
2076 // any more and we will ack to client right away. | 2076 // any more and we will ack to client right away. |
2077 EXPECT_EQ(0U, queued_event_count()); | 2077 EXPECT_EQ(0U, queued_event_count()); |
2078 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2078 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
2079 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2079 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
2080 EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count()); | 2080 EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count()); |
2081 | 2081 |
2082 // Do not dispatch the event until throttledTouchmoves intervals expires and | 2082 // Do not dispatch the event until throttledTouchmoves intervals expires and |
2083 // receive an ack from render. | 2083 // receive an ack from render. |
2084 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); | 2084 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2124 SetFollowupEvent(followup_scroll); | 2124 SetFollowupEvent(followup_scroll); |
2125 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2125 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2126 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 2126 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
2127 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2127 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
2128 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2128 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
2129 | 2129 |
2130 // Dispatch the touch move event when sufficient time has passed. | 2130 // Dispatch the touch move event when sufficient time has passed. |
2131 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); | 2131 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); |
2132 MoveTouchPoint(0, 0, 40); | 2132 MoveTouchPoint(0, 0, 40); |
2133 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 2133 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
2134 EXPECT_FALSE(sent_event().cancelable); | 2134 EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType); |
2135 // When we dispatch an async touchmove, we do not put it back to the queue | 2135 // When we dispatch an async touchmove, we do not put it back to the queue |
2136 // any more and we will ack to client right away. | 2136 // any more and we will ack to client right away. |
2137 EXPECT_EQ(0U, queued_event_count()); | 2137 EXPECT_EQ(0U, queued_event_count()); |
2138 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2138 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
2139 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2139 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
2140 EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count()); | 2140 EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count()); |
2141 | 2141 |
2142 // We receive an ack back from render but the time interval is not expired, | 2142 // We receive an ack back from render but the time interval is not expired, |
2143 // so we do not dispatch the touch move event. | 2143 // so we do not dispatch the touch move event. |
2144 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2144 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2145 EXPECT_EQ(0U, uncancelable_touch_moves_pending_ack_count()); | 2145 EXPECT_EQ(0U, uncancelable_touch_moves_pending_ack_count()); |
2146 MoveTouchPoint(0, 0, 50); | 2146 MoveTouchPoint(0, 0, 50); |
2147 EXPECT_TRUE(HasPendingAsyncTouchMove()); | 2147 EXPECT_TRUE(HasPendingAsyncTouchMove()); |
2148 EXPECT_EQ(0U, queued_event_count()); | 2148 EXPECT_EQ(0U, queued_event_count()); |
2149 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 2149 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
2150 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2150 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
2151 | 2151 |
2152 // Dispatch the touch move when sufficient time has passed. | 2152 // Dispatch the touch move when sufficient time has passed. |
2153 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); | 2153 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); |
2154 MoveTouchPoint(0, 0, 50); | 2154 MoveTouchPoint(0, 0, 50); |
2155 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 2155 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
2156 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type); | 2156 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type); |
2157 EXPECT_FALSE(sent_event().cancelable); | 2157 EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType); |
2158 EXPECT_EQ(0U, queued_event_count()); | 2158 EXPECT_EQ(0U, queued_event_count()); |
2159 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2159 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
2160 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2160 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
2161 EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count()); | 2161 EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count()); |
2162 } | 2162 } |
2163 | 2163 |
2164 TEST_F(TouchEventQueueTest, AsyncTouchFlushedByNonTouchMove) { | 2164 TEST_F(TouchEventQueueTest, AsyncTouchFlushedByNonTouchMove) { |
2165 // Process a TouchStart | 2165 // Process a TouchStart |
2166 PressTouchPoint(0, 1); | 2166 PressTouchPoint(0, 1); |
2167 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2167 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
(...skipping 14 matching lines...) Expand all Loading... |
2182 SetFollowupEvent(followup_scroll); | 2182 SetFollowupEvent(followup_scroll); |
2183 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2183 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2184 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 2184 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
2185 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2185 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
2186 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2186 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
2187 | 2187 |
2188 // Dispatch the touch move when sufficient time has passed. | 2188 // Dispatch the touch move when sufficient time has passed. |
2189 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); | 2189 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); |
2190 MoveTouchPoint(0, 0, 40); | 2190 MoveTouchPoint(0, 0, 40); |
2191 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 2191 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
2192 EXPECT_FALSE(sent_event().cancelable); | 2192 EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType); |
2193 // When we dispatch an async touchmove, we do not put it back to the queue | 2193 // When we dispatch an async touchmove, we do not put it back to the queue |
2194 // any more and we will ack to client right away. | 2194 // any more and we will ack to client right away. |
2195 EXPECT_EQ(0U, queued_event_count()); | 2195 EXPECT_EQ(0U, queued_event_count()); |
2196 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2196 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
2197 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2197 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
2198 EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count()); | 2198 EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count()); |
2199 | 2199 |
2200 for (int i = 0; i < 3; ++i) { | 2200 for (int i = 0; i < 3; ++i) { |
2201 // We throttle the touchmoves, put it in the pending_async_touch_move_, | 2201 // We throttle the touchmoves, put it in the pending_async_touch_move_, |
2202 // do not dispatch it. | 2202 // do not dispatch it. |
2203 MoveTouchPoint(0, 10 + 10 * i, 10 + 10 * i); | 2203 MoveTouchPoint(0, 10 + 10 * i, 10 + 10 * i); |
2204 EXPECT_TRUE(HasPendingAsyncTouchMove()); | 2204 EXPECT_TRUE(HasPendingAsyncTouchMove()); |
2205 EXPECT_EQ(0U, queued_event_count()); | 2205 EXPECT_EQ(0U, queued_event_count()); |
2206 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 2206 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
2207 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2207 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
2208 EXPECT_EQ(static_cast<size_t>(i + 1), | 2208 EXPECT_EQ(static_cast<size_t>(i + 1), |
2209 uncancelable_touch_moves_pending_ack_count()); | 2209 uncancelable_touch_moves_pending_ack_count()); |
2210 | 2210 |
2211 // Send touchstart will flush pending_async_touch_move_, and increase the | 2211 // Send touchstart will flush pending_async_touch_move_, and increase the |
2212 // count. In this case, we will first dispatch an async touchmove and | 2212 // count. In this case, we will first dispatch an async touchmove and |
2213 // then a touchstart. For the async touchmove, we will not send ack again. | 2213 // then a touchstart. For the async touchmove, we will not send ack again. |
2214 PressTouchPoint(30, 30); | 2214 PressTouchPoint(30, 30); |
2215 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 2215 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
2216 EXPECT_EQ(2U, all_sent_events().size()); | 2216 EXPECT_EQ(2U, all_sent_events().size()); |
2217 EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[0].type); | 2217 EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[0].type); |
2218 EXPECT_FALSE(all_sent_events()[0].cancelable); | 2218 EXPECT_NE(WebInputEvent::Blocking, all_sent_events()[0].dispatchType); |
2219 EXPECT_EQ(10 + 10 * i, all_sent_events()[0].touches[0].position.x); | 2219 EXPECT_EQ(10 + 10 * i, all_sent_events()[0].touches[0].position.x); |
2220 EXPECT_EQ(10 + 10 * i, all_sent_events()[0].touches[0].position.y); | 2220 EXPECT_EQ(10 + 10 * i, all_sent_events()[0].touches[0].position.y); |
2221 EXPECT_EQ(static_cast<size_t>(i + 2), | 2221 EXPECT_EQ(static_cast<size_t>(i + 2), |
2222 uncancelable_touch_moves_pending_ack_count()); | 2222 uncancelable_touch_moves_pending_ack_count()); |
2223 EXPECT_EQ(WebInputEvent::TouchStart, all_sent_events()[1].type); | 2223 EXPECT_EQ(WebInputEvent::TouchStart, all_sent_events()[1].type); |
2224 EXPECT_TRUE(all_sent_events()[1].cancelable); | 2224 EXPECT_EQ(WebInputEvent::Blocking, all_sent_events()[1].dispatchType); |
2225 EXPECT_EQ(2U, GetAndResetSentEventCount()); | 2225 EXPECT_EQ(2U, GetAndResetSentEventCount()); |
2226 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 2226 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
2227 | 2227 |
2228 SendTouchEventAckWithID(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, | 2228 SendTouchEventAckWithID(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, |
2229 GetUniqueTouchEventID()); | 2229 GetUniqueTouchEventID()); |
2230 EXPECT_EQ(0U, queued_event_count()); | 2230 EXPECT_EQ(0U, queued_event_count()); |
2231 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 2231 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
2232 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 2232 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
2233 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2233 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
2234 } | 2234 } |
(...skipping 25 matching lines...) Expand all Loading... |
2260 | 2260 |
2261 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2261 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2262 | 2262 |
2263 // When we receive this ack from render, and the count is 0, so we can | 2263 // When we receive this ack from render, and the count is 0, so we can |
2264 // dispatch the pending_async_touchmove_. | 2264 // dispatch the pending_async_touchmove_. |
2265 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2265 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2266 EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count()); | 2266 EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count()); |
2267 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 2267 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
2268 EXPECT_EQ(0U, queued_event_count()); | 2268 EXPECT_EQ(0U, queued_event_count()); |
2269 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type); | 2269 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type); |
2270 EXPECT_FALSE(sent_event().cancelable); | 2270 EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType); |
2271 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2271 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
2272 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 2272 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
2273 } | 2273 } |
2274 | 2274 |
2275 // Ensure that even when we receive the ack from render, we still need to wait | 2275 // Ensure that even when we receive the ack from render, we still need to wait |
2276 // for the interval expires to send the next async touchmove once the scroll | 2276 // for the interval expires to send the next async touchmove once the scroll |
2277 // starts. | 2277 // starts. |
2278 TEST_F(TouchEventQueueTest, DoNotIncreaseIfClientConsumeAsyncTouchMove) { | 2278 TEST_F(TouchEventQueueTest, DoNotIncreaseIfClientConsumeAsyncTouchMove) { |
2279 // Process a TouchStart | 2279 // Process a TouchStart |
2280 PressTouchPoint(0, 1); | 2280 PressTouchPoint(0, 1); |
(...skipping 15 matching lines...) Expand all Loading... |
2296 SetFollowupEvent(followup_scroll); | 2296 SetFollowupEvent(followup_scroll); |
2297 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2297 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2298 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 2298 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
2299 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2299 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
2300 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2300 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
2301 | 2301 |
2302 // Dispatch the touch move event when sufficient time has passed. | 2302 // Dispatch the touch move event when sufficient time has passed. |
2303 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); | 2303 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); |
2304 MoveTouchPoint(0, 0, 40); | 2304 MoveTouchPoint(0, 0, 40); |
2305 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 2305 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
2306 EXPECT_FALSE(sent_event().cancelable); | 2306 EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType); |
2307 // When we dispatch an async touchmove, we do not put it back to the queue | 2307 // When we dispatch an async touchmove, we do not put it back to the queue |
2308 // any more and we will ack to client right away. | 2308 // any more and we will ack to client right away. |
2309 EXPECT_EQ(0U, queued_event_count()); | 2309 EXPECT_EQ(0U, queued_event_count()); |
2310 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2310 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
2311 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2311 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
2312 EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count()); | 2312 EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count()); |
2313 | 2313 |
2314 // We receive an ack back from render but the time interval is not expired, | 2314 // We receive an ack back from render but the time interval is not expired, |
2315 // so we do not dispatch the touch move event. | 2315 // so we do not dispatch the touch move event. |
2316 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2316 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2317 EXPECT_EQ(0U, uncancelable_touch_moves_pending_ack_count()); | 2317 EXPECT_EQ(0U, uncancelable_touch_moves_pending_ack_count()); |
2318 MoveTouchPoint(0, 0, 50); | 2318 MoveTouchPoint(0, 0, 50); |
2319 EXPECT_TRUE(HasPendingAsyncTouchMove()); | 2319 EXPECT_TRUE(HasPendingAsyncTouchMove()); |
2320 EXPECT_EQ(0U, queued_event_count()); | 2320 EXPECT_EQ(0U, queued_event_count()); |
2321 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 2321 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
2322 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2322 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
2323 | 2323 |
2324 // Dispatch the touch move when sufficient time has passed. Becasue the event | 2324 // Dispatch the touch move when sufficient time has passed. Becasue the event |
2325 // is consumed by client already, we would not increase the count and ack to | 2325 // is consumed by client already, we would not increase the count and ack to |
2326 // client again. | 2326 // client again. |
2327 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); | 2327 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); |
2328 SetSyncAckResult(INPUT_EVENT_ACK_STATE_CONSUMED); | 2328 SetSyncAckResult(INPUT_EVENT_ACK_STATE_CONSUMED); |
2329 MoveTouchPoint(0, 0, 50); | 2329 MoveTouchPoint(0, 0, 50); |
2330 EXPECT_FALSE(HasPendingAsyncTouchMove()); | 2330 EXPECT_FALSE(HasPendingAsyncTouchMove()); |
2331 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type); | 2331 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type); |
2332 EXPECT_FALSE(sent_event().cancelable); | 2332 EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType); |
2333 EXPECT_EQ(0U, queued_event_count()); | 2333 EXPECT_EQ(0U, queued_event_count()); |
2334 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2334 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
2335 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2335 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
2336 EXPECT_EQ(0U, uncancelable_touch_moves_pending_ack_count()); | 2336 EXPECT_EQ(0U, uncancelable_touch_moves_pending_ack_count()); |
2337 } | 2337 } |
2338 | 2338 |
2339 TEST_F(TouchEventQueueTest, TouchAbsorptionWithConsumedFirstMove) { | 2339 TEST_F(TouchEventQueueTest, TouchAbsorptionWithConsumedFirstMove) { |
2340 // Queue a TouchStart. | 2340 // Queue a TouchStart. |
2341 PressTouchPoint(0, 1); | 2341 PressTouchPoint(0, 1); |
2342 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2342 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2343 EXPECT_EQ(0U, queued_event_count()); | 2343 EXPECT_EQ(0U, queued_event_count()); |
2344 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2344 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
2345 | 2345 |
2346 MoveTouchPoint(0, 20, 5); | 2346 MoveTouchPoint(0, 20, 5); |
2347 SendGestureEvent(blink::WebInputEvent::GestureScrollBegin); | 2347 SendGestureEvent(blink::WebInputEvent::GestureScrollBegin); |
2348 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 2348 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
2349 EXPECT_EQ(0U, queued_event_count()); | 2349 EXPECT_EQ(0U, queued_event_count()); |
2350 EXPECT_EQ(2U, GetAndResetSentEventCount()); | 2350 EXPECT_EQ(2U, GetAndResetSentEventCount()); |
2351 | 2351 |
2352 // Even if the first touchmove event was consumed, subsequent unconsumed | 2352 // Even if the first touchmove event was consumed, subsequent unconsumed |
2353 // touchmove events should trigger scrolling. | 2353 // touchmove events should trigger scrolling. |
2354 MoveTouchPoint(0, 60, 5); | 2354 MoveTouchPoint(0, 60, 5); |
2355 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 2355 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
2356 EXPECT_EQ(0U, queued_event_count()); | 2356 EXPECT_EQ(0U, queued_event_count()); |
2357 EXPECT_TRUE(sent_event().cancelable); | 2357 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType); |
2358 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2358 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
2359 | 2359 |
2360 MoveTouchPoint(0, 20, 5); | 2360 MoveTouchPoint(0, 20, 5); |
2361 WebGestureEvent followup_scroll; | 2361 WebGestureEvent followup_scroll; |
2362 followup_scroll.type = WebInputEvent::GestureScrollUpdate; | 2362 followup_scroll.type = WebInputEvent::GestureScrollUpdate; |
2363 SetFollowupEvent(followup_scroll); | 2363 SetFollowupEvent(followup_scroll); |
2364 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2364 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2365 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, | 2365 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, |
2366 INPUT_EVENT_ACK_STATE_CONSUMED); | 2366 INPUT_EVENT_ACK_STATE_CONSUMED); |
2367 EXPECT_EQ(0U, queued_event_count()); | 2367 EXPECT_EQ(0U, queued_event_count()); |
2368 EXPECT_TRUE(sent_event().cancelable); | 2368 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType); |
2369 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2369 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
2370 | 2370 |
2371 // Touch move event is throttled. | 2371 // Touch move event is throttled. |
2372 MoveTouchPoint(0, 60, 5); | 2372 MoveTouchPoint(0, 60, 5); |
2373 EXPECT_EQ(0U, queued_event_count()); | 2373 EXPECT_EQ(0U, queued_event_count()); |
2374 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 2374 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
2375 } | 2375 } |
2376 | 2376 |
2377 TEST_F(TouchEventQueueTest, TouchStartCancelableDuringScroll) { | 2377 TEST_F(TouchEventQueueTest, TouchStartCancelableDuringScroll) { |
2378 // Queue a touchstart and touchmove that go unconsumed, transitioning to an | 2378 // Queue a touchstart and touchmove that go unconsumed, transitioning to an |
2379 // active scroll sequence. | 2379 // active scroll sequence. |
2380 PressTouchPoint(0, 1); | 2380 PressTouchPoint(0, 1); |
2381 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2381 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2382 EXPECT_TRUE(sent_event().cancelable); | 2382 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType); |
2383 ASSERT_EQ(1U, GetAndResetSentEventCount()); | 2383 ASSERT_EQ(1U, GetAndResetSentEventCount()); |
2384 | 2384 |
2385 MoveTouchPoint(0, 20, 5); | 2385 MoveTouchPoint(0, 20, 5); |
2386 EXPECT_TRUE(sent_event().cancelable); | 2386 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType); |
2387 SendGestureEvent(blink::WebInputEvent::GestureScrollBegin); | 2387 SendGestureEvent(blink::WebInputEvent::GestureScrollBegin); |
2388 SendGestureEvent(blink::WebInputEvent::GestureScrollUpdate); | 2388 SendGestureEvent(blink::WebInputEvent::GestureScrollUpdate); |
2389 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2389 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2390 EXPECT_TRUE(sent_event().cancelable); | 2390 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType); |
2391 ASSERT_EQ(1U, GetAndResetSentEventCount()); | 2391 ASSERT_EQ(1U, GetAndResetSentEventCount()); |
2392 | 2392 |
2393 // Even though scrolling has begun, touchstart events should be cancelable, | 2393 // Even though scrolling has begun, touchstart events should be cancelable, |
2394 // allowing, for example, customized pinch processing. | 2394 // allowing, for example, customized pinch processing. |
2395 PressTouchPoint(10, 11); | 2395 PressTouchPoint(10, 11); |
2396 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 2396 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
2397 EXPECT_TRUE(sent_event().cancelable); | 2397 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType); |
2398 ASSERT_EQ(1U, GetAndResetSentEventCount()); | 2398 ASSERT_EQ(1U, GetAndResetSentEventCount()); |
2399 | 2399 |
2400 // As the touch start was consumed, touchmoves should no longer be throttled. | 2400 // As the touch start was consumed, touchmoves should no longer be throttled. |
2401 MoveTouchPoint(1, 11, 11); | 2401 MoveTouchPoint(1, 11, 11); |
2402 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 2402 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
2403 EXPECT_TRUE(sent_event().cancelable); | 2403 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType); |
2404 ASSERT_EQ(1U, GetAndResetSentEventCount()); | 2404 ASSERT_EQ(1U, GetAndResetSentEventCount()); |
2405 | 2405 |
2406 // With throttling disabled, touchend and touchmove events should also be | 2406 // With throttling disabled, touchend and touchmove events should also be |
2407 // cancelable. | 2407 // cancelable. |
2408 MoveTouchPoint(1, 12, 12); | 2408 MoveTouchPoint(1, 12, 12); |
2409 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 2409 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
2410 EXPECT_TRUE(sent_event().cancelable); | 2410 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType); |
2411 ASSERT_EQ(1U, GetAndResetSentEventCount()); | 2411 ASSERT_EQ(1U, GetAndResetSentEventCount()); |
2412 ReleaseTouchPoint(1); | 2412 ReleaseTouchPoint(1); |
2413 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 2413 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
2414 EXPECT_TRUE(sent_event().cancelable); | 2414 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType); |
2415 ASSERT_EQ(1U, GetAndResetSentEventCount()); | 2415 ASSERT_EQ(1U, GetAndResetSentEventCount()); |
2416 | 2416 |
2417 // If subsequent touchmoves aren't consumed, the generated scroll events | 2417 // If subsequent touchmoves aren't consumed, the generated scroll events |
2418 // will restore async touch dispatch. | 2418 // will restore async touch dispatch. |
2419 MoveTouchPoint(0, 25, 5); | 2419 MoveTouchPoint(0, 25, 5); |
2420 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2420 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2421 SendGestureEvent(blink::WebInputEvent::GestureScrollUpdate); | 2421 SendGestureEvent(blink::WebInputEvent::GestureScrollUpdate); |
2422 EXPECT_TRUE(sent_event().cancelable); | 2422 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType); |
2423 ASSERT_EQ(1U, GetAndResetSentEventCount()); | 2423 ASSERT_EQ(1U, GetAndResetSentEventCount()); |
2424 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); | 2424 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); |
2425 MoveTouchPoint(0, 30, 5); | 2425 MoveTouchPoint(0, 30, 5); |
2426 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2426 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2427 EXPECT_FALSE(sent_event().cancelable); | 2427 EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType); |
2428 ASSERT_EQ(1U, GetAndResetSentEventCount()); | 2428 ASSERT_EQ(1U, GetAndResetSentEventCount()); |
2429 | 2429 |
2430 // The touchend will be uncancelable during an active scroll sequence. | 2430 // The touchend will be uncancelable during an active scroll sequence. |
2431 ReleaseTouchPoint(0); | 2431 ReleaseTouchPoint(0); |
2432 EXPECT_FALSE(sent_event().cancelable); | 2432 EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType); |
2433 ASSERT_EQ(1U, GetAndResetSentEventCount()); | 2433 ASSERT_EQ(1U, GetAndResetSentEventCount()); |
2434 } | 2434 } |
2435 | 2435 |
2436 TEST_F(TouchEventQueueTest, UnseenTouchPointerIdsNotForwarded) { | 2436 TEST_F(TouchEventQueueTest, UnseenTouchPointerIdsNotForwarded) { |
2437 SyntheticWebTouchEvent event; | 2437 SyntheticWebTouchEvent event; |
2438 event.PressPoint(0, 0); | 2438 event.PressPoint(0, 0); |
2439 SendTouchEvent(event); | 2439 SendTouchEvent(event); |
2440 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2440 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
2441 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 2441 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
2442 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2442 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2707 EXPECT_EQ(0U, queued_event_count()); | 2707 EXPECT_EQ(0U, queued_event_count()); |
2708 | 2708 |
2709 EXPECT_EQ(WebInputEvent::TouchStart, all_sent_events()[0].type); | 2709 EXPECT_EQ(WebInputEvent::TouchStart, all_sent_events()[0].type); |
2710 EXPECT_EQ(WebInputEvent::TouchScrollStarted, all_sent_events()[1].type); | 2710 EXPECT_EQ(WebInputEvent::TouchScrollStarted, all_sent_events()[1].type); |
2711 EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[2].type); | 2711 EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[2].type); |
2712 EXPECT_EQ(WebInputEvent::TouchEnd, all_sent_events()[3].type); | 2712 EXPECT_EQ(WebInputEvent::TouchEnd, all_sent_events()[3].type); |
2713 EXPECT_EQ(4U, GetAndResetSentEventCount()); | 2713 EXPECT_EQ(4U, GetAndResetSentEventCount()); |
2714 } | 2714 } |
2715 | 2715 |
2716 } // namespace content | 2716 } // namespace content |
OLD | NEW |