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 "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 1809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1820 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1820 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
1821 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1821 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
1822 | 1822 |
1823 MoveTouchPoint(0, 0, 10); | 1823 MoveTouchPoint(0, 0, 10); |
1824 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1824 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1825 EXPECT_TRUE(HasPendingAsyncTouchMove()); | 1825 EXPECT_TRUE(HasPendingAsyncTouchMove()); |
1826 EXPECT_EQ(0U, queued_event_count()); | 1826 EXPECT_EQ(0U, queued_event_count()); |
1827 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1827 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
1828 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1828 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
1829 | 1829 |
1830 // As soon as a touchmove exceeds the outer slop region it will be forwarded | |
1831 // immediately. | |
1832 MoveTouchPoint(0, 0, 20); | |
1833 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
1834 EXPECT_FALSE(HasPendingAsyncTouchMove()); | |
1835 EXPECT_FALSE(sent_event().cancelable); | |
1836 EXPECT_EQ(0U, queued_event_count()); | |
1837 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
1838 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
1839 | |
1840 // Subsequent touchmove's should be deferred. | 1830 // Subsequent touchmove's should be deferred. |
1841 MoveTouchPoint(0, 0, 25); | 1831 MoveTouchPoint(0, 0, 25); |
1842 EXPECT_TRUE(HasPendingAsyncTouchMove()); | 1832 EXPECT_TRUE(HasPendingAsyncTouchMove()); |
1843 EXPECT_EQ(0U, queued_event_count()); | 1833 EXPECT_EQ(0U, queued_event_count()); |
1844 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1834 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
1845 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1835 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
1846 | 1836 |
1847 // The pending touchmove should be flushed with the the new touchmove if | 1837 // The pending touchmove should be flushed with the the new touchmove if |
1848 // sufficient time has passed. | 1838 // sufficient time has passed. |
1849 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); | 1839 AdvanceTouchTime(kMinSecondsBetweenThrottledTouchmoves + 0.1); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1929 EXPECT_EQ(1U, queued_event_count()); | 1919 EXPECT_EQ(1U, queued_event_count()); |
1930 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1920 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
1931 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1921 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
1932 | 1922 |
1933 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1923 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1934 EXPECT_EQ(0U, queued_event_count()); | 1924 EXPECT_EQ(0U, queued_event_count()); |
1935 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1925 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
1936 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1926 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
1937 } | 1927 } |
1938 | 1928 |
1929 TEST_F(TouchEventQueueTest, AsyncTouchFlushedByTouchEnd) { | |
Rick Byers
2015/01/28 20:00:09
thanks for adding this test
| |
1930 SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE); | |
Rick Byers
2015/01/28 20:00:08
we don't need to explicitly set this (it's the def
jdduke (slow)
2015/01/28 20:10:07
Probably not, only did it for consistency with oth
| |
1931 | |
1932 PressTouchPoint(0, 0); | |
1933 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
1934 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
1935 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
1936 | |
1937 // Initiate async touchmove dispatch after the start of a scroll sequence. | |
1938 MoveTouchPoint(0, 0, 5); | |
1939 WebGestureEvent followup_scroll; | |
1940 followup_scroll.type = WebInputEvent::GestureScrollBegin; | |
1941 SetFollowupEvent(followup_scroll); | |
1942 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
1943 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
1944 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
1945 | |
1946 MoveTouchPoint(0, 0, 10); | |
1947 followup_scroll.type = WebInputEvent::GestureScrollUpdate; | |
1948 SetFollowupEvent(followup_scroll); | |
1949 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
1950 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
1951 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
1952 | |
1953 // Now queue a second touchmove and verify it's not (yet) dispatched. | |
1954 MoveTouchPoint(0, 0, 100); | |
1955 EXPECT_TRUE(HasPendingAsyncTouchMove()); | |
1956 EXPECT_EQ(0U, queued_event_count()); | |
1957 EXPECT_EQ(0U, GetAndResetSentEventCount()); | |
1958 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
1959 | |
1960 // Return the touch sequence to the original touchstart position. | |
Rick Byers
2015/01/28 20:00:09
this gets coalesced into the above event, right?
jdduke (slow)
2015/01/28 20:10:07
yup, i'll make a note.
| |
1961 MoveTouchPoint(0, 0, 0); | |
1962 EXPECT_TRUE(HasPendingAsyncTouchMove()); | |
1963 EXPECT_EQ(0U, queued_event_count()); | |
1964 EXPECT_EQ(0U, GetAndResetSentEventCount()); | |
1965 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
1966 | |
1967 // Queuing the final touchend should flush the pending, async touchmove. | |
1968 ReleaseTouchPoint(0); | |
1969 EXPECT_FALSE(HasPendingAsyncTouchMove()); | |
1970 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type); | |
1971 EXPECT_FALSE(sent_event().cancelable); | |
1972 EXPECT_EQ(0, sent_event().touches[0].position.x); | |
1973 EXPECT_EQ(0, sent_event().touches[0].position.y); | |
1974 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
1975 | |
1976 // Touchend is not cancelable during async touch dispatch. | |
1977 SendTouchEventAck(INPUT_EVENT_ACK_STATE_IGNORED); | |
1978 EXPECT_EQ(WebInputEvent::TouchEnd, sent_event().type); | |
1979 EXPECT_FALSE(sent_event().cancelable); | |
1980 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
1981 } | |
1982 | |
1939 // Ensure that async touch dispatch and touch ack timeout interactions work | 1983 // Ensure that async touch dispatch and touch ack timeout interactions work |
1940 // appropriately. | 1984 // appropriately. |
1941 TEST_F(TouchEventQueueTest, AsyncTouchWithAckTimeout) { | 1985 TEST_F(TouchEventQueueTest, AsyncTouchWithAckTimeout) { |
1942 SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE); | 1986 SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE); |
1943 SetUpForTimeoutTesting(DefaultTouchTimeoutDelay()); | 1987 SetUpForTimeoutTesting(DefaultTouchTimeoutDelay()); |
1944 | 1988 |
1945 // The touchstart should start the timeout. | 1989 // The touchstart should start the timeout. |
1946 PressTouchPoint(0, 0); | 1990 PressTouchPoint(0, 0); |
1947 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1991 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
1948 EXPECT_TRUE(IsTimeoutRunning()); | 1992 EXPECT_TRUE(IsTimeoutRunning()); |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2249 | 2293 |
2250 // Give the touchmove a valid id; it should be sent. | 2294 // Give the touchmove a valid id; it should be sent. |
2251 event.touches[0].id = press_id; | 2295 event.touches[0].id = press_id; |
2252 SendTouchEvent(event); | 2296 SendTouchEvent(event); |
2253 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2297 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
2254 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 2298 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
2255 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2299 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
2256 } | 2300 } |
2257 | 2301 |
2258 } // namespace content | 2302 } // namespace content |
OLD | NEW |