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