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

Side by Side Diff: ui/events/blink/input_handler_proxy_unittest.cc

Issue 2569273002: Add constructors to WebInputEvents and setters so we can work at cleaning up these public structs. (Closed)
Patch Set: Rebase Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/events/blink/input_handler_proxy.h" 5 #include "ui/events/blink/input_handler_proxy.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 MATCHER_P(WheelEventsMatch, expected, "") { 88 MATCHER_P(WheelEventsMatch, expected, "") {
89 return WheelEventsMatch(arg, expected); 89 return WheelEventsMatch(arg, expected);
90 } 90 }
91 91
92 WebGestureEvent CreateFling(base::TimeTicks timestamp, 92 WebGestureEvent CreateFling(base::TimeTicks timestamp,
93 WebGestureDevice source_device, 93 WebGestureDevice source_device,
94 WebFloatPoint velocity, 94 WebFloatPoint velocity,
95 WebPoint point, 95 WebPoint point,
96 WebPoint global_point, 96 WebPoint global_point,
97 int modifiers) { 97 int modifiers) {
98 WebGestureEvent fling; 98 WebGestureEvent fling(WebInputEvent::GestureFlingStart, modifiers,
99 fling.type = WebInputEvent::GestureFlingStart; 99 (timestamp - base::TimeTicks()).InSecondsF());
100 fling.sourceDevice = source_device; 100 fling.sourceDevice = source_device;
101 fling.timeStampSeconds = (timestamp - base::TimeTicks()).InSecondsF();
102 fling.data.flingStart.velocityX = velocity.x; 101 fling.data.flingStart.velocityX = velocity.x;
103 fling.data.flingStart.velocityY = velocity.y; 102 fling.data.flingStart.velocityY = velocity.y;
104 fling.x = point.x; 103 fling.x = point.x;
105 fling.y = point.y; 104 fling.y = point.y;
106 fling.globalX = global_point.x; 105 fling.globalX = global_point.x;
107 fling.globalY = global_point.y; 106 fling.globalY = global_point.y;
108 fling.modifiers = modifiers;
109 return fling; 107 return fling;
110 } 108 }
111 109
112 WebGestureEvent CreateFling(WebGestureDevice source_device, 110 WebGestureEvent CreateFling(WebGestureDevice source_device,
113 WebFloatPoint velocity, 111 WebFloatPoint velocity,
114 WebPoint point, 112 WebPoint point,
115 WebPoint global_point, 113 WebPoint global_point,
116 int modifiers) { 114 int modifiers) {
117 return CreateFling(base::TimeTicks(), 115 return CreateFling(base::TimeTicks(),
118 source_device, 116 source_device,
119 velocity, 117 velocity,
120 point, 118 point,
121 global_point, 119 global_point,
122 modifiers); 120 modifiers);
123 } 121 }
124 122
125 ScopedWebInputEvent CreateGestureScrollOrPinch(WebInputEvent::Type type, 123 ScopedWebInputEvent CreateGestureScrollOrPinch(WebInputEvent::Type type,
126 float deltaYOrScale = 0, 124 float deltaYOrScale = 0,
127 int x = 0, 125 int x = 0,
128 int y = 0) { 126 int y = 0) {
129 WebGestureEvent gesture; 127 WebGestureEvent gesture(type, WebInputEvent::NoModifiers,
128 WebInputEvent::TimeStampForTesting);
130 gesture.sourceDevice = blink::WebGestureDeviceTouchpad; 129 gesture.sourceDevice = blink::WebGestureDeviceTouchpad;
131 gesture.type = type;
132 if (type == WebInputEvent::GestureScrollUpdate) { 130 if (type == WebInputEvent::GestureScrollUpdate) {
133 gesture.data.scrollUpdate.deltaY = deltaYOrScale; 131 gesture.data.scrollUpdate.deltaY = deltaYOrScale;
134 } else if (type == WebInputEvent::GesturePinchUpdate) { 132 } else if (type == WebInputEvent::GesturePinchUpdate) {
135 gesture.data.pinchUpdate.scale = deltaYOrScale; 133 gesture.data.pinchUpdate.scale = deltaYOrScale;
136 gesture.x = x; 134 gesture.x = x;
137 gesture.y = y; 135 gesture.y = y;
138 } 136 }
139 return WebInputEventTraits::Clone(gesture); 137 return WebInputEventTraits::Clone(gesture);
140 } 138 }
141 139
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 415
418 void StartFling(base::TimeTicks timestamp, 416 void StartFling(base::TimeTicks timestamp,
419 WebGestureDevice source_device, 417 WebGestureDevice source_device,
420 WebFloatPoint velocity, 418 WebFloatPoint velocity,
421 WebPoint position) { 419 WebPoint position) {
422 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 420 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
423 VERIFY_AND_RESET_MOCKS(); 421 VERIFY_AND_RESET_MOCKS();
424 422
425 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 423 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
426 .WillOnce(testing::Return(kImplThreadScrollState)); 424 .WillOnce(testing::Return(kImplThreadScrollState));
427 gesture_.type = WebInputEvent::GestureScrollBegin; 425 gesture_.setType(WebInputEvent::GestureScrollBegin);
428 gesture_.sourceDevice = source_device; 426 gesture_.sourceDevice = source_device;
429 EXPECT_EQ(expected_disposition_, 427 EXPECT_EQ(expected_disposition_,
430 input_handler_->HandleInputEvent(gesture_)); 428 input_handler_->HandleInputEvent(gesture_));
431 429
432 VERIFY_AND_RESET_MOCKS(); 430 VERIFY_AND_RESET_MOCKS();
433 431
434 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 432 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
435 .WillOnce(testing::Return(kImplThreadScrollState)); 433 .WillOnce(testing::Return(kImplThreadScrollState));
436 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 434 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
437 435
438 gesture_ = 436 gesture_ =
439 CreateFling(timestamp, source_device, velocity, position, position, 0); 437 CreateFling(timestamp, source_device, velocity, position, position, 0);
440 EXPECT_EQ(expected_disposition_, 438 EXPECT_EQ(expected_disposition_,
441 input_handler_->HandleInputEvent(gesture_)); 439 input_handler_->HandleInputEvent(gesture_));
442 440
443 VERIFY_AND_RESET_MOCKS(); 441 VERIFY_AND_RESET_MOCKS();
444 } 442 }
445 443
446 void CancelFling(base::TimeTicks timestamp) { 444 void CancelFling(base::TimeTicks timestamp) {
447 gesture_.timeStampSeconds = InSecondsF(timestamp); 445 gesture_.setTimeStampSeconds(InSecondsF(timestamp));
448 gesture_.type = WebInputEvent::GestureFlingCancel; 446 gesture_.setType(WebInputEvent::GestureFlingCancel);
449 EXPECT_EQ(expected_disposition_, 447 EXPECT_EQ(expected_disposition_,
450 input_handler_->HandleInputEvent(gesture_)); 448 input_handler_->HandleInputEvent(gesture_));
451 449
452 VERIFY_AND_RESET_MOCKS(); 450 VERIFY_AND_RESET_MOCKS();
453 } 451 }
454 452
455 void SetSmoothScrollEnabled(bool value) { 453 void SetSmoothScrollEnabled(bool value) {
456 input_handler_->smooth_scroll_enabled_ = value; 454 input_handler_->smooth_scroll_enabled_ = value;
457 } 455 }
458 456
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 528
531 base::WeakPtrFactory<InputHandlerProxyEventQueueTest> weak_ptr_factory_; 529 base::WeakPtrFactory<InputHandlerProxyEventQueueTest> weak_ptr_factory_;
532 }; 530 };
533 531
534 TEST_P(InputHandlerProxyTest, MouseWheelNoListener) { 532 TEST_P(InputHandlerProxyTest, MouseWheelNoListener) {
535 expected_disposition_ = InputHandlerProxy::DROP_EVENT; 533 expected_disposition_ = InputHandlerProxy::DROP_EVENT;
536 EXPECT_CALL(mock_input_handler_, 534 EXPECT_CALL(mock_input_handler_,
537 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) 535 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
538 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); 536 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
539 537
540 WebMouseWheelEvent wheel; 538 WebMouseWheelEvent wheel(WebInputEvent::MouseWheel, WebInputEvent::ControlKey,
541 wheel.type = WebInputEvent::MouseWheel; 539 WebInputEvent::TimeStampForTesting);
542 wheel.modifiers = WebInputEvent::ControlKey;
543 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); 540 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel));
544 VERIFY_AND_RESET_MOCKS(); 541 VERIFY_AND_RESET_MOCKS();
545 } 542 }
546 543
547 TEST_P(InputHandlerProxyTest, MouseWheelPassiveListener) { 544 TEST_P(InputHandlerProxyTest, MouseWheelPassiveListener) {
548 expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING; 545 expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING;
549 EXPECT_CALL(mock_input_handler_, 546 EXPECT_CALL(mock_input_handler_,
550 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) 547 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
551 .WillOnce(testing::Return(cc::EventListenerProperties::kPassive)); 548 .WillOnce(testing::Return(cc::EventListenerProperties::kPassive));
552 549
553 WebMouseWheelEvent wheel; 550 WebMouseWheelEvent wheel(WebInputEvent::MouseWheel, WebInputEvent::ControlKey,
554 wheel.type = WebInputEvent::MouseWheel; 551 WebInputEvent::TimeStampForTesting);
555 wheel.modifiers = WebInputEvent::ControlKey;
556 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); 552 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel));
557 VERIFY_AND_RESET_MOCKS(); 553 VERIFY_AND_RESET_MOCKS();
558 } 554 }
559 555
560 TEST_P(InputHandlerProxyTest, MouseWheelBlockingListener) { 556 TEST_P(InputHandlerProxyTest, MouseWheelBlockingListener) {
561 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; 557 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
562 EXPECT_CALL(mock_input_handler_, 558 EXPECT_CALL(mock_input_handler_,
563 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) 559 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
564 .WillOnce(testing::Return(cc::EventListenerProperties::kBlocking)); 560 .WillOnce(testing::Return(cc::EventListenerProperties::kBlocking));
565 561
566 WebMouseWheelEvent wheel; 562 WebMouseWheelEvent wheel(WebInputEvent::MouseWheel, WebInputEvent::ControlKey,
567 wheel.type = WebInputEvent::MouseWheel; 563 WebInputEvent::TimeStampForTesting);
568 wheel.modifiers = WebInputEvent::ControlKey;
569 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); 564 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel));
570 VERIFY_AND_RESET_MOCKS(); 565 VERIFY_AND_RESET_MOCKS();
571 } 566 }
572 567
573 TEST_P(InputHandlerProxyTest, GestureScrollStarted) { 568 TEST_P(InputHandlerProxyTest, GestureScrollStarted) {
574 // We shouldn't send any events to the widget for this gesture. 569 // We shouldn't send any events to the widget for this gesture.
575 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 570 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
576 VERIFY_AND_RESET_MOCKS(); 571 VERIFY_AND_RESET_MOCKS();
577 572
578 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 573 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
579 .WillOnce(testing::Return(kImplThreadScrollState)); 574 .WillOnce(testing::Return(kImplThreadScrollState));
580 575
581 gesture_.type = WebInputEvent::GestureScrollBegin; 576 gesture_.setType(WebInputEvent::GestureScrollBegin);
582 EXPECT_EQ(expected_disposition_,input_handler_->HandleInputEvent(gesture_)); 577 EXPECT_EQ(expected_disposition_,input_handler_->HandleInputEvent(gesture_));
583 578
584 // The event should not be marked as handled if scrolling is not possible. 579 // The event should not be marked as handled if scrolling is not possible.
585 expected_disposition_ = InputHandlerProxy::DROP_EVENT; 580 expected_disposition_ = InputHandlerProxy::DROP_EVENT;
586 VERIFY_AND_RESET_MOCKS(); 581 VERIFY_AND_RESET_MOCKS();
587 582
588 gesture_.type = WebInputEvent::GestureScrollUpdate; 583 gesture_.setType(WebInputEvent::GestureScrollUpdate);
589 gesture_.data.scrollUpdate.deltaY = 584 gesture_.data.scrollUpdate.deltaY =
590 -40; // -Y means scroll down - i.e. in the +Y direction. 585 -40; // -Y means scroll down - i.e. in the +Y direction.
591 EXPECT_CALL( 586 EXPECT_CALL(
592 mock_input_handler_, 587 mock_input_handler_,
593 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)))) 588 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0))))
594 .WillOnce(testing::Return(scroll_result_did_not_scroll_)); 589 .WillOnce(testing::Return(scroll_result_did_not_scroll_));
595 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 590 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
596 591
597 // Mark the event as handled if scroll happens. 592 // Mark the event as handled if scroll happens.
598 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 593 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
599 VERIFY_AND_RESET_MOCKS(); 594 VERIFY_AND_RESET_MOCKS();
600 595
601 gesture_.type = WebInputEvent::GestureScrollUpdate; 596 gesture_.setType(WebInputEvent::GestureScrollUpdate);
602 gesture_.data.scrollUpdate.deltaY = 597 gesture_.data.scrollUpdate.deltaY =
603 -40; // -Y means scroll down - i.e. in the +Y direction. 598 -40; // -Y means scroll down - i.e. in the +Y direction.
604 EXPECT_CALL( 599 EXPECT_CALL(
605 mock_input_handler_, 600 mock_input_handler_,
606 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)))) 601 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0))))
607 .WillOnce(testing::Return(scroll_result_did_scroll_)); 602 .WillOnce(testing::Return(scroll_result_did_scroll_));
608 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 603 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
609 604
610 VERIFY_AND_RESET_MOCKS(); 605 VERIFY_AND_RESET_MOCKS();
611 606
612 gesture_.type = WebInputEvent::GestureScrollEnd; 607 gesture_.setType(WebInputEvent::GestureScrollEnd);
613 gesture_.data.scrollUpdate.deltaY = 0; 608 gesture_.data.scrollUpdate.deltaY = 0;
614 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 609 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
615 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 610 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
616 611
617 VERIFY_AND_RESET_MOCKS(); 612 VERIFY_AND_RESET_MOCKS();
618 } 613 }
619 614
620 TEST_P(InputHandlerProxyTest, GestureScrollOnMainThread) { 615 TEST_P(InputHandlerProxyTest, GestureScrollOnMainThread) {
621 // We should send all events to the widget for this gesture. 616 // We should send all events to the widget for this gesture.
622 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; 617 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
623 VERIFY_AND_RESET_MOCKS(); 618 VERIFY_AND_RESET_MOCKS();
624 619
625 EXPECT_CALL(mock_input_handler_, ScrollBegin(::testing::_, ::testing::_)) 620 EXPECT_CALL(mock_input_handler_, ScrollBegin(::testing::_, ::testing::_))
626 .WillOnce(testing::Return(kMainThreadScrollState)); 621 .WillOnce(testing::Return(kMainThreadScrollState));
627 622
628 gesture_.type = WebInputEvent::GestureScrollBegin; 623 gesture_.setType(WebInputEvent::GestureScrollBegin);
629 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 624 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
630 625
631 VERIFY_AND_RESET_MOCKS(); 626 VERIFY_AND_RESET_MOCKS();
632 627
633 gesture_.type = WebInputEvent::GestureScrollUpdate; 628 gesture_.setType(WebInputEvent::GestureScrollUpdate);
634 gesture_.data.scrollUpdate.deltaY = 40; 629 gesture_.data.scrollUpdate.deltaY = 40;
635 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 630 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
636 631
637 VERIFY_AND_RESET_MOCKS(); 632 VERIFY_AND_RESET_MOCKS();
638 633
639 gesture_.type = WebInputEvent::GestureScrollEnd; 634 gesture_.setType(WebInputEvent::GestureScrollEnd);
640 gesture_.data.scrollUpdate.deltaY = 0; 635 gesture_.data.scrollUpdate.deltaY = 0;
641 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)) 636 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_))
642 .WillOnce(testing::Return()); 637 .WillOnce(testing::Return());
643 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 638 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
644 639
645 VERIFY_AND_RESET_MOCKS(); 640 VERIFY_AND_RESET_MOCKS();
646 } 641 }
647 642
648 TEST_P(InputHandlerProxyTest, GestureScrollIgnored) { 643 TEST_P(InputHandlerProxyTest, GestureScrollIgnored) {
649 // We shouldn't handle the GestureScrollBegin. 644 // We shouldn't handle the GestureScrollBegin.
650 // Instead, we should get a DROP_EVENT result, indicating 645 // Instead, we should get a DROP_EVENT result, indicating
651 // that we could determine that there's nothing that could scroll or otherwise 646 // that we could determine that there's nothing that could scroll or otherwise
652 // react to this gesture sequence and thus we should drop the whole gesture 647 // react to this gesture sequence and thus we should drop the whole gesture
653 // sequence on the floor, except for the ScrollEnd. 648 // sequence on the floor, except for the ScrollEnd.
654 expected_disposition_ = InputHandlerProxy::DROP_EVENT; 649 expected_disposition_ = InputHandlerProxy::DROP_EVENT;
655 VERIFY_AND_RESET_MOCKS(); 650 VERIFY_AND_RESET_MOCKS();
656 651
657 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 652 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
658 .WillOnce(testing::Return(kScrollIgnoredScrollState)); 653 .WillOnce(testing::Return(kScrollIgnoredScrollState));
659 654
660 gesture_.type = WebInputEvent::GestureScrollBegin; 655 gesture_.setType(WebInputEvent::GestureScrollBegin);
661 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 656 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
662 657
663 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; 658 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
664 gesture_.type = WebInputEvent::GestureScrollEnd; 659 gesture_.setType(WebInputEvent::GestureScrollEnd);
665 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)) 660 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_))
666 .WillOnce(testing::Return()); 661 .WillOnce(testing::Return());
667 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 662 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
668 663
669 VERIFY_AND_RESET_MOCKS(); 664 VERIFY_AND_RESET_MOCKS();
670 } 665 }
671 666
672 TEST_P(InputHandlerProxyTest, GestureScrollByPage) { 667 TEST_P(InputHandlerProxyTest, GestureScrollByPage) {
673 // We should send all events to the widget for this gesture. 668 // We should send all events to the widget for this gesture.
674 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; 669 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
675 VERIFY_AND_RESET_MOCKS(); 670 VERIFY_AND_RESET_MOCKS();
676 671
677 gesture_.type = WebInputEvent::GestureScrollBegin; 672 gesture_.setType(WebInputEvent::GestureScrollBegin);
678 gesture_.data.scrollBegin.deltaHintUnits = WebGestureEvent::ScrollUnits::Page; 673 gesture_.data.scrollBegin.deltaHintUnits = WebGestureEvent::ScrollUnits::Page;
679 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 674 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
680 675
681 VERIFY_AND_RESET_MOCKS(); 676 VERIFY_AND_RESET_MOCKS();
682 677
683 gesture_.type = WebInputEvent::GestureScrollUpdate; 678 gesture_.setType(WebInputEvent::GestureScrollUpdate);
684 gesture_.data.scrollUpdate.deltaY = 1; 679 gesture_.data.scrollUpdate.deltaY = 1;
685 gesture_.data.scrollUpdate.deltaUnits = WebGestureEvent::ScrollUnits::Page; 680 gesture_.data.scrollUpdate.deltaUnits = WebGestureEvent::ScrollUnits::Page;
686 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 681 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
687 682
688 VERIFY_AND_RESET_MOCKS(); 683 VERIFY_AND_RESET_MOCKS();
689 684
690 gesture_.type = WebInputEvent::GestureScrollEnd; 685 gesture_.setType(WebInputEvent::GestureScrollEnd);
691 gesture_.data.scrollUpdate.deltaY = 0; 686 gesture_.data.scrollUpdate.deltaY = 0;
692 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)) 687 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_))
693 .WillOnce(testing::Return()); 688 .WillOnce(testing::Return());
694 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 689 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
695 690
696 VERIFY_AND_RESET_MOCKS(); 691 VERIFY_AND_RESET_MOCKS();
697 } 692 }
698 693
699 // Mac does not smooth scroll wheel events (crbug.com/574283). 694 // Mac does not smooth scroll wheel events (crbug.com/574283).
700 #if !defined(OS_MACOSX) 695 #if !defined(OS_MACOSX)
701 TEST_P(InputHandlerProxyTest, GestureScrollByCoarsePixels) { 696 TEST_P(InputHandlerProxyTest, GestureScrollByCoarsePixels) {
702 #else 697 #else
703 TEST_P(InputHandlerProxyTest, DISABLED_GestureScrollByCoarsePixels) { 698 TEST_P(InputHandlerProxyTest, DISABLED_GestureScrollByCoarsePixels) {
704 #endif 699 #endif
705 SetSmoothScrollEnabled(true); 700 SetSmoothScrollEnabled(true);
706 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 701 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
707 702
708 gesture_.type = WebInputEvent::GestureScrollBegin; 703 gesture_.setType(WebInputEvent::GestureScrollBegin);
709 gesture_.data.scrollBegin.deltaHintUnits = 704 gesture_.data.scrollBegin.deltaHintUnits =
710 WebGestureEvent::ScrollUnits::Pixels; 705 WebGestureEvent::ScrollUnits::Pixels;
711 EXPECT_CALL(mock_input_handler_, ScrollAnimatedBegin(::testing::_)) 706 EXPECT_CALL(mock_input_handler_, ScrollAnimatedBegin(::testing::_))
712 .WillOnce(testing::Return(kImplThreadScrollState)); 707 .WillOnce(testing::Return(kImplThreadScrollState));
713 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 708 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
714 709
715 gesture_.type = WebInputEvent::GestureScrollUpdate; 710 gesture_.setType(WebInputEvent::GestureScrollUpdate);
716 gesture_.data.scrollUpdate.deltaUnits = WebGestureEvent::ScrollUnits::Pixels; 711 gesture_.data.scrollUpdate.deltaUnits = WebGestureEvent::ScrollUnits::Pixels;
717 712
718 EXPECT_CALL(mock_input_handler_, 713 EXPECT_CALL(mock_input_handler_,
719 ScrollAnimated(::testing::_, ::testing::_, ::testing::_)) 714 ScrollAnimated(::testing::_, ::testing::_, ::testing::_))
720 .WillOnce(testing::Return(kImplThreadScrollState)); 715 .WillOnce(testing::Return(kImplThreadScrollState));
721 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 716 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
722 717
723 VERIFY_AND_RESET_MOCKS(); 718 VERIFY_AND_RESET_MOCKS();
724 } 719 }
725 720
726 TEST_P(InputHandlerProxyTest, GestureScrollBeginThatTargetViewport) { 721 TEST_P(InputHandlerProxyTest, GestureScrollBeginThatTargetViewport) {
727 // We shouldn't send any events to the widget for this gesture. 722 // We shouldn't send any events to the widget for this gesture.
728 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 723 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
729 VERIFY_AND_RESET_MOCKS(); 724 VERIFY_AND_RESET_MOCKS();
730 725
731 EXPECT_CALL(mock_input_handler_, RootScrollBegin(testing::_, testing::_)) 726 EXPECT_CALL(mock_input_handler_, RootScrollBegin(testing::_, testing::_))
732 .WillOnce(testing::Return(kImplThreadScrollState)); 727 .WillOnce(testing::Return(kImplThreadScrollState));
733 728
734 gesture_.type = WebInputEvent::GestureScrollBegin; 729 gesture_.setType(WebInputEvent::GestureScrollBegin);
735 gesture_.data.scrollBegin.targetViewport = true; 730 gesture_.data.scrollBegin.targetViewport = true;
736 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 731 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
737 732
738 VERIFY_AND_RESET_MOCKS(); 733 VERIFY_AND_RESET_MOCKS();
739 } 734 }
740 735
741 TEST_P(InputHandlerProxyTest, GesturePinch) { 736 TEST_P(InputHandlerProxyTest, GesturePinch) {
742 // We shouldn't send any events to the widget for this gesture. 737 // We shouldn't send any events to the widget for this gesture.
743 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 738 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
744 VERIFY_AND_RESET_MOCKS(); 739 VERIFY_AND_RESET_MOCKS();
745 740
746 gesture_.type = WebInputEvent::GesturePinchBegin; 741 gesture_.setType(WebInputEvent::GesturePinchBegin);
747 EXPECT_CALL(mock_input_handler_, 742 EXPECT_CALL(mock_input_handler_,
748 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) 743 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
749 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); 744 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
750 EXPECT_CALL(mock_input_handler_, PinchGestureBegin()); 745 EXPECT_CALL(mock_input_handler_, PinchGestureBegin());
751 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 746 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
752 747
753 VERIFY_AND_RESET_MOCKS(); 748 VERIFY_AND_RESET_MOCKS();
754 749
755 gesture_.type = WebInputEvent::GesturePinchUpdate; 750 gesture_.setType(WebInputEvent::GesturePinchUpdate);
756 gesture_.data.pinchUpdate.scale = 1.5; 751 gesture_.data.pinchUpdate.scale = 1.5;
757 gesture_.x = 7; 752 gesture_.x = 7;
758 gesture_.y = 13; 753 gesture_.y = 13;
759 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(1.5, gfx::Point(7, 13))); 754 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(1.5, gfx::Point(7, 13)));
760 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 755 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
761 756
762 VERIFY_AND_RESET_MOCKS(); 757 VERIFY_AND_RESET_MOCKS();
763 758
764 gesture_.type = WebInputEvent::GesturePinchUpdate; 759 gesture_.setType(WebInputEvent::GesturePinchUpdate);
765 gesture_.data.pinchUpdate.scale = 0.5; 760 gesture_.data.pinchUpdate.scale = 0.5;
766 gesture_.data.pinchUpdate.zoomDisabled = true; 761 gesture_.data.pinchUpdate.zoomDisabled = true;
767 gesture_.x = 9; 762 gesture_.x = 9;
768 gesture_.y = 6; 763 gesture_.y = 6;
769 EXPECT_EQ(InputHandlerProxy::DROP_EVENT, 764 EXPECT_EQ(InputHandlerProxy::DROP_EVENT,
770 input_handler_->HandleInputEvent(gesture_)); 765 input_handler_->HandleInputEvent(gesture_));
771 gesture_.data.pinchUpdate.zoomDisabled = false; 766 gesture_.data.pinchUpdate.zoomDisabled = false;
772 767
773 VERIFY_AND_RESET_MOCKS(); 768 VERIFY_AND_RESET_MOCKS();
774 769
775 gesture_.type = WebInputEvent::GesturePinchUpdate; 770 gesture_.setType(WebInputEvent::GesturePinchUpdate);
776 gesture_.data.pinchUpdate.scale = 0.5; 771 gesture_.data.pinchUpdate.scale = 0.5;
777 gesture_.x = 9; 772 gesture_.x = 9;
778 gesture_.y = 6; 773 gesture_.y = 6;
779 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(.5, gfx::Point(9, 6))); 774 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(.5, gfx::Point(9, 6)));
780 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 775 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
781 776
782 VERIFY_AND_RESET_MOCKS(); 777 VERIFY_AND_RESET_MOCKS();
783 778
784 gesture_.type = WebInputEvent::GesturePinchEnd; 779 gesture_.setType(WebInputEvent::GesturePinchEnd);
785 EXPECT_CALL(mock_input_handler_, PinchGestureEnd()); 780 EXPECT_CALL(mock_input_handler_, PinchGestureEnd());
786 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 781 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
787 782
788 VERIFY_AND_RESET_MOCKS(); 783 VERIFY_AND_RESET_MOCKS();
789 } 784 }
790 785
791 TEST_P(InputHandlerProxyTest, GesturePinchWithWheelHandler) { 786 TEST_P(InputHandlerProxyTest, GesturePinchWithWheelHandler) {
792 // We will send the synthetic wheel event to the widget. 787 // We will send the synthetic wheel event to the widget.
793 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; 788 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
794 VERIFY_AND_RESET_MOCKS(); 789 VERIFY_AND_RESET_MOCKS();
795 790
796 gesture_.type = WebInputEvent::GesturePinchBegin; 791 gesture_.setType(WebInputEvent::GesturePinchBegin);
797 EXPECT_CALL(mock_input_handler_, 792 EXPECT_CALL(mock_input_handler_,
798 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) 793 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
799 .WillOnce(testing::Return(cc::EventListenerProperties::kBlocking)); 794 .WillOnce(testing::Return(cc::EventListenerProperties::kBlocking));
800 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 795 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
801 796
802 VERIFY_AND_RESET_MOCKS(); 797 VERIFY_AND_RESET_MOCKS();
803 798
804 gesture_.type = WebInputEvent::GesturePinchUpdate; 799 gesture_.setType(WebInputEvent::GesturePinchUpdate);
805 gesture_.data.pinchUpdate.scale = 1.5; 800 gesture_.data.pinchUpdate.scale = 1.5;
806 gesture_.x = 7; 801 gesture_.x = 7;
807 gesture_.y = 13; 802 gesture_.y = 13;
808 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 803 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
809 804
810 VERIFY_AND_RESET_MOCKS(); 805 VERIFY_AND_RESET_MOCKS();
811 806
812 gesture_.type = WebInputEvent::GesturePinchUpdate; 807 gesture_.setType(WebInputEvent::GesturePinchUpdate);
813 gesture_.data.pinchUpdate.scale = 0.5; 808 gesture_.data.pinchUpdate.scale = 0.5;
814 gesture_.x = 9; 809 gesture_.x = 9;
815 gesture_.y = 6; 810 gesture_.y = 6;
816 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 811 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
817 812
818 VERIFY_AND_RESET_MOCKS(); 813 VERIFY_AND_RESET_MOCKS();
819 814
820 gesture_.type = WebInputEvent::GesturePinchEnd; 815 gesture_.setType(WebInputEvent::GesturePinchEnd);
821 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 816 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
822 } 817 }
823 818
824 TEST_P(InputHandlerProxyTest, GesturePinchAfterScrollOnMainThread) { 819 TEST_P(InputHandlerProxyTest, GesturePinchAfterScrollOnMainThread) {
825 // Scrolls will start by being sent to the main thread. 820 // Scrolls will start by being sent to the main thread.
826 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; 821 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
827 VERIFY_AND_RESET_MOCKS(); 822 VERIFY_AND_RESET_MOCKS();
828 823
829 EXPECT_CALL(mock_input_handler_, ScrollBegin(::testing::_, ::testing::_)) 824 EXPECT_CALL(mock_input_handler_, ScrollBegin(::testing::_, ::testing::_))
830 .WillOnce(testing::Return(kMainThreadScrollState)); 825 .WillOnce(testing::Return(kMainThreadScrollState));
831 826
832 gesture_.type = WebInputEvent::GestureScrollBegin; 827 gesture_.setType(WebInputEvent::GestureScrollBegin);
833 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 828 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
834 829
835 VERIFY_AND_RESET_MOCKS(); 830 VERIFY_AND_RESET_MOCKS();
836 831
837 gesture_.type = WebInputEvent::GestureScrollUpdate; 832 gesture_.setType(WebInputEvent::GestureScrollUpdate);
838 gesture_.data.scrollUpdate.deltaY = 40; 833 gesture_.data.scrollUpdate.deltaY = 40;
839 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 834 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
840 835
841 // However, after the pinch gesture starts, they should go to the impl 836 // However, after the pinch gesture starts, they should go to the impl
842 // thread. 837 // thread.
843 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 838 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
844 VERIFY_AND_RESET_MOCKS(); 839 VERIFY_AND_RESET_MOCKS();
845 840
846 gesture_.type = WebInputEvent::GesturePinchBegin; 841 gesture_.setType(WebInputEvent::GesturePinchBegin);
842 ;
847 EXPECT_CALL(mock_input_handler_, 843 EXPECT_CALL(mock_input_handler_,
848 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) 844 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
849 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); 845 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
850 EXPECT_CALL(mock_input_handler_, PinchGestureBegin()); 846 EXPECT_CALL(mock_input_handler_, PinchGestureBegin());
851 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 847 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
852 848
853 VERIFY_AND_RESET_MOCKS(); 849 VERIFY_AND_RESET_MOCKS();
854 850
855 gesture_.type = WebInputEvent::GesturePinchUpdate; 851 gesture_.setType(WebInputEvent::GesturePinchUpdate);
856 gesture_.data.pinchUpdate.scale = 1.5; 852 gesture_.data.pinchUpdate.scale = 1.5;
857 gesture_.x = 7; 853 gesture_.x = 7;
858 gesture_.y = 13; 854 gesture_.y = 13;
859 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(1.5, gfx::Point(7, 13))); 855 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(1.5, gfx::Point(7, 13)));
860 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 856 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
861 857
862 VERIFY_AND_RESET_MOCKS(); 858 VERIFY_AND_RESET_MOCKS();
863 859
864 gesture_.type = WebInputEvent::GestureScrollUpdate; 860 gesture_.setType(WebInputEvent::GestureScrollUpdate);
865 gesture_.data.scrollUpdate.deltaY = 861 gesture_.data.scrollUpdate.deltaY =
866 -40; // -Y means scroll down - i.e. in the +Y direction. 862 -40; // -Y means scroll down - i.e. in the +Y direction.
867 EXPECT_CALL( 863 EXPECT_CALL(
868 mock_input_handler_, 864 mock_input_handler_,
869 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)))) 865 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0))))
870 .WillOnce(testing::Return(scroll_result_did_scroll_)); 866 .WillOnce(testing::Return(scroll_result_did_scroll_));
871 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 867 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
872 868
873 VERIFY_AND_RESET_MOCKS(); 869 VERIFY_AND_RESET_MOCKS();
874 870
875 gesture_.type = WebInputEvent::GesturePinchUpdate; 871 gesture_.setType(WebInputEvent::GesturePinchUpdate);
876 gesture_.data.pinchUpdate.scale = 0.5; 872 gesture_.data.pinchUpdate.scale = 0.5;
877 gesture_.x = 9; 873 gesture_.x = 9;
878 gesture_.y = 6; 874 gesture_.y = 6;
879 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(.5, gfx::Point(9, 6))); 875 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(.5, gfx::Point(9, 6)));
880 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 876 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
881 877
882 VERIFY_AND_RESET_MOCKS(); 878 VERIFY_AND_RESET_MOCKS();
883 879
884 gesture_.type = WebInputEvent::GesturePinchEnd; 880 gesture_.setType(WebInputEvent::GesturePinchEnd);
885 EXPECT_CALL(mock_input_handler_, PinchGestureEnd()); 881 EXPECT_CALL(mock_input_handler_, PinchGestureEnd());
886 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 882 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
887 883
888 // After the pinch gesture ends, they should go to back to the main 884 // After the pinch gesture ends, they should go to back to the main
889 // thread. 885 // thread.
890 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; 886 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
891 VERIFY_AND_RESET_MOCKS(); 887 VERIFY_AND_RESET_MOCKS();
892 888
893 gesture_.type = WebInputEvent::GestureScrollEnd; 889 gesture_.setType(WebInputEvent::GestureScrollEnd);
894 gesture_.data.scrollUpdate.deltaY = 0; 890 gesture_.data.scrollUpdate.deltaY = 0;
895 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)) 891 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_))
896 .WillOnce(testing::Return()); 892 .WillOnce(testing::Return());
897 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 893 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
898 894
899 VERIFY_AND_RESET_MOCKS(); 895 VERIFY_AND_RESET_MOCKS();
900 } 896 }
901 897
902 TEST_P(InputHandlerProxyTest, GestureFlingStartedTouchpad) { 898 TEST_P(InputHandlerProxyTest, GestureFlingStartedTouchpad) {
903 // We shouldn't send any events to the widget for this gesture. 899 // We shouldn't send any events to the widget for this gesture.
904 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 900 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
905 VERIFY_AND_RESET_MOCKS(); 901 VERIFY_AND_RESET_MOCKS();
906 902
907 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 903 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
908 .WillOnce(testing::Return(kImplThreadScrollState)); 904 .WillOnce(testing::Return(kImplThreadScrollState));
909 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 905 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
910 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 906 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
911 907
912 gesture_.type = WebInputEvent::GestureFlingStart; 908 gesture_.setType(WebInputEvent::GestureFlingStart);
913 gesture_.data.flingStart.velocityX = 10; 909 gesture_.data.flingStart.velocityX = 10;
914 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; 910 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad;
915 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 911 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
916 912
917 VERIFY_AND_RESET_MOCKS(); 913 VERIFY_AND_RESET_MOCKS();
918 914
919 // Verify that a GestureFlingCancel during an animation cancels it. 915 // Verify that a GestureFlingCancel during an animation cancels it.
920 gesture_.type = WebInputEvent::GestureFlingCancel; 916 gesture_.setType(WebInputEvent::GestureFlingCancel);
921 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; 917 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad;
922 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 918 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
923 } 919 }
924 920
925 TEST_P(InputHandlerProxyTest, GestureFlingOnMainThreadTouchpad) { 921 TEST_P(InputHandlerProxyTest, GestureFlingOnMainThreadTouchpad) {
926 // We should send all events to the widget for this gesture. 922 // We should send all events to the widget for this gesture.
927 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; 923 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
928 VERIFY_AND_RESET_MOCKS(); 924 VERIFY_AND_RESET_MOCKS();
929 925
930 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 926 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
931 .WillOnce(testing::Return(kMainThreadScrollState)); 927 .WillOnce(testing::Return(kMainThreadScrollState));
932 928
933 gesture_.type = WebInputEvent::GestureFlingStart; 929 gesture_.setType(WebInputEvent::GestureFlingStart);
934 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; 930 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad;
935 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 931 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
936 932
937 // Since we returned ScrollStatusOnMainThread from scrollBegin, ensure the 933 // Since we returned ScrollStatusOnMainThread from scrollBegin, ensure the
938 // input handler knows it's scrolling off the impl thread 934 // input handler knows it's scrolling off the impl thread
939 ASSERT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 935 ASSERT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
940 936
941 VERIFY_AND_RESET_MOCKS(); 937 VERIFY_AND_RESET_MOCKS();
942 938
943 // Even if we didn't start a fling ourselves, we still need to send the cancel 939 // Even if we didn't start a fling ourselves, we still need to send the cancel
944 // event to the widget. 940 // event to the widget.
945 gesture_.type = WebInputEvent::GestureFlingCancel; 941 gesture_.setType(WebInputEvent::GestureFlingCancel);
946 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; 942 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad;
947 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 943 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
948 } 944 }
949 945
950 TEST_P(InputHandlerProxyTest, GestureFlingIgnoredTouchpad) { 946 TEST_P(InputHandlerProxyTest, GestureFlingIgnoredTouchpad) {
951 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; 947 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
952 VERIFY_AND_RESET_MOCKS(); 948 VERIFY_AND_RESET_MOCKS();
953 949
954 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 950 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
955 .WillOnce(testing::Return(kScrollIgnoredScrollState)); 951 .WillOnce(testing::Return(kScrollIgnoredScrollState));
956 952
957 gesture_.type = WebInputEvent::GestureFlingStart; 953 gesture_.setType(WebInputEvent::GestureFlingStart);
958 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; 954 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad;
959 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 955 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
960 956
961 expected_disposition_ = InputHandlerProxy::DROP_EVENT; 957 expected_disposition_ = InputHandlerProxy::DROP_EVENT;
962 VERIFY_AND_RESET_MOCKS(); 958 VERIFY_AND_RESET_MOCKS();
963 959
964 // Since the previous fling was ignored, we should also be dropping the next 960 // Since the previous fling was ignored, we should also be dropping the next
965 // fling_cancel. 961 // fling_cancel.
966 gesture_.type = WebInputEvent::GestureFlingCancel; 962 gesture_.setType(WebInputEvent::GestureFlingCancel);
967 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; 963 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad;
968 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 964 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
969 } 965 }
970 966
971 TEST_P(InputHandlerProxyTest, GestureFlingAnimatesTouchpad) { 967 TEST_P(InputHandlerProxyTest, GestureFlingAnimatesTouchpad) {
972 // We shouldn't send any events to the widget for this gesture. 968 // We shouldn't send any events to the widget for this gesture.
973 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 969 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
974 VERIFY_AND_RESET_MOCKS(); 970 VERIFY_AND_RESET_MOCKS();
975 971
976 // On the fling start, we should schedule an animation but not actually start 972 // On the fling start, we should schedule an animation but not actually start
977 // scrolling. 973 // scrolling.
978 gesture_.type = WebInputEvent::GestureFlingStart; 974 gesture_.setType(WebInputEvent::GestureFlingStart);
979 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); 975 WebFloatPoint fling_delta = WebFloatPoint(1000, 0);
980 WebPoint fling_point = WebPoint(7, 13); 976 WebPoint fling_point = WebPoint(7, 13);
981 WebPoint fling_global_point = WebPoint(17, 23); 977 WebPoint fling_global_point = WebPoint(17, 23);
982 // Note that for trackpad, wheel events with the Control modifier are 978 // Note that for trackpad, wheel events with the Control modifier are
983 // special (reserved for zoom), so don't set that here. 979 // special (reserved for zoom), so don't set that here.
984 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; 980 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey;
985 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, 981 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad,
986 fling_delta, 982 fling_delta,
987 fling_point, 983 fling_point,
988 fling_global_point, 984 fling_global_point,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 EXPECT_SET_NEEDS_ANIMATE_INPUT(0); 1066 EXPECT_SET_NEEDS_ANIMATE_INPUT(0);
1071 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1067 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1072 .Times(0); 1068 .Times(0);
1073 time += base::TimeDelta::FromMilliseconds(100); 1069 time += base::TimeDelta::FromMilliseconds(100);
1074 Animate(time); 1070 Animate(time);
1075 1071
1076 // Since we've transferred the fling to the main thread, we need to pass the 1072 // Since we've transferred the fling to the main thread, we need to pass the
1077 // next GestureFlingCancel to the main 1073 // next GestureFlingCancel to the main
1078 // thread as well. 1074 // thread as well.
1079 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; 1075 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
1080 gesture_.type = WebInputEvent::GestureFlingCancel; 1076 gesture_.setType(WebInputEvent::GestureFlingCancel);
1081 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1077 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1082 1078
1083 VERIFY_AND_RESET_MOCKS(); 1079 VERIFY_AND_RESET_MOCKS();
1084 } 1080 }
1085 1081
1086 TEST_P(InputHandlerProxyTest, GestureFlingPassiveListener) { 1082 TEST_P(InputHandlerProxyTest, GestureFlingPassiveListener) {
1087 // We shouldn't send any events to the widget for this gesture. 1083 // We shouldn't send any events to the widget for this gesture.
1088 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1084 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1089 VERIFY_AND_RESET_MOCKS(); 1085 VERIFY_AND_RESET_MOCKS();
1090 1086
1091 // On the fling start, we should schedule an animation but not actually start 1087 // On the fling start, we should schedule an animation but not actually start
1092 // scrolling. 1088 // scrolling.
1093 gesture_.type = WebInputEvent::GestureFlingStart; 1089 gesture_.setType(WebInputEvent::GestureFlingStart);
1094 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); 1090 WebFloatPoint fling_delta = WebFloatPoint(1000, 0);
1095 WebPoint fling_point = WebPoint(7, 13); 1091 WebPoint fling_point = WebPoint(7, 13);
1096 WebPoint fling_global_point = WebPoint(17, 23); 1092 WebPoint fling_global_point = WebPoint(17, 23);
1097 // Note that for trackpad, wheel events with the Control modifier are 1093 // Note that for trackpad, wheel events with the Control modifier are
1098 // special (reserved for zoom), so don't set that here. 1094 // special (reserved for zoom), so don't set that here.
1099 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; 1095 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey;
1100 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, fling_delta, 1096 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, fling_delta,
1101 fling_point, fling_global_point, modifiers); 1097 fling_point, fling_global_point, modifiers);
1102 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 1098 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1103 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1099 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
(...skipping 21 matching lines...) Expand all
1125 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 1121 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1126 EXPECT_CALL(mock_input_handler_, 1122 EXPECT_CALL(mock_input_handler_,
1127 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) 1123 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
1128 .WillOnce(testing::Return(cc::EventListenerProperties::kPassive)); 1124 .WillOnce(testing::Return(cc::EventListenerProperties::kPassive));
1129 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1125 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1130 .WillOnce(testing::Return(kImplThreadScrollState)); 1126 .WillOnce(testing::Return(kImplThreadScrollState));
1131 EXPECT_CALL( 1127 EXPECT_CALL(
1132 mock_input_handler_, 1128 mock_input_handler_,
1133 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) 1129 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
1134 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1130 .WillOnce(testing::Return(scroll_result_did_scroll_));
1135 WebMouseWheelEvent expected_wheel; 1131 WebMouseWheelEvent expected_wheel(WebInputEvent::MouseWheel, modifiers,
1136 expected_wheel.type = WebInputEvent::MouseWheel; 1132 WebInputEvent::TimeStampForTesting);
1137 expected_wheel.modifiers = modifiers;
1138 expected_wheel.x = fling_point.x; 1133 expected_wheel.x = fling_point.x;
1139 expected_wheel.y = fling_point.y; 1134 expected_wheel.y = fling_point.y;
1140 expected_wheel.globalX = fling_global_point.x; 1135 expected_wheel.globalX = fling_global_point.x;
1141 expected_wheel.globalY = fling_global_point.y; 1136 expected_wheel.globalY = fling_global_point.y;
1142 expected_wheel.deltaX = fling_delta.x / 10; 1137 expected_wheel.deltaX = fling_delta.x / 10;
1143 expected_wheel.hasPreciseScrollingDeltas = true; 1138 expected_wheel.hasPreciseScrollingDeltas = true;
1144 1139
1145 EXPECT_CALL(mock_client_, DispatchNonBlockingEventToMainThread_( 1140 EXPECT_CALL(mock_client_, DispatchNonBlockingEventToMainThread_(
1146 WheelEventsMatch(expected_wheel))) 1141 WheelEventsMatch(expected_wheel)))
1147 .Times(1); 1142 .Times(1);
1148 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(1); 1143 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(1);
1149 1144
1150 time += base::TimeDelta::FromMilliseconds(100); 1145 time += base::TimeDelta::FromMilliseconds(100);
1151 Animate(time); 1146 Animate(time);
1152 1147
1153 VERIFY_AND_RESET_MOCKS(); 1148 VERIFY_AND_RESET_MOCKS();
1154 1149
1155 // Ensure we can cancel the gesture. 1150 // Ensure we can cancel the gesture.
1156 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1151 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1157 gesture_.type = WebInputEvent::GestureFlingCancel; 1152 gesture_.setType(WebInputEvent::GestureFlingCancel);
1158 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1153 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1159 1154
1160 VERIFY_AND_RESET_MOCKS(); 1155 VERIFY_AND_RESET_MOCKS();
1161 } 1156 }
1162 1157
1163 TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) { 1158 TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) {
1164 // We shouldn't send any events to the widget for this gesture. 1159 // We shouldn't send any events to the widget for this gesture.
1165 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1160 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1166 VERIFY_AND_RESET_MOCKS(); 1161 VERIFY_AND_RESET_MOCKS();
1167 1162
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 .Times(0); 1255 .Times(0);
1261 time += base::TimeDelta::FromMilliseconds(100); 1256 time += base::TimeDelta::FromMilliseconds(100);
1262 Animate(time); 1257 Animate(time);
1263 1258
1264 VERIFY_AND_RESET_MOCKS(); 1259 VERIFY_AND_RESET_MOCKS();
1265 1260
1266 // Since we've transferred the fling to the main thread, we need to pass the 1261 // Since we've transferred the fling to the main thread, we need to pass the
1267 // next GestureFlingCancel to the main 1262 // next GestureFlingCancel to the main
1268 // thread as well. 1263 // thread as well.
1269 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; 1264 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
1270 gesture_.type = WebInputEvent::GestureFlingCancel; 1265 gesture_.setType(WebInputEvent::GestureFlingCancel);
1271 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1266 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1272 1267
1273 VERIFY_AND_RESET_MOCKS(); 1268 VERIFY_AND_RESET_MOCKS();
1274 input_handler_->MainThreadHasStoppedFlinging(); 1269 input_handler_->MainThreadHasStoppedFlinging();
1275 1270
1276 // Start a second gesture fling, this time in the +Y direction with no X. 1271 // Start a second gesture fling, this time in the +Y direction with no X.
1277 fling_delta = WebFloatPoint(0, -1000); 1272 fling_delta = WebFloatPoint(0, -1000);
1278 fling_point = WebPoint(95, 87); 1273 fling_point = WebPoint(95, 87);
1279 fling_global_point = WebPoint(32, 71); 1274 fling_global_point = WebPoint(32, 71);
1280 modifiers = WebInputEvent::AltKey; 1275 modifiers = WebInputEvent::AltKey;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1350 VERIFY_AND_RESET_MOCKS(); 1345 VERIFY_AND_RESET_MOCKS();
1351 } 1346 }
1352 1347
1353 TEST_P(InputHandlerProxyTest, GestureFlingStartedTouchscreen) { 1348 TEST_P(InputHandlerProxyTest, GestureFlingStartedTouchscreen) {
1354 // We shouldn't send any events to the widget for this gesture. 1349 // We shouldn't send any events to the widget for this gesture.
1355 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1350 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1356 VERIFY_AND_RESET_MOCKS(); 1351 VERIFY_AND_RESET_MOCKS();
1357 1352
1358 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1353 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1359 .WillOnce(testing::Return(kImplThreadScrollState)); 1354 .WillOnce(testing::Return(kImplThreadScrollState));
1360 gesture_.type = WebInputEvent::GestureScrollBegin; 1355 gesture_.setType(WebInputEvent::GestureScrollBegin);
1361 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; 1356 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
1362 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1357 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1363 1358
1364 VERIFY_AND_RESET_MOCKS(); 1359 VERIFY_AND_RESET_MOCKS();
1365 1360
1366 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 1361 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
1367 .WillOnce(testing::Return(kImplThreadScrollState)); 1362 .WillOnce(testing::Return(kImplThreadScrollState));
1368 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 1363 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1369 1364
1370 gesture_.type = WebInputEvent::GestureFlingStart; 1365 gesture_.setType(WebInputEvent::GestureFlingStart);
1371 gesture_.data.flingStart.velocityX = 10; 1366 gesture_.data.flingStart.velocityX = 10;
1372 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; 1367 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
1373 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1368 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1374 1369
1375 VERIFY_AND_RESET_MOCKS(); 1370 VERIFY_AND_RESET_MOCKS();
1376 1371
1377 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 1372 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
1378 1373
1379 // Verify that a GestureFlingCancel during an animation cancels it. 1374 // Verify that a GestureFlingCancel during an animation cancels it.
1380 gesture_.type = WebInputEvent::GestureFlingCancel; 1375 gesture_.setType(WebInputEvent::GestureFlingCancel);
1381 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; 1376 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
1382 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1377 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1383 1378
1384 VERIFY_AND_RESET_MOCKS(); 1379 VERIFY_AND_RESET_MOCKS();
1385 } 1380 }
1386 1381
1387 TEST_P(InputHandlerProxyTest, GestureFlingOnMainThreadTouchscreen) { 1382 TEST_P(InputHandlerProxyTest, GestureFlingOnMainThreadTouchscreen) {
1388 // We should send all events to the widget for this gesture. 1383 // We should send all events to the widget for this gesture.
1389 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; 1384 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
1390 VERIFY_AND_RESET_MOCKS(); 1385 VERIFY_AND_RESET_MOCKS();
1391 1386
1392 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1387 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1393 .WillOnce(testing::Return(kMainThreadScrollState)); 1388 .WillOnce(testing::Return(kMainThreadScrollState));
1394 1389
1395 gesture_.type = WebInputEvent::GestureScrollBegin; 1390 gesture_.setType(WebInputEvent::GestureScrollBegin);
1396 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1391 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1397 1392
1398 VERIFY_AND_RESET_MOCKS(); 1393 VERIFY_AND_RESET_MOCKS();
1399 1394
1400 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()).Times(0); 1395 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()).Times(0);
1401 1396
1402 gesture_.type = WebInputEvent::GestureFlingStart; 1397 gesture_.setType(WebInputEvent::GestureFlingStart);
1403 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; 1398 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
1404 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1399 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1405 1400
1406 VERIFY_AND_RESET_MOCKS(); 1401 VERIFY_AND_RESET_MOCKS();
1407 1402
1408 // Even if we didn't start a fling ourselves, we still need to send the cancel 1403 // Even if we didn't start a fling ourselves, we still need to send the cancel
1409 // event to the widget. 1404 // event to the widget.
1410 gesture_.type = WebInputEvent::GestureFlingCancel; 1405 gesture_.setType(WebInputEvent::GestureFlingCancel);
1411 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; 1406 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
1412 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1407 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1413 } 1408 }
1414 1409
1415 TEST_P(InputHandlerProxyTest, GestureFlingIgnoredTouchscreen) { 1410 TEST_P(InputHandlerProxyTest, GestureFlingIgnoredTouchscreen) {
1416 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1411 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1417 VERIFY_AND_RESET_MOCKS(); 1412 VERIFY_AND_RESET_MOCKS();
1418 1413
1419 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1414 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1420 .WillOnce(testing::Return(kImplThreadScrollState)); 1415 .WillOnce(testing::Return(kImplThreadScrollState));
1421 1416
1422 gesture_.type = WebInputEvent::GestureScrollBegin; 1417 gesture_.setType(WebInputEvent::GestureScrollBegin);
1423 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; 1418 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
1424 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1419 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1425 1420
1426 expected_disposition_ = InputHandlerProxy::DROP_EVENT; 1421 expected_disposition_ = InputHandlerProxy::DROP_EVENT;
1427 VERIFY_AND_RESET_MOCKS(); 1422 VERIFY_AND_RESET_MOCKS();
1428 1423
1429 // Flings ignored by the InputHandler should be dropped, signalling the end 1424 // Flings ignored by the InputHandler should be dropped, signalling the end
1430 // of the touch scroll sequence. 1425 // of the touch scroll sequence.
1431 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 1426 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
1432 .WillOnce(testing::Return(kScrollIgnoredScrollState)); 1427 .WillOnce(testing::Return(kScrollIgnoredScrollState));
1433 1428
1434 gesture_.type = WebInputEvent::GestureFlingStart; 1429 gesture_.setType(WebInputEvent::GestureFlingStart);
1435 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; 1430 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
1436 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1431 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1437 1432
1438 VERIFY_AND_RESET_MOCKS(); 1433 VERIFY_AND_RESET_MOCKS();
1439 1434
1440 // Subsequent scrolls should behave normally, even without an intervening 1435 // Subsequent scrolls should behave normally, even without an intervening
1441 // GestureFlingCancel, as the original GestureFlingStart was dropped. 1436 // GestureFlingCancel, as the original GestureFlingStart was dropped.
1442 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1437 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1443 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1438 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1444 .WillOnce(testing::Return(kImplThreadScrollState)); 1439 .WillOnce(testing::Return(kImplThreadScrollState));
1445 gesture_.type = WebInputEvent::GestureScrollBegin; 1440 gesture_.setType(WebInputEvent::GestureScrollBegin);
1446 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; 1441 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
1447 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1442 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1448 1443
1449 VERIFY_AND_RESET_MOCKS(); 1444 VERIFY_AND_RESET_MOCKS();
1450 } 1445 }
1451 1446
1452 TEST_P(InputHandlerProxyTest, GestureFlingAnimatesTouchscreen) { 1447 TEST_P(InputHandlerProxyTest, GestureFlingAnimatesTouchscreen) {
1453 // We shouldn't send any events to the widget for this gesture. 1448 // We shouldn't send any events to the widget for this gesture.
1454 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1449 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1455 VERIFY_AND_RESET_MOCKS(); 1450 VERIFY_AND_RESET_MOCKS();
1456 1451
1457 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1452 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1458 .WillOnce(testing::Return(kImplThreadScrollState)); 1453 .WillOnce(testing::Return(kImplThreadScrollState));
1459 1454
1460 gesture_.type = WebInputEvent::GestureScrollBegin; 1455 gesture_.setType(WebInputEvent::GestureScrollBegin);
1461 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; 1456 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
1462 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1457 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1463 1458
1464 VERIFY_AND_RESET_MOCKS(); 1459 VERIFY_AND_RESET_MOCKS();
1465 1460
1466 // On the fling start, we should schedule an animation but not actually start 1461 // On the fling start, we should schedule an animation but not actually start
1467 // scrolling. 1462 // scrolling.
1468 WebFloatPoint fling_delta = WebFloatPoint(100, 0); 1463 WebFloatPoint fling_delta = WebFloatPoint(100, 0);
1469 WebPoint fling_point = WebPoint(7, 13); 1464 WebPoint fling_point = WebPoint(7, 13);
1470 WebPoint fling_global_point = WebPoint(17, 23); 1465 WebPoint fling_global_point = WebPoint(17, 23);
(...skipping 26 matching lines...) Expand all
1497 EXPECT_CALL( 1492 EXPECT_CALL(
1498 mock_input_handler_, 1493 mock_input_handler_,
1499 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) 1494 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
1500 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1495 .WillOnce(testing::Return(scroll_result_did_scroll_));
1501 time += base::TimeDelta::FromMilliseconds(100); 1496 time += base::TimeDelta::FromMilliseconds(100);
1502 Animate(time); 1497 Animate(time);
1503 1498
1504 VERIFY_AND_RESET_MOCKS(); 1499 VERIFY_AND_RESET_MOCKS();
1505 1500
1506 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 1501 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
1507 gesture_.type = WebInputEvent::GestureFlingCancel; 1502 gesture_.setType(WebInputEvent::GestureFlingCancel);
1508 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1503 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1509 1504
1510 VERIFY_AND_RESET_MOCKS(); 1505 VERIFY_AND_RESET_MOCKS();
1511 } 1506 }
1512 1507
1513 TEST_P(InputHandlerProxyTest, GestureFlingWithValidTimestamp) { 1508 TEST_P(InputHandlerProxyTest, GestureFlingWithValidTimestamp) {
1514 // We shouldn't send any events to the widget for this gesture. 1509 // We shouldn't send any events to the widget for this gesture.
1515 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1510 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1516 VERIFY_AND_RESET_MOCKS(); 1511 VERIFY_AND_RESET_MOCKS();
1517 1512
1518 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1513 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1519 .WillOnce(testing::Return(kImplThreadScrollState)); 1514 .WillOnce(testing::Return(kImplThreadScrollState));
1520 1515
1521 gesture_.type = WebInputEvent::GestureScrollBegin; 1516 gesture_.setType(WebInputEvent::GestureScrollBegin);
1522 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; 1517 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
1523 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1518 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1524 1519
1525 VERIFY_AND_RESET_MOCKS(); 1520 VERIFY_AND_RESET_MOCKS();
1526 1521
1527 // On the fling start, we should schedule an animation but not actually start 1522 // On the fling start, we should schedule an animation but not actually start
1528 // scrolling. 1523 // scrolling.
1529 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); 1524 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10);
1530 base::TimeTicks time = base::TimeTicks() + dt; 1525 base::TimeTicks time = base::TimeTicks() + dt;
1531 WebFloatPoint fling_delta = WebFloatPoint(100, 0); 1526 WebFloatPoint fling_delta = WebFloatPoint(100, 0);
(...skipping 21 matching lines...) Expand all
1553 EXPECT_CALL( 1548 EXPECT_CALL(
1554 mock_input_handler_, 1549 mock_input_handler_,
1555 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) 1550 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
1556 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1551 .WillOnce(testing::Return(scroll_result_did_scroll_));
1557 time += dt; 1552 time += dt;
1558 Animate(time); 1553 Animate(time);
1559 1554
1560 VERIFY_AND_RESET_MOCKS(); 1555 VERIFY_AND_RESET_MOCKS();
1561 1556
1562 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 1557 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
1563 gesture_.type = WebInputEvent::GestureFlingCancel; 1558 gesture_.setType(WebInputEvent::GestureFlingCancel);
1564 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1559 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1565 1560
1566 VERIFY_AND_RESET_MOCKS(); 1561 VERIFY_AND_RESET_MOCKS();
1567 } 1562 }
1568 1563
1569 TEST_P(InputHandlerProxyTest, GestureFlingWithInvalidTimestamp) { 1564 TEST_P(InputHandlerProxyTest, GestureFlingWithInvalidTimestamp) {
1570 // We shouldn't send any events to the widget for this gesture. 1565 // We shouldn't send any events to the widget for this gesture.
1571 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1566 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1572 VERIFY_AND_RESET_MOCKS(); 1567 VERIFY_AND_RESET_MOCKS();
1573 1568
1574 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1569 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1575 .WillOnce(testing::Return(kImplThreadScrollState)); 1570 .WillOnce(testing::Return(kImplThreadScrollState));
1576 1571
1577 gesture_.type = WebInputEvent::GestureScrollBegin; 1572 gesture_.setType(WebInputEvent::GestureScrollBegin);
1578 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; 1573 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
1579 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1574 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1580 1575
1581 VERIFY_AND_RESET_MOCKS(); 1576 VERIFY_AND_RESET_MOCKS();
1582 1577
1583 // On the fling start, we should schedule an animation but not actually start 1578 // On the fling start, we should schedule an animation but not actually start
1584 // scrolling. 1579 // scrolling.
1585 base::TimeDelta start_time_offset = base::TimeDelta::FromMilliseconds(10); 1580 base::TimeDelta start_time_offset = base::TimeDelta::FromMilliseconds(10);
1586 gesture_.type = WebInputEvent::GestureFlingStart; 1581 gesture_.setType(WebInputEvent::GestureFlingStart);
1587 WebFloatPoint fling_delta = WebFloatPoint(100, 0); 1582 WebFloatPoint fling_delta = WebFloatPoint(100, 0);
1588 WebPoint fling_point = WebPoint(7, 13); 1583 WebPoint fling_point = WebPoint(7, 13);
1589 WebPoint fling_global_point = WebPoint(17, 23); 1584 WebPoint fling_global_point = WebPoint(17, 23);
1590 int modifiers = WebInputEvent::ControlKey; 1585 int modifiers = WebInputEvent::ControlKey;
1591 gesture_.timeStampSeconds = start_time_offset.InSecondsF(); 1586 gesture_.setTimeStampSeconds(start_time_offset.InSecondsF());
1592 gesture_.data.flingStart.velocityX = fling_delta.x; 1587 gesture_.data.flingStart.velocityX = fling_delta.x;
1593 gesture_.data.flingStart.velocityY = fling_delta.y; 1588 gesture_.data.flingStart.velocityY = fling_delta.y;
1594 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; 1589 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
1595 gesture_.x = fling_point.x; 1590 gesture_.x = fling_point.x;
1596 gesture_.y = fling_point.y; 1591 gesture_.y = fling_point.y;
1597 gesture_.globalX = fling_global_point.x; 1592 gesture_.globalX = fling_global_point.x;
1598 gesture_.globalY = fling_global_point.y; 1593 gesture_.globalY = fling_global_point.y;
1599 gesture_.modifiers = modifiers; 1594 gesture_.setModifiers(modifiers);
1600 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 1595 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1601 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 1596 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
1602 .WillOnce(testing::Return(kImplThreadScrollState)); 1597 .WillOnce(testing::Return(kImplThreadScrollState));
1603 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1598 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1604 1599
1605 VERIFY_AND_RESET_MOCKS(); 1600 VERIFY_AND_RESET_MOCKS();
1606 // Event though a time stamp was provided for the fling event, it will be 1601 // Event though a time stamp was provided for the fling event, it will be
1607 // ignored as its too far in the past relative to the first animate call's 1602 // ignored as its too far in the past relative to the first animate call's
1608 // timestamp. 1603 // timestamp.
1609 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 1604 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1610 base::TimeTicks time = 1605 base::TimeTicks time =
1611 base::TimeTicks() + start_time_offset + base::TimeDelta::FromSeconds(1); 1606 base::TimeTicks() + start_time_offset + base::TimeDelta::FromSeconds(1);
1612 Animate(time); 1607 Animate(time);
1613 1608
1614 VERIFY_AND_RESET_MOCKS(); 1609 VERIFY_AND_RESET_MOCKS();
1615 1610
1616 // Further animation ticks should update the fling as usual. 1611 // Further animation ticks should update the fling as usual.
1617 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 1612 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1618 EXPECT_CALL( 1613 EXPECT_CALL(
1619 mock_input_handler_, 1614 mock_input_handler_,
1620 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) 1615 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
1621 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1616 .WillOnce(testing::Return(scroll_result_did_scroll_));
1622 time += base::TimeDelta::FromMilliseconds(10); 1617 time += base::TimeDelta::FromMilliseconds(10);
1623 Animate(time); 1618 Animate(time);
1624 1619
1625 VERIFY_AND_RESET_MOCKS(); 1620 VERIFY_AND_RESET_MOCKS();
1626 1621
1627 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 1622 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
1628 gesture_.type = WebInputEvent::GestureFlingCancel; 1623 gesture_.setType(WebInputEvent::GestureFlingCancel);
1629 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1624 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1630 1625
1631 VERIFY_AND_RESET_MOCKS(); 1626 VERIFY_AND_RESET_MOCKS();
1632 } 1627 }
1633 1628
1634 TEST_P(InputHandlerProxyTest, GestureScrollOnImplThreadFlagClearedAfterFling) { 1629 TEST_P(InputHandlerProxyTest, GestureScrollOnImplThreadFlagClearedAfterFling) {
1635 // We shouldn't send any events to the widget for this gesture. 1630 // We shouldn't send any events to the widget for this gesture.
1636 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1631 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1637 VERIFY_AND_RESET_MOCKS(); 1632 VERIFY_AND_RESET_MOCKS();
1638 1633
1639 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1634 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1640 .WillOnce(testing::Return(kImplThreadScrollState)); 1635 .WillOnce(testing::Return(kImplThreadScrollState));
1641 1636
1642 gesture_.type = WebInputEvent::GestureScrollBegin; 1637 gesture_.setType(WebInputEvent::GestureScrollBegin);
1643 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1638 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1644 1639
1645 // After sending a GestureScrollBegin, the member variable 1640 // After sending a GestureScrollBegin, the member variable
1646 // |gesture_scroll_on_impl_thread_| should be true. 1641 // |gesture_scroll_on_impl_thread_| should be true.
1647 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1642 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1648 1643
1649 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1644 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1650 VERIFY_AND_RESET_MOCKS(); 1645 VERIFY_AND_RESET_MOCKS();
1651 1646
1652 // On the fling start, we should schedule an animation but not actually start 1647 // On the fling start, we should schedule an animation but not actually start
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1686 EXPECT_CALL( 1681 EXPECT_CALL(
1687 mock_input_handler_, 1682 mock_input_handler_,
1688 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) 1683 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
1689 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1684 .WillOnce(testing::Return(scroll_result_did_scroll_));
1690 time += base::TimeDelta::FromMilliseconds(100); 1685 time += base::TimeDelta::FromMilliseconds(100);
1691 Animate(time); 1686 Animate(time);
1692 1687
1693 VERIFY_AND_RESET_MOCKS(); 1688 VERIFY_AND_RESET_MOCKS();
1694 1689
1695 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 1690 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
1696 gesture_.type = WebInputEvent::GestureFlingCancel; 1691 gesture_.setType(WebInputEvent::GestureFlingCancel);
1697 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1692 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1698 1693
1699 // |gesture_scroll_on_impl_thread_| should be false once 1694 // |gesture_scroll_on_impl_thread_| should be false once
1700 // the fling has finished (note no GestureScrollEnd has been sent). 1695 // the fling has finished (note no GestureScrollEnd has been sent).
1701 EXPECT_TRUE(!input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1696 EXPECT_TRUE(!input_handler_->gesture_scroll_on_impl_thread_for_testing());
1702 1697
1703 VERIFY_AND_RESET_MOCKS(); 1698 VERIFY_AND_RESET_MOCKS();
1704 } 1699 }
1705 1700
1706 TEST_P(InputHandlerProxyTest, 1701 TEST_P(InputHandlerProxyTest,
1707 BeginScrollWhenGestureScrollOnImplThreadFlagIsSet) { 1702 BeginScrollWhenGestureScrollOnImplThreadFlagIsSet) {
1708 // We shouldn't send any events to the widget for this gesture. 1703 // We shouldn't send any events to the widget for this gesture.
1709 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1704 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1710 VERIFY_AND_RESET_MOCKS(); 1705 VERIFY_AND_RESET_MOCKS();
1711 1706
1712 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1707 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1713 .WillOnce(testing::Return(kImplThreadScrollState)); 1708 .WillOnce(testing::Return(kImplThreadScrollState));
1714 1709
1715 gesture_.type = WebInputEvent::GestureScrollBegin; 1710 gesture_.setType(WebInputEvent::GestureScrollBegin);
1716 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1711 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1717 1712
1718 // After sending a GestureScrollBegin, the member variable 1713 // After sending a GestureScrollBegin, the member variable
1719 // |gesture_scroll_on_impl_thread_| should be true. 1714 // |gesture_scroll_on_impl_thread_| should be true.
1720 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1715 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1721 1716
1722 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1717 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1723 VERIFY_AND_RESET_MOCKS(); 1718 VERIFY_AND_RESET_MOCKS();
1724 1719
1725 // On the fling start, we should schedule an animation but not actually start 1720 // On the fling start, we should schedule an animation but not actually start
(...skipping 14 matching lines...) Expand all
1740 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1735 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1741 1736
1742 VERIFY_AND_RESET_MOCKS(); 1737 VERIFY_AND_RESET_MOCKS();
1743 1738
1744 // gesture_scroll_on_impl_thread_ is still true when this scroll begins. As a 1739 // gesture_scroll_on_impl_thread_ is still true when this scroll begins. As a
1745 // result, this scroll begin will cancel the previous fling. 1740 // result, this scroll begin will cancel the previous fling.
1746 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 1741 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
1747 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1742 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1748 .WillOnce(testing::Return(kImplThreadScrollState)); 1743 .WillOnce(testing::Return(kImplThreadScrollState));
1749 1744
1750 gesture_.type = WebInputEvent::GestureScrollBegin; 1745 gesture_.setType(WebInputEvent::GestureScrollBegin);
1751 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1746 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1752 1747
1753 // After sending a GestureScrollBegin, the member variable 1748 // After sending a GestureScrollBegin, the member variable
1754 // |gesture_scroll_on_impl_thread_| should be true. 1749 // |gesture_scroll_on_impl_thread_| should be true.
1755 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1750 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1756 VERIFY_AND_RESET_MOCKS(); 1751 VERIFY_AND_RESET_MOCKS();
1757 } 1752 }
1758 1753
1759 TEST_P(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) { 1754 TEST_P(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) {
1760 // We shouldn't send any events to the widget for this gesture. 1755 // We shouldn't send any events to the widget for this gesture.
1761 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1756 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1762 VERIFY_AND_RESET_MOCKS(); 1757 VERIFY_AND_RESET_MOCKS();
1763 1758
1764 // On the fling start, we should schedule an animation but not actually start 1759 // On the fling start, we should schedule an animation but not actually start
1765 // scrolling. 1760 // scrolling.
1766 gesture_.type = WebInputEvent::GestureFlingStart; 1761 gesture_.setType(WebInputEvent::GestureFlingStart);
1767 WebFloatPoint fling_delta = WebFloatPoint(100, 100); 1762 WebFloatPoint fling_delta = WebFloatPoint(100, 100);
1768 gesture_.data.flingStart.velocityX = fling_delta.x; 1763 gesture_.data.flingStart.velocityX = fling_delta.x;
1769 gesture_.data.flingStart.velocityY = fling_delta.y; 1764 gesture_.data.flingStart.velocityY = fling_delta.y;
1770 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1765 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1771 .WillOnce(testing::Return(kImplThreadScrollState)); 1766 .WillOnce(testing::Return(kImplThreadScrollState));
1772 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 1767 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
1773 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 1768 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1774 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1769 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1775 VERIFY_AND_RESET_MOCKS(); 1770 VERIFY_AND_RESET_MOCKS();
1776 1771
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1843 } 1838 }
1844 1839
1845 TEST_P(InputHandlerProxyTest, GestureFlingNotCancelledBySmallTimeDelta) { 1840 TEST_P(InputHandlerProxyTest, GestureFlingNotCancelledBySmallTimeDelta) {
1846 // We shouldn't send any events to the widget for this gesture. 1841 // We shouldn't send any events to the widget for this gesture.
1847 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1842 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1848 VERIFY_AND_RESET_MOCKS(); 1843 VERIFY_AND_RESET_MOCKS();
1849 1844
1850 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1845 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1851 .WillOnce(testing::Return(kImplThreadScrollState)); 1846 .WillOnce(testing::Return(kImplThreadScrollState));
1852 1847
1853 gesture_.type = WebInputEvent::GestureScrollBegin; 1848 gesture_.setType(WebInputEvent::GestureScrollBegin);
1854 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; 1849 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
1855 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1850 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1856 1851
1857 VERIFY_AND_RESET_MOCKS(); 1852 VERIFY_AND_RESET_MOCKS();
1858 1853
1859 // On the fling start, we should schedule an animation but not actually start 1854 // On the fling start, we should schedule an animation but not actually start
1860 // scrolling. 1855 // scrolling.
1861 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); 1856 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10);
1862 base::TimeTicks time = base::TimeTicks() + dt; 1857 base::TimeTicks time = base::TimeTicks() + dt;
1863 WebFloatPoint fling_delta = WebFloatPoint(100, 0); 1858 WebFloatPoint fling_delta = WebFloatPoint(100, 0);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 cc::InputHandlerScrollResult overscroll; 1918 cc::InputHandlerScrollResult overscroll;
1924 overscroll.did_scroll = true; 1919 overscroll.did_scroll = true;
1925 overscroll.did_overscroll_root = true; 1920 overscroll.did_overscroll_root = true;
1926 1921
1927 // We shouldn't send any events to the widget for this gesture. 1922 // We shouldn't send any events to the widget for this gesture.
1928 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1923 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1929 VERIFY_AND_RESET_MOCKS(); 1924 VERIFY_AND_RESET_MOCKS();
1930 1925
1931 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1926 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1932 .WillOnce(testing::Return(kImplThreadScrollState)); 1927 .WillOnce(testing::Return(kImplThreadScrollState));
1933 gesture_.type = WebInputEvent::GestureScrollBegin; 1928 gesture_.setType(WebInputEvent::GestureScrollBegin);
1934 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; 1929 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
1935 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1930 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1936 VERIFY_AND_RESET_MOCKS(); 1931 VERIFY_AND_RESET_MOCKS();
1937 1932
1938 // On the fling start, we should schedule an animation but not actually start 1933 // On the fling start, we should schedule an animation but not actually start
1939 // scrolling. 1934 // scrolling.
1940 gesture_.type = WebInputEvent::GestureFlingStart; 1935 gesture_.setType(WebInputEvent::GestureFlingStart);
1941 WebFloatPoint fling_delta = WebFloatPoint(100, 100); 1936 WebFloatPoint fling_delta = WebFloatPoint(100, 100);
1942 gesture_.data.flingStart.velocityX = fling_delta.x; 1937 gesture_.data.flingStart.velocityX = fling_delta.x;
1943 gesture_.data.flingStart.velocityY = fling_delta.y; 1938 gesture_.data.flingStart.velocityY = fling_delta.y;
1944 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 1939 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
1945 .WillOnce(testing::Return(kImplThreadScrollState)); 1940 .WillOnce(testing::Return(kImplThreadScrollState));
1946 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 1941 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1947 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1942 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1948 VERIFY_AND_RESET_MOCKS(); 1943 VERIFY_AND_RESET_MOCKS();
1949 1944
1950 // The first animate doesn't cause any scrolling. 1945 // The first animate doesn't cause any scrolling.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2033 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); 2028 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
2034 EXPECT_CALL( 2029 EXPECT_CALL(
2035 mock_input_handler_, 2030 mock_input_handler_,
2036 GetEventListenerProperties(cc::EventListenerClass::kTouchEndOrCancel)) 2031 GetEventListenerProperties(cc::EventListenerClass::kTouchEndOrCancel))
2037 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); 2032 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
2038 EXPECT_CALL(mock_input_handler_, EventListenerTypeForTouchStartAt(testing::_)) 2033 EXPECT_CALL(mock_input_handler_, EventListenerTypeForTouchStartAt(testing::_))
2039 .Times(2) 2034 .Times(2)
2040 .WillRepeatedly(testing::Return( 2035 .WillRepeatedly(testing::Return(
2041 cc::InputHandler::TouchStartEventListenerType::NO_HANDLER)); 2036 cc::InputHandler::TouchStartEventListenerType::NO_HANDLER));
2042 2037
2043 WebTouchEvent touch; 2038 WebTouchEvent touch(WebInputEvent::TouchStart, WebInputEvent::NoModifiers,
2044 touch.type = WebInputEvent::TouchStart; 2039 WebInputEvent::TimeStampForTesting);
2045 2040
2046 touch.touchesLength = 3; 2041 touch.touchesLength = 3;
2047 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StateStationary, 0, 0); 2042 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StateStationary, 0, 0);
2048 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); 2043 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10);
2049 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); 2044 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10);
2050 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); 2045 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch));
2051 2046
2052 VERIFY_AND_RESET_MOCKS(); 2047 VERIFY_AND_RESET_MOCKS();
2053 } 2048 }
2054 2049
2055 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPositive) { 2050 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPositive) {
2056 // One of the touch points is on a touch-region. So the event should be sent 2051 // One of the touch points is on a touch-region. So the event should be sent
2057 // to the main thread. 2052 // to the main thread.
2058 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; 2053 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
2059 VERIFY_AND_RESET_MOCKS(); 2054 VERIFY_AND_RESET_MOCKS();
2060 2055
2061 EXPECT_CALL(mock_input_handler_, 2056 EXPECT_CALL(mock_input_handler_,
2062 EventListenerTypeForTouchStartAt( 2057 EventListenerTypeForTouchStartAt(
2063 testing::Property(&gfx::Point::x, testing::Eq(0)))) 2058 testing::Property(&gfx::Point::x, testing::Eq(0))))
2064 .WillOnce(testing::Return( 2059 .WillOnce(testing::Return(
2065 cc::InputHandler::TouchStartEventListenerType::NO_HANDLER)); 2060 cc::InputHandler::TouchStartEventListenerType::NO_HANDLER));
2066 EXPECT_CALL(mock_input_handler_, 2061 EXPECT_CALL(mock_input_handler_,
2067 EventListenerTypeForTouchStartAt( 2062 EventListenerTypeForTouchStartAt(
2068 testing::Property(&gfx::Point::x, testing::Gt(0)))) 2063 testing::Property(&gfx::Point::x, testing::Gt(0))))
2069 .WillOnce(testing::Return(cc::InputHandler::TouchStartEventListenerType:: 2064 .WillOnce(testing::Return(cc::InputHandler::TouchStartEventListenerType::
2070 HANDLER_ON_SCROLLING_LAYER)); 2065 HANDLER_ON_SCROLLING_LAYER));
2071 // Since the second touch point hits a touch-region, there should be no 2066 // Since the second touch point hits a touch-region, there should be no
2072 // hit-testing for the third touch point. 2067 // hit-testing for the third touch point.
2073 2068
2074 WebTouchEvent touch; 2069 WebTouchEvent touch(WebInputEvent::TouchStart, WebInputEvent::NoModifiers,
2075 touch.type = WebInputEvent::TouchStart; 2070 WebInputEvent::TimeStampForTesting);
2076 2071
2077 touch.touchesLength = 3; 2072 touch.touchesLength = 3;
2078 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); 2073 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0);
2079 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); 2074 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10);
2080 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); 2075 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10);
2081 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); 2076 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch));
2082 2077
2083 VERIFY_AND_RESET_MOCKS(); 2078 VERIFY_AND_RESET_MOCKS();
2084 } 2079 }
2085 2080
2086 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPassivePositive) { 2081 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPassivePositive) {
2087 // One of the touch points is not on a touch-region. So the event should be 2082 // One of the touch points is not on a touch-region. So the event should be
2088 // sent to the impl thread. 2083 // sent to the impl thread.
2089 expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING; 2084 expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING;
2090 VERIFY_AND_RESET_MOCKS(); 2085 VERIFY_AND_RESET_MOCKS();
2091 2086
2092 EXPECT_CALL( 2087 EXPECT_CALL(
2093 mock_input_handler_, 2088 mock_input_handler_,
2094 GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove)) 2089 GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove))
2095 .WillRepeatedly(testing::Return(cc::EventListenerProperties::kPassive)); 2090 .WillRepeatedly(testing::Return(cc::EventListenerProperties::kPassive));
2096 EXPECT_CALL(mock_input_handler_, EventListenerTypeForTouchStartAt(testing::_)) 2091 EXPECT_CALL(mock_input_handler_, EventListenerTypeForTouchStartAt(testing::_))
2097 .WillRepeatedly(testing::Return( 2092 .WillRepeatedly(testing::Return(
2098 cc::InputHandler::TouchStartEventListenerType::NO_HANDLER)); 2093 cc::InputHandler::TouchStartEventListenerType::NO_HANDLER));
2099 2094
2100 WebTouchEvent touch; 2095 WebTouchEvent touch(WebInputEvent::TouchStart, WebInputEvent::NoModifiers,
2101 touch.type = WebInputEvent::TouchStart; 2096 WebInputEvent::TimeStampForTesting);
2102 2097
2103 touch.touchesLength = 3; 2098 touch.touchesLength = 3;
2104 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); 2099 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0);
2105 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); 2100 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10);
2106 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); 2101 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10);
2107 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); 2102 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch));
2108 2103
2109 VERIFY_AND_RESET_MOCKS(); 2104 VERIFY_AND_RESET_MOCKS();
2110 } 2105 }
2111 2106
2112 TEST_P(InputHandlerProxyTest, TouchStartPassiveAndTouchEndBlocking) { 2107 TEST_P(InputHandlerProxyTest, TouchStartPassiveAndTouchEndBlocking) {
2113 // The touch start is not in a touch-region but there is a touch end handler 2108 // The touch start is not in a touch-region but there is a touch end handler
2114 // so to maintain targeting we need to dispatch the touch start as 2109 // so to maintain targeting we need to dispatch the touch start as
2115 // non-blocking but drop all touch moves. 2110 // non-blocking but drop all touch moves.
2116 expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING; 2111 expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING;
2117 VERIFY_AND_RESET_MOCKS(); 2112 VERIFY_AND_RESET_MOCKS();
2118 2113
2119 EXPECT_CALL( 2114 EXPECT_CALL(
2120 mock_input_handler_, 2115 mock_input_handler_,
2121 GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove)) 2116 GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove))
2122 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); 2117 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
2123 EXPECT_CALL( 2118 EXPECT_CALL(
2124 mock_input_handler_, 2119 mock_input_handler_,
2125 GetEventListenerProperties(cc::EventListenerClass::kTouchEndOrCancel)) 2120 GetEventListenerProperties(cc::EventListenerClass::kTouchEndOrCancel))
2126 .WillOnce(testing::Return(cc::EventListenerProperties::kBlocking)); 2121 .WillOnce(testing::Return(cc::EventListenerProperties::kBlocking));
2127 EXPECT_CALL(mock_input_handler_, EventListenerTypeForTouchStartAt(testing::_)) 2122 EXPECT_CALL(mock_input_handler_, EventListenerTypeForTouchStartAt(testing::_))
2128 .WillOnce(testing::Return( 2123 .WillOnce(testing::Return(
2129 cc::InputHandler::TouchStartEventListenerType::NO_HANDLER)); 2124 cc::InputHandler::TouchStartEventListenerType::NO_HANDLER));
2130 2125
2131 WebTouchEvent touch; 2126 WebTouchEvent touch(WebInputEvent::TouchStart, WebInputEvent::NoModifiers,
2132 touch.type = WebInputEvent::TouchStart; 2127 WebInputEvent::TimeStampForTesting);
2133 touch.touchesLength = 1; 2128 touch.touchesLength = 1;
2134 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); 2129 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0);
2135 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); 2130 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch));
2136 2131
2137 touch.type = WebInputEvent::TouchMove; 2132 touch.setType(WebInputEvent::TouchMove);
2138 touch.touchesLength = 1; 2133 touch.touchesLength = 1;
2139 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); 2134 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10);
2140 EXPECT_EQ(InputHandlerProxy::DROP_EVENT, 2135 EXPECT_EQ(InputHandlerProxy::DROP_EVENT,
2141 input_handler_->HandleInputEvent(touch)); 2136 input_handler_->HandleInputEvent(touch));
2142 VERIFY_AND_RESET_MOCKS(); 2137 VERIFY_AND_RESET_MOCKS();
2143 } 2138 }
2144 2139
2145 TEST_P(InputHandlerProxyTest, GestureFlingCancelledByKeyboardEvent) { 2140 TEST_P(InputHandlerProxyTest, GestureFlingCancelledByKeyboardEvent) {
2146 // We shouldn't send any events to the widget for this gesture. 2141 // We shouldn't send any events to the widget for this gesture.
2147 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 2142 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
2148 VERIFY_AND_RESET_MOCKS(); 2143 VERIFY_AND_RESET_MOCKS();
2149 2144
2150 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 2145 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
2151 .WillOnce(testing::Return(kImplThreadScrollState)); 2146 .WillOnce(testing::Return(kImplThreadScrollState));
2152 gesture_.type = WebInputEvent::GestureScrollBegin; 2147 gesture_.setType(WebInputEvent::GestureScrollBegin);
2153 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; 2148 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
2154 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 2149 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
2155 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 2150 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
2156 VERIFY_AND_RESET_MOCKS(); 2151 VERIFY_AND_RESET_MOCKS();
2157 2152
2158 // Keyboard events received during a scroll should have no effect. 2153 // Keyboard events received during a scroll should have no effect.
2159 WebKeyboardEvent key_event; 2154 WebKeyboardEvent key_event(WebInputEvent::KeyDown, WebInputEvent::NoModifiers,
2160 key_event.type = WebInputEvent::KeyDown; 2155 WebInputEvent::TimeStampForTesting);
2161 EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE, 2156 EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE,
2162 input_handler_->HandleInputEvent(key_event)); 2157 input_handler_->HandleInputEvent(key_event));
2163 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 2158 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
2164 VERIFY_AND_RESET_MOCKS(); 2159 VERIFY_AND_RESET_MOCKS();
2165 2160
2166 // On the fling start, animation should be scheduled, but no scrolling occurs. 2161 // On the fling start, animation should be scheduled, but no scrolling occurs.
2167 gesture_.type = WebInputEvent::GestureFlingStart; 2162 gesture_.setType(WebInputEvent::GestureFlingStart);
2168 WebFloatPoint fling_delta = WebFloatPoint(100, 100); 2163 WebFloatPoint fling_delta = WebFloatPoint(100, 100);
2169 gesture_.data.flingStart.velocityX = fling_delta.x; 2164 gesture_.data.flingStart.velocityX = fling_delta.x;
2170 gesture_.data.flingStart.velocityY = fling_delta.y; 2165 gesture_.data.flingStart.velocityY = fling_delta.y;
2171 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 2166 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
2172 .WillOnce(testing::Return(kImplThreadScrollState)); 2167 .WillOnce(testing::Return(kImplThreadScrollState));
2173 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 2168 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
2174 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 2169 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
2175 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 2170 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
2176 VERIFY_AND_RESET_MOCKS(); 2171 VERIFY_AND_RESET_MOCKS();
2177 2172
2178 // Keyboard events received during a fling should cancel the active fling. 2173 // Keyboard events received during a fling should cancel the active fling.
2179 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 2174 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
2180 EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE, 2175 EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE,
2181 input_handler_->HandleInputEvent(key_event)); 2176 input_handler_->HandleInputEvent(key_event));
2182 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 2177 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
2183 VERIFY_AND_RESET_MOCKS(); 2178 VERIFY_AND_RESET_MOCKS();
2184 2179
2185 // The call to animate should have no effect, as the fling was cancelled. 2180 // The call to animate should have no effect, as the fling was cancelled.
2186 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); 2181 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
2187 Animate(time); 2182 Animate(time);
2188 VERIFY_AND_RESET_MOCKS(); 2183 VERIFY_AND_RESET_MOCKS();
2189 2184
2190 // A fling cancel should be dropped, as there is nothing to cancel. 2185 // A fling cancel should be dropped, as there is nothing to cancel.
2191 gesture_.type = WebInputEvent::GestureFlingCancel; 2186 gesture_.setType(WebInputEvent::GestureFlingCancel);
2192 EXPECT_EQ(InputHandlerProxy::DROP_EVENT, 2187 EXPECT_EQ(InputHandlerProxy::DROP_EVENT,
2193 input_handler_->HandleInputEvent(gesture_)); 2188 input_handler_->HandleInputEvent(gesture_));
2194 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 2189 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
2195 } 2190 }
2196 2191
2197 TEST_P(InputHandlerProxyTest, GestureFlingCancelledByWheelEvent) { 2192 TEST_P(InputHandlerProxyTest, GestureFlingCancelledByWheelEvent) {
2198 // We shouldn't send any events to the widget for this gesture. 2193 // We shouldn't send any events to the widget for this gesture.
2199 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 2194 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
2200 VERIFY_AND_RESET_MOCKS(); 2195 VERIFY_AND_RESET_MOCKS();
2201 2196
2202 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 2197 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
2203 .WillOnce(testing::Return(kImplThreadScrollState)); 2198 .WillOnce(testing::Return(kImplThreadScrollState));
2204 2199
2205 gesture_.type = WebInputEvent::GestureScrollBegin; 2200 gesture_.setType(WebInputEvent::GestureScrollBegin);
2206 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; 2201 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
2207 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 2202 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
2208 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 2203 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
2209 VERIFY_AND_RESET_MOCKS(); 2204 VERIFY_AND_RESET_MOCKS();
2210 2205
2211 // Wheel events received during a scroll shouldn't cancel the fling, but will 2206 // Wheel events received during a scroll shouldn't cancel the fling, but will
2212 // cause scrolling. 2207 // cause scrolling.
2213 cc::InputHandlerScrollResult result; 2208 cc::InputHandlerScrollResult result;
2214 2209
2215 EXPECT_CALL(mock_input_handler_, 2210 EXPECT_CALL(mock_input_handler_,
2216 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) 2211 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
2217 .WillOnce(testing::Return(cc::EventListenerProperties::kBlocking)); 2212 .WillOnce(testing::Return(cc::EventListenerProperties::kBlocking));
2218 2213
2219 WebMouseWheelEvent wheel_event; 2214 WebMouseWheelEvent wheel_event(WebInputEvent::MouseWheel,
2220 wheel_event.type = WebInputEvent::MouseWheel; 2215 WebInputEvent::NoModifiers,
2216 WebInputEvent::TimeStampForTesting);
2221 input_handler_->HandleInputEvent(wheel_event); 2217 input_handler_->HandleInputEvent(wheel_event);
2222 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 2218 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
2223 VERIFY_AND_RESET_MOCKS(); 2219 VERIFY_AND_RESET_MOCKS();
2224 2220
2225 // On the fling start, animation should be scheduled, but no scrolling occurs. 2221 // On the fling start, animation should be scheduled, but no scrolling occurs.
2226 gesture_.type = WebInputEvent::GestureFlingStart; 2222 gesture_.setType(WebInputEvent::GestureFlingStart);
2227 WebFloatPoint fling_delta = WebFloatPoint(100, 100); 2223 WebFloatPoint fling_delta = WebFloatPoint(100, 100);
2228 gesture_.data.flingStart.velocityX = fling_delta.x; 2224 gesture_.data.flingStart.velocityX = fling_delta.x;
2229 gesture_.data.flingStart.velocityY = fling_delta.y; 2225 gesture_.data.flingStart.velocityY = fling_delta.y;
2230 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 2226 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
2231 .WillOnce(testing::Return(kImplThreadScrollState)); 2227 .WillOnce(testing::Return(kImplThreadScrollState));
2232 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 2228 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
2233 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 2229 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
2234 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 2230 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
2235 VERIFY_AND_RESET_MOCKS(); 2231 VERIFY_AND_RESET_MOCKS();
2236 2232
2237 // Wheel events received during a fling should cancel the active fling, and 2233 // Wheel events received during a fling should cancel the active fling, and
2238 // cause a scroll. 2234 // cause a scroll.
2239 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 2235 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
2240 2236
2241 EXPECT_CALL(mock_input_handler_, 2237 EXPECT_CALL(mock_input_handler_,
2242 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) 2238 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
2243 .WillOnce(testing::Return(cc::EventListenerProperties::kBlocking)); 2239 .WillOnce(testing::Return(cc::EventListenerProperties::kBlocking));
2244 2240
2245 2241
2246 input_handler_->HandleInputEvent(wheel_event); 2242 input_handler_->HandleInputEvent(wheel_event);
2247 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 2243 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
2248 VERIFY_AND_RESET_MOCKS(); 2244 VERIFY_AND_RESET_MOCKS();
2249 2245
2250 // The call to animate should have no effect, as the fling was cancelled. 2246 // The call to animate should have no effect, as the fling was cancelled.
2251 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); 2247 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
2252 Animate(time); 2248 Animate(time);
2253 VERIFY_AND_RESET_MOCKS(); 2249 VERIFY_AND_RESET_MOCKS();
2254 2250
2255 // A fling cancel should be dropped, as there is nothing to cancel. 2251 // A fling cancel should be dropped, as there is nothing to cancel.
2256 gesture_.type = WebInputEvent::GestureFlingCancel; 2252 gesture_.setType(WebInputEvent::GestureFlingCancel);
2257 EXPECT_EQ(InputHandlerProxy::DROP_EVENT, 2253 EXPECT_EQ(InputHandlerProxy::DROP_EVENT,
2258 input_handler_->HandleInputEvent(gesture_)); 2254 input_handler_->HandleInputEvent(gesture_));
2259 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 2255 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
2260 } 2256 }
2261 2257
2262 TEST_P(InputHandlerProxyTest, GestureFlingWithNegativeTimeDelta) { 2258 TEST_P(InputHandlerProxyTest, GestureFlingWithNegativeTimeDelta) {
2263 // We shouldn't send any events to the widget for this gesture. 2259 // We shouldn't send any events to the widget for this gesture.
2264 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 2260 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
2265 VERIFY_AND_RESET_MOCKS(); 2261 VERIFY_AND_RESET_MOCKS();
2266 2262
2267 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 2263 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
2268 .WillOnce(testing::Return(kImplThreadScrollState)); 2264 .WillOnce(testing::Return(kImplThreadScrollState));
2269 2265
2270 gesture_.type = WebInputEvent::GestureScrollBegin; 2266 gesture_.setType(WebInputEvent::GestureScrollBegin);
2271 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; 2267 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
2272 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 2268 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
2273 2269
2274 VERIFY_AND_RESET_MOCKS(); 2270 VERIFY_AND_RESET_MOCKS();
2275 2271
2276 // On the fling start, we should schedule an animation but not actually start 2272 // On the fling start, we should schedule an animation but not actually start
2277 // scrolling. 2273 // scrolling.
2278 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); 2274 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10);
2279 base::TimeTicks time = base::TimeTicks() + dt; 2275 base::TimeTicks time = base::TimeTicks() + dt;
2280 WebFloatPoint fling_delta = WebFloatPoint(100, 0); 2276 WebFloatPoint fling_delta = WebFloatPoint(100, 0);
(...skipping 29 matching lines...) Expand all
2310 EXPECT_CALL( 2306 EXPECT_CALL(
2311 mock_input_handler_, 2307 mock_input_handler_,
2312 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) 2308 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
2313 .WillOnce(testing::Return(scroll_result_did_scroll_)); 2309 .WillOnce(testing::Return(scroll_result_did_scroll_));
2314 2310
2315 Animate(time + base::TimeDelta::FromMilliseconds(1)); 2311 Animate(time + base::TimeDelta::FromMilliseconds(1));
2316 2312
2317 VERIFY_AND_RESET_MOCKS(); 2313 VERIFY_AND_RESET_MOCKS();
2318 2314
2319 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 2315 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
2320 gesture_.type = WebInputEvent::GestureFlingCancel; 2316 gesture_.setType(WebInputEvent::GestureFlingCancel);
2321 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 2317 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
2322 2318
2323 VERIFY_AND_RESET_MOCKS(); 2319 VERIFY_AND_RESET_MOCKS();
2324 } 2320 }
2325 2321
2326 TEST_P(InputHandlerProxyTest, FlingBoost) { 2322 TEST_P(InputHandlerProxyTest, FlingBoost) {
2327 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); 2323 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10);
2328 base::TimeTicks time = base::TimeTicks() + dt; 2324 base::TimeTicks time = base::TimeTicks() + dt;
2329 base::TimeTicks last_animate_time = time; 2325 base::TimeTicks last_animate_time = time;
2330 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); 2326 WebFloatPoint fling_delta = WebFloatPoint(1000, 0);
2331 WebPoint fling_point = WebPoint(7, 13); 2327 WebPoint fling_point = WebPoint(7, 13);
2332 StartFling( 2328 StartFling(
2333 time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point); 2329 time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point);
2334 2330
2335 // Now cancel the fling. The fling cancellation should be deferred to allow 2331 // Now cancel the fling. The fling cancellation should be deferred to allow
2336 // fling boosting events to arrive. 2332 // fling boosting events to arrive.
2337 time += dt; 2333 time += dt;
2338 CancelFling(time); 2334 CancelFling(time);
2339 2335
2340 // The GestureScrollBegin should be swallowed by the fling if it hits the same 2336 // The GestureScrollBegin should be swallowed by the fling if it hits the same
2341 // scrolling layer. 2337 // scrolling layer.
2342 EXPECT_CALL(mock_input_handler_, 2338 EXPECT_CALL(mock_input_handler_,
2343 IsCurrentlyScrollingLayerAt(testing::_, testing::_)) 2339 IsCurrentlyScrollingLayerAt(testing::_, testing::_))
2344 .WillOnce(testing::Return(true)); 2340 .WillOnce(testing::Return(true));
2345 2341
2346 time += dt; 2342 time += dt;
2347 gesture_.timeStampSeconds = InSecondsF(time); 2343 gesture_.setTimeStampSeconds(InSecondsF(time));
2348 gesture_.type = WebInputEvent::GestureScrollBegin; 2344 gesture_.setType(WebInputEvent::GestureScrollBegin);
2349 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 2345 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
2350 2346
2351 VERIFY_AND_RESET_MOCKS(); 2347 VERIFY_AND_RESET_MOCKS();
2352 2348
2353 // Animate calls within the deferred cancellation window should continue. 2349 // Animate calls within the deferred cancellation window should continue.
2354 time += dt; 2350 time += dt;
2355 float expected_delta = 2351 float expected_delta =
2356 (time - last_animate_time).InSecondsF() * -fling_delta.x; 2352 (time - last_animate_time).InSecondsF() * -fling_delta.x;
2357 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 2353 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
2358 EXPECT_CALL(mock_input_handler_, 2354 EXPECT_CALL(mock_input_handler_,
2359 ScrollBy(testing::Property(&cc::ScrollState::delta_x, 2355 ScrollBy(testing::Property(&cc::ScrollState::delta_x,
2360 testing::Eq(expected_delta)))) 2356 testing::Eq(expected_delta))))
2361 .WillOnce(testing::Return(scroll_result_did_scroll_)); 2357 .WillOnce(testing::Return(scroll_result_did_scroll_));
2362 Animate(time); 2358 Animate(time);
2363 last_animate_time = time; 2359 last_animate_time = time;
2364 2360
2365 VERIFY_AND_RESET_MOCKS(); 2361 VERIFY_AND_RESET_MOCKS();
2366 2362
2367 // GestureScrollUpdates in the same direction and at sufficient speed should 2363 // GestureScrollUpdates in the same direction and at sufficient speed should
2368 // be swallowed by the fling. 2364 // be swallowed by the fling.
2369 time += dt; 2365 time += dt;
2370 gesture_.timeStampSeconds = InSecondsF(time); 2366 gesture_.setTimeStampSeconds(InSecondsF(time));
2371 gesture_.type = WebInputEvent::GestureScrollUpdate; 2367 gesture_.setType(WebInputEvent::GestureScrollUpdate);
2372 gesture_.data.scrollUpdate.deltaX = fling_delta.x; 2368 gesture_.data.scrollUpdate.deltaX = fling_delta.x;
2373 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 2369 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
2374 2370
2375 VERIFY_AND_RESET_MOCKS(); 2371 VERIFY_AND_RESET_MOCKS();
2376 2372
2377 // Animate calls within the deferred cancellation window should continue. 2373 // Animate calls within the deferred cancellation window should continue.
2378 time += dt; 2374 time += dt;
2379 expected_delta = (time - last_animate_time).InSecondsF() * -fling_delta.x; 2375 expected_delta = (time - last_animate_time).InSecondsF() * -fling_delta.x;
2380 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 2376 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
2381 EXPECT_CALL(mock_input_handler_, 2377 EXPECT_CALL(mock_input_handler_,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2434 .WillOnce(testing::Return(scroll_result_did_scroll_)); 2430 .WillOnce(testing::Return(scroll_result_did_scroll_));
2435 Animate(time); 2431 Animate(time);
2436 last_animate_time = time; 2432 last_animate_time = time;
2437 2433
2438 VERIFY_AND_RESET_MOCKS(); 2434 VERIFY_AND_RESET_MOCKS();
2439 2435
2440 // GestureFlingCancel should terminate the fling if no boosting gestures are 2436 // GestureFlingCancel should terminate the fling if no boosting gestures are
2441 // received within the timeout window. 2437 // received within the timeout window.
2442 2438
2443 time += dt; 2439 time += dt;
2444 gesture_.timeStampSeconds = InSecondsF(time); 2440 gesture_.setTimeStampSeconds(InSecondsF(time));
2445 gesture_.type = WebInputEvent::GestureFlingCancel; 2441 gesture_.setType(WebInputEvent::GestureFlingCancel);
2446 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 2442 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
2447 2443
2448 VERIFY_AND_RESET_MOCKS(); 2444 VERIFY_AND_RESET_MOCKS();
2449 2445
2450 time += base::TimeDelta::FromMilliseconds(100); 2446 time += base::TimeDelta::FromMilliseconds(100);
2451 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 2447 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
2452 Animate(time); 2448 Animate(time);
2453 2449
2454 VERIFY_AND_RESET_MOCKS(); 2450 VERIFY_AND_RESET_MOCKS();
2455 } 2451 }
(...skipping 14 matching lines...) Expand all
2470 // If the GestureScrollBegin targets a different layer, the fling should be 2466 // If the GestureScrollBegin targets a different layer, the fling should be
2471 // cancelled and the scroll should be handled as usual. 2467 // cancelled and the scroll should be handled as usual.
2472 EXPECT_CALL(mock_input_handler_, 2468 EXPECT_CALL(mock_input_handler_,
2473 IsCurrentlyScrollingLayerAt(testing::_, testing::_)) 2469 IsCurrentlyScrollingLayerAt(testing::_, testing::_))
2474 .WillOnce(testing::Return(false)); 2470 .WillOnce(testing::Return(false));
2475 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 2471 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
2476 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 2472 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
2477 .WillOnce(testing::Return(kImplThreadScrollState)); 2473 .WillOnce(testing::Return(kImplThreadScrollState));
2478 2474
2479 time += dt; 2475 time += dt;
2480 gesture_.timeStampSeconds = InSecondsF(time); 2476 gesture_.setTimeStampSeconds(InSecondsF(time));
2481 gesture_.type = WebInputEvent::GestureScrollBegin; 2477 gesture_.setType(WebInputEvent::GestureScrollBegin);
2482 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 2478 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
2483 2479
2484 VERIFY_AND_RESET_MOCKS(); 2480 VERIFY_AND_RESET_MOCKS();
2485 } 2481 }
2486 2482
2487 TEST_P(InputHandlerProxyTest, NoFlingBoostIfScrollDelayed) { 2483 TEST_P(InputHandlerProxyTest, NoFlingBoostIfScrollDelayed) {
2488 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); 2484 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10);
2489 base::TimeTicks time = base::TimeTicks() + dt; 2485 base::TimeTicks time = base::TimeTicks() + dt;
2490 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); 2486 WebFloatPoint fling_delta = WebFloatPoint(1000, 0);
2491 WebPoint fling_point = WebPoint(7, 13); 2487 WebPoint fling_point = WebPoint(7, 13);
2492 StartFling( 2488 StartFling(
2493 time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point); 2489 time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point);
2494 2490
2495 // Cancel the fling. The fling cancellation should be deferred to allow 2491 // Cancel the fling. The fling cancellation should be deferred to allow
2496 // fling boosting events to arrive. 2492 // fling boosting events to arrive.
2497 time += dt; 2493 time += dt;
2498 CancelFling(time); 2494 CancelFling(time);
2499 2495
2500 // The GestureScrollBegin should be swallowed by the fling if it hits the same 2496 // The GestureScrollBegin should be swallowed by the fling if it hits the same
2501 // scrolling layer. 2497 // scrolling layer.
2502 EXPECT_CALL(mock_input_handler_, 2498 EXPECT_CALL(mock_input_handler_,
2503 IsCurrentlyScrollingLayerAt(testing::_, testing::_)) 2499 IsCurrentlyScrollingLayerAt(testing::_, testing::_))
2504 .WillOnce(testing::Return(true)); 2500 .WillOnce(testing::Return(true));
2505 2501
2506 time += dt; 2502 time += dt;
2507 gesture_.timeStampSeconds = InSecondsF(time); 2503 gesture_.setTimeStampSeconds(InSecondsF(time));
2508 gesture_.type = WebInputEvent::GestureScrollBegin; 2504 gesture_.setType(WebInputEvent::GestureScrollBegin);
2509 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 2505 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
2510 2506
2511 VERIFY_AND_RESET_MOCKS(); 2507 VERIFY_AND_RESET_MOCKS();
2512 2508
2513 // If no GestureScrollUpdate or GestureFlingStart is received within the 2509 // If no GestureScrollUpdate or GestureFlingStart is received within the
2514 // timeout window, the fling should be cancelled and scrolling should resume. 2510 // timeout window, the fling should be cancelled and scrolling should resume.
2515 time += base::TimeDelta::FromMilliseconds(100); 2511 time += base::TimeDelta::FromMilliseconds(100);
2516 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 2512 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
2517 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 2513 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
2518 .WillOnce(testing::Return(kImplThreadScrollState)); 2514 .WillOnce(testing::Return(kImplThreadScrollState));
(...skipping 22 matching lines...) Expand all
2541 time += base::TimeDelta::FromMilliseconds(100); 2537 time += base::TimeDelta::FromMilliseconds(100);
2542 CancelFling(time); 2538 CancelFling(time);
2543 2539
2544 // The GestureScrollBegin should be swallowed by the fling if it hits the same 2540 // The GestureScrollBegin should be swallowed by the fling if it hits the same
2545 // scrolling layer. 2541 // scrolling layer.
2546 EXPECT_CALL(mock_input_handler_, 2542 EXPECT_CALL(mock_input_handler_,
2547 IsCurrentlyScrollingLayerAt(testing::_, testing::_)) 2543 IsCurrentlyScrollingLayerAt(testing::_, testing::_))
2548 .WillOnce(testing::Return(true)); 2544 .WillOnce(testing::Return(true));
2549 2545
2550 time += dt; 2546 time += dt;
2551 gesture_.timeStampSeconds = InSecondsF(time); 2547 gesture_.setTimeStampSeconds(InSecondsF(time));
2552 gesture_.type = WebInputEvent::GestureScrollBegin; 2548 gesture_.setType(WebInputEvent::GestureScrollBegin);
2553 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 2549 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
2554 2550
2555 VERIFY_AND_RESET_MOCKS(); 2551 VERIFY_AND_RESET_MOCKS();
2556 2552
2557 // Should exit scroll bosting on GestureScrollUpdate due to long delay 2553 // Should exit scroll bosting on GestureScrollUpdate due to long delay
2558 // since last animate. Cancel old fling and start new scroll. 2554 // since last animate. Cancel old fling and start new scroll.
2559 gesture_.type = WebInputEvent::GestureScrollUpdate; 2555 gesture_.setType(WebInputEvent::GestureScrollUpdate);
2560 gesture_.data.scrollUpdate.deltaY = -40; 2556 gesture_.data.scrollUpdate.deltaY = -40;
2561 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 2557 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
2562 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 2558 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
2563 .WillOnce(testing::Return(kImplThreadScrollState)); 2559 .WillOnce(testing::Return(kImplThreadScrollState));
2564 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)) 2560 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_))
2565 .WillOnce(testing::Return(scroll_result_did_scroll_)); 2561 .WillOnce(testing::Return(scroll_result_did_scroll_));
2566 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 2562 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
2567 2563
2568 VERIFY_AND_RESET_MOCKS(); 2564 VERIFY_AND_RESET_MOCKS();
2569 } 2565 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2622 time += dt; 2618 time += dt;
2623 CancelFling(time); 2619 CancelFling(time);
2624 2620
2625 // The GestureScrollBegin should be swallowed by the fling if it hits the same 2621 // The GestureScrollBegin should be swallowed by the fling if it hits the same
2626 // scrolling layer. 2622 // scrolling layer.
2627 EXPECT_CALL(mock_input_handler_, 2623 EXPECT_CALL(mock_input_handler_,
2628 IsCurrentlyScrollingLayerAt(testing::_, testing::_)) 2624 IsCurrentlyScrollingLayerAt(testing::_, testing::_))
2629 .WillOnce(testing::Return(true)); 2625 .WillOnce(testing::Return(true));
2630 2626
2631 time += dt; 2627 time += dt;
2632 gesture_.timeStampSeconds = InSecondsF(time); 2628 gesture_.setTimeStampSeconds(InSecondsF(time));
2633 gesture_.type = WebInputEvent::GestureScrollBegin; 2629 gesture_.setType(WebInputEvent::GestureScrollBegin);
2634 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 2630 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
2635 2631
2636 VERIFY_AND_RESET_MOCKS(); 2632 VERIFY_AND_RESET_MOCKS();
2637 2633
2638 // If the GestureScrollUpdate is in a different direction than the fling, 2634 // If the GestureScrollUpdate is in a different direction than the fling,
2639 // the fling should be cancelled and scrolling should resume. 2635 // the fling should be cancelled and scrolling should resume.
2640 time += dt; 2636 time += dt;
2641 gesture_.timeStampSeconds = InSecondsF(time); 2637 gesture_.setTimeStampSeconds(InSecondsF(time));
2642 gesture_.type = WebInputEvent::GestureScrollUpdate; 2638 gesture_.setType(WebInputEvent::GestureScrollUpdate);
2643 gesture_.data.scrollUpdate.deltaX = -fling_delta.x; 2639 gesture_.data.scrollUpdate.deltaX = -fling_delta.x;
2644 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 2640 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
2645 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 2641 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
2646 .WillOnce(testing::Return(kImplThreadScrollState)); 2642 .WillOnce(testing::Return(kImplThreadScrollState));
2647 EXPECT_CALL(mock_input_handler_, 2643 EXPECT_CALL(mock_input_handler_,
2648 ScrollBy(testing::Property(&cc::ScrollState::delta_x, 2644 ScrollBy(testing::Property(&cc::ScrollState::delta_x,
2649 testing::Eq(fling_delta.x)))) 2645 testing::Eq(fling_delta.x))))
2650 .WillOnce(testing::Return(scroll_result_did_scroll_)); 2646 .WillOnce(testing::Return(scroll_result_did_scroll_));
2651 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 2647 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
2652 2648
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2721 StartFling( 2717 StartFling(
2722 time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point); 2718 time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point);
2723 2719
2724 // Now cancel the fling. The fling cancellation should be deferred to allow 2720 // Now cancel the fling. The fling cancellation should be deferred to allow
2725 // fling boosting events to arrive. 2721 // fling boosting events to arrive.
2726 time += dt; 2722 time += dt;
2727 CancelFling(time); 2723 CancelFling(time);
2728 2724
2729 // The GestureScrollBegin should be swallowed by the fling. 2725 // The GestureScrollBegin should be swallowed by the fling.
2730 time += dt; 2726 time += dt;
2731 gesture_.timeStampSeconds = InSecondsF(time); 2727 gesture_.setTimeStampSeconds(InSecondsF(time));
2732 gesture_.type = WebInputEvent::GestureScrollBegin; 2728 gesture_.setType(WebInputEvent::GestureScrollBegin);
2733 EXPECT_CALL(mock_input_handler_, 2729 EXPECT_CALL(mock_input_handler_,
2734 IsCurrentlyScrollingLayerAt(testing::_, testing::_)) 2730 IsCurrentlyScrollingLayerAt(testing::_, testing::_))
2735 .WillOnce(testing::Return(true)); 2731 .WillOnce(testing::Return(true));
2736 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 2732 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
2737 2733
2738 VERIFY_AND_RESET_MOCKS(); 2734 VERIFY_AND_RESET_MOCKS();
2739 2735
2740 // Now animate the fling to completion (in this case, the fling should 2736 // Now animate the fling to completion (in this case, the fling should
2741 // terminate because the input handler reports a failed scroll). As the fling 2737 // terminate because the input handler reports a failed scroll). As the fling
2742 // was cancelled during an active scroll sequence, a synthetic 2738 // was cancelled during an active scroll sequence, a synthetic
2743 // GestureScrollBegin should be processed, resuming the scroll. 2739 // GestureScrollBegin should be processed, resuming the scroll.
2744 time += dt; 2740 time += dt;
2745 float expected_delta = 2741 float expected_delta =
2746 (time - last_animate_time).InSecondsF() * -fling_delta.x; 2742 (time - last_animate_time).InSecondsF() * -fling_delta.x;
2747 EXPECT_CALL(mock_input_handler_, 2743 EXPECT_CALL(mock_input_handler_,
2748 ScrollBy(testing::Property(&cc::ScrollState::delta_x, 2744 ScrollBy(testing::Property(&cc::ScrollState::delta_x,
2749 testing::Eq(expected_delta)))) 2745 testing::Eq(expected_delta))))
2750 .WillOnce(testing::Return(scroll_result_did_not_scroll_)); 2746 .WillOnce(testing::Return(scroll_result_did_not_scroll_));
2751 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 2747 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
2752 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 2748 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
2753 .WillOnce(testing::Return(kImplThreadScrollState)); 2749 .WillOnce(testing::Return(kImplThreadScrollState));
2754 Animate(time); 2750 Animate(time);
2755 2751
2756 VERIFY_AND_RESET_MOCKS(); 2752 VERIFY_AND_RESET_MOCKS();
2757 2753
2758 // Subsequent GestureScrollUpdates after the cancelled, boosted fling should 2754 // Subsequent GestureScrollUpdates after the cancelled, boosted fling should
2759 // cause scrolling as usual. 2755 // cause scrolling as usual.
2760 time += dt; 2756 time += dt;
2761 expected_delta = 7.3f; 2757 expected_delta = 7.3f;
2762 gesture_.timeStampSeconds = InSecondsF(time); 2758 gesture_.setTimeStampSeconds(InSecondsF(time));
2763 gesture_.type = WebInputEvent::GestureScrollUpdate; 2759 gesture_.setType(WebInputEvent::GestureScrollUpdate);
2764 gesture_.data.scrollUpdate.deltaX = -expected_delta; 2760 gesture_.data.scrollUpdate.deltaX = -expected_delta;
2765 EXPECT_CALL(mock_input_handler_, 2761 EXPECT_CALL(mock_input_handler_,
2766 ScrollBy(testing::Property(&cc::ScrollState::delta_x, 2762 ScrollBy(testing::Property(&cc::ScrollState::delta_x,
2767 testing::Eq(expected_delta)))) 2763 testing::Eq(expected_delta))))
2768 .WillOnce(testing::Return(scroll_result_did_scroll_)); 2764 .WillOnce(testing::Return(scroll_result_did_scroll_));
2769 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 2765 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
2770 2766
2771 VERIFY_AND_RESET_MOCKS(); 2767 VERIFY_AND_RESET_MOCKS();
2772 2768
2773 // GestureScrollEnd should terminate the resumed scroll properly. 2769 // GestureScrollEnd should terminate the resumed scroll properly.
2774 time += dt; 2770 time += dt;
2775 gesture_.timeStampSeconds = InSecondsF(time); 2771 gesture_.setTimeStampSeconds(InSecondsF(time));
2776 gesture_.type = WebInputEvent::GestureScrollEnd; 2772 gesture_.setType(WebInputEvent::GestureScrollEnd);
2777 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 2773 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
2778 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 2774 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
2779 2775
2780 VERIFY_AND_RESET_MOCKS(); 2776 VERIFY_AND_RESET_MOCKS();
2781 } 2777 }
2782 2778
2783 TEST_P(InputHandlerProxyTest, DidReceiveInputEvent_ForFling) { 2779 TEST_P(InputHandlerProxyTest, DidReceiveInputEvent_ForFling) {
2784 testing::StrictMock<MockInputHandlerProxyClientWithDidAnimateForInput> 2780 testing::StrictMock<MockInputHandlerProxyClientWithDidAnimateForInput>
2785 mock_client; 2781 mock_client;
2786 input_handler_.reset( 2782 input_handler_.reset(
2787 new TestInputHandlerProxy( 2783 new TestInputHandlerProxy(
2788 &mock_input_handler_, &mock_client)); 2784 &mock_input_handler_, &mock_client));
2789 if (install_synchronous_handler_) { 2785 if (install_synchronous_handler_) {
2790 EXPECT_CALL(mock_input_handler_, RequestUpdateForSynchronousInputHandler()) 2786 EXPECT_CALL(mock_input_handler_, RequestUpdateForSynchronousInputHandler())
2791 .Times(1); 2787 .Times(1);
2792 input_handler_->SetOnlySynchronouslyAnimateRootFlings( 2788 input_handler_->SetOnlySynchronouslyAnimateRootFlings(
2793 &mock_synchronous_input_handler_); 2789 &mock_synchronous_input_handler_);
2794 } 2790 }
2795 mock_input_handler_.set_is_scrolling_root(synchronous_root_scroll_); 2791 mock_input_handler_.set_is_scrolling_root(synchronous_root_scroll_);
2796 2792
2797 gesture_.type = WebInputEvent::GestureFlingStart; 2793 gesture_.setType(WebInputEvent::GestureFlingStart);
2798 WebFloatPoint fling_delta = WebFloatPoint(100, 100); 2794 WebFloatPoint fling_delta = WebFloatPoint(100, 100);
2799 gesture_.data.flingStart.velocityX = fling_delta.x; 2795 gesture_.data.flingStart.velocityX = fling_delta.x;
2800 gesture_.data.flingStart.velocityY = fling_delta.y; 2796 gesture_.data.flingStart.velocityY = fling_delta.y;
2801 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 2797 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
2802 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 2798 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
2803 .WillOnce(testing::Return(kImplThreadScrollState)); 2799 .WillOnce(testing::Return(kImplThreadScrollState));
2804 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 2800 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
2805 EXPECT_EQ(InputHandlerProxy::DID_HANDLE, 2801 EXPECT_EQ(InputHandlerProxy::DID_HANDLE,
2806 input_handler_->HandleInputEvent(gesture_)); 2802 input_handler_->HandleInputEvent(gesture_));
2807 VERIFY_AND_RESET_MOCKS(); 2803 VERIFY_AND_RESET_MOCKS();
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
3136 EXPECT_EQ(WebInputEvent::GesturePinchEnd, event_queue()[6]->event().type); 3132 EXPECT_EQ(WebInputEvent::GesturePinchEnd, event_queue()[6]->event().type);
3137 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 3133 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
3138 } 3134 }
3139 3135
3140 INSTANTIATE_TEST_CASE_P(AnimateInput, 3136 INSTANTIATE_TEST_CASE_P(AnimateInput,
3141 InputHandlerProxyTest, 3137 InputHandlerProxyTest,
3142 testing::ValuesIn(test_types)); 3138 testing::ValuesIn(test_types));
3143 3139
3144 } // namespace test 3140 } // namespace test
3145 } // namespace ui 3141 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698