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