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

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

Issue 2715623002: Add a passthrough touch event queue. (Closed)
Patch Set: Rebase on throttling change Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/input/touch_event_queue.h" 5 #include "content/browser/renderer_host/input/legacy_touch_event_queue.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
18 #include "content/browser/renderer_host/input/legacy_touch_event_queue.h"
19 #include "content/browser/renderer_host/input/timeout_monitor.h" 18 #include "content/browser/renderer_host/input/timeout_monitor.h"
20 #include "content/common/input/synthetic_web_input_event_builders.h" 19 #include "content/common/input/synthetic_web_input_event_builders.h"
21 #include "content/common/input/web_touch_event_traits.h" 20 #include "content/common/input/web_touch_event_traits.h"
22 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
23 #include "third_party/WebKit/public/platform/WebInputEvent.h" 22 #include "third_party/WebKit/public/platform/WebInputEvent.h"
24 #include "ui/events/base_event_utils.h" 23 #include "ui/events/base_event_utils.h"
25 24
26 using blink::WebGestureEvent; 25 using blink::WebGestureEvent;
27 using blink::WebInputEvent; 26 using blink::WebInputEvent;
28 using blink::WebTouchEvent; 27 using blink::WebTouchEvent;
29 using blink::WebTouchPoint; 28 using blink::WebTouchPoint;
30 29
31 namespace content { 30 namespace content {
32 namespace { 31 namespace {
33 32
34 const double kMinSecondsBetweenThrottledTouchmoves = 0.2; 33 const double kMinSecondsBetweenThrottledTouchmoves = 0.2;
35 const float kSlopLengthDips = 10; 34 const float kSlopLengthDips = 10;
36 const float kHalfSlopLengthDips = kSlopLengthDips / 2; 35 const float kHalfSlopLengthDips = kSlopLengthDips / 2;
37 36
38 base::TimeDelta DefaultTouchTimeoutDelay() { 37 base::TimeDelta DefaultTouchTimeoutDelay() {
39 return base::TimeDelta::FromMilliseconds(1); 38 return base::TimeDelta::FromMilliseconds(1);
40 } 39 }
41 } // namespace 40 } // namespace
42 41
43 class TouchEventQueueTest : public testing::Test, 42 class LegacyTouchEventQueueTest : public testing::Test,
44 public TouchEventQueueClient { 43 public TouchEventQueueClient {
45 public: 44 public:
46 TouchEventQueueTest() 45 LegacyTouchEventQueueTest()
47 : acked_event_count_(0), 46 : acked_event_count_(0),
48 last_acked_event_state_(INPUT_EVENT_ACK_STATE_UNKNOWN), 47 last_acked_event_state_(INPUT_EVENT_ACK_STATE_UNKNOWN),
49 slop_length_dips_(0) {} 48 slop_length_dips_(0) {}
50 49
51 ~TouchEventQueueTest() override {} 50 ~LegacyTouchEventQueueTest() override {}
52 51
53 // testing::Test 52 // testing::Test
54 void SetUp() override { 53 void SetUp() override {
55 ResetQueueWithConfig(TouchEventQueue::Config()); 54 ResetQueueWithConfig(TouchEventQueue::Config());
56 sent_events_ids_.clear(); 55 sent_events_ids_.clear();
57 } 56 }
58 57
59 void TearDown() override { queue_.reset(); } 58 void TearDown() override { queue_.reset(); }
60 59
61 // TouchEventQueueClient 60 // TouchEventQueueClient
(...skipping 13 matching lines...) Expand all
75 last_acked_event_ = event.event; 74 last_acked_event_ = event.event;
76 last_acked_event_state_ = ack_result; 75 last_acked_event_state_ = ack_result;
77 if (followup_touch_event_) { 76 if (followup_touch_event_) {
78 std::unique_ptr<WebTouchEvent> followup_touch_event = 77 std::unique_ptr<WebTouchEvent> followup_touch_event =
79 std::move(followup_touch_event_); 78 std::move(followup_touch_event_);
80 SendTouchEvent(*followup_touch_event); 79 SendTouchEvent(*followup_touch_event);
81 } 80 }
82 if (followup_gesture_event_) { 81 if (followup_gesture_event_) {
83 std::unique_ptr<WebGestureEvent> followup_gesture_event = 82 std::unique_ptr<WebGestureEvent> followup_gesture_event =
84 std::move(followup_gesture_event_); 83 std::move(followup_gesture_event_);
85 queue_->OnGestureScrollEvent( 84 queue_->OnGestureScrollEvent(GestureEventWithLatencyInfo(
86 GestureEventWithLatencyInfo(*followup_gesture_event, 85 *followup_gesture_event, ui::LatencyInfo()));
87 ui::LatencyInfo()));
88 } 86 }
89 } 87 }
90 88
91 void OnFilteringTouchEvent(const blink::WebTouchEvent& touch_event) override { 89 void OnFilteringTouchEvent(const blink::WebTouchEvent& touch_event) override {
92 } 90 }
93 91
94 protected: 92 protected:
95 void SetUpForTouchMoveSlopTesting(double slop_length_dips) { 93 void SetUpForTouchMoveSlopTesting(double slop_length_dips) {
96 slop_length_dips_ = slop_length_dips; 94 slop_length_dips_ = slop_length_dips;
97 } 95 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 } 238 }
241 239
242 void PrependTouchScrollNotification() { 240 void PrependTouchScrollNotification() {
243 queue_->PrependTouchScrollNotification(); 241 queue_->PrependTouchScrollNotification();
244 } 242 }
245 243
246 void AdvanceTouchTime(double seconds) { 244 void AdvanceTouchTime(double seconds) {
247 touch_event_.setTimeStampSeconds(touch_event_.timeStampSeconds() + seconds); 245 touch_event_.setTimeStampSeconds(touch_event_.timeStampSeconds() + seconds);
248 } 246 }
249 247
250 void ResetTouchEvent() { 248 void ResetTouchEvent() { touch_event_ = SyntheticWebTouchEvent(); }
251 touch_event_ = SyntheticWebTouchEvent();
252 }
253 249
254 size_t GetAndResetAckedEventCount() { 250 size_t GetAndResetAckedEventCount() {
255 size_t count = acked_event_count_; 251 size_t count = acked_event_count_;
256 acked_event_count_ = 0; 252 acked_event_count_ = 0;
257 return count; 253 return count;
258 } 254 }
259 255
260 size_t GetAndResetSentEventCount() { 256 size_t GetAndResetSentEventCount() {
261 size_t count = sent_events_.size(); 257 size_t count = sent_events_.size();
262 sent_events_.clear(); 258 sent_events_.clear();
(...skipping 13 matching lines...) Expand all
276 void SetIsMobileOptimizedSite(bool is_mobile_optimized) { 272 void SetIsMobileOptimizedSite(bool is_mobile_optimized) {
277 queue_->SetIsMobileOptimizedSite(is_mobile_optimized); 273 queue_->SetIsMobileOptimizedSite(is_mobile_optimized);
278 } 274 }
279 275
280 bool IsTimeoutRunning() const { return queue_->IsTimeoutRunningForTesting(); } 276 bool IsTimeoutRunning() const { return queue_->IsTimeoutRunningForTesting(); }
281 277
282 bool HasPendingAsyncTouchMove() const { 278 bool HasPendingAsyncTouchMove() const {
283 return queue_->HasPendingAsyncTouchMoveForTesting(); 279 return queue_->HasPendingAsyncTouchMoveForTesting();
284 } 280 }
285 281
286 size_t queued_event_count() const { 282 size_t queued_event_count() const { return queue_->size(); }
287 return queue_->size();
288 }
289 283
290 const WebTouchEvent& latest_event() const { 284 const WebTouchEvent& latest_event() const {
291 return queue_->GetLatestEventForTesting().event; 285 return queue_->GetLatestEventForTesting().event;
292 } 286 }
293 287
294 const WebTouchEvent& acked_event() const { 288 const WebTouchEvent& acked_event() const { return last_acked_event_; }
295 return last_acked_event_;
296 }
297 289
298 const WebTouchEvent& sent_event() const { 290 const WebTouchEvent& sent_event() const {
299 DCHECK(!sent_events_.empty()); 291 DCHECK(!sent_events_.empty());
300 return sent_events_.back(); 292 return sent_events_.back();
301 } 293 }
302 294
303 const std::vector<WebTouchEvent>& all_sent_events() const { 295 const std::vector<WebTouchEvent>& all_sent_events() const {
304 return sent_events_; 296 return sent_events_;
305 } 297 }
306 298
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 SyntheticWebTouchEvent touch_event_; 331 SyntheticWebTouchEvent touch_event_;
340 std::unique_ptr<WebTouchEvent> followup_touch_event_; 332 std::unique_ptr<WebTouchEvent> followup_touch_event_;
341 std::unique_ptr<WebGestureEvent> followup_gesture_event_; 333 std::unique_ptr<WebGestureEvent> followup_gesture_event_;
342 std::unique_ptr<InputEventAckState> sync_ack_result_; 334 std::unique_ptr<InputEventAckState> sync_ack_result_;
343 double slop_length_dips_; 335 double slop_length_dips_;
344 gfx::PointF anchor_; 336 gfx::PointF anchor_;
345 base::MessageLoopForUI message_loop_; 337 base::MessageLoopForUI message_loop_;
346 std::deque<int> sent_events_ids_; 338 std::deque<int> sent_events_ids_;
347 }; 339 };
348 340
349
350 // Tests that touch-events are queued properly. 341 // Tests that touch-events are queued properly.
351 TEST_F(TouchEventQueueTest, Basic) { 342 TEST_F(LegacyTouchEventQueueTest, Basic) {
352 PressTouchPoint(1, 1); 343 PressTouchPoint(1, 1);
353 EXPECT_EQ(1U, queued_event_count()); 344 EXPECT_EQ(1U, queued_event_count());
354 EXPECT_EQ(1U, GetAndResetSentEventCount()); 345 EXPECT_EQ(1U, GetAndResetSentEventCount());
355 346
356 // The second touch should not be sent since one is already in queue. 347 // The second touch should not be sent since one is already in queue.
357 MoveTouchPoint(0, 5, 5); 348 MoveTouchPoint(0, 5, 5);
358 EXPECT_EQ(2U, queued_event_count()); 349 EXPECT_EQ(2U, queued_event_count());
359 EXPECT_EQ(0U, GetAndResetSentEventCount()); 350 EXPECT_EQ(0U, GetAndResetSentEventCount());
360 351
361 // Receive an ACK for the first touch-event. 352 // Receive an ACK for the first touch-event.
362 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 353 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
363 EXPECT_EQ(1U, queued_event_count()); 354 EXPECT_EQ(1U, queued_event_count());
364 EXPECT_EQ(1U, GetAndResetSentEventCount()); 355 EXPECT_EQ(1U, GetAndResetSentEventCount());
365 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 356 EXPECT_EQ(1U, GetAndResetAckedEventCount());
366 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type()); 357 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type());
367 EXPECT_EQ(WebInputEvent::Blocking, acked_event().dispatchType); 358 EXPECT_EQ(WebInputEvent::Blocking, acked_event().dispatchType);
368 359
369 // Receive an ACK for the second touch-event. 360 // Receive an ACK for the second touch-event.
370 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 361 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
371 EXPECT_EQ(0U, queued_event_count()); 362 EXPECT_EQ(0U, queued_event_count());
372 EXPECT_EQ(0U, GetAndResetSentEventCount()); 363 EXPECT_EQ(0U, GetAndResetSentEventCount());
373 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 364 EXPECT_EQ(1U, GetAndResetAckedEventCount());
374 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type()); 365 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type());
375 EXPECT_EQ(WebInputEvent::Blocking, acked_event().dispatchType); 366 EXPECT_EQ(WebInputEvent::Blocking, acked_event().dispatchType);
376 } 367 }
377 368
378 // Tests that touch-events with multiple points are queued properly. 369 // Tests that touch-events with multiple points are queued properly.
379 TEST_F(TouchEventQueueTest, BasicMultiTouch) { 370 TEST_F(LegacyTouchEventQueueTest, BasicMultiTouch) {
380 const size_t kPointerCount = 10; 371 const size_t kPointerCount = 10;
381 for (float i = 0; i < kPointerCount; ++i) 372 for (float i = 0; i < kPointerCount; ++i)
382 PressTouchPoint(i, i); 373 PressTouchPoint(i, i);
383 374
384 EXPECT_EQ(1U, GetAndResetSentEventCount()); 375 EXPECT_EQ(1U, GetAndResetSentEventCount());
385 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 376 EXPECT_EQ(0U, GetAndResetAckedEventCount());
386 EXPECT_EQ(kPointerCount, queued_event_count()); 377 EXPECT_EQ(kPointerCount, queued_event_count());
387 378
388 for (int i = 0; i < static_cast<int>(kPointerCount); ++i) 379 for (int i = 0; i < static_cast<int>(kPointerCount); ++i)
389 MoveTouchPoint(i, 1.f + i, 2.f + i); 380 MoveTouchPoint(i, 1.f + i, 2.f + i);
(...skipping 25 matching lines...) Expand all
415 // Ack all releases. 406 // Ack all releases.
416 for (size_t i = 0; i < kPointerCount; ++i) 407 for (size_t i = 0; i < kPointerCount; ++i)
417 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 408 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
418 409
419 EXPECT_EQ(kPointerCount, GetAndResetAckedEventCount()); 410 EXPECT_EQ(kPointerCount, GetAndResetAckedEventCount());
420 EXPECT_EQ(kPointerCount - 1, GetAndResetSentEventCount()); 411 EXPECT_EQ(kPointerCount - 1, GetAndResetSentEventCount());
421 } 412 }
422 413
423 // Tests that the touch-queue continues delivering events for an active touch 414 // Tests that the touch-queue continues delivering events for an active touch
424 // sequence after all handlers are removed. 415 // sequence after all handlers are removed.
425 TEST_F(TouchEventQueueTest, TouchesForwardedIfHandlerRemovedDuringSequence) { 416 TEST_F(LegacyTouchEventQueueTest,
417 TouchesForwardedIfHandlerRemovedDuringSequence) {
426 OnHasTouchEventHandlers(true); 418 OnHasTouchEventHandlers(true);
427 EXPECT_EQ(0U, queued_event_count()); 419 EXPECT_EQ(0U, queued_event_count());
428 EXPECT_EQ(0U, GetAndResetSentEventCount()); 420 EXPECT_EQ(0U, GetAndResetSentEventCount());
429 421
430 // Send a touch-press event. 422 // Send a touch-press event.
431 PressTouchPoint(1, 1); 423 PressTouchPoint(1, 1);
432 EXPECT_EQ(1U, GetAndResetSentEventCount()); 424 EXPECT_EQ(1U, GetAndResetSentEventCount());
433 EXPECT_EQ(1U, queued_event_count()); 425 EXPECT_EQ(1U, queued_event_count());
434 426
435 // Signal that all touch handlers have been removed. 427 // Signal that all touch handlers have been removed.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 470
479 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 471 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
480 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 472 EXPECT_EQ(1U, GetAndResetAckedEventCount());
481 EXPECT_EQ(0U, GetAndResetSentEventCount()); 473 EXPECT_EQ(0U, GetAndResetSentEventCount());
482 EXPECT_EQ(0U, queued_event_count()); 474 EXPECT_EQ(0U, queued_event_count());
483 EXPECT_EQ(INPUT_EVENT_ACK_STATE_CONSUMED, acked_event_state()); 475 EXPECT_EQ(INPUT_EVENT_ACK_STATE_CONSUMED, acked_event_state());
484 } 476 }
485 477
486 // Tests that addition of a touch handler during a touch sequence will not cause 478 // Tests that addition of a touch handler during a touch sequence will not cause
487 // the remaining sequence to be forwarded. 479 // the remaining sequence to be forwarded.
488 TEST_F(TouchEventQueueTest, ActiveSequenceNotForwardedWhenHandlersAdded) { 480 TEST_F(LegacyTouchEventQueueTest, ActiveSequenceNotForwardedWhenHandlersAdded) {
489 OnHasTouchEventHandlers(false); 481 OnHasTouchEventHandlers(false);
490 482
491 // Send a touch-press event while there is no handler. 483 // Send a touch-press event while there is no handler.
492 PressTouchPoint(1, 1); 484 PressTouchPoint(1, 1);
493 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 485 EXPECT_EQ(1U, GetAndResetAckedEventCount());
494 EXPECT_EQ(0U, GetAndResetSentEventCount()); 486 EXPECT_EQ(0U, GetAndResetSentEventCount());
495 EXPECT_EQ(0U, queued_event_count()); 487 EXPECT_EQ(0U, queued_event_count());
496 488
497 OnHasTouchEventHandlers(true); 489 OnHasTouchEventHandlers(true);
498 490
499 // The remaining touch sequence should not be forwarded. 491 // The remaining touch sequence should not be forwarded.
500 MoveTouchPoint(0, 5, 5); 492 MoveTouchPoint(0, 5, 5);
501 ReleaseTouchPoint(0); 493 ReleaseTouchPoint(0);
502 EXPECT_EQ(2U, GetAndResetAckedEventCount()); 494 EXPECT_EQ(2U, GetAndResetAckedEventCount());
503 EXPECT_EQ(0U, GetAndResetSentEventCount()); 495 EXPECT_EQ(0U, GetAndResetSentEventCount());
504 EXPECT_EQ(0U, queued_event_count()); 496 EXPECT_EQ(0U, queued_event_count());
505 497
506 // A new touch sequence should resume forwarding. 498 // A new touch sequence should resume forwarding.
507 PressTouchPoint(1, 1); 499 PressTouchPoint(1, 1);
508 EXPECT_EQ(1U, queued_event_count()); 500 EXPECT_EQ(1U, queued_event_count());
509 EXPECT_EQ(1U, GetAndResetSentEventCount()); 501 EXPECT_EQ(1U, GetAndResetSentEventCount());
510 } 502 }
511 503
512 // Tests that removal of a touch handler during a touch sequence will prevent 504 // Tests that removal of a touch handler during a touch sequence will prevent
513 // the remaining sequence from being forwarded, even if another touch handler is 505 // the remaining sequence from being forwarded, even if another touch handler is
514 // registered during the same touch sequence. 506 // registered during the same touch sequence.
515 TEST_F(TouchEventQueueTest, ActiveSequenceDroppedWhenHandlersRemoved) { 507 TEST_F(LegacyTouchEventQueueTest, ActiveSequenceDroppedWhenHandlersRemoved) {
516 // Send a touch-press event. 508 // Send a touch-press event.
517 PressTouchPoint(1, 1); 509 PressTouchPoint(1, 1);
518 EXPECT_EQ(1U, GetAndResetSentEventCount()); 510 EXPECT_EQ(1U, GetAndResetSentEventCount());
519 EXPECT_EQ(1U, queued_event_count()); 511 EXPECT_EQ(1U, queued_event_count());
520 512
521 // Queue a touch-move event. 513 // Queue a touch-move event.
522 MoveTouchPoint(0, 5, 5); 514 MoveTouchPoint(0, 5, 5);
523 EXPECT_EQ(2U, queued_event_count()); 515 EXPECT_EQ(2U, queued_event_count());
524 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 516 EXPECT_EQ(0U, GetAndResetAckedEventCount());
525 EXPECT_EQ(0U, GetAndResetSentEventCount()); 517 EXPECT_EQ(0U, GetAndResetSentEventCount());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 EXPECT_EQ(0U, GetAndResetSentEventCount()); 551 EXPECT_EQ(0U, GetAndResetSentEventCount());
560 552
561 // A new touch sequence should be forwarded properly. 553 // A new touch sequence should be forwarded properly.
562 PressTouchPoint(1, 1); 554 PressTouchPoint(1, 1);
563 EXPECT_EQ(1U, queued_event_count()); 555 EXPECT_EQ(1U, queued_event_count());
564 EXPECT_EQ(1U, GetAndResetSentEventCount()); 556 EXPECT_EQ(1U, GetAndResetSentEventCount());
565 } 557 }
566 558
567 // Tests that removal/addition of a touch handler without any intervening 559 // Tests that removal/addition of a touch handler without any intervening
568 // touch activity has no affect on touch forwarding. 560 // touch activity has no affect on touch forwarding.
569 TEST_F(TouchEventQueueTest, 561 TEST_F(LegacyTouchEventQueueTest,
570 ActiveSequenceUnaffectedByRepeatedHandlerRemovalAndAddition) { 562 ActiveSequenceUnaffectedByRepeatedHandlerRemovalAndAddition) {
571 // Send a touch-press event. 563 // Send a touch-press event.
572 PressTouchPoint(1, 1); 564 PressTouchPoint(1, 1);
573 EXPECT_EQ(1U, GetAndResetSentEventCount()); 565 EXPECT_EQ(1U, GetAndResetSentEventCount());
574 EXPECT_EQ(1U, queued_event_count()); 566 EXPECT_EQ(1U, queued_event_count());
575 567
576 // Simulate the case where the touchstart handler removes itself, and adds a 568 // Simulate the case where the touchstart handler removes itself, and adds a
577 // touchmove handler. 569 // touchmove handler.
578 OnHasTouchEventHandlers(false); 570 OnHasTouchEventHandlers(false);
579 OnHasTouchEventHandlers(true); 571 OnHasTouchEventHandlers(true);
580 572
581 // Queue a touch-move event. 573 // Queue a touch-move event.
582 MoveTouchPoint(0, 5, 5); 574 MoveTouchPoint(0, 5, 5);
583 EXPECT_EQ(2U, queued_event_count()); 575 EXPECT_EQ(2U, queued_event_count());
584 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 576 EXPECT_EQ(0U, GetAndResetAckedEventCount());
585 EXPECT_EQ(0U, GetAndResetSentEventCount()); 577 EXPECT_EQ(0U, GetAndResetSentEventCount());
586 578
587 // The ack should trigger forwarding of the touchmove, as if no touch 579 // The ack should trigger forwarding of the touchmove, as if no touch
588 // handler registration changes have occurred. 580 // handler registration changes have occurred.
589 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 581 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
590 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 582 EXPECT_EQ(1U, GetAndResetAckedEventCount());
591 EXPECT_EQ(1U, GetAndResetSentEventCount()); 583 EXPECT_EQ(1U, GetAndResetSentEventCount());
592 EXPECT_EQ(1U, queued_event_count()); 584 EXPECT_EQ(1U, queued_event_count());
593 } 585 }
594 586
595 // Tests that touch-events are coalesced properly in the queue. 587 // Tests that touch-events are coalesced properly in the queue.
596 TEST_F(TouchEventQueueTest, Coalesce) { 588 TEST_F(LegacyTouchEventQueueTest, Coalesce) {
597 // Send a touch-press event. 589 // Send a touch-press event.
598 PressTouchPoint(1, 1); 590 PressTouchPoint(1, 1);
599 EXPECT_EQ(1U, GetAndResetSentEventCount()); 591 EXPECT_EQ(1U, GetAndResetSentEventCount());
600 592
601 // Send a few touch-move events, followed by a touch-release event. All the 593 // Send a few touch-move events, followed by a touch-release event. All the
602 // touch-move events should be coalesced into a single event. 594 // touch-move events should be coalesced into a single event.
603 for (float i = 5; i < 15; ++i) 595 for (float i = 5; i < 15; ++i)
604 MoveTouchPoint(0, i, i); 596 MoveTouchPoint(0, i, i);
605 597
606 EXPECT_EQ(0U, GetAndResetSentEventCount()); 598 EXPECT_EQ(0U, GetAndResetSentEventCount());
(...skipping 19 matching lines...) Expand all
626 // ACK the release. 618 // ACK the release.
627 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 619 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
628 EXPECT_EQ(0U, queued_event_count()); 620 EXPECT_EQ(0U, queued_event_count());
629 EXPECT_EQ(0U, GetAndResetSentEventCount()); 621 EXPECT_EQ(0U, GetAndResetSentEventCount());
630 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 622 EXPECT_EQ(1U, GetAndResetAckedEventCount());
631 EXPECT_EQ(WebInputEvent::TouchEnd, acked_event().type()); 623 EXPECT_EQ(WebInputEvent::TouchEnd, acked_event().type());
632 } 624 }
633 625
634 // Tests that an event that has already been sent but hasn't been ack'ed yet 626 // Tests that an event that has already been sent but hasn't been ack'ed yet
635 // doesn't get coalesced with newer events. 627 // doesn't get coalesced with newer events.
636 TEST_F(TouchEventQueueTest, SentTouchEventDoesNotCoalesce) { 628 TEST_F(LegacyTouchEventQueueTest, SentTouchEventDoesNotCoalesce) {
637 // Send a touch-press event. 629 // Send a touch-press event.
638 PressTouchPoint(1, 1); 630 PressTouchPoint(1, 1);
639 EXPECT_EQ(1U, GetAndResetSentEventCount()); 631 EXPECT_EQ(1U, GetAndResetSentEventCount());
640 632
641 // Send a few touch-move events, followed by a touch-release event. All the 633 // Send a few touch-move events, followed by a touch-release event. All the
642 // touch-move events should be coalesced into a single event. 634 // touch-move events should be coalesced into a single event.
643 for (float i = 5; i < 15; ++i) 635 for (float i = 5; i < 15; ++i)
644 MoveTouchPoint(0, i, i); 636 MoveTouchPoint(0, i, i);
645 637
646 EXPECT_EQ(0U, GetAndResetSentEventCount()); 638 EXPECT_EQ(0U, GetAndResetSentEventCount());
647 EXPECT_EQ(2U, queued_event_count()); 639 EXPECT_EQ(2U, queued_event_count());
648 640
649 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 641 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
650 EXPECT_EQ(1U, GetAndResetSentEventCount()); 642 EXPECT_EQ(1U, GetAndResetSentEventCount());
651 EXPECT_EQ(1U, queued_event_count()); 643 EXPECT_EQ(1U, queued_event_count());
652 644
653 // The coalesced touch-move event has been sent to the renderer. Any new 645 // The coalesced touch-move event has been sent to the renderer. Any new
654 // touch-move event should not be coalesced with the sent event. 646 // touch-move event should not be coalesced with the sent event.
655 MoveTouchPoint(0, 5, 5); 647 MoveTouchPoint(0, 5, 5);
656 EXPECT_EQ(2U, queued_event_count()); 648 EXPECT_EQ(2U, queued_event_count());
657 649
658 MoveTouchPoint(0, 7, 7); 650 MoveTouchPoint(0, 7, 7);
659 EXPECT_EQ(2U, queued_event_count()); 651 EXPECT_EQ(2U, queued_event_count());
660 } 652 }
661 653
662 // Tests that coalescing works correctly for multi-touch events. 654 // Tests that coalescing works correctly for multi-touch events.
663 TEST_F(TouchEventQueueTest, MultiTouch) { 655 TEST_F(LegacyTouchEventQueueTest, MultiTouch) {
664 // Press the first finger. 656 // Press the first finger.
665 PressTouchPoint(1, 1); 657 PressTouchPoint(1, 1);
666 EXPECT_EQ(1U, GetAndResetSentEventCount()); 658 EXPECT_EQ(1U, GetAndResetSentEventCount());
667 659
668 // Move the finger. 660 // Move the finger.
669 MoveTouchPoint(0, 5, 5); 661 MoveTouchPoint(0, 5, 5);
670 EXPECT_EQ(2U, queued_event_count()); 662 EXPECT_EQ(2U, queued_event_count());
671 663
672 // Now press a second finger. 664 // Now press a second finger.
673 PressTouchPoint(2, 2); 665 PressTouchPoint(2, 2);
(...skipping 13 matching lines...) Expand all
687 EXPECT_EQ(4U, queued_event_count()); 679 EXPECT_EQ(4U, queued_event_count());
688 680
689 // Make sure both fingers are marked as having been moved in the coalesced 681 // Make sure both fingers are marked as having been moved in the coalesced
690 // event. 682 // event.
691 const WebTouchEvent& event = latest_event(); 683 const WebTouchEvent& event = latest_event();
692 EXPECT_EQ(WebTouchPoint::StateMoved, event.touches[0].state); 684 EXPECT_EQ(WebTouchPoint::StateMoved, event.touches[0].state);
693 EXPECT_EQ(WebTouchPoint::StateMoved, event.touches[1].state); 685 EXPECT_EQ(WebTouchPoint::StateMoved, event.touches[1].state);
694 } 686 }
695 687
696 // Tests that the touch-event queue is robust to redundant acks. 688 // Tests that the touch-event queue is robust to redundant acks.
697 TEST_F(TouchEventQueueTest, SpuriousAcksIgnored) { 689 TEST_F(LegacyTouchEventQueueTest, SpuriousAcksIgnored) {
698 // Trigger a spurious ack. 690 // Trigger a spurious ack.
699 SendTouchEventAckWithID(INPUT_EVENT_ACK_STATE_CONSUMED, 0); 691 SendTouchEventAckWithID(INPUT_EVENT_ACK_STATE_CONSUMED, 0);
700 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 692 EXPECT_EQ(0U, GetAndResetAckedEventCount());
701 693
702 // Send and ack a touch press. 694 // Send and ack a touch press.
703 PressTouchPoint(1, 1); 695 PressTouchPoint(1, 1);
704 EXPECT_EQ(1U, GetAndResetSentEventCount()); 696 EXPECT_EQ(1U, GetAndResetSentEventCount());
705 EXPECT_EQ(1U, queued_event_count()); 697 EXPECT_EQ(1U, queued_event_count());
706 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 698 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
707 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 699 EXPECT_EQ(1U, GetAndResetAckedEventCount());
708 EXPECT_EQ(0U, queued_event_count()); 700 EXPECT_EQ(0U, queued_event_count());
709 701
710 // Trigger a spurious ack. 702 // Trigger a spurious ack.
711 SendTouchEventAckWithID(INPUT_EVENT_ACK_STATE_CONSUMED, 3); 703 SendTouchEventAckWithID(INPUT_EVENT_ACK_STATE_CONSUMED, 3);
712 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 704 EXPECT_EQ(0U, GetAndResetAckedEventCount());
713 } 705 }
714 706
715 // Tests that touch-move events are not sent to the renderer if the preceding 707 // Tests that touch-move events are not sent to the renderer if the preceding
716 // touch-press event did not have a consumer (and consequently, did not hit the 708 // touch-press event did not have a consumer (and consequently, did not hit the
717 // main thread in the renderer). Also tests that all queued/coalesced touch 709 // main thread in the renderer). Also tests that all queued/coalesced touch
718 // events are flushed immediately when the ACK for the touch-press comes back 710 // events are flushed immediately when the ACK for the touch-press comes back
719 // with NO_CONSUMER status. 711 // with NO_CONSUMER status.
720 TEST_F(TouchEventQueueTest, NoConsumer) { 712 TEST_F(LegacyTouchEventQueueTest, NoConsumer) {
721 // The first touch-press should reach the renderer. 713 // The first touch-press should reach the renderer.
722 PressTouchPoint(1, 1); 714 PressTouchPoint(1, 1);
723 EXPECT_EQ(1U, GetAndResetSentEventCount()); 715 EXPECT_EQ(1U, GetAndResetSentEventCount());
724 716
725 // The second touch should not be sent since one is already in queue. 717 // The second touch should not be sent since one is already in queue.
726 MoveTouchPoint(0, 5, 5); 718 MoveTouchPoint(0, 5, 5);
727 EXPECT_EQ(0U, GetAndResetSentEventCount()); 719 EXPECT_EQ(0U, GetAndResetSentEventCount());
728 EXPECT_EQ(2U, queued_event_count()); 720 EXPECT_EQ(2U, queued_event_count());
729 721
730 // Receive an ACK for the first touch-event. This should release the queued 722 // Receive an ACK for the first touch-event. This should release the queued
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 // Send a second press event. Even though the first touch press had 766 // Send a second press event. Even though the first touch press had
775 // NO_CONSUMER, this press event should reach the renderer. 767 // NO_CONSUMER, this press event should reach the renderer.
776 PressTouchPoint(1, 1); 768 PressTouchPoint(1, 1);
777 EXPECT_EQ(1U, GetAndResetSentEventCount()); 769 EXPECT_EQ(1U, GetAndResetSentEventCount());
778 EXPECT_EQ(1U, queued_event_count()); 770 EXPECT_EQ(1U, queued_event_count());
779 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 771 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
780 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type()); 772 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type());
781 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 773 EXPECT_EQ(1U, GetAndResetAckedEventCount());
782 } 774 }
783 775
784 TEST_F(TouchEventQueueTest, ConsumerIgnoreMultiFinger) { 776 TEST_F(LegacyTouchEventQueueTest, ConsumerIgnoreMultiFinger) {
785 // Interleave three pointer press, move and release events. 777 // Interleave three pointer press, move and release events.
786 PressTouchPoint(1, 1); 778 PressTouchPoint(1, 1);
787 MoveTouchPoint(0, 5, 5); 779 MoveTouchPoint(0, 5, 5);
788 PressTouchPoint(10, 10); 780 PressTouchPoint(10, 10);
789 MoveTouchPoint(1, 15, 15); 781 MoveTouchPoint(1, 15, 15);
790 PressTouchPoint(20, 20); 782 PressTouchPoint(20, 20);
791 MoveTouchPoint(2, 25, 25); 783 MoveTouchPoint(2, 25, 25);
792 ReleaseTouchPoint(2); 784 ReleaseTouchPoint(2);
793 MoveTouchPoint(1, 20, 20); 785 MoveTouchPoint(1, 20, 20);
794 ReleaseTouchPoint(1); 786 ReleaseTouchPoint(1);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); 820 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
829 EXPECT_EQ(6U, queued_event_count()); 821 EXPECT_EQ(6U, queued_event_count());
830 822
831 while (queued_event_count()) 823 while (queued_event_count())
832 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 824 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
833 825
834 EXPECT_EQ(6U, GetAndResetSentEventCount()); 826 EXPECT_EQ(6U, GetAndResetSentEventCount());
835 } 827 }
836 828
837 // Tests that touch-event's enqueued via a touch ack are properly handled. 829 // Tests that touch-event's enqueued via a touch ack are properly handled.
838 TEST_F(TouchEventQueueTest, AckWithFollowupEvents) { 830 TEST_F(LegacyTouchEventQueueTest, AckWithFollowupEvents) {
839 // Queue a touch down. 831 // Queue a touch down.
840 PressTouchPoint(1, 1); 832 PressTouchPoint(1, 1);
841 EXPECT_EQ(1U, queued_event_count()); 833 EXPECT_EQ(1U, queued_event_count());
842 EXPECT_EQ(1U, GetAndResetSentEventCount()); 834 EXPECT_EQ(1U, GetAndResetSentEventCount());
843 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 835 EXPECT_EQ(0U, GetAndResetAckedEventCount());
844 836
845 // Create a touch event that will be queued synchronously by a touch ack. 837 // Create a touch event that will be queued synchronously by a touch ack.
846 // Note, this will be triggered by all subsequent touch acks. 838 // Note, this will be triggered by all subsequent touch acks.
847 WebTouchEvent followup_event( 839 WebTouchEvent followup_event(
848 WebInputEvent::TouchMove, WebInputEvent::NoModifiers, 840 WebInputEvent::TouchMove, WebInputEvent::NoModifiers,
(...skipping 18 matching lines...) Expand all
867 859
868 // Receive an ACK for the touch-move followup event. This should cause the 860 // Receive an ACK for the touch-move followup event. This should cause the
869 // subsequent touch move event be sent to the renderer. 861 // subsequent touch move event be sent to the renderer.
870 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 862 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
871 EXPECT_EQ(1U, queued_event_count()); 863 EXPECT_EQ(1U, queued_event_count());
872 EXPECT_EQ(1U, GetAndResetSentEventCount()); 864 EXPECT_EQ(1U, GetAndResetSentEventCount());
873 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 865 EXPECT_EQ(1U, GetAndResetAckedEventCount());
874 } 866 }
875 867
876 // Tests that touch-events can be synchronously ack'ed. 868 // Tests that touch-events can be synchronously ack'ed.
877 TEST_F(TouchEventQueueTest, SynchronousAcks) { 869 TEST_F(LegacyTouchEventQueueTest, SynchronousAcks) {
878 // TouchStart 870 // TouchStart
879 SetSyncAckResult(INPUT_EVENT_ACK_STATE_CONSUMED); 871 SetSyncAckResult(INPUT_EVENT_ACK_STATE_CONSUMED);
880 PressTouchPoint(1, 1); 872 PressTouchPoint(1, 1);
881 EXPECT_EQ(0U, queued_event_count()); 873 EXPECT_EQ(0U, queued_event_count());
882 EXPECT_EQ(1U, GetAndResetSentEventCount()); 874 EXPECT_EQ(1U, GetAndResetSentEventCount());
883 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 875 EXPECT_EQ(1U, GetAndResetAckedEventCount());
884 876
885 // TouchMove 877 // TouchMove
886 SetSyncAckResult(INPUT_EVENT_ACK_STATE_CONSUMED); 878 SetSyncAckResult(INPUT_EVENT_ACK_STATE_CONSUMED);
887 MoveTouchPoint(0, 2, 2); 879 MoveTouchPoint(0, 2, 2);
(...skipping 17 matching lines...) Expand all
905 897
906 SetSyncAckResult(INPUT_EVENT_ACK_STATE_CONSUMED); 898 SetSyncAckResult(INPUT_EVENT_ACK_STATE_CONSUMED);
907 CancelTouchPoint(0); 899 CancelTouchPoint(0);
908 EXPECT_EQ(0U, queued_event_count()); 900 EXPECT_EQ(0U, queued_event_count());
909 EXPECT_EQ(1U, GetAndResetSentEventCount()); 901 EXPECT_EQ(1U, GetAndResetSentEventCount());
910 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 902 EXPECT_EQ(1U, GetAndResetAckedEventCount());
911 } 903 }
912 904
913 // Tests that followup events triggered by an immediate ack from 905 // Tests that followup events triggered by an immediate ack from
914 // TouchEventQueue::QueueEvent() are properly handled. 906 // TouchEventQueue::QueueEvent() are properly handled.
915 TEST_F(TouchEventQueueTest, ImmediateAckWithFollowupEvents) { 907 TEST_F(LegacyTouchEventQueueTest, ImmediateAckWithFollowupEvents) {
916 // Create a touch event that will be queued synchronously by a touch ack. 908 // Create a touch event that will be queued synchronously by a touch ack.
917 WebTouchEvent followup_event( 909 WebTouchEvent followup_event(
918 WebInputEvent::TouchStart, WebInputEvent::NoModifiers, 910 WebInputEvent::TouchStart, WebInputEvent::NoModifiers,
919 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); 911 ui::EventTimeStampToSeconds(ui::EventTimeForNow()));
920 followup_event.touchesLength = 1; 912 followup_event.touchesLength = 1;
921 followup_event.touches[0].id = 1; 913 followup_event.touches[0].id = 1;
922 followup_event.touches[0].state = WebTouchPoint::StatePressed; 914 followup_event.touches[0].state = WebTouchPoint::StatePressed;
923 SetFollowupEvent(followup_event); 915 SetFollowupEvent(followup_event);
924 916
925 // Now, enqueue a stationary touch that will not be forwarded. This should be 917 // Now, enqueue a stationary touch that will not be forwarded. This should be
926 // immediately ack'ed with "NO_CONSUMER_EXISTS". The followup event should 918 // immediately ack'ed with "NO_CONSUMER_EXISTS". The followup event should
927 // then be enqueued and immediately sent to the renderer. 919 // then be enqueued and immediately sent to the renderer.
928 WebTouchEvent stationary_event( 920 WebTouchEvent stationary_event(
929 WebInputEvent::TouchMove, WebInputEvent::NoModifiers, 921 WebInputEvent::TouchMove, WebInputEvent::NoModifiers,
930 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); 922 ui::EventTimeStampToSeconds(ui::EventTimeForNow()));
931 ; 923 ;
932 stationary_event.touchesLength = 1; 924 stationary_event.touchesLength = 1;
933 stationary_event.touches[0].id = 1; 925 stationary_event.touches[0].id = 1;
934 stationary_event.touches[0].state = WebTouchPoint::StateStationary; 926 stationary_event.touches[0].state = WebTouchPoint::StateStationary;
935 SendTouchEvent(stationary_event); 927 SendTouchEvent(stationary_event);
936 928
937 EXPECT_EQ(1U, queued_event_count()); 929 EXPECT_EQ(1U, queued_event_count());
938 EXPECT_EQ(1U, GetAndResetSentEventCount()); 930 EXPECT_EQ(1U, GetAndResetSentEventCount());
939 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 931 EXPECT_EQ(1U, GetAndResetAckedEventCount());
940 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); 932 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state());
941 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type()); 933 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type());
942 } 934 }
943 935
944 // Tests basic TouchEvent forwarding suppression. 936 // Tests basic TouchEvent forwarding suppression.
945 TEST_F(TouchEventQueueTest, NoTouchBasic) { 937 TEST_F(LegacyTouchEventQueueTest, NoTouchBasic) {
946 // Disable TouchEvent forwarding. 938 // Disable TouchEvent forwarding.
947 OnHasTouchEventHandlers(false); 939 OnHasTouchEventHandlers(false);
948 PressTouchPoint(30, 5); 940 PressTouchPoint(30, 5);
949 EXPECT_EQ(0U, GetAndResetSentEventCount()); 941 EXPECT_EQ(0U, GetAndResetSentEventCount());
950 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 942 EXPECT_EQ(1U, GetAndResetAckedEventCount());
951 943
952 // TouchMove should not be sent to renderer. 944 // TouchMove should not be sent to renderer.
953 MoveTouchPoint(0, 65, 10); 945 MoveTouchPoint(0, 65, 10);
954 EXPECT_EQ(0U, GetAndResetSentEventCount()); 946 EXPECT_EQ(0U, GetAndResetSentEventCount());
955 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 947 EXPECT_EQ(1U, GetAndResetAckedEventCount());
(...skipping 16 matching lines...) Expand all
972 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 964 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
973 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 965 EXPECT_EQ(1U, GetAndResetAckedEventCount());
974 966
975 ReleaseTouchPoint(0); 967 ReleaseTouchPoint(0);
976 EXPECT_EQ(1U, GetAndResetSentEventCount()); 968 EXPECT_EQ(1U, GetAndResetSentEventCount());
977 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 969 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
978 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 970 EXPECT_EQ(1U, GetAndResetAckedEventCount());
979 } 971 }
980 972
981 // Tests that IsTouchStartPendingAck works correctly. 973 // Tests that IsTouchStartPendingAck works correctly.
982 TEST_F(TouchEventQueueTest, PendingStart) { 974 TEST_F(LegacyTouchEventQueueTest, PendingStart) {
983
984 EXPECT_FALSE(IsPendingAckTouchStart()); 975 EXPECT_FALSE(IsPendingAckTouchStart());
985 976
986 // Send the touchstart for one point (#1). 977 // Send the touchstart for one point (#1).
987 PressTouchPoint(1, 1); 978 PressTouchPoint(1, 1);
988 EXPECT_EQ(1U, queued_event_count()); 979 EXPECT_EQ(1U, queued_event_count());
989 EXPECT_TRUE(IsPendingAckTouchStart()); 980 EXPECT_TRUE(IsPendingAckTouchStart());
990 981
991 // Send a touchmove for that point (#2). 982 // Send a touchmove for that point (#2).
992 MoveTouchPoint(0, 5, 5); 983 MoveTouchPoint(0, 5, 5);
993 EXPECT_EQ(2U, queued_event_count()); 984 EXPECT_EQ(2U, queued_event_count());
(...skipping 24 matching lines...) Expand all
1018 EXPECT_EQ(1U, queued_event_count()); 1009 EXPECT_EQ(1U, queued_event_count());
1019 EXPECT_TRUE(IsPendingAckTouchStart()); 1010 EXPECT_TRUE(IsPendingAckTouchStart());
1020 1011
1021 // Ack the touchstart for the third point (#4). 1012 // Ack the touchstart for the third point (#4).
1022 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1013 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1023 EXPECT_EQ(0U, queued_event_count()); 1014 EXPECT_EQ(0U, queued_event_count());
1024 EXPECT_FALSE(IsPendingAckTouchStart()); 1015 EXPECT_FALSE(IsPendingAckTouchStart());
1025 } 1016 }
1026 1017
1027 // Tests that the touch timeout is started when sending certain touch types. 1018 // Tests that the touch timeout is started when sending certain touch types.
1028 TEST_F(TouchEventQueueTest, TouchTimeoutTypes) { 1019 TEST_F(LegacyTouchEventQueueTest, TouchTimeoutTypes) {
1029 SetUpForTimeoutTesting(); 1020 SetUpForTimeoutTesting();
1030 1021
1031 // Sending a TouchStart will start the timeout. 1022 // Sending a TouchStart will start the timeout.
1032 PressTouchPoint(0, 1); 1023 PressTouchPoint(0, 1);
1033 EXPECT_TRUE(IsTimeoutRunning()); 1024 EXPECT_TRUE(IsTimeoutRunning());
1034 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1025 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1035 EXPECT_FALSE(IsTimeoutRunning()); 1026 EXPECT_FALSE(IsTimeoutRunning());
1036 1027
1037 // A TouchMove should start the timeout. 1028 // A TouchMove should start the timeout.
1038 MoveTouchPoint(0, 5, 5); 1029 MoveTouchPoint(0, 5, 5);
(...skipping 13 matching lines...) Expand all
1052 ASSERT_FALSE(IsTimeoutRunning()); 1043 ASSERT_FALSE(IsTimeoutRunning());
1053 CancelTouchPoint(0); 1044 CancelTouchPoint(0);
1054 EXPECT_FALSE(IsTimeoutRunning()); 1045 EXPECT_FALSE(IsTimeoutRunning());
1055 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1046 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1056 EXPECT_FALSE(IsTimeoutRunning()); 1047 EXPECT_FALSE(IsTimeoutRunning());
1057 } 1048 }
1058 1049
1059 // Tests that a delayed TouchEvent ack will trigger a TouchCancel timeout, 1050 // Tests that a delayed TouchEvent ack will trigger a TouchCancel timeout,
1060 // disabling touch forwarding until the next TouchStart is received after 1051 // disabling touch forwarding until the next TouchStart is received after
1061 // the timeout events are ack'ed. 1052 // the timeout events are ack'ed.
1062 TEST_F(TouchEventQueueTest, TouchTimeoutBasic) { 1053 TEST_F(LegacyTouchEventQueueTest, TouchTimeoutBasic) {
1063 SetUpForTimeoutTesting(); 1054 SetUpForTimeoutTesting();
1064 1055
1065 // Queue a TouchStart. 1056 // Queue a TouchStart.
1066 GetAndResetSentEventCount(); 1057 GetAndResetSentEventCount();
1067 GetAndResetAckedEventCount(); 1058 GetAndResetAckedEventCount();
1068 PressTouchPoint(0, 1); 1059 PressTouchPoint(0, 1);
1069 ASSERT_EQ(1U, GetAndResetSentEventCount()); 1060 ASSERT_EQ(1U, GetAndResetSentEventCount());
1070 ASSERT_EQ(0U, GetAndResetAckedEventCount()); 1061 ASSERT_EQ(0U, GetAndResetAckedEventCount());
1071 EXPECT_TRUE(IsTimeoutRunning()); 1062 EXPECT_TRUE(IsTimeoutRunning());
1072 1063
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 // Subsequent events should be handled normally. 1097 // Subsequent events should be handled normally.
1107 PressTouchPoint(0, 1); 1098 PressTouchPoint(0, 1);
1108 EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type()); 1099 EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type());
1109 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType); 1100 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType);
1110 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1101 EXPECT_EQ(1U, GetAndResetSentEventCount());
1111 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1102 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1112 } 1103 }
1113 1104
1114 // Tests that the timeout is never started if the renderer consumes 1105 // Tests that the timeout is never started if the renderer consumes
1115 // a TouchEvent from the current touch sequence. 1106 // a TouchEvent from the current touch sequence.
1116 TEST_F(TouchEventQueueTest, NoTouchTimeoutIfRendererIsConsumingGesture) { 1107 TEST_F(LegacyTouchEventQueueTest, NoTouchTimeoutIfRendererIsConsumingGesture) {
1117 SetUpForTimeoutTesting(); 1108 SetUpForTimeoutTesting();
1118 1109
1119 // Queue a TouchStart. 1110 // Queue a TouchStart.
1120 PressTouchPoint(0, 1); 1111 PressTouchPoint(0, 1);
1121 ASSERT_TRUE(IsTimeoutRunning()); 1112 ASSERT_TRUE(IsTimeoutRunning());
1122 1113
1123 // Mark the event as consumed. This should prevent the timeout from 1114 // Mark the event as consumed. This should prevent the timeout from
1124 // being activated on subsequent TouchEvents in this gesture. 1115 // being activated on subsequent TouchEvents in this gesture.
1125 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 1116 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
1126 EXPECT_FALSE(IsTimeoutRunning()); 1117 EXPECT_FALSE(IsTimeoutRunning());
(...skipping 13 matching lines...) Expand all
1140 EXPECT_FALSE(IsTimeoutRunning()); 1131 EXPECT_FALSE(IsTimeoutRunning());
1141 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1132 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1142 1133
1143 // A TouchCancel should not start the timeout. 1134 // A TouchCancel should not start the timeout.
1144 CancelTouchPoint(0); 1135 CancelTouchPoint(0);
1145 EXPECT_FALSE(IsTimeoutRunning()); 1136 EXPECT_FALSE(IsTimeoutRunning());
1146 } 1137 }
1147 1138
1148 // Tests that the timeout is never started if the renderer consumes 1139 // Tests that the timeout is never started if the renderer consumes
1149 // a TouchEvent from the current touch sequence. 1140 // a TouchEvent from the current touch sequence.
1150 TEST_F(TouchEventQueueTest, NoTouchTimeoutIfDisabledAfterTouchStart) { 1141 TEST_F(LegacyTouchEventQueueTest, NoTouchTimeoutIfDisabledAfterTouchStart) {
1151 SetUpForTimeoutTesting(); 1142 SetUpForTimeoutTesting();
1152 1143
1153 // Queue a TouchStart. 1144 // Queue a TouchStart.
1154 PressTouchPoint(0, 1); 1145 PressTouchPoint(0, 1);
1155 ASSERT_TRUE(IsTimeoutRunning()); 1146 ASSERT_TRUE(IsTimeoutRunning());
1156 1147
1157 // Send the ack immediately. The timeout should not have fired. 1148 // Send the ack immediately. The timeout should not have fired.
1158 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1149 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1159 EXPECT_FALSE(IsTimeoutRunning()); 1150 EXPECT_FALSE(IsTimeoutRunning());
1160 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1151 EXPECT_EQ(1U, GetAndResetSentEventCount());
1161 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1152 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1162 1153
1163 // Now explicitly disable the timeout. 1154 // Now explicitly disable the timeout.
1164 SetAckTimeoutDisabled(); 1155 SetAckTimeoutDisabled();
1165 EXPECT_FALSE(IsTimeoutRunning()); 1156 EXPECT_FALSE(IsTimeoutRunning());
1166 1157
1167 // A TouchMove should not start or trigger the timeout. 1158 // A TouchMove should not start or trigger the timeout.
1168 MoveTouchPoint(0, 5, 5); 1159 MoveTouchPoint(0, 5, 5);
1169 EXPECT_FALSE(IsTimeoutRunning()); 1160 EXPECT_FALSE(IsTimeoutRunning());
1170 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1161 EXPECT_EQ(1U, GetAndResetSentEventCount());
1171 RunTasksAndWait(DefaultTouchTimeoutDelay() * 2); 1162 RunTasksAndWait(DefaultTouchTimeoutDelay() * 2);
1172 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1163 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1173 } 1164 }
1174 1165
1175 // Tests that the timeout is never started if the ack is synchronous. 1166 // Tests that the timeout is never started if the ack is synchronous.
1176 TEST_F(TouchEventQueueTest, NoTouchTimeoutIfAckIsSynchronous) { 1167 TEST_F(LegacyTouchEventQueueTest, NoTouchTimeoutIfAckIsSynchronous) {
1177 SetUpForTimeoutTesting(); 1168 SetUpForTimeoutTesting();
1178 1169
1179 // Queue a TouchStart. 1170 // Queue a TouchStart.
1180 SetSyncAckResult(INPUT_EVENT_ACK_STATE_CONSUMED); 1171 SetSyncAckResult(INPUT_EVENT_ACK_STATE_CONSUMED);
1181 ASSERT_FALSE(IsTimeoutRunning()); 1172 ASSERT_FALSE(IsTimeoutRunning());
1182 PressTouchPoint(0, 1); 1173 PressTouchPoint(0, 1);
1183 EXPECT_FALSE(IsTimeoutRunning()); 1174 EXPECT_FALSE(IsTimeoutRunning());
1184 } 1175 }
1185 1176
1186 // Tests that the timeout does not fire if explicitly disabled while an event 1177 // Tests that the timeout does not fire if explicitly disabled while an event
1187 // is in-flight. 1178 // is in-flight.
1188 TEST_F(TouchEventQueueTest, NoTouchTimeoutIfDisabledWhileTimerIsActive) { 1179 TEST_F(LegacyTouchEventQueueTest, NoTouchTimeoutIfDisabledWhileTimerIsActive) {
1189 SetUpForTimeoutTesting(); 1180 SetUpForTimeoutTesting();
1190 1181
1191 // Queue a TouchStart. 1182 // Queue a TouchStart.
1192 PressTouchPoint(0, 1); 1183 PressTouchPoint(0, 1);
1193 ASSERT_TRUE(IsTimeoutRunning()); 1184 ASSERT_TRUE(IsTimeoutRunning());
1194 1185
1195 // Verify that disabling the timeout also turns off the timer. 1186 // Verify that disabling the timeout also turns off the timer.
1196 SetAckTimeoutDisabled(); 1187 SetAckTimeoutDisabled();
1197 EXPECT_FALSE(IsTimeoutRunning()); 1188 EXPECT_FALSE(IsTimeoutRunning());
1198 RunTasksAndWait(DefaultTouchTimeoutDelay() * 2); 1189 RunTasksAndWait(DefaultTouchTimeoutDelay() * 2);
1199 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1190 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1200 } 1191 }
1201 1192
1202 // Tests that the timeout does not fire if the delay is zero. 1193 // Tests that the timeout does not fire if the delay is zero.
1203 TEST_F(TouchEventQueueTest, NoTouchTimeoutIfTimeoutDelayIsZero) { 1194 TEST_F(LegacyTouchEventQueueTest, NoTouchTimeoutIfTimeoutDelayIsZero) {
1204 SetUpForTimeoutTesting(base::TimeDelta(), base::TimeDelta()); 1195 SetUpForTimeoutTesting(base::TimeDelta(), base::TimeDelta());
1205 1196
1206 // As the delay is zero, timeout behavior should be disabled. 1197 // As the delay is zero, timeout behavior should be disabled.
1207 PressTouchPoint(0, 1); 1198 PressTouchPoint(0, 1);
1208 EXPECT_FALSE(IsTimeoutRunning()); 1199 EXPECT_FALSE(IsTimeoutRunning());
1209 RunTasksAndWait(DefaultTouchTimeoutDelay() * 2); 1200 RunTasksAndWait(DefaultTouchTimeoutDelay() * 2);
1210 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1201 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1211 } 1202 }
1212 1203
1213 // Tests that timeout delays for mobile sites take effect when appropriate. 1204 // Tests that timeout delays for mobile sites take effect when appropriate.
1214 TEST_F(TouchEventQueueTest, TouchTimeoutConfiguredForMobile) { 1205 TEST_F(LegacyTouchEventQueueTest, TouchTimeoutConfiguredForMobile) {
1215 base::TimeDelta desktop_delay = DefaultTouchTimeoutDelay(); 1206 base::TimeDelta desktop_delay = DefaultTouchTimeoutDelay();
1216 base::TimeDelta mobile_delay = base::TimeDelta(); 1207 base::TimeDelta mobile_delay = base::TimeDelta();
1217 SetUpForTimeoutTesting(desktop_delay, mobile_delay); 1208 SetUpForTimeoutTesting(desktop_delay, mobile_delay);
1218 1209
1219 // The desktop delay is non-zero, allowing timeout behavior. 1210 // The desktop delay is non-zero, allowing timeout behavior.
1220 SetIsMobileOptimizedSite(false); 1211 SetIsMobileOptimizedSite(false);
1221 1212
1222 PressTouchPoint(0, 1); 1213 PressTouchPoint(0, 1);
1223 ASSERT_TRUE(IsTimeoutRunning()); 1214 ASSERT_TRUE(IsTimeoutRunning());
1224 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 1215 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
1225 ReleaseTouchPoint(0); 1216 ReleaseTouchPoint(0);
1226 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 1217 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
1227 EXPECT_EQ(2U, GetAndResetAckedEventCount()); 1218 EXPECT_EQ(2U, GetAndResetAckedEventCount());
1228 ASSERT_FALSE(IsTimeoutRunning()); 1219 ASSERT_FALSE(IsTimeoutRunning());
1229 1220
1230 // The mobile delay is zero, preventing timeout behavior. 1221 // The mobile delay is zero, preventing timeout behavior.
1231 SetIsMobileOptimizedSite(true); 1222 SetIsMobileOptimizedSite(true);
1232 1223
1233 PressTouchPoint(0, 1); 1224 PressTouchPoint(0, 1);
1234 EXPECT_FALSE(IsTimeoutRunning()); 1225 EXPECT_FALSE(IsTimeoutRunning());
1235 RunTasksAndWait(DefaultTouchTimeoutDelay() * 2); 1226 RunTasksAndWait(DefaultTouchTimeoutDelay() * 2);
1236 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1227 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1237 } 1228 }
1238 1229
1239 // Tests that a TouchCancel timeout plays nice when the timed out touch stream 1230 // Tests that a TouchCancel timeout plays nice when the timed out touch stream
1240 // turns into a scroll gesture sequence. 1231 // turns into a scroll gesture sequence.
1241 TEST_F(TouchEventQueueTest, TouchTimeoutWithFollowupGesture) { 1232 TEST_F(LegacyTouchEventQueueTest, TouchTimeoutWithFollowupGesture) {
1242 SetUpForTimeoutTesting(); 1233 SetUpForTimeoutTesting();
1243 1234
1244 // Queue a TouchStart. 1235 // Queue a TouchStart.
1245 PressTouchPoint(0, 1); 1236 PressTouchPoint(0, 1);
1246 EXPECT_TRUE(IsTimeoutRunning()); 1237 EXPECT_TRUE(IsTimeoutRunning());
1247 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1238 EXPECT_EQ(1U, GetAndResetSentEventCount());
1248 1239
1249 // The cancelled sequence may turn into a scroll gesture. 1240 // The cancelled sequence may turn into a scroll gesture.
1250 WebGestureEvent followup_scroll( 1241 WebGestureEvent followup_scroll(
1251 WebInputEvent::GestureScrollBegin, WebInputEvent::NoModifiers, 1242 WebInputEvent::GestureScrollBegin, WebInputEvent::NoModifiers,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 SendGestureEvent(blink::WebInputEvent::GestureScrollEnd); 1278 SendGestureEvent(blink::WebInputEvent::GestureScrollEnd);
1288 PressTouchPoint(0, 1); 1279 PressTouchPoint(0, 1);
1289 EXPECT_TRUE(IsTimeoutRunning()); 1280 EXPECT_TRUE(IsTimeoutRunning());
1290 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1281 EXPECT_EQ(1U, GetAndResetSentEventCount());
1291 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1282 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1292 } 1283 }
1293 1284
1294 // Tests that a TouchCancel timeout plays nice when the timed out touch stream 1285 // Tests that a TouchCancel timeout plays nice when the timed out touch stream
1295 // turns into a scroll gesture sequence, but the original event acks are 1286 // turns into a scroll gesture sequence, but the original event acks are
1296 // significantly delayed. 1287 // significantly delayed.
1297 TEST_F(TouchEventQueueTest, TouchTimeoutWithFollowupGestureAndDelayedAck) { 1288 TEST_F(LegacyTouchEventQueueTest,
1289 TouchTimeoutWithFollowupGestureAndDelayedAck) {
1298 SetUpForTimeoutTesting(); 1290 SetUpForTimeoutTesting();
1299 1291
1300 // Queue a TouchStart. 1292 // Queue a TouchStart.
1301 PressTouchPoint(0, 1); 1293 PressTouchPoint(0, 1);
1302 EXPECT_TRUE(IsTimeoutRunning()); 1294 EXPECT_TRUE(IsTimeoutRunning());
1303 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1295 EXPECT_EQ(1U, GetAndResetSentEventCount());
1304 1296
1305 // The cancelled sequence may turn into a scroll gesture. 1297 // The cancelled sequence may turn into a scroll gesture.
1306 WebGestureEvent followup_scroll( 1298 WebGestureEvent followup_scroll(
1307 WebInputEvent::GestureScrollBegin, WebInputEvent::NoModifiers, 1299 WebInputEvent::GestureScrollBegin, WebInputEvent::NoModifiers,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 EXPECT_EQ(0U, GetAndResetSentEventCount()); 1336 EXPECT_EQ(0U, GetAndResetSentEventCount());
1345 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1337 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1346 1338
1347 PressTouchPoint(0, 1); 1339 PressTouchPoint(0, 1);
1348 EXPECT_TRUE(IsTimeoutRunning()); 1340 EXPECT_TRUE(IsTimeoutRunning());
1349 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1341 EXPECT_EQ(1U, GetAndResetSentEventCount());
1350 } 1342 }
1351 1343
1352 // Tests that a delayed TouchEvent ack will not trigger a TouchCancel timeout if 1344 // Tests that a delayed TouchEvent ack will not trigger a TouchCancel timeout if
1353 // the timed-out event had no consumer. 1345 // the timed-out event had no consumer.
1354 TEST_F(TouchEventQueueTest, NoCancelOnTouchTimeoutWithoutConsumer) { 1346 TEST_F(LegacyTouchEventQueueTest, NoCancelOnTouchTimeoutWithoutConsumer) {
1355 SetUpForTimeoutTesting(); 1347 SetUpForTimeoutTesting();
1356 1348
1357 // Queue a TouchStart. 1349 // Queue a TouchStart.
1358 PressTouchPoint(0, 1); 1350 PressTouchPoint(0, 1);
1359 ASSERT_EQ(1U, GetAndResetSentEventCount()); 1351 ASSERT_EQ(1U, GetAndResetSentEventCount());
1360 ASSERT_EQ(0U, GetAndResetAckedEventCount()); 1352 ASSERT_EQ(0U, GetAndResetAckedEventCount());
1361 EXPECT_TRUE(IsTimeoutRunning()); 1353 EXPECT_TRUE(IsTimeoutRunning());
1362 1354
1363 // Delay the ack. 1355 // Delay the ack.
1364 RunTasksAndWait(DefaultTouchTimeoutDelay() * 2); 1356 RunTasksAndWait(DefaultTouchTimeoutDelay() * 2);
(...skipping 18 matching lines...) Expand all
1383 EXPECT_EQ(0U, GetAndResetSentEventCount()); 1375 EXPECT_EQ(0U, GetAndResetSentEventCount());
1384 1376
1385 // Subsequent events should be handled normally. 1377 // Subsequent events should be handled normally.
1386 PressTouchPoint(0, 1); 1378 PressTouchPoint(0, 1);
1387 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1379 EXPECT_EQ(1U, GetAndResetSentEventCount());
1388 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1380 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1389 } 1381 }
1390 1382
1391 // Tests that TouchMove's movedBeyondSlopRegion is set to false if within the 1383 // Tests that TouchMove's movedBeyondSlopRegion is set to false if within the
1392 // boundary-inclusive slop region for an unconsumed TouchStart. 1384 // boundary-inclusive slop region for an unconsumed TouchStart.
1393 TEST_F(TouchEventQueueTest, TouchMovedBeyondSlopRegionCheck) { 1385 TEST_F(LegacyTouchEventQueueTest, TouchMovedBeyondSlopRegionCheck) {
1394 SetUpForTouchMoveSlopTesting(kSlopLengthDips); 1386 SetUpForTouchMoveSlopTesting(kSlopLengthDips);
1395 1387
1396 // Queue a TouchStart. 1388 // Queue a TouchStart.
1397 PressTouchPoint(0, 0); 1389 PressTouchPoint(0, 0);
1398 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1390 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1399 ASSERT_EQ(1U, GetAndResetSentEventCount()); 1391 ASSERT_EQ(1U, GetAndResetSentEventCount());
1400 ASSERT_EQ(1U, GetAndResetAckedEventCount()); 1392 ASSERT_EQ(1U, GetAndResetAckedEventCount());
1401 1393
1402 // TouchMove's movedBeyondSlopRegion within the slop region is set to false. 1394 // TouchMove's movedBeyondSlopRegion within the slop region is set to false.
1403 MoveTouchPoint(0, 0, kHalfSlopLengthDips); 1395 MoveTouchPoint(0, 0, kHalfSlopLengthDips);
(...skipping 29 matching lines...) Expand all
1433 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1425 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1434 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1426 EXPECT_EQ(1U, GetAndResetSentEventCount());
1435 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1427 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1436 EXPECT_FALSE(acked_event().movedBeyondSlopRegion); 1428 EXPECT_FALSE(acked_event().movedBeyondSlopRegion);
1437 1429
1438 // When a TouchMove exceeds the (Euclidean) distance, the TouchMove's 1430 // When a TouchMove exceeds the (Euclidean) distance, the TouchMove's
1439 // movedBeyondSlopRegion is set to true. 1431 // movedBeyondSlopRegion is set to true.
1440 const float kFortyFiveDegreeSlopLengthXY = 1432 const float kFortyFiveDegreeSlopLengthXY =
1441 kSlopLengthDips * std::sqrt(2.f) / 2; 1433 kSlopLengthDips * std::sqrt(2.f) / 2;
1442 MoveTouchPoint(0, kFortyFiveDegreeSlopLengthXY + .2f, 1434 MoveTouchPoint(0, kFortyFiveDegreeSlopLengthXY + .2f,
1443 kFortyFiveDegreeSlopLengthXY + .2f); 1435 kFortyFiveDegreeSlopLengthXY + .2f);
1444 EXPECT_EQ(1U, queued_event_count()); 1436 EXPECT_EQ(1U, queued_event_count());
1445 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1437 EXPECT_EQ(1U, GetAndResetSentEventCount());
1446 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1438 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1447 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1439 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1448 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1440 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1449 EXPECT_TRUE(acked_event().movedBeyondSlopRegion); 1441 EXPECT_TRUE(acked_event().movedBeyondSlopRegion);
1450 } 1442 }
1451 1443
1452 // Tests that even very small TouchMove's movedBeyondSlopRegion is set to true 1444 // Tests that even very small TouchMove's movedBeyondSlopRegion is set to true
1453 // when the slop region's dimension is 0. 1445 // when the slop region's dimension is 0.
1454 TEST_F(TouchEventQueueTest, MovedBeyondSlopRegionAlwaysTrueIfDimensionZero) { 1446 TEST_F(LegacyTouchEventQueueTest,
1447 MovedBeyondSlopRegionAlwaysTrueIfDimensionZero) {
1455 // Queue a TouchStart. 1448 // Queue a TouchStart.
1456 PressTouchPoint(0, 0); 1449 PressTouchPoint(0, 0);
1457 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1450 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1458 ASSERT_EQ(1U, GetAndResetSentEventCount()); 1451 ASSERT_EQ(1U, GetAndResetSentEventCount());
1459 ASSERT_EQ(1U, GetAndResetAckedEventCount()); 1452 ASSERT_EQ(1U, GetAndResetAckedEventCount());
1460 1453
1461 // Small TouchMove's movedBeyondSlopRegion is set to true. 1454 // Small TouchMove's movedBeyondSlopRegion is set to true.
1462 MoveTouchPoint(0, 0.001f, 0.001f); 1455 MoveTouchPoint(0, 0.001f, 0.001f);
1463 EXPECT_EQ(1U, queued_event_count()); 1456 EXPECT_EQ(1U, queued_event_count());
1464 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1457 EXPECT_EQ(1U, GetAndResetSentEventCount());
1465 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1458 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1466 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1459 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1467 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1460 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1468 EXPECT_TRUE(acked_event().movedBeyondSlopRegion); 1461 EXPECT_TRUE(acked_event().movedBeyondSlopRegion);
1469 } 1462 }
1470 1463
1471 // Tests that secondary touch points can be forwarded even if the primary touch 1464 // Tests that secondary touch points can be forwarded even if the primary touch
1472 // point had no consumer. 1465 // point had no consumer.
1473 TEST_F(TouchEventQueueTest, SecondaryTouchForwardedAfterPrimaryHadNoConsumer) { 1466 TEST_F(LegacyTouchEventQueueTest,
1467 SecondaryTouchForwardedAfterPrimaryHadNoConsumer) {
1474 // Queue a TouchStart. 1468 // Queue a TouchStart.
1475 PressTouchPoint(0, 0); 1469 PressTouchPoint(0, 0);
1476 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); 1470 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
1477 ASSERT_EQ(1U, GetAndResetSentEventCount()); 1471 ASSERT_EQ(1U, GetAndResetSentEventCount());
1478 ASSERT_EQ(1U, GetAndResetAckedEventCount()); 1472 ASSERT_EQ(1U, GetAndResetAckedEventCount());
1479 1473
1480 // Events should not be forwarded, as the point had no consumer. 1474 // Events should not be forwarded, as the point had no consumer.
1481 MoveTouchPoint(0, 0, 15); 1475 MoveTouchPoint(0, 0, 15);
1482 EXPECT_EQ(0U, queued_event_count()); 1476 EXPECT_EQ(0U, queued_event_count());
1483 EXPECT_EQ(0U, GetAndResetSentEventCount()); 1477 EXPECT_EQ(0U, GetAndResetSentEventCount());
1484 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1478 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1485 1479
1486 // Simulate a secondary pointer press. 1480 // Simulate a secondary pointer press.
1487 PressTouchPoint(20, 0); 1481 PressTouchPoint(20, 0);
1488 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1482 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1489 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1483 EXPECT_EQ(1U, GetAndResetSentEventCount());
1490 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1484 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1491 1485
1492 // TouchMove with a secondary pointer should not be suppressed. 1486 // TouchMove with a secondary pointer should not be suppressed.
1493 MoveTouchPoint(1, 25, 0); 1487 MoveTouchPoint(1, 25, 0);
1494 EXPECT_EQ(1U, queued_event_count()); 1488 EXPECT_EQ(1U, queued_event_count());
1495 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1489 EXPECT_EQ(1U, GetAndResetSentEventCount());
1496 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1490 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1497 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1491 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1498 } 1492 }
1499 1493
1500 // Tests that secondary touch points can be forwarded after scrolling begins 1494 // Tests that secondary touch points can be forwarded after scrolling begins
1501 // while first touch point has no consumer. 1495 // while first touch point has no consumer.
1502 TEST_F(TouchEventQueueTest, NoForwardingAfterScrollWithNoTouchConsumers) { 1496 TEST_F(LegacyTouchEventQueueTest, NoForwardingAfterScrollWithNoTouchConsumers) {
1503 // Queue a TouchStart. 1497 // Queue a TouchStart.
1504 PressTouchPoint(0, 0); 1498 PressTouchPoint(0, 0);
1505 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); 1499 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
1506 ASSERT_EQ(1U, GetAndResetSentEventCount()); 1500 ASSERT_EQ(1U, GetAndResetSentEventCount());
1507 ASSERT_EQ(1U, GetAndResetAckedEventCount()); 1501 ASSERT_EQ(1U, GetAndResetAckedEventCount());
1508 1502
1509 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin, 1503 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin,
1510 WebInputEvent::NoModifiers, 1504 WebInputEvent::NoModifiers,
1511 WebInputEvent::TimeStampForTesting); 1505 WebInputEvent::TimeStampForTesting);
1512 SetFollowupEvent(followup_scroll); 1506 SetFollowupEvent(followup_scroll);
1513 MoveTouchPoint(0, 20, 5); 1507 MoveTouchPoint(0, 20, 5);
1514 EXPECT_EQ(0U, GetAndResetSentEventCount()); 1508 EXPECT_EQ(0U, GetAndResetSentEventCount());
1515 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1509 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1516 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); 1510 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state());
1517 1511
1518 // The secondary pointer press should be forwarded. 1512 // The secondary pointer press should be forwarded.
1519 PressTouchPoint(20, 0); 1513 PressTouchPoint(20, 0);
1520 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 1514 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
1521 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1515 EXPECT_EQ(1U, GetAndResetSentEventCount());
1522 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1516 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1523 1517
1524 // TouchMove with a secondary pointer should also be forwarded. 1518 // TouchMove with a secondary pointer should also be forwarded.
1525 MoveTouchPoint(1, 25, 0); 1519 MoveTouchPoint(1, 25, 0);
1526 EXPECT_EQ(1U, queued_event_count()); 1520 EXPECT_EQ(1U, queued_event_count());
1527 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1521 EXPECT_EQ(1U, GetAndResetSentEventCount());
1528 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 1522 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
1529 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1523 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1530 } 1524 }
1531 1525
1532 TEST_F(TouchEventQueueTest, AsyncTouch) { 1526 TEST_F(LegacyTouchEventQueueTest, AsyncTouch) {
1533 // Queue a TouchStart. 1527 // Queue a TouchStart.
1534 PressTouchPoint(0, 1); 1528 PressTouchPoint(0, 1);
1535 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1529 EXPECT_EQ(1U, GetAndResetSentEventCount());
1536 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1530 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1537 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1531 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1538 1532
1539 for (int i = 0; i < 3; ++i) { 1533 for (int i = 0; i < 3; ++i) {
1540 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, 1534 SendGestureEventAck(WebInputEvent::GestureScrollUpdate,
1541 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1535 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1542 1536
1543 MoveTouchPoint(0, 10, 5+i); 1537 MoveTouchPoint(0, 10, 5 + i);
1544 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1538 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1545 EXPECT_FALSE(HasPendingAsyncTouchMove()); 1539 EXPECT_FALSE(HasPendingAsyncTouchMove());
1546 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType); 1540 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType);
1547 EXPECT_EQ(0U, queued_event_count()); 1541 EXPECT_EQ(0U, queued_event_count());
1548 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1542 EXPECT_EQ(1U, GetAndResetSentEventCount());
1549 1543
1550 // Consuming a scroll event will throttle subsequent touchmoves. 1544 // Consuming a scroll event will throttle subsequent touchmoves.
1551 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, 1545 SendGestureEventAck(WebInputEvent::GestureScrollUpdate,
1552 INPUT_EVENT_ACK_STATE_CONSUMED); 1546 INPUT_EVENT_ACK_STATE_CONSUMED);
1553 MoveTouchPoint(0, 10, 7+i); 1547 MoveTouchPoint(0, 10, 7 + i);
1554 EXPECT_TRUE(HasPendingAsyncTouchMove()); 1548 EXPECT_TRUE(HasPendingAsyncTouchMove());
1555 EXPECT_EQ(0U, queued_event_count()); 1549 EXPECT_EQ(0U, queued_event_count());
1556 EXPECT_EQ(0U, GetAndResetSentEventCount()); 1550 EXPECT_EQ(0U, GetAndResetSentEventCount());
1557 } 1551 }
1558 } 1552 }
1559 1553
1560 // Ensure that touchmove's are appropriately throttled during a typical 1554 // Ensure that touchmove's are appropriately throttled during a typical
1561 // scroll sequences that transitions between scrolls consumed and unconsumed. 1555 // scroll sequences that transitions between scrolls consumed and unconsumed.
1562 TEST_F(TouchEventQueueTest, AsyncTouchThrottledAfterScroll) { 1556 TEST_F(LegacyTouchEventQueueTest, AsyncTouchThrottledAfterScroll) {
1563 // Process a TouchStart 1557 // Process a TouchStart
1564 PressTouchPoint(0, 1); 1558 PressTouchPoint(0, 1);
1565 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1559 EXPECT_EQ(1U, GetAndResetSentEventCount());
1566 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1560 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1567 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1561 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1568 1562
1569 // Now send the first touch move and associated GestureScrollBegin. 1563 // Now send the first touch move and associated GestureScrollBegin.
1570 MoveTouchPoint(0, 0, 5); 1564 MoveTouchPoint(0, 0, 5);
1571 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin, 1565 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin,
1572 WebInputEvent::NoModifiers, 1566 WebInputEvent::NoModifiers,
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 EXPECT_EQ(1U, queued_event_count()); 1733 EXPECT_EQ(1U, queued_event_count());
1740 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1734 EXPECT_EQ(1U, GetAndResetSentEventCount());
1741 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1735 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1742 1736
1743 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1737 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1744 EXPECT_EQ(0U, queued_event_count()); 1738 EXPECT_EQ(0U, queued_event_count());
1745 EXPECT_EQ(0U, GetAndResetSentEventCount()); 1739 EXPECT_EQ(0U, GetAndResetSentEventCount());
1746 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1740 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1747 } 1741 }
1748 1742
1749 TEST_F(TouchEventQueueTest, AsyncTouchFlushedByTouchEnd) { 1743 TEST_F(LegacyTouchEventQueueTest, AsyncTouchFlushedByTouchEnd) {
1750 PressTouchPoint(0, 0); 1744 PressTouchPoint(0, 0);
1751 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1745 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1752 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1746 EXPECT_EQ(1U, GetAndResetSentEventCount());
1753 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1747 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1754 1748
1755 // Initiate async touchmove dispatch after the start of a scroll sequence. 1749 // Initiate async touchmove dispatch after the start of a scroll sequence.
1756 MoveTouchPoint(0, 0, 5); 1750 MoveTouchPoint(0, 0, 5);
1757 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin, 1751 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin,
1758 WebInputEvent::NoModifiers, 1752 WebInputEvent::NoModifiers,
1759 WebInputEvent::TimeStampForTesting); 1753 WebInputEvent::TimeStampForTesting);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 EXPECT_EQ(0, all_sent_events()[0].touches[0].position.x); 1789 EXPECT_EQ(0, all_sent_events()[0].touches[0].position.x);
1796 EXPECT_EQ(0, all_sent_events()[0].touches[0].position.y); 1790 EXPECT_EQ(0, all_sent_events()[0].touches[0].position.y);
1797 EXPECT_EQ(WebInputEvent::TouchEnd, all_sent_events()[1].type()); 1791 EXPECT_EQ(WebInputEvent::TouchEnd, all_sent_events()[1].type());
1798 EXPECT_NE(WebInputEvent::Blocking, all_sent_events()[1].dispatchType); 1792 EXPECT_NE(WebInputEvent::Blocking, all_sent_events()[1].dispatchType);
1799 EXPECT_EQ(2U, GetAndResetSentEventCount()); 1793 EXPECT_EQ(2U, GetAndResetSentEventCount());
1800 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 1794 EXPECT_EQ(0U, GetAndResetAckedEventCount());
1801 } 1795 }
1802 1796
1803 // Ensure that async touch dispatch and touch ack timeout interactions work 1797 // Ensure that async touch dispatch and touch ack timeout interactions work
1804 // appropriately. 1798 // appropriately.
1805 TEST_F(TouchEventQueueTest, AsyncTouchWithAckTimeout) { 1799 TEST_F(LegacyTouchEventQueueTest, AsyncTouchWithAckTimeout) {
1806 SetUpForTimeoutTesting(); 1800 SetUpForTimeoutTesting();
1807 1801
1808 // The touchstart should start the timeout. 1802 // The touchstart should start the timeout.
1809 PressTouchPoint(0, 0); 1803 PressTouchPoint(0, 0);
1810 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1804 EXPECT_EQ(1U, GetAndResetSentEventCount());
1811 EXPECT_TRUE(IsTimeoutRunning()); 1805 EXPECT_TRUE(IsTimeoutRunning());
1812 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1806 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1813 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1807 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1814 EXPECT_FALSE(IsTimeoutRunning()); 1808 EXPECT_FALSE(IsTimeoutRunning());
1815 1809
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, 1871 SendGestureEventAck(WebInputEvent::GestureScrollUpdate,
1878 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1872 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1879 MoveTouchPoint(0, 25, 5); 1873 MoveTouchPoint(0, 25, 5);
1880 EXPECT_FALSE(HasPendingAsyncTouchMove()); 1874 EXPECT_FALSE(HasPendingAsyncTouchMove());
1881 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1875 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1882 EXPECT_EQ(0U, GetAndResetSentEventCount()); 1876 EXPECT_EQ(0U, GetAndResetSentEventCount());
1883 } 1877 }
1884 1878
1885 // Ensure that if the touch ack for an async touchmove triggers a follow-up 1879 // Ensure that if the touch ack for an async touchmove triggers a follow-up
1886 // touch event, that follow-up touch will be forwarded appropriately. 1880 // touch event, that follow-up touch will be forwarded appropriately.
1887 TEST_F(TouchEventQueueTest, AsyncTouchWithTouchCancelAfterAck) { 1881 TEST_F(LegacyTouchEventQueueTest, AsyncTouchWithTouchCancelAfterAck) {
1888 PressTouchPoint(0, 0); 1882 PressTouchPoint(0, 0);
1889 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1883 EXPECT_EQ(1U, GetAndResetSentEventCount());
1890 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1884 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1891 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1885 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1892 1886
1893 // The start of a scroll gesture should trigger async touch event dispatch. 1887 // The start of a scroll gesture should trigger async touch event dispatch.
1894 MoveTouchPoint(0, 1, 1); 1888 MoveTouchPoint(0, 1, 1);
1895 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1889 EXPECT_EQ(1U, GetAndResetSentEventCount());
1896 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin, 1890 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin,
1897 WebInputEvent::NoModifiers, 1891 WebInputEvent::NoModifiers,
(...skipping 30 matching lines...) Expand all
1928 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1922 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1929 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1923 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1930 EXPECT_EQ(0U, queued_event_count()); 1924 EXPECT_EQ(0U, queued_event_count());
1931 EXPECT_EQ(WebInputEvent::TouchCancel, acked_event().type()); 1925 EXPECT_EQ(WebInputEvent::TouchCancel, acked_event().type());
1932 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1926 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1933 EXPECT_EQ(0U, GetAndResetSentEventCount()); 1927 EXPECT_EQ(0U, GetAndResetSentEventCount());
1934 } 1928 }
1935 1929
1936 // Ensure that the async touch is fully reset if the touch sequence restarts 1930 // Ensure that the async touch is fully reset if the touch sequence restarts
1937 // without properly terminating. 1931 // without properly terminating.
1938 TEST_F(TouchEventQueueTest, AsyncTouchWithHardTouchStartReset) { 1932 TEST_F(LegacyTouchEventQueueTest, AsyncTouchWithHardTouchStartReset) {
1939 PressTouchPoint(0, 0); 1933 PressTouchPoint(0, 0);
1940 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1934 EXPECT_EQ(1U, GetAndResetSentEventCount());
1941 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1935 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1942 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1936 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1943 1937
1944 // Trigger async touchmove dispatch. 1938 // Trigger async touchmove dispatch.
1945 MoveTouchPoint(0, 1, 1); 1939 MoveTouchPoint(0, 1, 1);
1946 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1940 EXPECT_EQ(1U, GetAndResetSentEventCount());
1947 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin, 1941 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin,
1948 WebInputEvent::NoModifiers, 1942 WebInputEvent::NoModifiers,
(...skipping 20 matching lines...) Expand all
1969 PressTouchPoint(0, 0); 1963 PressTouchPoint(0, 0);
1970 EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type()); 1964 EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type());
1971 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1965 EXPECT_EQ(1U, GetAndResetSentEventCount());
1972 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1966 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1973 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1967 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1974 } 1968 }
1975 1969
1976 // Ensure that even when the interval expires, we still need to wait for the 1970 // Ensure that even when the interval expires, we still need to wait for the
1977 // ack sent back from render to send the next async touchmove once the scroll 1971 // ack sent back from render to send the next async touchmove once the scroll
1978 // starts. 1972 // starts.
1979 TEST_F(TouchEventQueueTest, SendNextThrottledAsyncTouchMoveAfterAck) { 1973 TEST_F(LegacyTouchEventQueueTest, SendNextThrottledAsyncTouchMoveAfterAck) {
1980 // Process a TouchStart 1974 // Process a TouchStart
1981 PressTouchPoint(0, 1); 1975 PressTouchPoint(0, 1);
1982 EXPECT_EQ(1U, GetAndResetSentEventCount()); 1976 EXPECT_EQ(1U, GetAndResetSentEventCount());
1983 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1977 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1984 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 1978 EXPECT_EQ(1U, GetAndResetAckedEventCount());
1985 1979
1986 // Initiate async touchmove dispatch after the start of a scroll sequence. 1980 // Initiate async touchmove dispatch after the start of a scroll sequence.
1987 MoveTouchPoint(0, 0, 5); 1981 MoveTouchPoint(0, 0, 5);
1988 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin, 1982 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin,
1989 WebInputEvent::NoModifiers, 1983 WebInputEvent::NoModifiers,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2031 EXPECT_FALSE(HasPendingAsyncTouchMove()); 2025 EXPECT_FALSE(HasPendingAsyncTouchMove());
2032 EXPECT_EQ(0U, queued_event_count()); 2026 EXPECT_EQ(0U, queued_event_count());
2033 EXPECT_EQ(1U, GetAndResetSentEventCount()); 2027 EXPECT_EQ(1U, GetAndResetSentEventCount());
2034 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 2028 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2035 EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count()); 2029 EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count());
2036 } 2030 }
2037 2031
2038 // Ensure that even when we receive the ack from render, we still need to wait 2032 // Ensure that even when we receive the ack from render, we still need to wait
2039 // for the interval expires to send the next async touchmove once the scroll 2033 // for the interval expires to send the next async touchmove once the scroll
2040 // starts. 2034 // starts.
2041 TEST_F(TouchEventQueueTest, SendNextAsyncTouchMoveAfterAckAndTimeExpire) { 2035 TEST_F(LegacyTouchEventQueueTest, SendNextAsyncTouchMoveAfterAckAndTimeExpire) {
2042 // Process a TouchStart 2036 // Process a TouchStart
2043 PressTouchPoint(0, 1); 2037 PressTouchPoint(0, 1);
2044 EXPECT_EQ(1U, GetAndResetSentEventCount()); 2038 EXPECT_EQ(1U, GetAndResetSentEventCount());
2045 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2039 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2046 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 2040 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2047 2041
2048 // Initiate async touchmove dispatch after the start of a scroll sequence. 2042 // Initiate async touchmove dispatch after the start of a scroll sequence.
2049 MoveTouchPoint(0, 0, 5); 2043 MoveTouchPoint(0, 0, 5);
2050 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin, 2044 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin,
2051 WebInputEvent::NoModifiers, 2045 WebInputEvent::NoModifiers,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2090 MoveTouchPoint(0, 0, 50); 2084 MoveTouchPoint(0, 0, 50);
2091 EXPECT_FALSE(HasPendingAsyncTouchMove()); 2085 EXPECT_FALSE(HasPendingAsyncTouchMove());
2092 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type()); 2086 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type());
2093 EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType); 2087 EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType);
2094 EXPECT_EQ(0U, queued_event_count()); 2088 EXPECT_EQ(0U, queued_event_count());
2095 EXPECT_EQ(1U, GetAndResetSentEventCount()); 2089 EXPECT_EQ(1U, GetAndResetSentEventCount());
2096 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 2090 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2097 EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count()); 2091 EXPECT_EQ(1U, uncancelable_touch_moves_pending_ack_count());
2098 } 2092 }
2099 2093
2100 TEST_F(TouchEventQueueTest, AsyncTouchFlushedByNonTouchMove) { 2094 TEST_F(LegacyTouchEventQueueTest, AsyncTouchFlushedByNonTouchMove) {
2101 // Process a TouchStart 2095 // Process a TouchStart
2102 PressTouchPoint(0, 1); 2096 PressTouchPoint(0, 1);
2103 EXPECT_EQ(1U, GetAndResetSentEventCount()); 2097 EXPECT_EQ(1U, GetAndResetSentEventCount());
2104 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2098 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2105 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 2099 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2106 2100
2107 // Initiate async touchmove dispatch after the start of a scroll sequence. 2101 // Initiate async touchmove dispatch after the start of a scroll sequence.
2108 MoveTouchPoint(0, 0, 5); 2102 MoveTouchPoint(0, 0, 5);
2109 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin, 2103 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin,
2110 WebInputEvent::NoModifiers, 2104 WebInputEvent::NoModifiers,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
2205 EXPECT_EQ(0U, queued_event_count()); 2199 EXPECT_EQ(0U, queued_event_count());
2206 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type()); 2200 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type());
2207 EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType); 2201 EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType);
2208 EXPECT_EQ(1U, GetAndResetSentEventCount()); 2202 EXPECT_EQ(1U, GetAndResetSentEventCount());
2209 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 2203 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2210 } 2204 }
2211 2205
2212 // Ensure that even when we receive the ack from render, we still need to wait 2206 // Ensure that even when we receive the ack from render, we still need to wait
2213 // for the interval expires to send the next async touchmove once the scroll 2207 // for the interval expires to send the next async touchmove once the scroll
2214 // starts. 2208 // starts.
2215 TEST_F(TouchEventQueueTest, DoNotIncreaseIfClientConsumeAsyncTouchMove) { 2209 TEST_F(LegacyTouchEventQueueTest, DoNotIncreaseIfClientConsumeAsyncTouchMove) {
2216 // Process a TouchStart 2210 // Process a TouchStart
2217 PressTouchPoint(0, 1); 2211 PressTouchPoint(0, 1);
2218 EXPECT_EQ(1U, GetAndResetSentEventCount()); 2212 EXPECT_EQ(1U, GetAndResetSentEventCount());
2219 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2213 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2220 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 2214 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2221 2215
2222 // Initiate async touchmove dispatch after the start of a scroll sequence. 2216 // Initiate async touchmove dispatch after the start of a scroll sequence.
2223 MoveTouchPoint(0, 0, 5); 2217 MoveTouchPoint(0, 0, 5);
2224 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin, 2218 WebGestureEvent followup_scroll(WebInputEvent::GestureScrollBegin,
2225 WebInputEvent::NoModifiers, 2219 WebInputEvent::NoModifiers,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2267 MoveTouchPoint(0, 0, 50); 2261 MoveTouchPoint(0, 0, 50);
2268 EXPECT_FALSE(HasPendingAsyncTouchMove()); 2262 EXPECT_FALSE(HasPendingAsyncTouchMove());
2269 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type()); 2263 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type());
2270 EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType); 2264 EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType);
2271 EXPECT_EQ(0U, queued_event_count()); 2265 EXPECT_EQ(0U, queued_event_count());
2272 EXPECT_EQ(1U, GetAndResetSentEventCount()); 2266 EXPECT_EQ(1U, GetAndResetSentEventCount());
2273 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 2267 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2274 EXPECT_EQ(0U, uncancelable_touch_moves_pending_ack_count()); 2268 EXPECT_EQ(0U, uncancelable_touch_moves_pending_ack_count());
2275 } 2269 }
2276 2270
2277 TEST_F(TouchEventQueueTest, TouchAbsorptionWithConsumedFirstMove) { 2271 TEST_F(LegacyTouchEventQueueTest, TouchAbsorptionWithConsumedFirstMove) {
2278 // Queue a TouchStart. 2272 // Queue a TouchStart.
2279 PressTouchPoint(0, 1); 2273 PressTouchPoint(0, 1);
2280 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2274 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2281 EXPECT_EQ(0U, queued_event_count()); 2275 EXPECT_EQ(0U, queued_event_count());
2282 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 2276 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2283 2277
2284 MoveTouchPoint(0, 20, 5); 2278 MoveTouchPoint(0, 20, 5);
2285 SendGestureEvent(blink::WebInputEvent::GestureScrollBegin); 2279 SendGestureEvent(blink::WebInputEvent::GestureScrollBegin);
2286 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 2280 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2287 EXPECT_EQ(0U, queued_event_count()); 2281 EXPECT_EQ(0U, queued_event_count());
(...skipping 18 matching lines...) Expand all
2306 EXPECT_EQ(0U, queued_event_count()); 2300 EXPECT_EQ(0U, queued_event_count());
2307 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType); 2301 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType);
2308 EXPECT_EQ(1U, GetAndResetSentEventCount()); 2302 EXPECT_EQ(1U, GetAndResetSentEventCount());
2309 2303
2310 // Touch move event is throttled. 2304 // Touch move event is throttled.
2311 MoveTouchPoint(0, 60, 5); 2305 MoveTouchPoint(0, 60, 5);
2312 EXPECT_EQ(0U, queued_event_count()); 2306 EXPECT_EQ(0U, queued_event_count());
2313 EXPECT_EQ(0U, GetAndResetSentEventCount()); 2307 EXPECT_EQ(0U, GetAndResetSentEventCount());
2314 } 2308 }
2315 2309
2316 TEST_F(TouchEventQueueTest, TouchStartCancelableDuringScroll) { 2310 TEST_F(LegacyTouchEventQueueTest, TouchStartCancelableDuringScroll) {
2317 // Queue a touchstart and touchmove that go unconsumed, transitioning to an 2311 // Queue a touchstart and touchmove that go unconsumed, transitioning to an
2318 // active scroll sequence. 2312 // active scroll sequence.
2319 PressTouchPoint(0, 1); 2313 PressTouchPoint(0, 1);
2320 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2314 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2321 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType); 2315 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType);
2322 ASSERT_EQ(1U, GetAndResetSentEventCount()); 2316 ASSERT_EQ(1U, GetAndResetSentEventCount());
2323 2317
2324 MoveTouchPoint(0, 20, 5); 2318 MoveTouchPoint(0, 20, 5);
2325 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType); 2319 EXPECT_EQ(WebInputEvent::Blocking, sent_event().dispatchType);
2326 SendGestureEvent(blink::WebInputEvent::GestureScrollBegin); 2320 SendGestureEvent(blink::WebInputEvent::GestureScrollBegin);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2365 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2359 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2366 EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType); 2360 EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType);
2367 ASSERT_EQ(1U, GetAndResetSentEventCount()); 2361 ASSERT_EQ(1U, GetAndResetSentEventCount());
2368 2362
2369 // The touchend will be uncancelable during an active scroll sequence. 2363 // The touchend will be uncancelable during an active scroll sequence.
2370 ReleaseTouchPoint(0); 2364 ReleaseTouchPoint(0);
2371 EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType); 2365 EXPECT_NE(WebInputEvent::Blocking, sent_event().dispatchType);
2372 ASSERT_EQ(1U, GetAndResetSentEventCount()); 2366 ASSERT_EQ(1U, GetAndResetSentEventCount());
2373 } 2367 }
2374 2368
2375 TEST_F(TouchEventQueueTest, UnseenTouchPointerIdsNotForwarded) { 2369 TEST_F(LegacyTouchEventQueueTest, UnseenTouchPointerIdsNotForwarded) {
2376 SyntheticWebTouchEvent event; 2370 SyntheticWebTouchEvent event;
2377 event.PressPoint(0, 0); 2371 event.PressPoint(0, 0);
2378 SendTouchEvent(event); 2372 SendTouchEvent(event);
2379 EXPECT_EQ(1U, GetAndResetSentEventCount()); 2373 EXPECT_EQ(1U, GetAndResetSentEventCount());
2380 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 2374 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2381 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 2375 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2382 2376
2383 // Give the touchmove a previously unseen pointer id; it should not be sent. 2377 // Give the touchmove a previously unseen pointer id; it should not be sent.
2384 int press_id = event.touches[0].id; 2378 int press_id = event.touches[0].id;
2385 event.MovePoint(0, 1, 1); 2379 event.MovePoint(0, 1, 1);
(...skipping 18 matching lines...) Expand all
2404 2398
2405 // Give the touchmove a valid id; it should be sent. 2399 // Give the touchmove a valid id; it should be sent.
2406 event.touches[0].id = press_id; 2400 event.touches[0].id = press_id;
2407 SendTouchEvent(event); 2401 SendTouchEvent(event);
2408 EXPECT_EQ(1U, GetAndResetSentEventCount()); 2402 EXPECT_EQ(1U, GetAndResetSentEventCount());
2409 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 2403 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2410 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 2404 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2411 } 2405 }
2412 2406
2413 // Tests that touch points states are correct in TouchMove events. 2407 // Tests that touch points states are correct in TouchMove events.
2414 TEST_F(TouchEventQueueTest, PointerStatesInTouchMove) { 2408 TEST_F(LegacyTouchEventQueueTest, PointerStatesInTouchMove) {
2415 PressTouchPoint(1, 1); 2409 PressTouchPoint(1, 1);
2416 PressTouchPoint(2, 2); 2410 PressTouchPoint(2, 2);
2417 PressTouchPoint(3, 3); 2411 PressTouchPoint(3, 3);
2418 PressTouchPoint(4, 4); 2412 PressTouchPoint(4, 4);
2419 EXPECT_EQ(4U, queued_event_count()); 2413 EXPECT_EQ(4U, queued_event_count());
2420 EXPECT_EQ(1U, GetAndResetSentEventCount()); 2414 EXPECT_EQ(1U, GetAndResetSentEventCount());
2421 2415
2422 // Receive ACK for the first three touch-events. 2416 // Receive ACK for the first three touch-events.
2423 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 2417 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2424 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 2418 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2461 const WebTouchEvent& event3 = sent_event(); 2455 const WebTouchEvent& event3 = sent_event();
2462 EXPECT_EQ(WebInputEvent::TouchMove, event3.type()); 2456 EXPECT_EQ(WebInputEvent::TouchMove, event3.type());
2463 EXPECT_EQ(WebTouchPoint::StateStationary, event3.touches[0].state); 2457 EXPECT_EQ(WebTouchPoint::StateStationary, event3.touches[0].state);
2464 EXPECT_EQ(WebTouchPoint::StateStationary, event3.touches[1].state); 2458 EXPECT_EQ(WebTouchPoint::StateStationary, event3.touches[1].state);
2465 EXPECT_EQ(WebTouchPoint::StateStationary, event3.touches[2].state); 2459 EXPECT_EQ(WebTouchPoint::StateStationary, event3.touches[2].state);
2466 EXPECT_EQ(WebTouchPoint::StateMoved, event3.touches[3].state); 2460 EXPECT_EQ(WebTouchPoint::StateMoved, event3.touches[3].state);
2467 } 2461 }
2468 2462
2469 // Tests that touch point state is correct in TouchMove events 2463 // Tests that touch point state is correct in TouchMove events
2470 // when point properties other than position changed. 2464 // when point properties other than position changed.
2471 TEST_F(TouchEventQueueTest, PointerStatesWhenOtherThanPositionChanged) { 2465 TEST_F(LegacyTouchEventQueueTest, PointerStatesWhenOtherThanPositionChanged) {
2472 PressTouchPoint(1, 1); 2466 PressTouchPoint(1, 1);
2473 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 2467 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2474 2468
2475 // Default initial radiusX/Y is (1.f, 1.f). 2469 // Default initial radiusX/Y is (1.f, 1.f).
2476 // Default initial rotationAngle is 1.f. 2470 // Default initial rotationAngle is 1.f.
2477 // Default initial force is 1.f. 2471 // Default initial force is 1.f.
2478 2472
2479 // Change touch point radius only. 2473 // Change touch point radius only.
2480 ChangeTouchPointRadius(0, 1.5f, 1.f); 2474 ChangeTouchPointRadius(0, 1.5f, 1.f);
2481 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 2475 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
(...skipping 20 matching lines...) Expand all
2502 const WebTouchEvent& event3 = sent_event(); 2496 const WebTouchEvent& event3 = sent_event();
2503 EXPECT_EQ(WebInputEvent::TouchMove, event3.type()); 2497 EXPECT_EQ(WebInputEvent::TouchMove, event3.type());
2504 EXPECT_EQ(WebTouchPoint::StateMoved, event3.touches[0].state); 2498 EXPECT_EQ(WebTouchPoint::StateMoved, event3.touches[0].state);
2505 2499
2506 EXPECT_EQ(0U, queued_event_count()); 2500 EXPECT_EQ(0U, queued_event_count());
2507 EXPECT_EQ(4U, GetAndResetSentEventCount()); 2501 EXPECT_EQ(4U, GetAndResetSentEventCount());
2508 EXPECT_EQ(4U, GetAndResetAckedEventCount()); 2502 EXPECT_EQ(4U, GetAndResetAckedEventCount());
2509 } 2503 }
2510 2504
2511 // Tests that TouchMoves are filtered when none of the points are changed. 2505 // Tests that TouchMoves are filtered when none of the points are changed.
2512 TEST_F(TouchEventQueueTest, FilterTouchMovesWhenNoPointerChanged) { 2506 TEST_F(LegacyTouchEventQueueTest, FilterTouchMovesWhenNoPointerChanged) {
2513 PressTouchPoint(1, 1); 2507 PressTouchPoint(1, 1);
2514 PressTouchPoint(2, 2); 2508 PressTouchPoint(2, 2);
2515 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 2509 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2516 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 2510 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2517 EXPECT_EQ(0U, queued_event_count()); 2511 EXPECT_EQ(0U, queued_event_count());
2518 EXPECT_EQ(2U, GetAndResetSentEventCount()); 2512 EXPECT_EQ(2U, GetAndResetSentEventCount());
2519 EXPECT_EQ(2U, GetAndResetAckedEventCount()); 2513 EXPECT_EQ(2U, GetAndResetAckedEventCount());
2520 2514
2521 // Move 1st touch point. 2515 // Move 1st touch point.
2522 MoveTouchPoint(0, 10, 10); 2516 MoveTouchPoint(0, 10, 10);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2555 // TouchMove should be allowed and test for touches state. 2549 // TouchMove should be allowed and test for touches state.
2556 const WebTouchEvent& event2 = sent_event(); 2550 const WebTouchEvent& event2 = sent_event();
2557 EXPECT_EQ(WebInputEvent::TouchMove, event2.type()); 2551 EXPECT_EQ(WebInputEvent::TouchMove, event2.type());
2558 EXPECT_EQ(WebTouchPoint::StateStationary, event2.touches[0].state); 2552 EXPECT_EQ(WebTouchPoint::StateStationary, event2.touches[0].state);
2559 EXPECT_EQ(WebTouchPoint::StateMoved, event2.touches[1].state); 2553 EXPECT_EQ(WebTouchPoint::StateMoved, event2.touches[1].state);
2560 EXPECT_EQ(1U, GetAndResetSentEventCount()); 2554 EXPECT_EQ(1U, GetAndResetSentEventCount());
2561 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 2555 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2562 } 2556 }
2563 2557
2564 // Tests that touch-scroll-notification is not pushed into an empty queue. 2558 // Tests that touch-scroll-notification is not pushed into an empty queue.
2565 TEST_F(TouchEventQueueTest, TouchScrollNotificationOrder_EmptyQueue) { 2559 TEST_F(LegacyTouchEventQueueTest, TouchScrollNotificationOrder_EmptyQueue) {
2566 PrependTouchScrollNotification(); 2560 PrependTouchScrollNotification();
2567 2561
2568 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 2562 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2569 EXPECT_EQ(0U, queued_event_count()); 2563 EXPECT_EQ(0U, queued_event_count());
2570 EXPECT_EQ(0U, GetAndResetSentEventCount()); 2564 EXPECT_EQ(0U, GetAndResetSentEventCount());
2571 } 2565 }
2572 2566
2573 // Tests touch-scroll-notification firing order when the event is placed at the 2567 // Tests touch-scroll-notification firing order when the event is placed at the
2574 // end of touch queue because of a pending ack for the head of the queue. 2568 // end of touch queue because of a pending ack for the head of the queue.
2575 TEST_F(TouchEventQueueTest, TouchScrollNotificationOrder_EndOfQueue) { 2569 TEST_F(LegacyTouchEventQueueTest, TouchScrollNotificationOrder_EndOfQueue) {
2576 PressTouchPoint(1, 1); 2570 PressTouchPoint(1, 1);
2577 2571
2578 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 2572 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2579 EXPECT_EQ(1U, queued_event_count()); 2573 EXPECT_EQ(1U, queued_event_count());
2580 2574
2581 // Send the touch-scroll-notification when 3 events are in the queue. 2575 // Send the touch-scroll-notification when 3 events are in the queue.
2582 PrependTouchScrollNotification(); 2576 PrependTouchScrollNotification();
2583 2577
2584 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 2578 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2585 EXPECT_EQ(2U, queued_event_count()); 2579 EXPECT_EQ(2U, queued_event_count());
(...skipping 11 matching lines...) Expand all
2597 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 2591 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2598 EXPECT_EQ(0U, queued_event_count()); 2592 EXPECT_EQ(0U, queued_event_count());
2599 2593
2600 EXPECT_EQ(WebInputEvent::TouchStart, all_sent_events()[0].type()); 2594 EXPECT_EQ(WebInputEvent::TouchStart, all_sent_events()[0].type());
2601 EXPECT_EQ(WebInputEvent::TouchScrollStarted, all_sent_events()[1].type()); 2595 EXPECT_EQ(WebInputEvent::TouchScrollStarted, all_sent_events()[1].type());
2602 EXPECT_EQ(2U, GetAndResetSentEventCount()); 2596 EXPECT_EQ(2U, GetAndResetSentEventCount());
2603 } 2597 }
2604 2598
2605 // Tests touch-scroll-notification firing order when the event is placed in the 2599 // Tests touch-scroll-notification firing order when the event is placed in the
2606 // 2nd position in the touch queue between two events. 2600 // 2nd position in the touch queue between two events.
2607 TEST_F(TouchEventQueueTest, TouchScrollNotificationOrder_SecondPosition) { 2601 TEST_F(LegacyTouchEventQueueTest, TouchScrollNotificationOrder_SecondPosition) {
2608 PressTouchPoint(1, 1); 2602 PressTouchPoint(1, 1);
2609 MoveTouchPoint(0, 5, 5); 2603 MoveTouchPoint(0, 5, 5);
2610 ReleaseTouchPoint(0); 2604 ReleaseTouchPoint(0);
2611 2605
2612 EXPECT_EQ(0U, GetAndResetAckedEventCount()); 2606 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2613 EXPECT_EQ(3U, queued_event_count()); 2607 EXPECT_EQ(3U, queued_event_count());
2614 2608
2615 // Send the touch-scroll-notification when 3 events are in the queue. 2609 // Send the touch-scroll-notification when 3 events are in the queue.
2616 PrependTouchScrollNotification(); 2610 PrependTouchScrollNotification();
2617 2611
(...skipping 29 matching lines...) Expand all
2647 2641
2648 EXPECT_EQ(WebInputEvent::TouchStart, all_sent_events()[0].type()); 2642 EXPECT_EQ(WebInputEvent::TouchStart, all_sent_events()[0].type());
2649 EXPECT_EQ(WebInputEvent::TouchScrollStarted, all_sent_events()[1].type()); 2643 EXPECT_EQ(WebInputEvent::TouchScrollStarted, all_sent_events()[1].type());
2650 EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[2].type()); 2644 EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[2].type());
2651 EXPECT_EQ(WebInputEvent::TouchEnd, all_sent_events()[3].type()); 2645 EXPECT_EQ(WebInputEvent::TouchEnd, all_sent_events()[3].type());
2652 EXPECT_EQ(4U, GetAndResetSentEventCount()); 2646 EXPECT_EQ(4U, GetAndResetSentEventCount());
2653 } 2647 }
2654 2648
2655 // Tests that if touchStartOrFirstTouchMove is correctly set up for touch 2649 // Tests that if touchStartOrFirstTouchMove is correctly set up for touch
2656 // events. 2650 // events.
2657 TEST_F(TouchEventQueueTest, TouchStartOrFirstTouchMove) { 2651 TEST_F(LegacyTouchEventQueueTest, TouchStartOrFirstTouchMove) {
2658 PressTouchPoint(1, 1); 2652 PressTouchPoint(1, 1);
2659 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 2653 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2660 EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type()); 2654 EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type());
2661 EXPECT_TRUE(sent_event().touchStartOrFirstTouchMove); 2655 EXPECT_TRUE(sent_event().touchStartOrFirstTouchMove);
2662 2656
2663 MoveTouchPoint(0, 5, 5); 2657 MoveTouchPoint(0, 5, 5);
2664 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 2658 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2665 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type()); 2659 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type());
2666 EXPECT_TRUE(sent_event().touchStartOrFirstTouchMove); 2660 EXPECT_TRUE(sent_event().touchStartOrFirstTouchMove);
2667 2661
2668 MoveTouchPoint(0, 15, 15); 2662 MoveTouchPoint(0, 15, 15);
2669 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 2663 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2670 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type()); 2664 EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type());
2671 EXPECT_FALSE(sent_event().touchStartOrFirstTouchMove); 2665 EXPECT_FALSE(sent_event().touchStartOrFirstTouchMove);
2672 2666
2673 ReleaseTouchPoint(0); 2667 ReleaseTouchPoint(0);
2674 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); 2668 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2675 EXPECT_EQ(WebInputEvent::TouchEnd, sent_event().type()); 2669 EXPECT_EQ(WebInputEvent::TouchEnd, sent_event().type());
2676 EXPECT_FALSE(sent_event().touchStartOrFirstTouchMove); 2670 EXPECT_FALSE(sent_event().touchStartOrFirstTouchMove);
2677 } 2671 }
2678 2672
2679 } // namespace content 2673 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698