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