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

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

Issue 872633005: Stop sending an async touchmove for the app slop region (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment Created 5 years, 11 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
« no previous file with comments | « content/browser/renderer_host/input/touch_event_queue.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1918 matching lines...) Expand 10 before | Expand all | Expand 10 after
1929 EXPECT_EQ(1U, queued_event_count()); 1929 EXPECT_EQ(1U, queued_event_count());
1930 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1930 EXPECT_EQ(1U, GetAndResetSentEventCount());
1931 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1931 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1932 1932
1933 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1933 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1934 EXPECT_EQ(0U, queued_event_count()); 1934 EXPECT_EQ(0U, queued_event_count());
1935 EXPECT_EQ(0U, GetAndResetSentEventCount()); 1935 EXPECT_EQ(0U, GetAndResetSentEventCount());
1936 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1936 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1937 } 1937 }
1938 1938
1939 TEST_F(TouchEventQueueTest, AsyncTouchDeferredDuringTouchAck) {
1940 SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE);
1941
1942 // Initiate scroll-induced touch throttling.
1943 PressTouchPoint(0, 0);
1944 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1945 EXPECT_EQ(1U, GetAndResetSentEventCount());
1946 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1947
1948 MoveTouchPoint(0, 0, 5);
1949 EXPECT_EQ(1U, queued_event_count());
1950 EXPECT_EQ(1U, GetAndResetSentEventCount());
1951 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1952 SendGestureEvent(WebInputEvent::GestureScrollBegin);
1953 SendGestureEvent(WebInputEvent::GestureScrollUpdate);
1954
1955 // Now queue a touchmove that exceeds the application slop region.
1956 MoveTouchPoint(0, 0, 20);
1957 EXPECT_FALSE(HasPendingAsyncTouchMove());
1958 EXPECT_EQ(2U, queued_event_count());
1959 EXPECT_EQ(0U, GetAndResetSentEventCount());
1960 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1961
1962 // Despite the second touchmove exceeding the application slop region, its
1963 // sending will be deferred until after the original touch was ack'ed.
1964 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1965 EXPECT_TRUE(HasPendingAsyncTouchMove());
1966 EXPECT_EQ(0U, queued_event_count());
1967 EXPECT_EQ(0U, GetAndResetSentEventCount());
1968 EXPECT_EQ(2U, GetAndResetAckedEventCount());
1969
1970 // A subsequent touchmove will flush the deferred async touchmove,
Rick Byers 2015/01/27 17:59:15 coalescing means it's more like 'replace' than 'fl
1971 MoveTouchPoint(0, 0, 25);
1972 EXPECT_FALSE(HasPendingAsyncTouchMove());
1973 EXPECT_FALSE(sent_event().cancelable);
1974 EXPECT_EQ(1U, GetAndResetSentEventCount());
1975 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1976 }
1977
1939 // Ensure that async touch dispatch and touch ack timeout interactions work 1978 // Ensure that async touch dispatch and touch ack timeout interactions work
1940 // appropriately. 1979 // appropriately.
1941 TEST_F(TouchEventQueueTest, AsyncTouchWithAckTimeout) { 1980 TEST_F(TouchEventQueueTest, AsyncTouchWithAckTimeout) {
1942 SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE); 1981 SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE);
1943 SetUpForTimeoutTesting(DefaultTouchTimeoutDelay()); 1982 SetUpForTimeoutTesting(DefaultTouchTimeoutDelay());
1944 1983
1945 // The touchstart should start the timeout. 1984 // The touchstart should start the timeout.
1946 PressTouchPoint(0, 0); 1985 PressTouchPoint(0, 0);
1947 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1986 EXPECT_EQ(1U, GetAndResetSentEventCount());
1948 EXPECT_TRUE(IsTimeoutRunning()); 1987 EXPECT_TRUE(IsTimeoutRunning());
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
2249 2288
2250 // Give the touchmove a valid id; it should be sent. 2289 // Give the touchmove a valid id; it should be sent.
2251 event.touches[0].id = press_id; 2290 event.touches[0].id = press_id;
2252 SendTouchEvent(event); 2291 SendTouchEvent(event);
2253 EXPECT_EQ(1U, GetAndResetSentEventCount()); 2292 EXPECT_EQ(1U, GetAndResetSentEventCount());
2254 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 2293 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2255 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 2294 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2256 } 2295 }
2257 2296
2258 } // namespace content 2297 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/input/touch_event_queue.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698