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