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