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

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

Issue 156783006: Consuming a touch move prevents only the next scroll update. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clean up error handling and tests. Created 6 years, 10 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 | Annotate | Revision Log
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 20 matching lines...) Expand all
31 last_acked_event_state_(INPUT_EVENT_ACK_STATE_UNKNOWN) {} 31 last_acked_event_state_(INPUT_EVENT_ACK_STATE_UNKNOWN) {}
32 32
33 virtual ~TouchEventQueueTest() {} 33 virtual ~TouchEventQueueTest() {}
34 34
35 // testing::Test 35 // testing::Test
36 virtual void SetUp() OVERRIDE { 36 virtual void SetUp() OVERRIDE {
37 queue_.reset(new TouchEventQueue(this)); 37 queue_.reset(new TouchEventQueue(this));
38 queue_->OnHasTouchEventHandlers(true); 38 queue_->OnHasTouchEventHandlers(true);
39 } 39 }
40 40
41 virtual void SetTouchScrollingMode(TouchEventQueue::TouchScrollingMode mode) {
42 queue_.reset(new TouchEventQueue(this, mode));
43 queue_->OnHasTouchEventHandlers(true);
44 }
45
41 virtual void TearDown() OVERRIDE { 46 virtual void TearDown() OVERRIDE {
42 queue_.reset(); 47 queue_.reset();
43 } 48 }
44 49
45 // TouchEventQueueClient 50 // TouchEventQueueClient
46 virtual void SendTouchEventImmediately( 51 virtual void SendTouchEventImmediately(
47 const TouchEventWithLatencyInfo& event) OVERRIDE { 52 const TouchEventWithLatencyInfo& event) OVERRIDE {
48 ++sent_event_count_; 53 ++sent_event_count_;
49 last_sent_event_ = event.event; 54 last_sent_event_ = event.event;
50 if (sync_ack_result_) 55 if (sync_ack_result_)
51 SendTouchEventACK(*sync_ack_result_.Pass()); 56 SendTouchEventAck(*sync_ack_result_.Pass());
52 } 57 }
53 58
54 virtual void OnTouchEventAck( 59 virtual void OnTouchEventAck(
55 const TouchEventWithLatencyInfo& event, 60 const TouchEventWithLatencyInfo& event,
56 InputEventAckState ack_result) OVERRIDE { 61 InputEventAckState ack_result) OVERRIDE {
57 ++acked_event_count_; 62 ++acked_event_count_;
58 last_acked_event_ = event.event; 63 last_acked_event_ = event.event;
59 last_acked_event_state_ = ack_result; 64 last_acked_event_state_ = ack_result;
60 if (followup_touch_event_) { 65 if (followup_touch_event_) {
61 scoped_ptr<WebTouchEvent> followup_touch_event = 66 scoped_ptr<WebTouchEvent> followup_touch_event =
(...skipping 23 matching lines...) Expand all
85 queue_->QueueEvent(TouchEventWithLatencyInfo(event, ui::LatencyInfo())); 90 queue_->QueueEvent(TouchEventWithLatencyInfo(event, ui::LatencyInfo()));
86 } 91 }
87 92
88 void SendGestureEvent(WebInputEvent::Type type) { 93 void SendGestureEvent(WebInputEvent::Type type) {
89 WebGestureEvent event; 94 WebGestureEvent event;
90 event.type = type; 95 event.type = type;
91 queue_->OnGestureScrollEvent( 96 queue_->OnGestureScrollEvent(
92 GestureEventWithLatencyInfo(event, ui::LatencyInfo())); 97 GestureEventWithLatencyInfo(event, ui::LatencyInfo()));
93 } 98 }
94 99
95 void SendTouchEventACK(InputEventAckState ack_result) { 100 void SendTouchEventAck(InputEventAckState ack_result) {
96 queue_->ProcessTouchAck(ack_result, ui::LatencyInfo()); 101 queue_->ProcessTouchAck(ack_result, ui::LatencyInfo());
97 } 102 }
98 103
104 void SendGestureEventAck(WebInputEvent::Type type,
105 InputEventAckState ack_result) {
106 blink::WebGestureEvent gesture_event;
107 gesture_event.type = type;
108 GestureEventWithLatencyInfo event(gesture_event, ui::LatencyInfo());
109 queue_->OnGestureEventAck(event, ack_result);
110 }
111
99 void SetFollowupEvent(const WebTouchEvent& event) { 112 void SetFollowupEvent(const WebTouchEvent& event) {
100 followup_touch_event_.reset(new WebTouchEvent(event)); 113 followup_touch_event_.reset(new WebTouchEvent(event));
101 } 114 }
102 115
103 void SetFollowupEvent(const WebGestureEvent& event) { 116 void SetFollowupEvent(const WebGestureEvent& event) {
104 followup_gesture_event_.reset(new WebGestureEvent(event)); 117 followup_gesture_event_.reset(new WebGestureEvent(event));
105 } 118 }
106 119
107 void SetSyncAckResult(InputEventAckState sync_ack_result) { 120 void SetSyncAckResult(InputEventAckState sync_ack_result) {
108 sync_ack_result_.reset(new InputEventAckState(sync_ack_result)); 121 sync_ack_result_.reset(new InputEventAckState(sync_ack_result));
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 PressTouchPoint(1, 1); 216 PressTouchPoint(1, 1);
204 EXPECT_EQ(1U, queued_event_count()); 217 EXPECT_EQ(1U, queued_event_count());
205 EXPECT_EQ(1U, GetAndResetSentEventCount()); 218 EXPECT_EQ(1U, GetAndResetSentEventCount());
206 219
207 // The second touch should not be sent since one is already in queue. 220 // The second touch should not be sent since one is already in queue.
208 MoveTouchPoint(0, 5, 5); 221 MoveTouchPoint(0, 5, 5);
209 EXPECT_EQ(2U, queued_event_count()); 222 EXPECT_EQ(2U, queued_event_count());
210 EXPECT_EQ(0U, GetAndResetSentEventCount()); 223 EXPECT_EQ(0U, GetAndResetSentEventCount());
211 224
212 // Receive an ACK for the first touch-event. 225 // Receive an ACK for the first touch-event.
213 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); 226 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
214 EXPECT_EQ(1U, queued_event_count()); 227 EXPECT_EQ(1U, queued_event_count());
215 EXPECT_EQ(1U, GetAndResetSentEventCount()); 228 EXPECT_EQ(1U, GetAndResetSentEventCount());
216 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 229 EXPECT_EQ(1U, GetAndResetAckedEventCount());
217 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type); 230 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type);
218 231
219 // Receive an ACK for the second touch-event. 232 // Receive an ACK for the second touch-event.
220 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); 233 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
221 EXPECT_EQ(0U, queued_event_count()); 234 EXPECT_EQ(0U, queued_event_count());
222 EXPECT_EQ(0U, GetAndResetSentEventCount()); 235 EXPECT_EQ(0U, GetAndResetSentEventCount());
223 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 236 EXPECT_EQ(1U, GetAndResetAckedEventCount());
224 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type); 237 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type);
225 } 238 }
226 239
227 // Tests that the touch-queue is emptied if a page stops listening for touch 240 // Tests that the touch-queue is emptied if a page stops listening for touch
228 // events. 241 // events.
229 TEST_F(TouchEventQueueTest, QueueFlushedWhenHandlersRemoved) { 242 TEST_F(TouchEventQueueTest, QueueFlushedWhenHandlersRemoved) {
230 OnHasTouchEventHandlers(true); 243 OnHasTouchEventHandlers(true);
(...skipping 10 matching lines...) Expand all
241 for (int i = 5; i < 15; ++i) { 254 for (int i = 5; i < 15; ++i) {
242 PressTouchPoint(1, 1); 255 PressTouchPoint(1, 1);
243 MoveTouchPoint(0, i, i); 256 MoveTouchPoint(0, i, i);
244 ReleaseTouchPoint(0); 257 ReleaseTouchPoint(0);
245 } 258 }
246 EXPECT_EQ(32U, queued_event_count()); 259 EXPECT_EQ(32U, queued_event_count());
247 EXPECT_EQ(0U, GetAndResetSentEventCount()); 260 EXPECT_EQ(0U, GetAndResetSentEventCount());
248 261
249 // Receive an ACK for the first touch-event. One of the queued touch-event 262 // Receive an ACK for the first touch-event. One of the queued touch-event
250 // should be forwarded. 263 // should be forwarded.
251 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); 264 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
252 EXPECT_EQ(31U, queued_event_count()); 265 EXPECT_EQ(31U, queued_event_count());
253 EXPECT_EQ(1U, GetAndResetSentEventCount()); 266 EXPECT_EQ(1U, GetAndResetSentEventCount());
254 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 267 EXPECT_EQ(1U, GetAndResetAckedEventCount());
255 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type); 268 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type);
256 269
257 // Flush the queue. The touch-event queue should now be emptied, but none of 270 // Flush the queue. The touch-event queue should now be emptied, but none of
258 // the queued touch-events should be sent to the renderer. 271 // the queued touch-events should be sent to the renderer.
259 OnHasTouchEventHandlers(false); 272 OnHasTouchEventHandlers(false);
260 EXPECT_EQ(0U, queued_event_count()); 273 EXPECT_EQ(0U, queued_event_count());
261 EXPECT_EQ(0U, GetAndResetSentEventCount()); 274 EXPECT_EQ(0U, GetAndResetSentEventCount());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 EXPECT_EQ(2U, queued_event_count()); 315 EXPECT_EQ(2U, queued_event_count());
303 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 316 EXPECT_EQ(0U, GetAndResetAckedEventCount());
304 EXPECT_EQ(0U, GetAndResetSentEventCount()); 317 EXPECT_EQ(0U, GetAndResetSentEventCount());
305 318
306 // Touch handle deregistration should flush the queue. 319 // Touch handle deregistration should flush the queue.
307 OnHasTouchEventHandlers(false); 320 OnHasTouchEventHandlers(false);
308 EXPECT_EQ(2U, GetAndResetAckedEventCount()); 321 EXPECT_EQ(2U, GetAndResetAckedEventCount());
309 EXPECT_EQ(0U, queued_event_count()); 322 EXPECT_EQ(0U, queued_event_count());
310 323
311 // The ack should be ignored as the touch queue is now empty. 324 // The ack should be ignored as the touch queue is now empty.
312 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); 325 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
313 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 326 EXPECT_EQ(0U, GetAndResetAckedEventCount());
314 EXPECT_EQ(0U, queued_event_count()); 327 EXPECT_EQ(0U, queued_event_count());
315 328
316 // Events should be dropped while there is no touch handler. 329 // Events should be dropped while there is no touch handler.
317 MoveTouchPoint(0, 10, 10); 330 MoveTouchPoint(0, 10, 10);
318 EXPECT_EQ(0U, queued_event_count()); 331 EXPECT_EQ(0U, queued_event_count());
319 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 332 EXPECT_EQ(1U, GetAndResetAckedEventCount());
320 EXPECT_EQ(0U, GetAndResetSentEventCount()); 333 EXPECT_EQ(0U, GetAndResetSentEventCount());
321 334
322 // Simulate touch handler registration in the middle of a touch sequence. 335 // Simulate touch handler registration in the middle of a touch sequence.
(...skipping 21 matching lines...) Expand all
344 // touch-move events should be coalesced into a single event. 357 // touch-move events should be coalesced into a single event.
345 for (int i = 5; i < 15; ++i) 358 for (int i = 5; i < 15; ++i)
346 MoveTouchPoint(0, i, i); 359 MoveTouchPoint(0, i, i);
347 360
348 EXPECT_EQ(0U, GetAndResetSentEventCount()); 361 EXPECT_EQ(0U, GetAndResetSentEventCount());
349 ReleaseTouchPoint(0); 362 ReleaseTouchPoint(0);
350 EXPECT_EQ(0U, GetAndResetSentEventCount()); 363 EXPECT_EQ(0U, GetAndResetSentEventCount());
351 EXPECT_EQ(3U, queued_event_count()); 364 EXPECT_EQ(3U, queued_event_count());
352 365
353 // ACK the press. Coalesced touch-move events should be sent. 366 // ACK the press. Coalesced touch-move events should be sent.
354 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); 367 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
355 EXPECT_EQ(2U, queued_event_count()); 368 EXPECT_EQ(2U, queued_event_count());
356 EXPECT_EQ(1U, GetAndResetSentEventCount()); 369 EXPECT_EQ(1U, GetAndResetSentEventCount());
357 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 370 EXPECT_EQ(1U, GetAndResetAckedEventCount());
358 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type); 371 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type);
359 EXPECT_EQ(INPUT_EVENT_ACK_STATE_CONSUMED, acked_event_state()); 372 EXPECT_EQ(INPUT_EVENT_ACK_STATE_CONSUMED, acked_event_state());
360 373
361 // ACK the moves. 374 // ACK the moves.
362 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); 375 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
363 EXPECT_EQ(1U, queued_event_count()); 376 EXPECT_EQ(1U, queued_event_count());
364 EXPECT_EQ(1U, GetAndResetSentEventCount()); 377 EXPECT_EQ(1U, GetAndResetSentEventCount());
365 EXPECT_EQ(10U, GetAndResetAckedEventCount()); 378 EXPECT_EQ(10U, GetAndResetAckedEventCount());
366 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type); 379 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type);
367 380
368 // ACK the release. 381 // ACK the release.
369 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); 382 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
370 EXPECT_EQ(0U, queued_event_count()); 383 EXPECT_EQ(0U, queued_event_count());
371 EXPECT_EQ(0U, GetAndResetSentEventCount()); 384 EXPECT_EQ(0U, GetAndResetSentEventCount());
372 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 385 EXPECT_EQ(1U, GetAndResetAckedEventCount());
373 EXPECT_EQ(WebInputEvent::TouchEnd, acked_event().type); 386 EXPECT_EQ(WebInputEvent::TouchEnd, acked_event().type);
374 } 387 }
375 388
376 // Tests that an event that has already been sent but hasn't been ack'ed yet 389 // Tests that an event that has already been sent but hasn't been ack'ed yet
377 // doesn't get coalesced with newer events. 390 // doesn't get coalesced with newer events.
378 TEST_F(TouchEventQueueTest, SentTouchEventDoesNotCoalesce) { 391 TEST_F(TouchEventQueueTest, SentTouchEventDoesNotCoalesce) {
379 // Send a touch-press event. 392 // Send a touch-press event.
380 PressTouchPoint(1, 1); 393 PressTouchPoint(1, 1);
381 EXPECT_EQ(1U, GetAndResetSentEventCount()); 394 EXPECT_EQ(1U, GetAndResetSentEventCount());
382 395
383 // Send a few touch-move events, followed by a touch-release event. All the 396 // Send a few touch-move events, followed by a touch-release event. All the
384 // touch-move events should be coalesced into a single event. 397 // touch-move events should be coalesced into a single event.
385 for (int i = 5; i < 15; ++i) 398 for (int i = 5; i < 15; ++i)
386 MoveTouchPoint(0, i, i); 399 MoveTouchPoint(0, i, i);
387 400
388 EXPECT_EQ(0U, GetAndResetSentEventCount()); 401 EXPECT_EQ(0U, GetAndResetSentEventCount());
389 EXPECT_EQ(2U, queued_event_count()); 402 EXPECT_EQ(2U, queued_event_count());
390 403
391 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 404 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
392 EXPECT_EQ(1U, GetAndResetSentEventCount()); 405 EXPECT_EQ(1U, GetAndResetSentEventCount());
393 EXPECT_EQ(1U, queued_event_count()); 406 EXPECT_EQ(1U, queued_event_count());
394 407
395 // The coalesced touch-move event has been sent to the renderer. Any new 408 // The coalesced touch-move event has been sent to the renderer. Any new
396 // touch-move event should not be coalesced with the sent event. 409 // touch-move event should not be coalesced with the sent event.
397 MoveTouchPoint(0, 5, 5); 410 MoveTouchPoint(0, 5, 5);
398 EXPECT_EQ(2U, queued_event_count()); 411 EXPECT_EQ(2U, queued_event_count());
399 412
400 MoveTouchPoint(0, 7, 7); 413 MoveTouchPoint(0, 7, 7);
401 EXPECT_EQ(2U, queued_event_count()); 414 EXPECT_EQ(2U, queued_event_count());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 PressTouchPoint(1, 1); 456 PressTouchPoint(1, 1);
444 EXPECT_EQ(1U, GetAndResetSentEventCount()); 457 EXPECT_EQ(1U, GetAndResetSentEventCount());
445 EXPECT_EQ(1U, queued_event_count()); 458 EXPECT_EQ(1U, queued_event_count());
446 459
447 MoveTouchPoint(0, 10, 10); 460 MoveTouchPoint(0, 10, 10);
448 EXPECT_EQ(0U, GetAndResetSentEventCount()); 461 EXPECT_EQ(0U, GetAndResetSentEventCount());
449 EXPECT_EQ(2U, queued_event_count()); 462 EXPECT_EQ(2U, queued_event_count());
450 463
451 // Receive an ACK for the press. This should cause the queued touch-move to 464 // Receive an ACK for the press. This should cause the queued touch-move to
452 // be sent to the renderer. 465 // be sent to the renderer.
453 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); 466 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
454 EXPECT_EQ(1U, GetAndResetSentEventCount()); 467 EXPECT_EQ(1U, GetAndResetSentEventCount());
455 EXPECT_EQ(1U, queued_event_count()); 468 EXPECT_EQ(1U, queued_event_count());
456 469
457 OnHasTouchEventHandlers(false); 470 OnHasTouchEventHandlers(false);
458 EXPECT_EQ(0U, GetAndResetSentEventCount()); 471 EXPECT_EQ(0U, GetAndResetSentEventCount());
459 EXPECT_EQ(0U, queued_event_count()); 472 EXPECT_EQ(0U, queued_event_count());
460 473
461 // Now receive an ACK for the move. 474 // Now receive an ACK for the move.
462 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); 475 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
463 EXPECT_EQ(0U, GetAndResetSentEventCount()); 476 EXPECT_EQ(0U, GetAndResetSentEventCount());
464 EXPECT_EQ(0U, queued_event_count()); 477 EXPECT_EQ(0U, queued_event_count());
465 } 478 }
466 479
467 // Tests that touch-move events are not sent to the renderer if the preceding 480 // Tests that touch-move events are not sent to the renderer if the preceding
468 // touch-press event did not have a consumer (and consequently, did not hit the 481 // touch-press event did not have a consumer (and consequently, did not hit the
469 // main thread in the renderer). Also tests that all queued/coalesced touch 482 // main thread in the renderer). Also tests that all queued/coalesced touch
470 // events are flushed immediately when the ACK for the touch-press comes back 483 // events are flushed immediately when the ACK for the touch-press comes back
471 // with NO_CONSUMER status. 484 // with NO_CONSUMER status.
472 TEST_F(TouchEventQueueTest, NoConsumer) { 485 TEST_F(TouchEventQueueTest, NoConsumer) {
473 // The first touch-press should reach the renderer. 486 // The first touch-press should reach the renderer.
474 PressTouchPoint(1, 1); 487 PressTouchPoint(1, 1);
475 EXPECT_EQ(1U, GetAndResetSentEventCount()); 488 EXPECT_EQ(1U, GetAndResetSentEventCount());
476 489
477 // The second touch should not be sent since one is already in queue. 490 // The second touch should not be sent since one is already in queue.
478 MoveTouchPoint(0, 5, 5); 491 MoveTouchPoint(0, 5, 5);
479 EXPECT_EQ(0U, GetAndResetSentEventCount()); 492 EXPECT_EQ(0U, GetAndResetSentEventCount());
480 EXPECT_EQ(2U, queued_event_count()); 493 EXPECT_EQ(2U, queued_event_count());
481 494
482 // Receive an ACK for the first touch-event. This should release the queued 495 // Receive an ACK for the first touch-event. This should release the queued
483 // touch-event, but it should not be sent to the renderer. 496 // touch-event, but it should not be sent to the renderer.
484 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); 497 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
485 EXPECT_EQ(0U, queued_event_count()); 498 EXPECT_EQ(0U, queued_event_count());
486 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type); 499 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type);
487 EXPECT_EQ(2U, GetAndResetAckedEventCount()); 500 EXPECT_EQ(2U, GetAndResetAckedEventCount());
488 EXPECT_EQ(0U, GetAndResetSentEventCount()); 501 EXPECT_EQ(0U, GetAndResetSentEventCount());
489 502
490 // Send a release event. This should not reach the renderer. 503 // Send a release event. This should not reach the renderer.
491 ReleaseTouchPoint(0); 504 ReleaseTouchPoint(0);
492 EXPECT_EQ(0U, GetAndResetSentEventCount()); 505 EXPECT_EQ(0U, GetAndResetSentEventCount());
493 EXPECT_EQ(WebInputEvent::TouchEnd, acked_event().type); 506 EXPECT_EQ(WebInputEvent::TouchEnd, acked_event().type);
494 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 507 EXPECT_EQ(1U, GetAndResetAckedEventCount());
495 508
496 // Send a press-event, followed by move and release events, and another press 509 // Send a press-event, followed by move and release events, and another press
497 // event, before the ACK for the first press event comes back. All of the 510 // event, before the ACK for the first press event comes back. All of the
498 // events should be queued first. After the NO_CONSUMER ack for the first 511 // events should be queued first. After the NO_CONSUMER ack for the first
499 // touch-press, all events upto the second touch-press should be flushed. 512 // touch-press, all events upto the second touch-press should be flushed.
500 PressTouchPoint(10, 10); 513 PressTouchPoint(10, 10);
501 EXPECT_EQ(1U, GetAndResetSentEventCount()); 514 EXPECT_EQ(1U, GetAndResetSentEventCount());
502 515
503 MoveTouchPoint(0, 5, 5); 516 MoveTouchPoint(0, 5, 5);
504 MoveTouchPoint(0, 6, 5); 517 MoveTouchPoint(0, 6, 5);
505 ReleaseTouchPoint(0); 518 ReleaseTouchPoint(0);
506 519
507 PressTouchPoint(6, 5); 520 PressTouchPoint(6, 5);
508 EXPECT_EQ(0U, GetAndResetSentEventCount()); 521 EXPECT_EQ(0U, GetAndResetSentEventCount());
509 // The queue should hold the first sent touch-press event, the coalesced 522 // The queue should hold the first sent touch-press event, the coalesced
510 // touch-move event, the touch-end event and the second touch-press event. 523 // touch-move event, the touch-end event and the second touch-press event.
511 EXPECT_EQ(4U, queued_event_count()); 524 EXPECT_EQ(4U, queued_event_count());
512 525
513 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); 526 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
514 EXPECT_EQ(1U, GetAndResetSentEventCount()); 527 EXPECT_EQ(1U, GetAndResetSentEventCount());
515 EXPECT_EQ(WebInputEvent::TouchEnd, acked_event().type); 528 EXPECT_EQ(WebInputEvent::TouchEnd, acked_event().type);
516 EXPECT_EQ(4U, GetAndResetAckedEventCount()); 529 EXPECT_EQ(4U, GetAndResetAckedEventCount());
517 EXPECT_EQ(1U, queued_event_count()); 530 EXPECT_EQ(1U, queued_event_count());
518 531
519 // ACK the second press event as NO_CONSUMER too. 532 // ACK the second press event as NO_CONSUMER too.
520 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); 533 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
521 EXPECT_EQ(0U, GetAndResetSentEventCount()); 534 EXPECT_EQ(0U, GetAndResetSentEventCount());
522 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type); 535 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type);
523 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 536 EXPECT_EQ(1U, GetAndResetAckedEventCount());
524 EXPECT_EQ(0U, queued_event_count()); 537 EXPECT_EQ(0U, queued_event_count());
525 538
526 // Send a second press event. Even though the first touch had NO_CONSUMER, 539 // Send a second press event. Even though the first touch had NO_CONSUMER,
527 // this press event should reach the renderer. 540 // this press event should reach the renderer.
528 PressTouchPoint(1, 1); 541 PressTouchPoint(1, 1);
529 EXPECT_EQ(1U, GetAndResetSentEventCount()); 542 EXPECT_EQ(1U, GetAndResetSentEventCount());
530 EXPECT_EQ(1U, queued_event_count()); 543 EXPECT_EQ(1U, queued_event_count());
(...skipping 19 matching lines...) Expand all
550 563
551 // Since the first touch-press is still pending ACK, no other event should 564 // Since the first touch-press is still pending ACK, no other event should
552 // have been sent to the renderer. 565 // have been sent to the renderer.
553 EXPECT_EQ(0U, GetAndResetSentEventCount()); 566 EXPECT_EQ(0U, GetAndResetSentEventCount());
554 // The queue includes the two presses, the first touch-move of the first 567 // The queue includes the two presses, the first touch-move of the first
555 // point, and a coalesced touch-move of both points. 568 // point, and a coalesced touch-move of both points.
556 EXPECT_EQ(4U, queued_event_count()); 569 EXPECT_EQ(4U, queued_event_count());
557 570
558 // ACK the first press as CONSUMED. This should cause the first touch-move of 571 // ACK the first press as CONSUMED. This should cause the first touch-move of
559 // the first touch-point to be dispatched. 572 // the first touch-point to be dispatched.
560 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); 573 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
561 EXPECT_EQ(1U, GetAndResetSentEventCount()); 574 EXPECT_EQ(1U, GetAndResetSentEventCount());
562 EXPECT_EQ(3U, queued_event_count()); 575 EXPECT_EQ(3U, queued_event_count());
563 576
564 // ACK the first move as CONSUMED. 577 // ACK the first move as CONSUMED.
565 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); 578 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
566 EXPECT_EQ(1U, GetAndResetSentEventCount()); 579 EXPECT_EQ(1U, GetAndResetSentEventCount());
567 EXPECT_EQ(2U, queued_event_count()); 580 EXPECT_EQ(2U, queued_event_count());
568 581
569 // ACK the second press as NO_CONSUMER_EXISTS. This will dequeue the coalesced 582 // ACK the second press as NO_CONSUMER_EXISTS. This will dequeue the coalesced
570 // touch-move event (which contains both touch points). Although the second 583 // touch-move event (which contains both touch points). Although the second
571 // touch-point does not need to be sent to the renderer, the first touch-point 584 // touch-point does not need to be sent to the renderer, the first touch-point
572 // did move, and so the coalesced touch-event will be sent to the renderer. 585 // did move, and so the coalesced touch-event will be sent to the renderer.
573 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); 586 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
574 EXPECT_EQ(1U, GetAndResetSentEventCount()); 587 EXPECT_EQ(1U, GetAndResetSentEventCount());
575 EXPECT_EQ(1U, queued_event_count()); 588 EXPECT_EQ(1U, queued_event_count());
576 589
577 // ACK the coalesced move as NOT_CONSUMED. 590 // ACK the coalesced move as NOT_CONSUMED.
578 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 591 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
579 EXPECT_EQ(0U, GetAndResetSentEventCount()); 592 EXPECT_EQ(0U, GetAndResetSentEventCount());
580 EXPECT_EQ(0U, queued_event_count()); 593 EXPECT_EQ(0U, queued_event_count());
581 594
582 // Move just the second touch point. Because the first touch point did not 595 // Move just the second touch point. Because the first touch point did not
583 // move, this event should not reach the renderer. 596 // move, this event should not reach the renderer.
584 MoveTouchPoint(1, 30, 30); 597 MoveTouchPoint(1, 30, 30);
585 EXPECT_EQ(0U, GetAndResetSentEventCount()); 598 EXPECT_EQ(0U, GetAndResetSentEventCount());
586 EXPECT_EQ(0U, queued_event_count()); 599 EXPECT_EQ(0U, queued_event_count());
587 600
588 // Move just the first touch point. This should reach the renderer. 601 // Move just the first touch point. This should reach the renderer.
589 MoveTouchPoint(0, 10, 10); 602 MoveTouchPoint(0, 10, 10);
590 EXPECT_EQ(1U, GetAndResetSentEventCount()); 603 EXPECT_EQ(1U, GetAndResetSentEventCount());
591 EXPECT_EQ(1U, queued_event_count()); 604 EXPECT_EQ(1U, queued_event_count());
592 605
593 // Move both fingers. This event should reach the renderer (after the ACK of 606 // Move both fingers. This event should reach the renderer (after the ACK of
594 // the previous move event is received), because the first touch point did 607 // the previous move event is received), because the first touch point did
595 // move. 608 // move.
596 MoveTouchPoints(0, 15, 15, 1, 25, 25); 609 MoveTouchPoints(0, 15, 15, 1, 25, 25);
597 EXPECT_EQ(0U, GetAndResetSentEventCount()); 610 EXPECT_EQ(0U, GetAndResetSentEventCount());
598 611
599 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); 612 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
600 EXPECT_EQ(1U, GetAndResetSentEventCount()); 613 EXPECT_EQ(1U, GetAndResetSentEventCount());
601 EXPECT_EQ(1U, queued_event_count()); 614 EXPECT_EQ(1U, queued_event_count());
602 615
603 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); 616 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
604 EXPECT_EQ(0U, GetAndResetSentEventCount()); 617 EXPECT_EQ(0U, GetAndResetSentEventCount());
605 EXPECT_EQ(0U, queued_event_count()); 618 EXPECT_EQ(0U, queued_event_count());
606 619
607 // Release the first finger. Then move the second finger around some, then 620 // Release the first finger. Then move the second finger around some, then
608 // press another finger. Once the release event is ACKed, the move events of 621 // press another finger. Once the release event is ACKed, the move events of
609 // the second finger should be immediately released to the view, and the 622 // the second finger should be immediately released to the view, and the
610 // touch-press event should be dispatched to the renderer. 623 // touch-press event should be dispatched to the renderer.
611 ReleaseTouchPoint(0); 624 ReleaseTouchPoint(0);
612 EXPECT_EQ(1U, GetAndResetSentEventCount()); 625 EXPECT_EQ(1U, GetAndResetSentEventCount());
613 EXPECT_EQ(1U, queued_event_count()); 626 EXPECT_EQ(1U, queued_event_count());
614 627
615 MoveTouchPoint(1, 40, 40); 628 MoveTouchPoint(1, 40, 40);
616 629
617 MoveTouchPoint(1, 50, 50); 630 MoveTouchPoint(1, 50, 50);
618 631
619 PressTouchPoint(1, 1); 632 PressTouchPoint(1, 1);
620 633
621 MoveTouchPoint(1, 30, 30); 634 MoveTouchPoint(1, 30, 30);
622 EXPECT_EQ(0U, GetAndResetSentEventCount()); 635 EXPECT_EQ(0U, GetAndResetSentEventCount());
623 EXPECT_EQ(4U, queued_event_count()); 636 EXPECT_EQ(4U, queued_event_count());
624 637
625 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 638 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
626 EXPECT_EQ(1U, GetAndResetSentEventCount()); 639 EXPECT_EQ(1U, GetAndResetSentEventCount());
627 EXPECT_EQ(2U, queued_event_count()); 640 EXPECT_EQ(2U, queued_event_count());
628 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type); 641 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type);
629 642
630 // ACK the press with NO_CONSUMED_EXISTS. This should release the queued 643 // ACK the press with NO_CONSUMED_EXISTS. This should release the queued
631 // touch-move events to the view. 644 // touch-move events to the view.
632 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); 645 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
633 EXPECT_EQ(0U, GetAndResetSentEventCount()); 646 EXPECT_EQ(0U, GetAndResetSentEventCount());
634 EXPECT_EQ(0U, queued_event_count()); 647 EXPECT_EQ(0U, queued_event_count());
635 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type); 648 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type);
636 649
637 ReleaseTouchPoint(2); 650 ReleaseTouchPoint(2);
638 ReleaseTouchPoint(1); 651 ReleaseTouchPoint(1);
639 EXPECT_EQ(0U, GetAndResetSentEventCount()); 652 EXPECT_EQ(0U, GetAndResetSentEventCount());
640 EXPECT_EQ(0U, queued_event_count()); 653 EXPECT_EQ(0U, queued_event_count());
641 } 654 }
642 655
643 // Tests that touch-event's enqueued via a touch ack are properly handled. 656 // Tests that touch-event's enqueued via a touch ack are properly handled.
644 TEST_F(TouchEventQueueTest, AckWithFollowupEvents) { 657 TEST_F(TouchEventQueueTest, AckWithFollowupEvents) {
645 // Queue a touch down. 658 // Queue a touch down.
646 PressTouchPoint(1, 1); 659 PressTouchPoint(1, 1);
647 EXPECT_EQ(1U, queued_event_count()); 660 EXPECT_EQ(1U, queued_event_count());
648 EXPECT_EQ(1U, GetAndResetSentEventCount()); 661 EXPECT_EQ(1U, GetAndResetSentEventCount());
649 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 662 EXPECT_EQ(0U, GetAndResetAckedEventCount());
650 663
651 // Create a touch event that will be queued synchronously by a touch ack. 664 // Create a touch event that will be queued synchronously by a touch ack.
652 // Note, this will be triggered by all subsequent touch acks. 665 // Note, this will be triggered by all subsequent touch acks.
653 WebTouchEvent followup_event; 666 WebTouchEvent followup_event;
654 followup_event.type = WebInputEvent::TouchStart; 667 followup_event.type = WebInputEvent::TouchStart;
655 followup_event.touchesLength = 1; 668 followup_event.touchesLength = 1;
656 followup_event.touches[0].id = 1; 669 followup_event.touches[0].id = 1;
657 followup_event.touches[0].state = WebTouchPoint::StatePressed; 670 followup_event.touches[0].state = WebTouchPoint::StatePressed;
658 SetFollowupEvent(followup_event); 671 SetFollowupEvent(followup_event);
659 672
660 // Receive an ACK for the press. This should cause the followup touch-move to 673 // Receive an ACK for the press. This should cause the followup touch-move to
661 // be sent to the renderer. 674 // be sent to the renderer.
662 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); 675 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
663 EXPECT_EQ(1U, queued_event_count()); 676 EXPECT_EQ(1U, queued_event_count());
664 EXPECT_EQ(1U, GetAndResetSentEventCount()); 677 EXPECT_EQ(1U, GetAndResetSentEventCount());
665 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 678 EXPECT_EQ(1U, GetAndResetAckedEventCount());
666 EXPECT_EQ(INPUT_EVENT_ACK_STATE_CONSUMED, acked_event_state()); 679 EXPECT_EQ(INPUT_EVENT_ACK_STATE_CONSUMED, acked_event_state());
667 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type); 680 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type);
668 681
669 // Queue another event. 682 // Queue another event.
670 MoveTouchPoint(0, 2, 2); 683 MoveTouchPoint(0, 2, 2);
671 EXPECT_EQ(2U, queued_event_count()); 684 EXPECT_EQ(2U, queued_event_count());
672 685
673 // Receive an ACK for the touch-move followup event. This should cause the 686 // Receive an ACK for the touch-move followup event. This should cause the
674 // subsequent touch move event be sent to the renderer. 687 // subsequent touch move event be sent to the renderer.
675 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); 688 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
676 EXPECT_EQ(1U, queued_event_count()); 689 EXPECT_EQ(1U, queued_event_count());
677 EXPECT_EQ(1U, GetAndResetSentEventCount()); 690 EXPECT_EQ(1U, GetAndResetSentEventCount());
678 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 691 EXPECT_EQ(1U, GetAndResetAckedEventCount());
679 } 692 }
680 693
681 // Tests that touch-events can be synchronously ack'ed. 694 // Tests that touch-events can be synchronously ack'ed.
682 TEST_F(TouchEventQueueTest, SynchronousAcks) { 695 TEST_F(TouchEventQueueTest, SynchronousAcks) {
683 // TouchStart 696 // TouchStart
684 SetSyncAckResult(INPUT_EVENT_ACK_STATE_CONSUMED); 697 SetSyncAckResult(INPUT_EVENT_ACK_STATE_CONSUMED);
685 PressTouchPoint(1, 1); 698 PressTouchPoint(1, 1);
(...skipping 10 matching lines...) Expand all
696 709
697 // TouchEnd 710 // TouchEnd
698 SetSyncAckResult(INPUT_EVENT_ACK_STATE_CONSUMED); 711 SetSyncAckResult(INPUT_EVENT_ACK_STATE_CONSUMED);
699 ReleaseTouchPoint(0); 712 ReleaseTouchPoint(0);
700 EXPECT_EQ(0U, queued_event_count()); 713 EXPECT_EQ(0U, queued_event_count());
701 EXPECT_EQ(1U, GetAndResetSentEventCount()); 714 EXPECT_EQ(1U, GetAndResetSentEventCount());
702 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 715 EXPECT_EQ(1U, GetAndResetAckedEventCount());
703 716
704 // TouchCancel (first inserting a TouchStart so the TouchCancel will be sent) 717 // TouchCancel (first inserting a TouchStart so the TouchCancel will be sent)
705 PressTouchPoint(1, 1); 718 PressTouchPoint(1, 1);
706 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); 719 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
707 EXPECT_EQ(0U, queued_event_count()); 720 EXPECT_EQ(0U, queued_event_count());
708 EXPECT_EQ(1U, GetAndResetSentEventCount()); 721 EXPECT_EQ(1U, GetAndResetSentEventCount());
709 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 722 EXPECT_EQ(1U, GetAndResetAckedEventCount());
710 723
711 SetSyncAckResult(INPUT_EVENT_ACK_STATE_CONSUMED); 724 SetSyncAckResult(INPUT_EVENT_ACK_STATE_CONSUMED);
712 CancelTouchPoint(0); 725 CancelTouchPoint(0);
713 EXPECT_EQ(0U, queued_event_count()); 726 EXPECT_EQ(0U, queued_event_count());
714 EXPECT_EQ(1U, GetAndResetSentEventCount()); 727 EXPECT_EQ(1U, GetAndResetSentEventCount());
715 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 728 EXPECT_EQ(1U, GetAndResetAckedEventCount());
716 } 729 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 // TouchEnd should not be sent to renderer. 772 // TouchEnd should not be sent to renderer.
760 ReleaseTouchPoint(0); 773 ReleaseTouchPoint(0);
761 EXPECT_EQ(0U, GetAndResetSentEventCount()); 774 EXPECT_EQ(0U, GetAndResetSentEventCount());
762 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 775 EXPECT_EQ(1U, GetAndResetAckedEventCount());
763 776
764 // Enable TouchEvent forwarding. 777 // Enable TouchEvent forwarding.
765 OnHasTouchEventHandlers(true); 778 OnHasTouchEventHandlers(true);
766 779
767 PressTouchPoint(80, 10); 780 PressTouchPoint(80, 10);
768 EXPECT_EQ(1U, GetAndResetSentEventCount()); 781 EXPECT_EQ(1U, GetAndResetSentEventCount());
769 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 782 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
770 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 783 EXPECT_EQ(1U, GetAndResetAckedEventCount());
771 784
772 MoveTouchPoint(0, 80, 20); 785 MoveTouchPoint(0, 80, 20);
773 EXPECT_EQ(1U, GetAndResetSentEventCount()); 786 EXPECT_EQ(1U, GetAndResetSentEventCount());
774 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 787 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
775 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 788 EXPECT_EQ(1U, GetAndResetAckedEventCount());
776 789
777 ReleaseTouchPoint(0); 790 ReleaseTouchPoint(0);
778 EXPECT_EQ(1U, GetAndResetSentEventCount()); 791 EXPECT_EQ(1U, GetAndResetSentEventCount());
779 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 792 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
780 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 793 EXPECT_EQ(1U, GetAndResetAckedEventCount());
781 } 794 }
782 795
783 // Tests that no TouchEvents are sent to renderer during scrolling. 796 // Tests that no TouchEvents are sent to renderer during scrolling.
784 TEST_F(TouchEventQueueTest, NoTouchOnScroll) { 797 TEST_F(TouchEventQueueTest, NoTouchOnScroll) {
785 // Queue a TouchStart. 798 // Queue a TouchStart.
786 PressTouchPoint(0, 1); 799 PressTouchPoint(0, 1);
787 EXPECT_EQ(1U, GetAndResetSentEventCount()); 800 EXPECT_EQ(1U, GetAndResetSentEventCount());
788 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 801 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
789 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 802 EXPECT_EQ(1U, GetAndResetAckedEventCount());
790 803
791 MoveTouchPoint(0, 20, 5); 804 MoveTouchPoint(0, 20, 5);
792 EXPECT_EQ(1U, queued_event_count()); 805 EXPECT_EQ(1U, queued_event_count());
793 EXPECT_EQ(1U, GetAndResetSentEventCount()); 806 EXPECT_EQ(1U, GetAndResetSentEventCount());
794 807
795 // Queue another TouchStart. 808 // Queue another TouchStart.
796 PressTouchPoint(20, 20); 809 PressTouchPoint(20, 20);
797 EXPECT_EQ(2U, queued_event_count()); 810 EXPECT_EQ(2U, queued_event_count());
798 EXPECT_EQ(0U, GetAndResetSentEventCount()); 811 EXPECT_EQ(0U, GetAndResetSentEventCount());
799 EXPECT_EQ(WebInputEvent::TouchStart, latest_event().type); 812 EXPECT_EQ(WebInputEvent::TouchStart, latest_event().type);
800 813
801 // GestureScrollBegin inserts a synthetic TouchCancel before the TouchStart. 814 // GestureScrollBegin inserts a synthetic TouchCancel before the TouchStart.
802 WebGestureEvent followup_scroll; 815 WebGestureEvent followup_scroll;
803 followup_scroll.type = WebInputEvent::GestureScrollBegin; 816 followup_scroll.type = WebInputEvent::GestureScrollBegin;
804 SetFollowupEvent(followup_scroll); 817 SetFollowupEvent(followup_scroll);
805 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 818 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
806 EXPECT_EQ(1U, GetAndResetSentEventCount()); 819 EXPECT_EQ(1U, GetAndResetSentEventCount());
807 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 820 EXPECT_EQ(1U, GetAndResetAckedEventCount());
808 EXPECT_EQ(2U, queued_event_count()); 821 EXPECT_EQ(2U, queued_event_count());
809 EXPECT_EQ(WebInputEvent::TouchCancel, sent_event().type); 822 EXPECT_EQ(WebInputEvent::TouchCancel, sent_event().type);
810 EXPECT_EQ(WebInputEvent::TouchStart, latest_event().type); 823 EXPECT_EQ(WebInputEvent::TouchStart, latest_event().type);
811 824
812 // Acking the TouchCancel will result in dispatch of the next TouchStart. 825 // Acking the TouchCancel will result in dispatch of the next TouchStart.
813 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 826 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
814 // The synthetic TouchCancel should not reach client, only the TouchStart. 827 // The synthetic TouchCancel should not reach client, only the TouchStart.
815 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 828 EXPECT_EQ(1U, GetAndResetAckedEventCount());
816 EXPECT_EQ(0U, GetAndResetSentEventCount()); 829 EXPECT_EQ(0U, GetAndResetSentEventCount());
817 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type); 830 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type);
818 831
819 // TouchMove should not be sent to the renderer. 832 // TouchMove should not be sent to the renderer.
820 MoveTouchPoint(0, 30, 5); 833 MoveTouchPoint(0, 30, 5);
821 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 834 EXPECT_EQ(1U, GetAndResetAckedEventCount());
822 EXPECT_EQ(0U, GetAndResetSentEventCount()); 835 EXPECT_EQ(0U, GetAndResetSentEventCount());
823 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); 836 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state());
824 837
825 // GestureScrollUpdates should not change affect touch forwarding. 838 // GestureScrollUpdates should not change affect touch forwarding.
826 SendGestureEvent(WebInputEvent::GestureScrollUpdate); 839 SendGestureEvent(WebInputEvent::GestureScrollUpdate);
827 840
828 // TouchEnd should not be sent to the renderer. 841 // TouchEnd should not be sent to the renderer.
829 ReleaseTouchPoint(0); 842 ReleaseTouchPoint(0);
830 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 843 EXPECT_EQ(1U, GetAndResetAckedEventCount());
831 EXPECT_EQ(0U, GetAndResetSentEventCount()); 844 EXPECT_EQ(0U, GetAndResetSentEventCount());
832 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); 845 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state());
833 846
834 ReleaseTouchPoint(0); 847 ReleaseTouchPoint(0);
835 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 848 EXPECT_EQ(1U, GetAndResetAckedEventCount());
836 EXPECT_EQ(0U, GetAndResetSentEventCount()); 849 EXPECT_EQ(0U, GetAndResetSentEventCount());
837 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); 850 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state());
838 851
839 // Touch events from a new gesture sequence should be forwarded normally. 852 // Touch events from a new gesture sequence should be forwarded normally.
840 PressTouchPoint(80, 10); 853 PressTouchPoint(80, 10);
841 EXPECT_EQ(1U, GetAndResetSentEventCount()); 854 EXPECT_EQ(1U, GetAndResetSentEventCount());
842 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 855 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
843 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 856 EXPECT_EQ(1U, GetAndResetAckedEventCount());
844 857
845 MoveTouchPoint(0, 80, 20); 858 MoveTouchPoint(0, 80, 20);
846 EXPECT_EQ(1U, GetAndResetSentEventCount()); 859 EXPECT_EQ(1U, GetAndResetSentEventCount());
847 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 860 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
848 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 861 EXPECT_EQ(1U, GetAndResetAckedEventCount());
849 862
850 ReleaseTouchPoint(0); 863 ReleaseTouchPoint(0);
851 EXPECT_EQ(1U, GetAndResetSentEventCount()); 864 EXPECT_EQ(1U, GetAndResetSentEventCount());
852 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 865 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
853 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 866 EXPECT_EQ(1U, GetAndResetAckedEventCount());
854 } 867 }
855 868
856 // Tests that a scroll event will not insert a synthetic TouchCancel if there 869 // Tests that a scroll event will not insert a synthetic TouchCancel if there
857 // was no consumer for the current touch sequence. 870 // was no consumer for the current touch sequence.
858 TEST_F(TouchEventQueueTest, NoTouchCancelOnScrollIfNoConsumer) { 871 TEST_F(TouchEventQueueTest, NoTouchCancelOnScrollIfNoConsumer) {
859 // Queue a TouchStart. 872 // Queue a TouchStart.
860 PressTouchPoint(0, 1); 873 PressTouchPoint(0, 1);
861 EXPECT_EQ(1U, GetAndResetSentEventCount()); 874 EXPECT_EQ(1U, GetAndResetSentEventCount());
862 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); 875 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
863 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 876 EXPECT_EQ(1U, GetAndResetAckedEventCount());
864 EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type); 877 EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type);
865 878
866 // Queue a TouchMove that turns into a GestureScrollBegin. 879 // Queue a TouchMove that turns into a GestureScrollBegin.
867 WebGestureEvent followup_scroll; 880 WebGestureEvent followup_scroll;
868 followup_scroll.type = WebInputEvent::GestureScrollBegin; 881 followup_scroll.type = WebInputEvent::GestureScrollBegin;
869 SetFollowupEvent(followup_scroll); 882 SetFollowupEvent(followup_scroll);
870 MoveTouchPoint(0, 20, 5); 883 MoveTouchPoint(0, 20, 5);
871 884
872 // The TouchMove has no consumer, and should be ack'ed immediately. However, 885 // The TouchMove has no consumer, and should be ack'ed immediately. However,
(...skipping 13 matching lines...) Expand all
886 899
887 // TouchEnd should not be sent to the renderer. 900 // TouchEnd should not be sent to the renderer.
888 ReleaseTouchPoint(0); 901 ReleaseTouchPoint(0);
889 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 902 EXPECT_EQ(1U, GetAndResetAckedEventCount());
890 EXPECT_EQ(0U, GetAndResetSentEventCount()); 903 EXPECT_EQ(0U, GetAndResetSentEventCount());
891 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); 904 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state());
892 905
893 // Touch events from a new gesture sequence should be forwarded normally. 906 // Touch events from a new gesture sequence should be forwarded normally.
894 PressTouchPoint(80, 10); 907 PressTouchPoint(80, 10);
895 EXPECT_EQ(1U, GetAndResetSentEventCount()); 908 EXPECT_EQ(1U, GetAndResetSentEventCount());
896 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 909 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
897 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 910 EXPECT_EQ(1U, GetAndResetAckedEventCount());
898 } 911 }
899 912
900 // Tests that IsTouchStartPendingAck works correctly. 913 // Tests that IsTouchStartPendingAck works correctly.
901 TEST_F(TouchEventQueueTest, PendingStart) { 914 TEST_F(TouchEventQueueTest, PendingStart) {
902 915
903 EXPECT_FALSE(IsPendingAckTouchStart()); 916 EXPECT_FALSE(IsPendingAckTouchStart());
904 917
905 // Send the touchstart for one point (#1). 918 // Send the touchstart for one point (#1).
906 PressTouchPoint(1, 1); 919 PressTouchPoint(1, 1);
907 EXPECT_EQ(1U, queued_event_count()); 920 EXPECT_EQ(1U, queued_event_count());
908 EXPECT_TRUE(IsPendingAckTouchStart()); 921 EXPECT_TRUE(IsPendingAckTouchStart());
909 922
910 // Send a touchmove for that point (#2). 923 // Send a touchmove for that point (#2).
911 MoveTouchPoint(0, 5, 5); 924 MoveTouchPoint(0, 5, 5);
912 EXPECT_EQ(2U, queued_event_count()); 925 EXPECT_EQ(2U, queued_event_count());
913 EXPECT_TRUE(IsPendingAckTouchStart()); 926 EXPECT_TRUE(IsPendingAckTouchStart());
914 927
915 // Ack the touchstart (#1). 928 // Ack the touchstart (#1).
916 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 929 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
917 EXPECT_EQ(1U, queued_event_count()); 930 EXPECT_EQ(1U, queued_event_count());
918 EXPECT_FALSE(IsPendingAckTouchStart()); 931 EXPECT_FALSE(IsPendingAckTouchStart());
919 932
920 // Send a touchstart for another point (#3). 933 // Send a touchstart for another point (#3).
921 PressTouchPoint(10, 10); 934 PressTouchPoint(10, 10);
922 EXPECT_EQ(2U, queued_event_count()); 935 EXPECT_EQ(2U, queued_event_count());
923 EXPECT_FALSE(IsPendingAckTouchStart()); 936 EXPECT_FALSE(IsPendingAckTouchStart());
924 937
925 // Ack the touchmove (#2). 938 // Ack the touchmove (#2).
926 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 939 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
927 EXPECT_EQ(1U, queued_event_count()); 940 EXPECT_EQ(1U, queued_event_count());
928 EXPECT_TRUE(IsPendingAckTouchStart()); 941 EXPECT_TRUE(IsPendingAckTouchStart());
929 942
930 // Send a touchstart for a third point (#4). 943 // Send a touchstart for a third point (#4).
931 PressTouchPoint(15, 15); 944 PressTouchPoint(15, 15);
932 EXPECT_EQ(2U, queued_event_count()); 945 EXPECT_EQ(2U, queued_event_count());
933 EXPECT_TRUE(IsPendingAckTouchStart()); 946 EXPECT_TRUE(IsPendingAckTouchStart());
934 947
935 // Ack the touchstart for the second point (#3). 948 // Ack the touchstart for the second point (#3).
936 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 949 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
937 EXPECT_EQ(1U, queued_event_count()); 950 EXPECT_EQ(1U, queued_event_count());
938 EXPECT_TRUE(IsPendingAckTouchStart()); 951 EXPECT_TRUE(IsPendingAckTouchStart());
939 952
940 // Ack the touchstart for the third point (#4). 953 // Ack the touchstart for the third point (#4).
941 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 954 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
942 EXPECT_EQ(0U, queued_event_count()); 955 EXPECT_EQ(0U, queued_event_count());
943 EXPECT_FALSE(IsPendingAckTouchStart()); 956 EXPECT_FALSE(IsPendingAckTouchStart());
944 } 957 }
945 958
946 // Tests that the touch timeout is started when sending certain touch types. 959 // Tests that the touch timeout is started when sending certain touch types.
947 TEST_F(TouchEventQueueTest, TouchTimeoutTypes) { 960 TEST_F(TouchEventQueueTest, TouchTimeoutTypes) {
948 SetUpForTimeoutTesting(kDefaultTouchTimeoutDelayMs); 961 SetUpForTimeoutTesting(kDefaultTouchTimeoutDelayMs);
949 962
950 // Sending a TouchStart will start the timeout. 963 // Sending a TouchStart will start the timeout.
951 PressTouchPoint(0, 1); 964 PressTouchPoint(0, 1);
952 EXPECT_TRUE(IsTimeoutRunning()); 965 EXPECT_TRUE(IsTimeoutRunning());
953 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 966 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
954 EXPECT_FALSE(IsTimeoutRunning()); 967 EXPECT_FALSE(IsTimeoutRunning());
955 968
956 // A TouchMove should start the timeout. 969 // A TouchMove should start the timeout.
957 MoveTouchPoint(0, 5, 5); 970 MoveTouchPoint(0, 5, 5);
958 EXPECT_TRUE(IsTimeoutRunning()); 971 EXPECT_TRUE(IsTimeoutRunning());
959 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 972 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
960 EXPECT_FALSE(IsTimeoutRunning()); 973 EXPECT_FALSE(IsTimeoutRunning());
961 974
962 // A TouchEnd should not start the timeout. 975 // A TouchEnd should not start the timeout.
963 ReleaseTouchPoint(0); 976 ReleaseTouchPoint(0);
964 EXPECT_FALSE(IsTimeoutRunning()); 977 EXPECT_FALSE(IsTimeoutRunning());
965 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 978 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
966 EXPECT_FALSE(IsTimeoutRunning()); 979 EXPECT_FALSE(IsTimeoutRunning());
967 980
968 // A TouchCancel should not start the timeout. 981 // A TouchCancel should not start the timeout.
969 PressTouchPoint(0, 1); 982 PressTouchPoint(0, 1);
970 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 983 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
971 ASSERT_FALSE(IsTimeoutRunning()); 984 ASSERT_FALSE(IsTimeoutRunning());
972 CancelTouchPoint(0); 985 CancelTouchPoint(0);
973 EXPECT_FALSE(IsTimeoutRunning()); 986 EXPECT_FALSE(IsTimeoutRunning());
974 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 987 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
975 EXPECT_FALSE(IsTimeoutRunning()); 988 EXPECT_FALSE(IsTimeoutRunning());
976 } 989 }
977 990
978 // Tests that a delayed TouchEvent ack will trigger a TouchCancel timeout, 991 // Tests that a delayed TouchEvent ack will trigger a TouchCancel timeout,
979 // disabling touch forwarding until the next TouchStart is received after 992 // disabling touch forwarding until the next TouchStart is received after
980 // the timeout events are ack'ed. 993 // the timeout events are ack'ed.
981 TEST_F(TouchEventQueueTest, TouchTimeoutBasic) { 994 TEST_F(TouchEventQueueTest, TouchTimeoutBasic) {
982 SetUpForTimeoutTesting(kDefaultTouchTimeoutDelayMs); 995 SetUpForTimeoutTesting(kDefaultTouchTimeoutDelayMs);
983 996
984 // Queue a TouchStart. 997 // Queue a TouchStart.
(...skipping 12 matching lines...) Expand all
997 base::MessageLoop::current()->Run(); 1010 base::MessageLoop::current()->Run();
998 1011
999 // The timeout should have fired, synthetically ack'ing the timed-out event. 1012 // The timeout should have fired, synthetically ack'ing the timed-out event.
1000 // TouchEvent forwarding is disabled until the ack is received for the 1013 // TouchEvent forwarding is disabled until the ack is received for the
1001 // timed-out event and the future cancel event. 1014 // timed-out event and the future cancel event.
1002 EXPECT_FALSE(IsTimeoutRunning()); 1015 EXPECT_FALSE(IsTimeoutRunning());
1003 EXPECT_EQ(0U, GetAndResetSentEventCount()); 1016 EXPECT_EQ(0U, GetAndResetSentEventCount());
1004 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1017 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1005 1018
1006 // Ack'ing the original event should trigger a cancel event. 1019 // Ack'ing the original event should trigger a cancel event.
1007 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1020 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1008 EXPECT_FALSE(IsTimeoutRunning()); 1021 EXPECT_FALSE(IsTimeoutRunning());
1009 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1022 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1010 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1023 EXPECT_EQ(1U, GetAndResetSentEventCount());
1011 1024
1012 // Touch events should not be forwarded until we receive the cancel acks. 1025 // Touch events should not be forwarded until we receive the cancel acks.
1013 MoveTouchPoint(0, 1, 1); 1026 MoveTouchPoint(0, 1, 1);
1014 ASSERT_EQ(0U, GetAndResetSentEventCount()); 1027 ASSERT_EQ(0U, GetAndResetSentEventCount());
1015 ASSERT_EQ(1U, GetAndResetAckedEventCount()); 1028 ASSERT_EQ(1U, GetAndResetAckedEventCount());
1016 1029
1017 ReleaseTouchPoint(0); 1030 ReleaseTouchPoint(0);
1018 ASSERT_EQ(0U, GetAndResetSentEventCount()); 1031 ASSERT_EQ(0U, GetAndResetSentEventCount());
1019 ASSERT_EQ(1U, GetAndResetAckedEventCount()); 1032 ASSERT_EQ(1U, GetAndResetAckedEventCount());
1020 1033
1021 // The synthetic TouchCancel ack should not reach the client, but should 1034 // The synthetic TouchCancel ack should not reach the client, but should
1022 // resume touch forwarding. 1035 // resume touch forwarding.
1023 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1036 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1024 EXPECT_EQ(0U, GetAndResetSentEventCount()); 1037 EXPECT_EQ(0U, GetAndResetSentEventCount());
1025 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1038 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1026 1039
1027 // Subsequent events should be handled normally. 1040 // Subsequent events should be handled normally.
1028 PressTouchPoint(0, 1); 1041 PressTouchPoint(0, 1);
1029 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1042 EXPECT_EQ(1U, GetAndResetSentEventCount());
1030 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1043 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1031 } 1044 }
1032 1045
1033 // Tests that the timeout is never started if the renderer consumes 1046 // Tests that the timeout is never started if the renderer consumes
1034 // a TouchEvent from the current touch sequence. 1047 // a TouchEvent from the current touch sequence.
1035 TEST_F(TouchEventQueueTest, NoTouchTimeoutIfRendererIsConsumingGesture) { 1048 TEST_F(TouchEventQueueTest, NoTouchTimeoutIfRendererIsConsumingGesture) {
1036 SetUpForTimeoutTesting(kDefaultTouchTimeoutDelayMs); 1049 SetUpForTimeoutTesting(kDefaultTouchTimeoutDelayMs);
1037 1050
1038 // Queue a TouchStart. 1051 // Queue a TouchStart.
1039 PressTouchPoint(0, 1); 1052 PressTouchPoint(0, 1);
1040 ASSERT_TRUE(IsTimeoutRunning()); 1053 ASSERT_TRUE(IsTimeoutRunning());
1041 1054
1042 // Mark the event as consumed. This should prevent the timeout from 1055 // Mark the event as consumed. This should prevent the timeout from
1043 // being activated on subsequent TouchEvents in this gesture. 1056 // being activated on subsequent TouchEvents in this gesture.
1044 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); 1057 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
1045 EXPECT_FALSE(IsTimeoutRunning()); 1058 EXPECT_FALSE(IsTimeoutRunning());
1046 1059
1047 // A TouchMove should not start the timeout. 1060 // A TouchMove should not start the timeout.
1048 MoveTouchPoint(0, 5, 5); 1061 MoveTouchPoint(0, 5, 5);
1049 EXPECT_FALSE(IsTimeoutRunning()); 1062 EXPECT_FALSE(IsTimeoutRunning());
1050 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1063 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1051 1064
1052 // A secondary TouchStart should not start the timeout. 1065 // A secondary TouchStart should not start the timeout.
1053 PressTouchPoint(1, 0); 1066 PressTouchPoint(1, 0);
1054 EXPECT_FALSE(IsTimeoutRunning()); 1067 EXPECT_FALSE(IsTimeoutRunning());
1055 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1068 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1056 1069
1057 // A TouchEnd should not start the timeout. 1070 // A TouchEnd should not start the timeout.
1058 ReleaseTouchPoint(1); 1071 ReleaseTouchPoint(1);
1059 EXPECT_FALSE(IsTimeoutRunning()); 1072 EXPECT_FALSE(IsTimeoutRunning());
1060 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1073 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1061 1074
1062 // A TouchCancel should not start the timeout. 1075 // A TouchCancel should not start the timeout.
1063 CancelTouchPoint(0); 1076 CancelTouchPoint(0);
1064 EXPECT_FALSE(IsTimeoutRunning()); 1077 EXPECT_FALSE(IsTimeoutRunning());
1065 } 1078 }
1066 1079
1067 // Tests that the timeout is never started if the ack is synchronous. 1080 // Tests that the timeout is never started if the ack is synchronous.
1068 TEST_F(TouchEventQueueTest, NoTouchTimeoutIfAckIsSynchronous) { 1081 TEST_F(TouchEventQueueTest, NoTouchTimeoutIfAckIsSynchronous) {
1069 SetUpForTimeoutTesting(kDefaultTouchTimeoutDelayMs); 1082 SetUpForTimeoutTesting(kDefaultTouchTimeoutDelayMs);
1070 1083
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 base::TimeDelta::FromMilliseconds(kDefaultTouchTimeoutDelayMs * 2)); 1123 base::TimeDelta::FromMilliseconds(kDefaultTouchTimeoutDelayMs * 2));
1111 base::MessageLoop::current()->Run(); 1124 base::MessageLoop::current()->Run();
1112 1125
1113 // The timeout should have fired, disabling touch forwarding until both acks 1126 // The timeout should have fired, disabling touch forwarding until both acks
1114 // are received, acking the timed out event. 1127 // are received, acking the timed out event.
1115 EXPECT_FALSE(IsTimeoutRunning()); 1128 EXPECT_FALSE(IsTimeoutRunning());
1116 EXPECT_EQ(0U, GetAndResetSentEventCount()); 1129 EXPECT_EQ(0U, GetAndResetSentEventCount());
1117 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1130 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1118 1131
1119 // Ack the original event, triggering a TouchCancel. 1132 // Ack the original event, triggering a TouchCancel.
1120 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); 1133 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
1121 EXPECT_FALSE(IsTimeoutRunning()); 1134 EXPECT_FALSE(IsTimeoutRunning());
1122 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1135 EXPECT_EQ(1U, GetAndResetSentEventCount());
1123 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1136 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1124 1137
1125 // Ack the cancel event. Normally, this would resume touch forwarding, 1138 // Ack the cancel event. Normally, this would resume touch forwarding,
1126 // but we're still within a scroll gesture so it remains disabled. 1139 // but we're still within a scroll gesture so it remains disabled.
1127 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); 1140 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
1128 EXPECT_FALSE(IsTimeoutRunning()); 1141 EXPECT_FALSE(IsTimeoutRunning());
1129 EXPECT_EQ(0U, GetAndResetSentEventCount()); 1142 EXPECT_EQ(0U, GetAndResetSentEventCount());
1130 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1143 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1131 1144
1132 // Try to forward touch events for the current sequence. 1145 // Try to forward touch events for the current sequence.
1133 GetAndResetSentEventCount(); 1146 GetAndResetSentEventCount();
1134 GetAndResetAckedEventCount(); 1147 GetAndResetAckedEventCount();
1135 MoveTouchPoint(0, 1, 1); 1148 MoveTouchPoint(0, 1, 1);
1136 ReleaseTouchPoint(0); 1149 ReleaseTouchPoint(0);
1137 EXPECT_FALSE(IsTimeoutRunning()); 1150 EXPECT_FALSE(IsTimeoutRunning());
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 // Now end the scroll sequence. Events will not be forwarded until the two 1199 // Now end the scroll sequence. Events will not be forwarded until the two
1187 // outstanding touch acks are received. 1200 // outstanding touch acks are received.
1188 SendGestureEvent(blink::WebInputEvent::GestureScrollEnd); 1201 SendGestureEvent(blink::WebInputEvent::GestureScrollEnd);
1189 MoveTouchPoint(0, 2, 2); 1202 MoveTouchPoint(0, 2, 2);
1190 ReleaseTouchPoint(0); 1203 ReleaseTouchPoint(0);
1191 EXPECT_FALSE(IsTimeoutRunning()); 1204 EXPECT_FALSE(IsTimeoutRunning());
1192 EXPECT_EQ(0U, GetAndResetSentEventCount()); 1205 EXPECT_EQ(0U, GetAndResetSentEventCount());
1193 EXPECT_EQ(2U, GetAndResetAckedEventCount()); 1206 EXPECT_EQ(2U, GetAndResetAckedEventCount());
1194 1207
1195 // Ack the original event, triggering a cancel. 1208 // Ack the original event, triggering a cancel.
1196 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); 1209 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
1197 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1210 EXPECT_EQ(1U, GetAndResetSentEventCount());
1198 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1211 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1199 1212
1200 // Ack the cancel event, resuming touch forwarding. 1213 // Ack the cancel event, resuming touch forwarding.
1201 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); 1214 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
1202 EXPECT_EQ(0U, GetAndResetSentEventCount()); 1215 EXPECT_EQ(0U, GetAndResetSentEventCount());
1203 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1216 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1204 1217
1205 PressTouchPoint(0, 1); 1218 PressTouchPoint(0, 1);
1206 EXPECT_TRUE(IsTimeoutRunning()); 1219 EXPECT_TRUE(IsTimeoutRunning());
1207 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1220 EXPECT_EQ(1U, GetAndResetSentEventCount());
1208 } 1221 }
1209 1222
1210 // Tests that a delayed TouchEvent ack will not trigger a TouchCancel timeout if 1223 // Tests that a delayed TouchEvent ack will not trigger a TouchCancel timeout if
1211 // the timed-out event had no consumer. 1224 // the timed-out event had no consumer.
(...skipping 20 matching lines...) Expand all
1232 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1245 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1233 1246
1234 // Touch events should not be forwarded until we receive the original ack. 1247 // Touch events should not be forwarded until we receive the original ack.
1235 MoveTouchPoint(0, 1, 1); 1248 MoveTouchPoint(0, 1, 1);
1236 ReleaseTouchPoint(0); 1249 ReleaseTouchPoint(0);
1237 ASSERT_EQ(0U, GetAndResetSentEventCount()); 1250 ASSERT_EQ(0U, GetAndResetSentEventCount());
1238 ASSERT_EQ(2U, GetAndResetAckedEventCount()); 1251 ASSERT_EQ(2U, GetAndResetAckedEventCount());
1239 1252
1240 // Ack'ing the original event should not trigger a cancel event, as the 1253 // Ack'ing the original event should not trigger a cancel event, as the
1241 // TouchStart had no consumer. However, it should re-enable touch forwarding. 1254 // TouchStart had no consumer. However, it should re-enable touch forwarding.
1242 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); 1255 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
1243 EXPECT_FALSE(IsTimeoutRunning()); 1256 EXPECT_FALSE(IsTimeoutRunning());
1244 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1257 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1245 EXPECT_EQ(0U, GetAndResetSentEventCount()); 1258 EXPECT_EQ(0U, GetAndResetSentEventCount());
1246 1259
1247 // Subsequent events should be handled normally. 1260 // Subsequent events should be handled normally.
1248 PressTouchPoint(0, 1); 1261 PressTouchPoint(0, 1);
1249 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1262 EXPECT_EQ(1U, GetAndResetSentEventCount());
1250 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1263 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1251 } 1264 }
1252 1265
1253 // Tests that TouchMove's are dropped if within the slop suppression region 1266 // Tests that TouchMove's are dropped if within the slop suppression region
1254 // for an unconsumed TouchStart 1267 // for an unconsumed TouchStart
1255 TEST_F(TouchEventQueueTest, TouchMoveSuppressionWithinSlopRegion) { 1268 TEST_F(TouchEventQueueTest, TouchMoveSuppressionWithinSlopRegion) {
1256 const double kSlopLengthDips = 10.; 1269 const double kSlopLengthDips = 10.;
1257 const double kHalfSlopLengthDips = kSlopLengthDips / 2; 1270 const double kHalfSlopLengthDips = kSlopLengthDips / 2;
1258 SetUpForTouchMoveSlopTesting(kSlopLengthDips); 1271 SetUpForTouchMoveSlopTesting(kSlopLengthDips);
1259 1272
1260 // Queue a TouchStart. 1273 // Queue a TouchStart.
1261 PressTouchPoint(0, 0); 1274 PressTouchPoint(0, 0);
1262 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1275 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1263 ASSERT_EQ(1U, GetAndResetSentEventCount()); 1276 ASSERT_EQ(1U, GetAndResetSentEventCount());
1264 ASSERT_EQ(1U, GetAndResetAckedEventCount()); 1277 ASSERT_EQ(1U, GetAndResetAckedEventCount());
1265 1278
1266 // TouchMove's within the region should be suppressed. 1279 // TouchMove's within the region should be suppressed.
1267 MoveTouchPoint(0, 0, kHalfSlopLengthDips); 1280 MoveTouchPoint(0, 0, kHalfSlopLengthDips);
1268 EXPECT_EQ(0U, queued_event_count()); 1281 EXPECT_EQ(0U, queued_event_count());
1269 EXPECT_EQ(0U, GetAndResetSentEventCount()); 1282 EXPECT_EQ(0U, GetAndResetSentEventCount());
1270 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1283 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1271 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, acked_event_state()); 1284 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, acked_event_state());
1272 1285
(...skipping 13 matching lines...) Expand all
1286 // TouchMove's should be suppressed. 1299 // TouchMove's should be suppressed.
1287 // TODO(jdduke): Remove ceil with adoption of floating point touch coords, 1300 // TODO(jdduke): Remove ceil with adoption of floating point touch coords,
1288 // crbug/336807. 1301 // crbug/336807.
1289 const double kFortyFiveDegreeSlopLengthXY = 1302 const double kFortyFiveDegreeSlopLengthXY =
1290 std::ceil(kSlopLengthDips * std::sqrt(2.) / 2.); 1303 std::ceil(kSlopLengthDips * std::sqrt(2.) / 2.);
1291 MoveTouchPoint(0, kFortyFiveDegreeSlopLengthXY + .1, 1304 MoveTouchPoint(0, kFortyFiveDegreeSlopLengthXY + .1,
1292 kFortyFiveDegreeSlopLengthXY + .1); 1305 kFortyFiveDegreeSlopLengthXY + .1);
1293 EXPECT_EQ(1U, queued_event_count()); 1306 EXPECT_EQ(1U, queued_event_count());
1294 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1307 EXPECT_EQ(1U, GetAndResetSentEventCount());
1295 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1308 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1296 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1309 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1297 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1310 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1298 1311
1299 // Even TouchMove's within the original slop region should now be forwarded. 1312 // Even TouchMove's within the original slop region should now be forwarded.
1300 MoveTouchPoint(0, 0, 0); 1313 MoveTouchPoint(0, 0, 0);
1301 EXPECT_EQ(1U, queued_event_count()); 1314 EXPECT_EQ(1U, queued_event_count());
1302 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1315 EXPECT_EQ(1U, GetAndResetSentEventCount());
1303 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1316 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1304 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1317 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1305 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1318 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1306 1319
1307 // A new touch sequence should reset suppression. 1320 // A new touch sequence should reset suppression.
1308 ReleaseTouchPoint(0); 1321 ReleaseTouchPoint(0);
1309 PressTouchPoint(0, 0); 1322 PressTouchPoint(0, 0);
1310 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1323 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1311 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1324 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1312 ASSERT_EQ(2U, GetAndResetSentEventCount()); 1325 ASSERT_EQ(2U, GetAndResetSentEventCount());
1313 ASSERT_EQ(2U, GetAndResetAckedEventCount()); 1326 ASSERT_EQ(2U, GetAndResetAckedEventCount());
1314 ASSERT_EQ(0U, queued_event_count()); 1327 ASSERT_EQ(0U, queued_event_count());
1315 1328
1316 // The slop region is boundary-inclusive. 1329 // The slop region is boundary-inclusive.
1317 MoveTouchPoint(0, kSlopLengthDips, 0); 1330 MoveTouchPoint(0, kSlopLengthDips, 0);
1318 EXPECT_EQ(0U, queued_event_count()); 1331 EXPECT_EQ(0U, queued_event_count());
1319 EXPECT_EQ(0U, GetAndResetSentEventCount()); 1332 EXPECT_EQ(0U, GetAndResetSentEventCount());
1320 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1333 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1321 1334
1322 MoveTouchPoint(0, kSlopLengthDips + 1., 0); 1335 MoveTouchPoint(0, kSlopLengthDips + 1., 0);
1323 EXPECT_EQ(1U, queued_event_count()); 1336 EXPECT_EQ(1U, queued_event_count());
1324 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1337 EXPECT_EQ(1U, GetAndResetSentEventCount());
1325 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1338 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1326 } 1339 }
1327 1340
1328 // Tests that TouchMove's are not dropped within the slop suppression region if 1341 // Tests that TouchMove's are not dropped within the slop suppression region if
1329 // the touchstart was consumed. 1342 // the touchstart was consumed.
1330 TEST_F(TouchEventQueueTest, NoTouchMoveSuppressionAfterTouchConsumed) { 1343 TEST_F(TouchEventQueueTest, NoTouchMoveSuppressionAfterTouchConsumed) {
1331 const double kSlopLengthDips = 10.; 1344 const double kSlopLengthDips = 10.;
1332 const double kHalfSlopLengthDips = kSlopLengthDips / 2; 1345 const double kHalfSlopLengthDips = kSlopLengthDips / 2;
1333 SetUpForTouchMoveSlopTesting(kSlopLengthDips); 1346 SetUpForTouchMoveSlopTesting(kSlopLengthDips);
1334 1347
1335 // Queue a TouchStart. 1348 // Queue a TouchStart.
1336 PressTouchPoint(0, 1); 1349 PressTouchPoint(0, 1);
1337 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); 1350 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
1338 ASSERT_EQ(1U, GetAndResetSentEventCount()); 1351 ASSERT_EQ(1U, GetAndResetSentEventCount());
1339 ASSERT_EQ(1U, GetAndResetAckedEventCount()); 1352 ASSERT_EQ(1U, GetAndResetAckedEventCount());
1340 1353
1341 // TouchMove's within the region should not be suppressed, as a touch was 1354 // TouchMove's within the region should not be suppressed, as a touch was
1342 // consumed. 1355 // consumed.
1343 MoveTouchPoint(0, 0, kHalfSlopLengthDips); 1356 MoveTouchPoint(0, 0, kHalfSlopLengthDips);
1344 EXPECT_EQ(1U, queued_event_count()); 1357 EXPECT_EQ(1U, queued_event_count());
1345 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1358 EXPECT_EQ(1U, GetAndResetSentEventCount());
1346 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1359 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1347 } 1360 }
1348 1361
1349 // Tests that TouchMove's are not dropped if a secondary pointer is present 1362 // Tests that TouchMove's are not dropped if a secondary pointer is present
1350 // during any movement. 1363 // during any movement.
1351 TEST_F(TouchEventQueueTest, NoTouchMoveSuppressionAfterMultiTouch) { 1364 TEST_F(TouchEventQueueTest, NoTouchMoveSuppressionAfterMultiTouch) {
1352 const double kSlopLengthDips = 10.; 1365 const double kSlopLengthDips = 10.;
1353 const double kHalfSlopLengthDips = kSlopLengthDips / 2; 1366 const double kHalfSlopLengthDips = kSlopLengthDips / 2;
1354 const double kDoubleSlopLengthDips = 10.; 1367 const double kDoubleSlopLengthDips = 10.;
1355 SetUpForTouchMoveSlopTesting(kSlopLengthDips); 1368 SetUpForTouchMoveSlopTesting(kSlopLengthDips);
1356 1369
1357 // Queue a TouchStart. 1370 // Queue a TouchStart.
1358 PressTouchPoint(0, 1); 1371 PressTouchPoint(0, 1);
1359 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1372 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1360 ASSERT_EQ(1U, GetAndResetSentEventCount()); 1373 ASSERT_EQ(1U, GetAndResetSentEventCount());
1361 ASSERT_EQ(1U, GetAndResetAckedEventCount()); 1374 ASSERT_EQ(1U, GetAndResetAckedEventCount());
1362 1375
1363 // TouchMove's within the region should be suppressed. 1376 // TouchMove's within the region should be suppressed.
1364 MoveTouchPoint(0, 0, kHalfSlopLengthDips); 1377 MoveTouchPoint(0, 0, kHalfSlopLengthDips);
1365 EXPECT_EQ(0U, queued_event_count()); 1378 EXPECT_EQ(0U, queued_event_count());
1366 EXPECT_EQ(0U, GetAndResetSentEventCount()); 1379 EXPECT_EQ(0U, GetAndResetSentEventCount());
1367 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1380 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1368 1381
1369 // Simulate a secondary pointer press. 1382 // Simulate a secondary pointer press.
1370 PressTouchPoint(kDoubleSlopLengthDips, 0); 1383 PressTouchPoint(kDoubleSlopLengthDips, 0);
1371 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1384 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1372 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1385 EXPECT_EQ(1U, GetAndResetSentEventCount());
1373 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1386 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1374 1387
1375 // TouchMove with a secondary pointer should not be suppressed. 1388 // TouchMove with a secondary pointer should not be suppressed.
1376 MoveTouchPoint(1, kDoubleSlopLengthDips, 0); 1389 MoveTouchPoint(1, kDoubleSlopLengthDips, 0);
1377 EXPECT_EQ(1U, queued_event_count()); 1390 EXPECT_EQ(1U, queued_event_count());
1378 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1391 EXPECT_EQ(1U, GetAndResetSentEventCount());
1379 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1392 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1380 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1393 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1381 1394
1382 // Release the secondary pointer. 1395 // Release the secondary pointer.
1383 ReleaseTouchPoint(0); 1396 ReleaseTouchPoint(0);
1384 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1397 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1385 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1398 EXPECT_EQ(1U, GetAndResetSentEventCount());
1386 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1399 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1387 1400
1388 // TouchMove's should not should be suppressed, even with the original 1401 // TouchMove's should not should be suppressed, even with the original
1389 // unmoved pointer. 1402 // unmoved pointer.
1390 MoveTouchPoint(0, 0, 0); 1403 MoveTouchPoint(0, 0, 0);
1391 EXPECT_EQ(1U, queued_event_count()); 1404 EXPECT_EQ(1U, queued_event_count());
1392 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1405 EXPECT_EQ(1U, GetAndResetSentEventCount());
1393 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1406 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1394 } 1407 }
1395 1408
1409 TEST_F(TouchEventQueueTest, SyncTouchMoveDoesntCancelTouchOnScroll) {
1410 SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_SYNC_TOUCHMOVE);
1411 // Queue a TouchStart.
1412 PressTouchPoint(0, 1);
1413 EXPECT_EQ(1U, GetAndResetSentEventCount());
1414 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1415 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1416
1417 MoveTouchPoint(0, 20, 5);
1418 EXPECT_EQ(1U, queued_event_count());
1419 EXPECT_EQ(1U, GetAndResetSentEventCount());
1420
1421 // GestureScrollBegin doesn't insert a synthetic TouchCancel.
1422 WebGestureEvent followup_scroll;
1423 followup_scroll.type = WebInputEvent::GestureScrollBegin;
1424 SetFollowupEvent(followup_scroll);
1425 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1426 EXPECT_EQ(0U, GetAndResetSentEventCount());
1427 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1428 EXPECT_EQ(0U, queued_event_count());
1429 }
1430
1431 TEST_F(TouchEventQueueTest, TouchAbsorption) {
1432 SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_ABSORB_TOUCHMOVE);
1433 // Queue a TouchStart.
1434 PressTouchPoint(0, 1);
1435 EXPECT_EQ(1U, GetAndResetSentEventCount());
1436 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1437 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1438
1439 for (int i = 0; i < 3; ++i) {
1440 SendGestureEventAck(WebInputEvent::GestureScrollUpdate,
1441 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1442
1443 MoveTouchPoint(0, 20, 5);
1444 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1445 EXPECT_EQ(0U, queued_event_count());
1446 EXPECT_EQ(1U, GetAndResetSentEventCount());
1447
1448 // Consuming a scroll event prevents the next touch moves from being
1449 // dispatched.
1450 SendGestureEventAck(WebInputEvent::GestureScrollUpdate,
1451 INPUT_EVENT_ACK_STATE_CONSUMED);
1452 MoveTouchPoint(0, 20, 5);
1453 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1454 EXPECT_EQ(0U, queued_event_count());
1455 EXPECT_EQ(0U, GetAndResetSentEventCount());
1456 }
1457 }
1458
1396 } // namespace content 1459 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698