Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: content/browser/renderer_host/input/touch_event_queue_unittest.cc

Issue 997283002: Coalesce async touch move events until the ack back from render (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "content/browser/renderer_host/input/timeout_monitor.h" 9 #include "content/browser/renderer_host/input/timeout_monitor.h"
10 #include "content/browser/renderer_host/input/touch_event_queue.h" 10 #include "content/browser/renderer_host/input/touch_event_queue.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 WebGestureEvent event; 111 WebGestureEvent event;
112 event.type = type; 112 event.type = type;
113 queue_->OnGestureScrollEvent( 113 queue_->OnGestureScrollEvent(
114 GestureEventWithLatencyInfo(event, ui::LatencyInfo())); 114 GestureEventWithLatencyInfo(event, ui::LatencyInfo()));
115 } 115 }
116 116
117 void SendTouchEventAck(InputEventAckState ack_result) { 117 void SendTouchEventAck(InputEventAckState ack_result) {
118 queue_->ProcessTouchAck(ack_result, ui::LatencyInfo()); 118 queue_->ProcessTouchAck(ack_result, ui::LatencyInfo());
119 } 119 }
120 120
121 void SendUncancelableTouchMoveEventAck() {
122 queue_->ProcessUncancelableTouchMoveAck();
123 }
124
121 void SendGestureEventAck(WebInputEvent::Type type, 125 void SendGestureEventAck(WebInputEvent::Type type,
122 InputEventAckState ack_result) { 126 InputEventAckState ack_result) {
123 blink::WebGestureEvent gesture_event; 127 blink::WebGestureEvent gesture_event;
124 gesture_event.type = type; 128 gesture_event.type = type;
125 GestureEventWithLatencyInfo event(gesture_event, ui::LatencyInfo()); 129 GestureEventWithLatencyInfo event(gesture_event, ui::LatencyInfo());
126 queue_->OnGestureEventAck(event, ack_result); 130 queue_->OnGestureEventAck(event, ack_result);
127 } 131 }
128 132
129 void SetFollowupEvent(const WebTouchEvent& event) { 133 void SetFollowupEvent(const WebTouchEvent& event) {
130 followup_touch_event_.reset(new WebTouchEvent(event)); 134 followup_touch_event_.reset(new WebTouchEvent(event));
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 InputEventAckState acked_event_state() const { 268 InputEventAckState acked_event_state() const {
265 return last_acked_event_state_; 269 return last_acked_event_state_;
266 } 270 }
267 271
268 static void RunTasksAndWait(base::TimeDelta delay) { 272 static void RunTasksAndWait(base::TimeDelta delay) {
269 base::MessageLoop::current()->PostDelayedTask( 273 base::MessageLoop::current()->PostDelayedTask(
270 FROM_HERE, base::MessageLoop::QuitClosure(), delay); 274 FROM_HERE, base::MessageLoop::QuitClosure(), delay);
271 base::MessageLoop::current()->Run(); 275 base::MessageLoop::current()->Run();
272 } 276 }
273 277
278 int uncancelable_touch_moves_pending_ack_count() const {
279 return queue_->UncancelableTouchMovesPendingAckCount();
280 }
281
274 private: 282 private:
275 void SendTouchEvent() { 283 void SendTouchEvent() {
276 SendTouchEvent(touch_event_); 284 SendTouchEvent(touch_event_);
277 touch_event_.ResetPoints(); 285 touch_event_.ResetPoints();
278 } 286 }
279 287
280 void ResetQueueWithConfig(const TouchEventQueue::Config& config) { 288 void ResetQueueWithConfig(const TouchEventQueue::Config& config) {
281 queue_.reset(new TouchEventQueue(this, config)); 289 queue_.reset(new TouchEventQueue(this, config));
282 queue_->OnHasTouchEventHandlers(true); 290 queue_->OnHasTouchEventHandlers(true);
283 } 291 }
(...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1627 followup_scroll.type = WebInputEvent::GestureScrollBegin; 1635 followup_scroll.type = WebInputEvent::GestureScrollBegin;
1628 SetFollowupEvent(followup_scroll); 1636 SetFollowupEvent(followup_scroll);
1629 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1637 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1630 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1638 EXPECT_EQ(1U, GetAndResetSentEventCount());
1631 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1639 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1632 1640
1633 MoveTouchPoint(0, 0, 6); 1641 MoveTouchPoint(0, 0, 6);
1634 followup_scroll.type = WebInputEvent::GestureScrollUpdate; 1642 followup_scroll.type = WebInputEvent::GestureScrollUpdate;
1635 SetFollowupEvent(followup_scroll); 1643 SetFollowupEvent(followup_scroll);
1636 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1644 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1645 SendUncancelableTouchMoveEventAck();
1637 EXPECT_FALSE(HasPendingAsyncTouchMove()); 1646 EXPECT_FALSE(HasPendingAsyncTouchMove());
1638 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1647 EXPECT_EQ(1U, GetAndResetSentEventCount());
1639 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1648 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1640 1649
1641 MoveTouchPoint(0, 0, 10); 1650 MoveTouchPoint(0, 0, 10);
1642 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1651 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1643 EXPECT_TRUE(HasPendingAsyncTouchMove()); 1652 EXPECT_TRUE(HasPendingAsyncTouchMove());
1644 EXPECT_EQ(0U, queued_event_count()); 1653 EXPECT_EQ(0U, queued_event_count());
1645 EXPECT_EQ(0U, GetAndResetSentEventCount()); 1654 EXPECT_EQ(0U, GetAndResetSentEventCount());
1646 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1655 EXPECT_EQ(1U, GetAndResetAckedEventCount());
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, 1833 SendGestureEventAck(WebInputEvent::GestureScrollUpdate,
1825 INPUT_EVENT_ACK_STATE_CONSUMED); 1834 INPUT_EVENT_ACK_STATE_CONSUMED);
1826 1835
1827 // An async touch should fire after the throttling interval has expired, but 1836 // An async touch should fire after the throttling interval has expired, but
1828 // it should not start the touch ack timeout. 1837 // it should not start the touch ack timeout.
1829 MoveTouchPoint(0, 5, 5); 1838 MoveTouchPoint(0, 5, 5);
1830 EXPECT_TRUE(HasPendingAsyncTouchMove()); 1839 EXPECT_TRUE(HasPendingAsyncTouchMove());
1831 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1840 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1832 1841
1833 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); 1842 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1);
1843 SendUncancelableTouchMoveEventAck();
1834 MoveTouchPoint(0, 5, 5); 1844 MoveTouchPoint(0, 5, 5);
1835 EXPECT_FALSE(IsTimeoutRunning()); 1845 EXPECT_FALSE(IsTimeoutRunning());
1836 EXPECT_FALSE(HasPendingAsyncTouchMove()); 1846 EXPECT_FALSE(HasPendingAsyncTouchMove());
1837 EXPECT_FALSE(sent_event().cancelable); 1847 EXPECT_FALSE(sent_event().cancelable);
1838 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1848 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1839 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1849 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1840 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1850 EXPECT_EQ(1U, GetAndResetSentEventCount());
1841 1851
1842 // An unconsumed scroll event will resume synchronous touchmoves, which are 1852 // An unconsumed scroll event will resume synchronous touchmoves, which are
1843 // subject to the ack timeout. 1853 // subject to the ack timeout.
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1963 // by the new touch sequence. 1973 // by the new touch sequence.
1964 SendGestureEvent(WebInputEvent::GestureScrollEnd); 1974 SendGestureEvent(WebInputEvent::GestureScrollEnd);
1965 ResetTouchEvent(); 1975 ResetTouchEvent();
1966 1976
1967 PressTouchPoint(0, 0); 1977 PressTouchPoint(0, 0);
1968 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1978 EXPECT_EQ(1U, GetAndResetSentEventCount());
1969 EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type); 1979 EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type);
1970 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1980 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1971 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1981 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1972 } 1982 }
1973 1983
tdresser 2015/04/01 13:29:03 Add a new test that specifically tests the coalesc
1984 // Ensure that even when the interval expires, we still need to wait for the
1985 // ack sent back from render to send the next async touchmove once the scroll
1986 // starts.
1987 TEST_F(TouchEventQueueTest, SendNextThrottledAsyncTouchMoveAfterAck) {
1988 // Process a TouchStart
1989 PressTouchPoint(0, 1);
1990 EXPECT_EQ(1U, GetAndResetSentEventCount());
1991 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1992 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1993
1994 // Initiate async touchmove dispatch after the start of a scroll sequence.
1995 MoveTouchPoint(0, 0, 5);
1996 WebGestureEvent followup_scroll;
1997 followup_scroll.type = WebInputEvent::GestureScrollBegin;
1998 SetFollowupEvent(followup_scroll);
1999 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2000 EXPECT_EQ(1U, GetAndResetSentEventCount());
2001 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2002
2003 MoveTouchPoint(0, 0, 10);
2004 followup_scroll.type = WebInputEvent::GestureScrollUpdate;
2005 SetFollowupEvent(followup_scroll);
2006 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2007 EXPECT_FALSE(HasPendingAsyncTouchMove());
2008 EXPECT_EQ(1U, GetAndResetSentEventCount());
2009 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2010
2011 // We set the next touch event time to be after the throttled interval.
2012 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1);
2013 // Dispatch the touch move event when sufficient time has passed.
2014 MoveTouchPoint(0, 0, 40);
2015 EXPECT_FALSE(HasPendingAsyncTouchMove());
2016 EXPECT_FALSE(sent_event().cancelable);
2017 EXPECT_EQ(1U, queued_event_count());
2018 EXPECT_EQ(1U, GetAndResetSentEventCount());
2019 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2020 EXPECT_EQ(1, uncancelable_touch_moves_pending_ack_count());
2021
2022 // We receive the fake ack for the above touchmove and clear the queue.
2023 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2024 EXPECT_EQ(0U, queued_event_count());
2025 EXPECT_EQ(0U, GetAndResetSentEventCount());
2026 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2027
2028 // Do not dispatch the event until throttledTouchmoves intervals expires and
2029 // receive an ack from render.
2030 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1);
2031 MoveTouchPoint(0, 0, 50);
2032 EXPECT_TRUE(HasPendingAsyncTouchMove());
2033 EXPECT_EQ(0U, queued_event_count());
2034 EXPECT_EQ(0U, GetAndResetSentEventCount());
2035 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2036 EXPECT_EQ(1, uncancelable_touch_moves_pending_ack_count());
2037
2038 // Send pending_async_touch_move_ when we receive an ack back from render.
2039 SendUncancelableTouchMoveEventAck();
2040 EXPECT_FALSE(HasPendingAsyncTouchMove());
2041 EXPECT_EQ(1U, queued_event_count());
2042 EXPECT_EQ(1U, GetAndResetSentEventCount());
2043 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2044 EXPECT_EQ(1, uncancelable_touch_moves_pending_ack_count());
2045 }
2046
2047 // Ensure that even when we receive the ack from render, we still need to wait
2048 // for the interval expires to send the next async touchmove once the scroll
2049 // starts.
2050 TEST_F(TouchEventQueueTest, SendNextAsyncTouchMoveAfterAckAndTimeExpire) {
2051 // Process a TouchStart
2052 PressTouchPoint(0, 1);
2053 EXPECT_EQ(1U, GetAndResetSentEventCount());
2054 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2055 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2056
2057 // Initiate async touchmove dispatch after the start of a scroll sequence.
2058 MoveTouchPoint(0, 0, 5);
2059 WebGestureEvent followup_scroll;
2060 followup_scroll.type = WebInputEvent::GestureScrollBegin;
2061 SetFollowupEvent(followup_scroll);
2062 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2063 EXPECT_EQ(1U, GetAndResetSentEventCount());
2064 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2065
2066 MoveTouchPoint(0, 0, 10);
2067 followup_scroll.type = WebInputEvent::GestureScrollUpdate;
2068 SetFollowupEvent(followup_scroll);
2069 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2070 EXPECT_FALSE(HasPendingAsyncTouchMove());
2071 EXPECT_EQ(1U, GetAndResetSentEventCount());
2072 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2073
2074 // Dispatch the touch move event when sufficient time has passed.
2075 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1);
2076 MoveTouchPoint(0, 0, 40);
2077 EXPECT_FALSE(HasPendingAsyncTouchMove());
2078 EXPECT_FALSE(sent_event().cancelable);
2079 EXPECT_EQ(1U, queued_event_count());
2080 EXPECT_EQ(1U, GetAndResetSentEventCount());
2081 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2082 EXPECT_EQ(1, uncancelable_touch_moves_pending_ack_count());
2083
2084 // We receive the fake ack for the above touchmove and clear the queue.
2085 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2086 EXPECT_EQ(0U, queued_event_count());
2087 EXPECT_EQ(0U, GetAndResetSentEventCount());
2088 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2089
2090 // We receive an ack back from render but the time interval is not expired,
2091 // so we do not dispatch the touch move event.
2092 SendUncancelableTouchMoveEventAck();
2093 EXPECT_EQ(0, uncancelable_touch_moves_pending_ack_count());
2094 MoveTouchPoint(0, 0, 50);
2095 EXPECT_TRUE(HasPendingAsyncTouchMove());
2096 EXPECT_EQ(0U, queued_event_count());
2097 EXPECT_EQ(0U, GetAndResetSentEventCount());
2098 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2099
2100 // Dispatch the touch move when sufficient time has passed.
2101 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1);
2102 MoveTouchPoint(0, 0, 50);
2103 EXPECT_FALSE(HasPendingAsyncTouchMove());
2104 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type);
2105 EXPECT_FALSE(sent_event().cancelable);
2106 EXPECT_EQ(1U, queued_event_count());
2107 EXPECT_EQ(1U, GetAndResetSentEventCount());
2108 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2109 EXPECT_EQ(1, uncancelable_touch_moves_pending_ack_count());
2110 }
2111
2112 TEST_F(TouchEventQueueTest, AsyncTouchFlushedByNonTouchMove) {
2113 // Process a TouchStart
2114 PressTouchPoint(0, 1);
2115 EXPECT_EQ(1U, GetAndResetSentEventCount());
2116 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2117 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2118
2119 // Initiate async touchmove dispatch after the start of a scroll sequence.
2120 MoveTouchPoint(0, 0, 5);
2121 WebGestureEvent followup_scroll;
2122 followup_scroll.type = WebInputEvent::GestureScrollBegin;
2123 SetFollowupEvent(followup_scroll);
2124 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2125 EXPECT_EQ(1U, GetAndResetSentEventCount());
2126 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2127
2128 MoveTouchPoint(0, 0, 10);
2129 followup_scroll.type = WebInputEvent::GestureScrollUpdate;
2130 SetFollowupEvent(followup_scroll);
2131 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2132 EXPECT_FALSE(HasPendingAsyncTouchMove());
2133 EXPECT_EQ(1U, GetAndResetSentEventCount());
2134 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2135
2136 // Dispatch the touch move when sufficient time has passed.
2137 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1);
2138 MoveTouchPoint(0, 0, 40);
2139 EXPECT_FALSE(HasPendingAsyncTouchMove());
2140 EXPECT_FALSE(sent_event().cancelable);
2141 EXPECT_EQ(1U, queued_event_count());
2142 EXPECT_EQ(1U, GetAndResetSentEventCount());
2143 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2144 EXPECT_EQ(1, uncancelable_touch_moves_pending_ack_count());
2145
2146 // We receive the fake ack for the above touchmove and clear the queue.
2147 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2148 EXPECT_EQ(0U, queued_event_count());
2149 EXPECT_EQ(0U, GetAndResetSentEventCount());
2150 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2151
2152 for (int i = 0; i < 3; ++i) {
2153 // We throttle the touchmoves, put it in the pending_async_touch_move_,
2154 // do not dispatch it.
2155 MoveTouchPoint(0, 10 + 10 * i, 10 + 10 * i);
2156 EXPECT_TRUE(HasPendingAsyncTouchMove());
2157 EXPECT_EQ(0U, queued_event_count());
2158 EXPECT_EQ(0U, GetAndResetSentEventCount());
2159 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2160 EXPECT_EQ(i + 1, uncancelable_touch_moves_pending_ack_count());
2161
2162 // Send touchstart will flush pending_async_touch_move_, and increase the
2163 // count.
2164 PressTouchPoint(30, 30);
2165 EXPECT_FALSE(HasPendingAsyncTouchMove());
2166 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type);
2167 EXPECT_FALSE(sent_event().cancelable);
2168 EXPECT_EQ(10 + 10 * i, sent_event().touches[0].position.x);
2169 EXPECT_EQ(10 + 10 * i, sent_event().touches[0].position.y);
2170 EXPECT_EQ(1U, GetAndResetSentEventCount());
2171 EXPECT_EQ(i + 2, uncancelable_touch_moves_pending_ack_count());
2172
2173 // Touchstart is cancelable during async touch dispatch.
2174 SendTouchEventAck(INPUT_EVENT_ACK_STATE_IGNORED);
2175 EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type);
2176 EXPECT_TRUE(sent_event().cancelable);
2177 EXPECT_EQ(1U, GetAndResetSentEventCount());
2178 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2179 EXPECT_EQ(i + 2, uncancelable_touch_moves_pending_ack_count());
2180
2181 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2182 EXPECT_EQ(0U, queued_event_count());
2183 EXPECT_FALSE(HasPendingAsyncTouchMove());
2184 EXPECT_EQ(0U, GetAndResetSentEventCount());
2185 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2186 }
2187
2188 EXPECT_EQ(4, uncancelable_touch_moves_pending_ack_count());
2189 // When we receive an ack from render we decrease the count.
2190 SendUncancelableTouchMoveEventAck();
2191 EXPECT_EQ(3, uncancelable_touch_moves_pending_ack_count());
2192 EXPECT_EQ(0U, queued_event_count());
2193 EXPECT_FALSE(HasPendingAsyncTouchMove());
2194
2195 // Do not dispatch the next uncancelable touchmove when we have not recevied
2196 // all the acks back from render.
2197 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1);
2198 MoveTouchPoint(0, 20, 30);
2199 EXPECT_TRUE(HasPendingAsyncTouchMove());
2200 EXPECT_EQ(0U, queued_event_count());
2201 EXPECT_EQ(0U, GetAndResetSentEventCount());
2202 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2203 EXPECT_EQ(3, uncancelable_touch_moves_pending_ack_count());
2204
2205 // Once we receive the ack from render, we do not dispatch the
2206 // pending_async_touchmove_ until the count is 0.
2207 SendUncancelableTouchMoveEventAck();
2208 EXPECT_EQ(2, uncancelable_touch_moves_pending_ack_count());
2209 EXPECT_EQ(0U, queued_event_count());
2210 EXPECT_TRUE(HasPendingAsyncTouchMove());
2211
2212 SendUncancelableTouchMoveEventAck();
2213
2214 // When we receive this ack from render, and the count is 0, so we can
2215 // dispatch the pending_async_touchmove_.
2216 SendUncancelableTouchMoveEventAck();
2217 EXPECT_EQ(1, uncancelable_touch_moves_pending_ack_count());
2218 EXPECT_FALSE(HasPendingAsyncTouchMove());
2219 EXPECT_EQ(1U, queued_event_count());
2220 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type);
2221 EXPECT_FALSE(sent_event().cancelable);
2222 EXPECT_EQ(1U, GetAndResetSentEventCount());
2223 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2224 }
2225
1974 TEST_F(TouchEventQueueTest, TouchAbsorptionWithConsumedFirstMove) { 2226 TEST_F(TouchEventQueueTest, TouchAbsorptionWithConsumedFirstMove) {
1975 // Queue a TouchStart. 2227 // Queue a TouchStart.
1976 PressTouchPoint(0, 1); 2228 PressTouchPoint(0, 1);
1977 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2229 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1978 EXPECT_EQ(0U, queued_event_count()); 2230 EXPECT_EQ(0U, queued_event_count());
1979 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 2231 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1980 2232
1981 MoveTouchPoint(0, 20, 5); 2233 MoveTouchPoint(0, 20, 5);
1982 SendGestureEvent(blink::WebInputEvent::GestureScrollBegin); 2234 SendGestureEvent(blink::WebInputEvent::GestureScrollBegin);
1983 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 2235 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2052 2304
2053 // If subsequent touchmoves aren't consumed, the generated scroll events 2305 // If subsequent touchmoves aren't consumed, the generated scroll events
2054 // will restore async touch dispatch. 2306 // will restore async touch dispatch.
2055 MoveTouchPoint(0, 25, 5); 2307 MoveTouchPoint(0, 25, 5);
2056 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2308 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2057 SendGestureEvent(blink::WebInputEvent::GestureScrollUpdate); 2309 SendGestureEvent(blink::WebInputEvent::GestureScrollUpdate);
2058 ASSERT_EQ(1U, GetAndResetSentEventCount()); 2310 ASSERT_EQ(1U, GetAndResetSentEventCount());
2059 EXPECT_TRUE(sent_event().cancelable); 2311 EXPECT_TRUE(sent_event().cancelable);
2060 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); 2312 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1);
2061 MoveTouchPoint(0, 30, 5); 2313 MoveTouchPoint(0, 30, 5);
2314 SendUncancelableTouchMoveEventAck();
2062 ASSERT_EQ(1U, GetAndResetSentEventCount()); 2315 ASSERT_EQ(1U, GetAndResetSentEventCount());
2063 SendTouchEventAck(INPUT_EVENT_ACK_STATE_IGNORED); 2316 SendTouchEventAck(INPUT_EVENT_ACK_STATE_IGNORED);
2064 EXPECT_FALSE(sent_event().cancelable); 2317 EXPECT_FALSE(sent_event().cancelable);
2065 2318
2066 // The touchend will be uncancelable during an active scroll sequence. 2319 // The touchend will be uncancelable during an active scroll sequence.
2067 ReleaseTouchPoint(0); 2320 ReleaseTouchPoint(0);
2068 ASSERT_EQ(1U, GetAndResetSentEventCount()); 2321 ASSERT_EQ(1U, GetAndResetSentEventCount());
2069 EXPECT_FALSE(sent_event().cancelable); 2322 EXPECT_FALSE(sent_event().cancelable);
2070 } 2323 }
2071 2324
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
2252 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 2505 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2253 2506
2254 // TouchMove should be allowed and test for touches state. 2507 // TouchMove should be allowed and test for touches state.
2255 const WebTouchEvent& event2 = sent_event(); 2508 const WebTouchEvent& event2 = sent_event();
2256 EXPECT_EQ(WebInputEvent::TouchMove, event2.type); 2509 EXPECT_EQ(WebInputEvent::TouchMove, event2.type);
2257 EXPECT_EQ(WebTouchPoint::StateStationary, event2.touches[0].state); 2510 EXPECT_EQ(WebTouchPoint::StateStationary, event2.touches[0].state);
2258 EXPECT_EQ(WebTouchPoint::StateMoved, event2.touches[1].state); 2511 EXPECT_EQ(WebTouchPoint::StateMoved, event2.touches[1].state);
2259 } 2512 }
2260 2513
2261 } // namespace content 2514 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698