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

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: minor changes in comments ONLY. 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 1886 matching lines...) Expand 10 before | Expand all | Expand 10 after
1897 // An unconsumed scroll should resume synchronous touch handling. 1897 // An unconsumed scroll should resume synchronous touch handling.
1898 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, 1898 SendGestureEventAck(WebInputEvent::GestureScrollUpdate,
1899 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1899 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1900 1900
1901 // The pending touchmove should be coalesced with the next (now synchronous) 1901 // The pending touchmove should be coalesced with the next (now synchronous)
1902 // touchmove. 1902 // touchmove.
1903 MoveTouchPoint(0, 0, 25); 1903 MoveTouchPoint(0, 0, 25);
1904 EXPECT_TRUE(sent_event().cancelable); 1904 EXPECT_TRUE(sent_event().cancelable);
1905 EXPECT_FALSE(HasPendingAsyncTouchMove()); 1905 EXPECT_FALSE(HasPendingAsyncTouchMove());
1906 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type); 1906 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type);
1907 EXPECT_EQ(WebTouchPoint::StateMoved, sent_event().touches[0].state); 1907 EXPECT_EQ(WebTouchPoint::StateStationary, sent_event().touches[0].state);
1908 EXPECT_EQ(WebTouchPoint::StateMoved, sent_event().touches[1].state); 1908 EXPECT_EQ(WebTouchPoint::StateMoved, sent_event().touches[1].state);
1909 EXPECT_EQ(1U, queued_event_count()); 1909 EXPECT_EQ(1U, queued_event_count());
1910 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1910 EXPECT_EQ(1U, GetAndResetSentEventCount());
1911 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1911 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1912 1912
1913 // Subsequent touches will queue until the preceding, synchronous touches are 1913 // Subsequent touches will queue until the preceding, synchronous touches are
1914 // ack'ed. 1914 // ack'ed.
1915 ReleaseTouchPoint(1); 1915 ReleaseTouchPoint(1);
1916 EXPECT_EQ(2U, queued_event_count()); 1916 EXPECT_EQ(2U, queued_event_count());
1917 ReleaseTouchPoint(0); 1917 ReleaseTouchPoint(0);
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
2248 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 2248 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2249 2249
2250 // Give the touchmove a valid id; it should be sent. 2250 // Give the touchmove a valid id; it should be sent.
2251 event.touches[0].id = press_id; 2251 event.touches[0].id = press_id;
2252 SendTouchEvent(event); 2252 SendTouchEvent(event);
2253 EXPECT_EQ(1U, GetAndResetSentEventCount()); 2253 EXPECT_EQ(1U, GetAndResetSentEventCount());
2254 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 2254 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2255 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 2255 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2256 } 2256 }
2257 2257
2258 // Tests that touches state is correct in TouchMove events.
2259 TEST_F(TouchEventQueueTest, TouchMoveTouchesState) {
2260 PressTouchPoint(1, 1);
2261 PressTouchPoint(2, 2);
2262 PressTouchPoint(3, 3);
2263 PressTouchPoint(4, 4);
2264 EXPECT_EQ(4U, queued_event_count());
2265 EXPECT_EQ(1U, GetAndResetSentEventCount());
2266
2267 // Receive ACK for the first three touch-events.
2268 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2269 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2270 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2271 EXPECT_EQ(1U, queued_event_count());
2272
2273 // Test current touches state before sending TouchMoves.
2274 const WebTouchEvent& event1 = sent_event();
2275 EXPECT_EQ(WebInputEvent::TouchStart, event1.type);
2276 EXPECT_EQ(WebTouchPoint::StateStationary, event1.touches[0].state);
2277 EXPECT_EQ(WebTouchPoint::StateStationary, event1.touches[1].state);
2278 EXPECT_EQ(WebTouchPoint::StateStationary, event1.touches[2].state);
2279 EXPECT_EQ(WebTouchPoint::StatePressed, event1.touches[3].state);
2280
2281 // Move x-position for 1st touch, y-position for 2nd touch
2282 // and do not move other touches.
2283 MoveTouchPoints(0, 1.1, 1, 1, 2, 20.001);
jdduke (slow) 2015/01/20 18:18:09 Looks like you simply need to add float modifiers
USE s.singapati at gmail.com 2015/01/26 10:26:07 Done.
2284 MoveTouchPoints(2, 3, 3, 3, 4, 4);
2285 EXPECT_EQ(2U, queued_event_count());
2286
2287 // Receive an ACK for the last TouchPress event.
2288 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2289
2290 // 1st TouchMove is sent. Test for touches state.
2291 const WebTouchEvent& event2 = sent_event();
2292 EXPECT_EQ(WebInputEvent::TouchMove, event2.type);
2293 EXPECT_EQ(WebTouchPoint::StateMoved, event2.touches[0].state);
2294 EXPECT_EQ(WebTouchPoint::StateMoved, event2.touches[1].state);
2295 EXPECT_EQ(WebTouchPoint::StateStationary, event2.touches[2].state);
2296 EXPECT_EQ(WebTouchPoint::StateStationary, event2.touches[3].state);
2297
2298 // Move only 4th touch but not others.
2299 MoveTouchPoints(0, 1.1, 1, 1, 2, 20.001);
2300 MoveTouchPoints(2, 3, 3, 3, 4.1, 4.1);
2301
2302 // Receive an ACK for previous (1st) TouchMove.
2303 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2304
2305 // 2nd TouchMove is sent. Test for touches state.
2306 const WebTouchEvent& event3 = sent_event();
2307 EXPECT_EQ(WebInputEvent::TouchMove, event3.type);
2308 EXPECT_EQ(WebTouchPoint::StateStationary, event3.touches[0].state);
2309 EXPECT_EQ(WebTouchPoint::StateStationary, event3.touches[1].state);
2310 EXPECT_EQ(WebTouchPoint::StateStationary, event3.touches[2].state);
2311 EXPECT_EQ(WebTouchPoint::StateMoved, event3.touches[3].state);
2312 }
2313
2258 } // namespace content 2314 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/input/touch_event_queue.cc ('k') | content/common/input/touch_event_stream_validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698