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

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

Issue 788923002: Touch Events - changedTouches list includes non-changed touch points on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added CHECK for last sent event and minor fixes. 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
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 1917 matching lines...) Expand 10 before | Expand all | Expand 10 after
1928 // An unconsumed scroll should resume synchronous touch handling. 1928 // An unconsumed scroll should resume synchronous touch handling.
1929 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, 1929 SendGestureEventAck(WebInputEvent::GestureScrollUpdate,
1930 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1930 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1931 1931
1932 // The pending touchmove should be coalesced with the next (now synchronous) 1932 // The pending touchmove should be coalesced with the next (now synchronous)
1933 // touchmove. 1933 // touchmove.
1934 MoveTouchPoint(0, 0, 25); 1934 MoveTouchPoint(0, 0, 25);
1935 EXPECT_TRUE(sent_event().cancelable); 1935 EXPECT_TRUE(sent_event().cancelable);
1936 EXPECT_FALSE(HasPendingAsyncTouchMove()); 1936 EXPECT_FALSE(HasPendingAsyncTouchMove());
1937 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type); 1937 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type);
1938 EXPECT_EQ(WebTouchPoint::StateMoved, sent_event().touches[0].state); 1938 EXPECT_EQ(WebTouchPoint::StateStationary, sent_event().touches[0].state);
1939 EXPECT_EQ(WebTouchPoint::StateMoved, sent_event().touches[1].state); 1939 EXPECT_EQ(WebTouchPoint::StateMoved, sent_event().touches[1].state);
1940 EXPECT_EQ(1U, queued_event_count()); 1940 EXPECT_EQ(1U, queued_event_count());
1941 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1941 EXPECT_EQ(1U, GetAndResetSentEventCount());
1942 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1942 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1943 1943
1944 // Subsequent touches will queue until the preceding, synchronous touches are 1944 // Subsequent touches will queue until the preceding, synchronous touches are
1945 // ack'ed. 1945 // ack'ed.
1946 ReleaseTouchPoint(1); 1946 ReleaseTouchPoint(1);
1947 EXPECT_EQ(2U, queued_event_count()); 1947 EXPECT_EQ(2U, queued_event_count());
1948 ReleaseTouchPoint(0); 1948 ReleaseTouchPoint(0);
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
2218 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 2218 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2219 2219
2220 // Give the touchmove a valid id; it should be sent. 2220 // Give the touchmove a valid id; it should be sent.
2221 event.touches[0].id = press_id; 2221 event.touches[0].id = press_id;
2222 SendTouchEvent(event); 2222 SendTouchEvent(event);
2223 EXPECT_EQ(1U, GetAndResetSentEventCount()); 2223 EXPECT_EQ(1U, GetAndResetSentEventCount());
2224 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 2224 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2225 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 2225 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2226 } 2226 }
2227 2227
2228 // Tests that touches state is correct in TouchMove events.
2229 TEST_F(TouchEventQueueTest, TouchMoveTouchesState) {
2230 PressTouchPoint(1, 1);
2231 PressTouchPoint(2, 2);
2232 PressTouchPoint(3, 3);
2233 PressTouchPoint(4, 4);
2234 EXPECT_EQ(4U, queued_event_count());
2235 EXPECT_EQ(1U, GetAndResetSentEventCount());
2236
2237 // Receive ACK for the first three touch-events
2238 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2239 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2240 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2241 EXPECT_EQ(1U, queued_event_count());
2242
2243 // Test current touches state before sending TouchMoves
2244 const WebTouchEvent& event1 = sent_event();
2245 EXPECT_EQ(WebInputEvent::TouchStart, event1.type);
2246 EXPECT_EQ(WebTouchPoint::StateStationary, event1.touches[0].state);
2247 EXPECT_EQ(WebTouchPoint::StateStationary, event1.touches[1].state);
2248 EXPECT_EQ(WebTouchPoint::StateStationary, event1.touches[2].state);
2249 EXPECT_EQ(WebTouchPoint::StatePressed, event1.touches[3].state);
2250
2251 // Move x-position for 1st touch, y-position for 2nd touch
2252 // and do not move other touches.
2253 MoveTouchPoints(0, 1.1, 1, 1, 2, 20.001);
2254 MoveTouchPoints(2, 3, 3, 3, 4, 4);
2255 EXPECT_EQ(2U, queued_event_count());
2256
2257 // Receive an ACK for the last TouchPress event
2258 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2259
2260 // 1st TouchMove is sent. Test for touches state.
2261 const WebTouchEvent& event2 = sent_event();
2262 EXPECT_EQ(WebInputEvent::TouchMove, event2.type);
2263 EXPECT_EQ(WebTouchPoint::StateMoved, event2.touches[0].state);
2264 EXPECT_EQ(WebTouchPoint::StateMoved, event2.touches[1].state);
2265 EXPECT_EQ(WebTouchPoint::StateStationary, event2.touches[2].state);
2266 EXPECT_EQ(WebTouchPoint::StateStationary, event2.touches[3].state);
2267
2268 // Move only 4th touch but not others.
2269 MoveTouchPoints(0, 1.1, 1, 1, 2, 20.001);
2270 MoveTouchPoints(2, 3, 3, 3, 4.1, 4.1);
2271
2272 // Receive an ACK for previous (1st) TouchMove
2273 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2274
2275 // 2nd TouchMove is sent. Test for touches state.
2276 const WebTouchEvent& event3 = sent_event();
2277 EXPECT_EQ(WebInputEvent::TouchMove, event3.type);
2278 EXPECT_EQ(WebTouchPoint::StateStationary, event3.touches[0].state);
2279 EXPECT_EQ(WebTouchPoint::StateStationary, event3.touches[1].state);
2280 EXPECT_EQ(WebTouchPoint::StateStationary, event3.touches[2].state);
2281 EXPECT_EQ(WebTouchPoint::StateMoved, event3.touches[3].state);
2282 }
2283
2228 } // namespace content 2284 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698