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 "content/renderer/input/input_handler_proxy.h" | 5 #include "content/renderer/input/input_handler_proxy.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "cc/trees/swap_promise_monitor.h" | 9 #include "cc/trees/swap_promise_monitor.h" |
10 #include "content/common/input/did_overscroll_params.h" | 10 #include "content/common/input/did_overscroll_params.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 class MockInputHandler : public cc::InputHandler { | 75 class MockInputHandler : public cc::InputHandler { |
76 public: | 76 public: |
77 MockInputHandler() {} | 77 MockInputHandler() {} |
78 ~MockInputHandler() override {} | 78 ~MockInputHandler() override {} |
79 | 79 |
80 MOCK_METHOD0(PinchGestureBegin, void()); | 80 MOCK_METHOD0(PinchGestureBegin, void()); |
81 MOCK_METHOD2(PinchGestureUpdate, | 81 MOCK_METHOD2(PinchGestureUpdate, |
82 void(float magnify_delta, const gfx::Point& anchor)); | 82 void(float magnify_delta, const gfx::Point& anchor)); |
83 MOCK_METHOD0(PinchGestureEnd, void()); | 83 MOCK_METHOD0(PinchGestureEnd, void()); |
84 | 84 |
85 MOCK_METHOD0(SetNeedsAnimate, void()); | 85 MOCK_METHOD0(SetNeedsAnimateInput, void()); |
86 | 86 |
87 MOCK_METHOD2(ScrollBegin, | 87 MOCK_METHOD2(ScrollBegin, |
88 ScrollStatus(const gfx::Point& viewport_point, | 88 ScrollStatus(const gfx::Point& viewport_point, |
89 cc::InputHandler::ScrollInputType type)); | 89 cc::InputHandler::ScrollInputType type)); |
90 MOCK_METHOD2(ScrollAnimated, | 90 MOCK_METHOD2(ScrollAnimated, |
91 ScrollStatus(const gfx::Point& viewport_point, | 91 ScrollStatus(const gfx::Point& viewport_point, |
92 const gfx::Vector2dF& scroll_delta)); | 92 const gfx::Vector2dF& scroll_delta)); |
93 MOCK_METHOD2(ScrollBy, | 93 MOCK_METHOD2(ScrollBy, |
94 cc::InputHandlerScrollResult( | 94 cc::InputHandlerScrollResult( |
95 const gfx::Point& viewport_point, | 95 const gfx::Point& viewport_point, |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); | 242 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
243 gesture_.type = WebInputEvent::GestureScrollBegin; | 243 gesture_.type = WebInputEvent::GestureScrollBegin; |
244 gesture_.sourceDevice = source_device; | 244 gesture_.sourceDevice = source_device; |
245 EXPECT_EQ(expected_disposition_, | 245 EXPECT_EQ(expected_disposition_, |
246 input_handler_->HandleInputEvent(gesture_)); | 246 input_handler_->HandleInputEvent(gesture_)); |
247 | 247 |
248 VERIFY_AND_RESET_MOCKS(); | 248 VERIFY_AND_RESET_MOCKS(); |
249 | 249 |
250 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 250 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
251 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); | 251 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
252 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 252 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
253 | 253 |
254 gesture_ = | 254 gesture_ = |
255 CreateFling(timestamp, source_device, velocity, position, position, 0); | 255 CreateFling(timestamp, source_device, velocity, position, position, 0); |
256 EXPECT_EQ(expected_disposition_, | 256 EXPECT_EQ(expected_disposition_, |
257 input_handler_->HandleInputEvent(gesture_)); | 257 input_handler_->HandleInputEvent(gesture_)); |
258 | 258 |
259 VERIFY_AND_RESET_MOCKS(); | 259 VERIFY_AND_RESET_MOCKS(); |
260 } | 260 } |
261 | 261 |
262 void CancelFling(base::TimeTicks timestamp) { | 262 void CancelFling(base::TimeTicks timestamp) { |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 } | 544 } |
545 | 545 |
546 TEST_F(InputHandlerProxyTest, GestureFlingStartedTouchpad) { | 546 TEST_F(InputHandlerProxyTest, GestureFlingStartedTouchpad) { |
547 // We shouldn't send any events to the widget for this gesture. | 547 // We shouldn't send any events to the widget for this gesture. |
548 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 548 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
549 VERIFY_AND_RESET_MOCKS(); | 549 VERIFY_AND_RESET_MOCKS(); |
550 | 550 |
551 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 551 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
552 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); | 552 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
553 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 553 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
554 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 554 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
555 | 555 |
556 gesture_.type = WebInputEvent::GestureFlingStart; | 556 gesture_.type = WebInputEvent::GestureFlingStart; |
557 gesture_.data.flingStart.velocityX = 10; | 557 gesture_.data.flingStart.velocityX = 10; |
558 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; | 558 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; |
559 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 559 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
560 | 560 |
561 VERIFY_AND_RESET_MOCKS(); | 561 VERIFY_AND_RESET_MOCKS(); |
562 | 562 |
563 // Verify that a GestureFlingCancel during an animation cancels it. | 563 // Verify that a GestureFlingCancel during an animation cancels it. |
564 gesture_.type = WebInputEvent::GestureFlingCancel; | 564 gesture_.type = WebInputEvent::GestureFlingCancel; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 WebPoint fling_point = WebPoint(7, 13); | 624 WebPoint fling_point = WebPoint(7, 13); |
625 WebPoint fling_global_point = WebPoint(17, 23); | 625 WebPoint fling_global_point = WebPoint(17, 23); |
626 // Note that for trackpad, wheel events with the Control modifier are | 626 // Note that for trackpad, wheel events with the Control modifier are |
627 // special (reserved for zoom), so don't set that here. | 627 // special (reserved for zoom), so don't set that here. |
628 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; | 628 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; |
629 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, | 629 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, |
630 fling_delta, | 630 fling_delta, |
631 fling_point, | 631 fling_point, |
632 fling_global_point, | 632 fling_global_point, |
633 modifiers); | 633 modifiers); |
634 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 634 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
635 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 635 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
636 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); | 636 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
637 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 637 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
638 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 638 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
639 | 639 |
640 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 640 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
641 // The first animate call should let us pick up an animation start time, but | 641 // The first animate call should let us pick up an animation start time, but |
642 // we shouldn't actually move anywhere just yet. The first frame after the | 642 // we shouldn't actually move anywhere just yet. The first frame after the |
643 // fling start will typically include the last scroll from the gesture that | 643 // fling start will typically include the last scroll from the gesture that |
644 // lead to the scroll (either wheel or gesture scroll), so there should be no | 644 // lead to the scroll (either wheel or gesture scroll), so there should be no |
645 // visible hitch. | 645 // visible hitch. |
646 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 646 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
647 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 647 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
648 .Times(0); | 648 .Times(0); |
649 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); | 649 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); |
650 input_handler_->Animate(time); | 650 input_handler_->Animate(time); |
651 | 651 |
652 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 652 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
653 | 653 |
654 // The second call should start scrolling in the -X direction. | 654 // The second call should start scrolling in the -X direction. |
655 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 655 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
656 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 656 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
657 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); | 657 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
658 EXPECT_CALL(mock_input_handler_, | 658 EXPECT_CALL(mock_input_handler_, |
659 ScrollBy(testing::_, | 659 ScrollBy(testing::_, |
660 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) | 660 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) |
661 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 661 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
662 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 662 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
663 time += base::TimeDelta::FromMilliseconds(100); | 663 time += base::TimeDelta::FromMilliseconds(100); |
664 input_handler_->Animate(time); | 664 input_handler_->Animate(time); |
665 | 665 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 testing::Field(&WebSize::width, testing::Gt(0)))))); | 698 testing::Field(&WebSize::width, testing::Gt(0)))))); |
699 time += base::TimeDelta::FromMilliseconds(100); | 699 time += base::TimeDelta::FromMilliseconds(100); |
700 input_handler_->Animate(time); | 700 input_handler_->Animate(time); |
701 | 701 |
702 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 702 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
703 testing::Mock::VerifyAndClearExpectations(&mock_client_); | 703 testing::Mock::VerifyAndClearExpectations(&mock_client_); |
704 | 704 |
705 // Since we've aborted the fling, the next animation should be a no-op and | 705 // Since we've aborted the fling, the next animation should be a no-op and |
706 // should not result in another | 706 // should not result in another |
707 // frame being requested. | 707 // frame being requested. |
708 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()).Times(0); | 708 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(0); |
709 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 709 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
710 .Times(0); | 710 .Times(0); |
711 time += base::TimeDelta::FromMilliseconds(100); | 711 time += base::TimeDelta::FromMilliseconds(100); |
712 input_handler_->Animate(time); | 712 input_handler_->Animate(time); |
713 | 713 |
714 // Since we've transferred the fling to the main thread, we need to pass the | 714 // Since we've transferred the fling to the main thread, we need to pass the |
715 // next GestureFlingCancel to the main | 715 // next GestureFlingCancel to the main |
716 // thread as well. | 716 // thread as well. |
717 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; | 717 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; |
718 gesture_.type = WebInputEvent::GestureFlingCancel; | 718 gesture_.type = WebInputEvent::GestureFlingCancel; |
(...skipping 10 matching lines...) Expand all Loading... |
729 WebPoint fling_point = WebPoint(7, 13); | 729 WebPoint fling_point = WebPoint(7, 13); |
730 WebPoint fling_global_point = WebPoint(17, 23); | 730 WebPoint fling_global_point = WebPoint(17, 23); |
731 // Note that for trackpad, wheel events with the Control modifier are | 731 // Note that for trackpad, wheel events with the Control modifier are |
732 // special (reserved for zoom), so don't set that here. | 732 // special (reserved for zoom), so don't set that here. |
733 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; | 733 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; |
734 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, | 734 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, |
735 fling_delta, | 735 fling_delta, |
736 fling_point, | 736 fling_point, |
737 fling_global_point, | 737 fling_global_point, |
738 modifiers); | 738 modifiers); |
739 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 739 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
740 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 740 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
741 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); | 741 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
742 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 742 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
743 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 743 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
744 | 744 |
745 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 745 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
746 | 746 |
747 // Start the fling animation at time 10. This shouldn't actually scroll, just | 747 // Start the fling animation at time 10. This shouldn't actually scroll, just |
748 // establish a start time. | 748 // establish a start time. |
749 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 749 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
750 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 750 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
751 .Times(0); | 751 .Times(0); |
752 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); | 752 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); |
753 input_handler_->Animate(time); | 753 input_handler_->Animate(time); |
754 | 754 |
755 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 755 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
756 | 756 |
757 // The second call should start scrolling in the -X direction. | 757 // The second call should start scrolling in the -X direction. |
758 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 758 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
759 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 759 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
760 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); | 760 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
761 EXPECT_CALL(mock_input_handler_, | 761 EXPECT_CALL(mock_input_handler_, |
762 ScrollBy(testing::_, | 762 ScrollBy(testing::_, |
763 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) | 763 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) |
764 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 764 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
765 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 765 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
766 time += base::TimeDelta::FromMilliseconds(100); | 766 time += base::TimeDelta::FromMilliseconds(100); |
767 input_handler_->Animate(time); | 767 input_handler_->Animate(time); |
768 | 768 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 testing::Field(&WebSize::width, testing::Gt(0)))))); | 802 testing::Field(&WebSize::width, testing::Gt(0)))))); |
803 time += base::TimeDelta::FromMilliseconds(100); | 803 time += base::TimeDelta::FromMilliseconds(100); |
804 input_handler_->Animate(time); | 804 input_handler_->Animate(time); |
805 | 805 |
806 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 806 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
807 testing::Mock::VerifyAndClearExpectations(&mock_client_); | 807 testing::Mock::VerifyAndClearExpectations(&mock_client_); |
808 | 808 |
809 // Since we've aborted the fling, the next animation should be a no-op and | 809 // Since we've aborted the fling, the next animation should be a no-op and |
810 // should not result in another | 810 // should not result in another |
811 // frame being requested. | 811 // frame being requested. |
812 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()).Times(0); | 812 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(0); |
813 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 813 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
814 .Times(0); | 814 .Times(0); |
815 time += base::TimeDelta::FromMilliseconds(100); | 815 time += base::TimeDelta::FromMilliseconds(100); |
816 input_handler_->Animate(time); | 816 input_handler_->Animate(time); |
817 | 817 |
818 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 818 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
819 | 819 |
820 // Since we've transferred the fling to the main thread, we need to pass the | 820 // Since we've transferred the fling to the main thread, we need to pass the |
821 // next GestureFlingCancel to the main | 821 // next GestureFlingCancel to the main |
822 // thread as well. | 822 // thread as well. |
823 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; | 823 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; |
824 gesture_.type = WebInputEvent::GestureFlingCancel; | 824 gesture_.type = WebInputEvent::GestureFlingCancel; |
825 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 825 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
826 | 826 |
827 VERIFY_AND_RESET_MOCKS(); | 827 VERIFY_AND_RESET_MOCKS(); |
828 input_handler_->MainThreadHasStoppedFlinging(); | 828 input_handler_->MainThreadHasStoppedFlinging(); |
829 | 829 |
830 // Start a second gesture fling, this time in the +Y direction with no X. | 830 // Start a second gesture fling, this time in the +Y direction with no X. |
831 fling_delta = WebFloatPoint(0, -1000); | 831 fling_delta = WebFloatPoint(0, -1000); |
832 fling_point = WebPoint(95, 87); | 832 fling_point = WebPoint(95, 87); |
833 fling_global_point = WebPoint(32, 71); | 833 fling_global_point = WebPoint(32, 71); |
834 modifiers = WebInputEvent::AltKey; | 834 modifiers = WebInputEvent::AltKey; |
835 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, | 835 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, |
836 fling_delta, | 836 fling_delta, |
837 fling_point, | 837 fling_point, |
838 fling_global_point, | 838 fling_global_point, |
839 modifiers); | 839 modifiers); |
840 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 840 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
841 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 841 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
842 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); | 842 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
843 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 843 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
844 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 844 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
845 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 845 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
846 | 846 |
847 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 847 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
848 | 848 |
849 // Start the second fling animation at time 30. | 849 // Start the second fling animation at time 30. |
850 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 850 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
851 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 851 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
852 .Times(0); | 852 .Times(0); |
853 time = base::TimeTicks() + base::TimeDelta::FromSeconds(30); | 853 time = base::TimeTicks() + base::TimeDelta::FromSeconds(30); |
854 input_handler_->Animate(time); | 854 input_handler_->Animate(time); |
855 | 855 |
856 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 856 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
857 | 857 |
858 // Tick the second fling once normally. | 858 // Tick the second fling once normally. |
859 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 859 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
860 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 860 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
861 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); | 861 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
862 EXPECT_CALL(mock_input_handler_, | 862 EXPECT_CALL(mock_input_handler_, |
863 ScrollBy(testing::_, | 863 ScrollBy(testing::_, |
864 testing::Property(&gfx::Vector2dF::y, testing::Gt(0)))) | 864 testing::Property(&gfx::Vector2dF::y, testing::Gt(0)))) |
865 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 865 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
866 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 866 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
867 time += base::TimeDelta::FromMilliseconds(100); | 867 time += base::TimeDelta::FromMilliseconds(100); |
868 input_handler_->Animate(time); | 868 input_handler_->Animate(time); |
869 | 869 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 904 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
905 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); | 905 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
906 gesture_.type = WebInputEvent::GestureScrollBegin; | 906 gesture_.type = WebInputEvent::GestureScrollBegin; |
907 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; | 907 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; |
908 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 908 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
909 | 909 |
910 VERIFY_AND_RESET_MOCKS(); | 910 VERIFY_AND_RESET_MOCKS(); |
911 | 911 |
912 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 912 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
913 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); | 913 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
914 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 914 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
915 | 915 |
916 gesture_.type = WebInputEvent::GestureFlingStart; | 916 gesture_.type = WebInputEvent::GestureFlingStart; |
917 gesture_.data.flingStart.velocityX = 10; | 917 gesture_.data.flingStart.velocityX = 10; |
918 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; | 918 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; |
919 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 919 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
920 | 920 |
921 VERIFY_AND_RESET_MOCKS(); | 921 VERIFY_AND_RESET_MOCKS(); |
922 | 922 |
923 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 923 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
924 | 924 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 WebFloatPoint fling_delta = WebFloatPoint(100, 0); | 1010 WebFloatPoint fling_delta = WebFloatPoint(100, 0); |
1011 WebPoint fling_point = WebPoint(7, 13); | 1011 WebPoint fling_point = WebPoint(7, 13); |
1012 WebPoint fling_global_point = WebPoint(17, 23); | 1012 WebPoint fling_global_point = WebPoint(17, 23); |
1013 // Note that for touchscreen the control modifier is not special. | 1013 // Note that for touchscreen the control modifier is not special. |
1014 int modifiers = WebInputEvent::ControlKey; | 1014 int modifiers = WebInputEvent::ControlKey; |
1015 gesture_ = CreateFling(blink::WebGestureDeviceTouchscreen, | 1015 gesture_ = CreateFling(blink::WebGestureDeviceTouchscreen, |
1016 fling_delta, | 1016 fling_delta, |
1017 fling_point, | 1017 fling_point, |
1018 fling_global_point, | 1018 fling_global_point, |
1019 modifiers); | 1019 modifiers); |
1020 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1020 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1021 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 1021 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
1022 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); | 1022 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
1023 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1023 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1024 | 1024 |
1025 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1025 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1026 // The first animate call should let us pick up an animation start time, but | 1026 // The first animate call should let us pick up an animation start time, but |
1027 // we shouldn't actually move anywhere just yet. The first frame after the | 1027 // we shouldn't actually move anywhere just yet. The first frame after the |
1028 // fling start will typically include the last scroll from the gesture that | 1028 // fling start will typically include the last scroll from the gesture that |
1029 // lead to the scroll (either wheel or gesture scroll), so there should be no | 1029 // lead to the scroll (either wheel or gesture scroll), so there should be no |
1030 // visible hitch. | 1030 // visible hitch. |
1031 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1031 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1032 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); | 1032 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); |
1033 input_handler_->Animate(time); | 1033 input_handler_->Animate(time); |
1034 | 1034 |
1035 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1035 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1036 | 1036 |
1037 // The second call should start scrolling in the -X direction. | 1037 // The second call should start scrolling in the -X direction. |
1038 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1038 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1039 EXPECT_CALL(mock_input_handler_, | 1039 EXPECT_CALL(mock_input_handler_, |
1040 ScrollBy(testing::_, | 1040 ScrollBy(testing::_, |
1041 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) | 1041 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) |
1042 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 1042 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
1043 time += base::TimeDelta::FromMilliseconds(100); | 1043 time += base::TimeDelta::FromMilliseconds(100); |
1044 input_handler_->Animate(time); | 1044 input_handler_->Animate(time); |
1045 | 1045 |
1046 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1046 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1047 | 1047 |
1048 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 1048 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
(...skipping 22 matching lines...) Expand all Loading... |
1071 WebFloatPoint fling_delta = WebFloatPoint(100, 0); | 1071 WebFloatPoint fling_delta = WebFloatPoint(100, 0); |
1072 WebPoint fling_point = WebPoint(7, 13); | 1072 WebPoint fling_point = WebPoint(7, 13); |
1073 WebPoint fling_global_point = WebPoint(17, 23); | 1073 WebPoint fling_global_point = WebPoint(17, 23); |
1074 int modifiers = WebInputEvent::ControlKey; | 1074 int modifiers = WebInputEvent::ControlKey; |
1075 gesture_ = CreateFling(time, | 1075 gesture_ = CreateFling(time, |
1076 blink::WebGestureDeviceTouchscreen, | 1076 blink::WebGestureDeviceTouchscreen, |
1077 fling_delta, | 1077 fling_delta, |
1078 fling_point, | 1078 fling_point, |
1079 fling_global_point, | 1079 fling_global_point, |
1080 modifiers); | 1080 modifiers); |
1081 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1081 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1082 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 1082 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
1083 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); | 1083 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
1084 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1084 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1085 | 1085 |
1086 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1086 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1087 // With a valid time stamp, the first animate call should skip start time | 1087 // With a valid time stamp, the first animate call should skip start time |
1088 // initialization and immediately begin scroll update production. This reduces | 1088 // initialization and immediately begin scroll update production. This reduces |
1089 // the likelihood of a hitch between the scroll preceding the fling and | 1089 // the likelihood of a hitch between the scroll preceding the fling and |
1090 // the first scroll generated by the fling. | 1090 // the first scroll generated by the fling. |
1091 // Scrolling should start in the -X direction. | 1091 // Scrolling should start in the -X direction. |
1092 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1092 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1093 EXPECT_CALL(mock_input_handler_, | 1093 EXPECT_CALL(mock_input_handler_, |
1094 ScrollBy(testing::_, | 1094 ScrollBy(testing::_, |
1095 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) | 1095 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) |
1096 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 1096 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
1097 time += dt; | 1097 time += dt; |
1098 input_handler_->Animate(time); | 1098 input_handler_->Animate(time); |
1099 | 1099 |
1100 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1100 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1101 | 1101 |
1102 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 1102 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
(...skipping 25 matching lines...) Expand all Loading... |
1128 int modifiers = WebInputEvent::ControlKey; | 1128 int modifiers = WebInputEvent::ControlKey; |
1129 gesture_.timeStampSeconds = start_time_offset.InSecondsF(); | 1129 gesture_.timeStampSeconds = start_time_offset.InSecondsF(); |
1130 gesture_.data.flingStart.velocityX = fling_delta.x; | 1130 gesture_.data.flingStart.velocityX = fling_delta.x; |
1131 gesture_.data.flingStart.velocityY = fling_delta.y; | 1131 gesture_.data.flingStart.velocityY = fling_delta.y; |
1132 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; | 1132 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; |
1133 gesture_.x = fling_point.x; | 1133 gesture_.x = fling_point.x; |
1134 gesture_.y = fling_point.y; | 1134 gesture_.y = fling_point.y; |
1135 gesture_.globalX = fling_global_point.x; | 1135 gesture_.globalX = fling_global_point.x; |
1136 gesture_.globalY = fling_global_point.y; | 1136 gesture_.globalY = fling_global_point.y; |
1137 gesture_.modifiers = modifiers; | 1137 gesture_.modifiers = modifiers; |
1138 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1138 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1139 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 1139 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
1140 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); | 1140 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
1141 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1141 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1142 | 1142 |
1143 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1143 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1144 // Event though a time stamp was provided for the fling event, it will be | 1144 // Event though a time stamp was provided for the fling event, it will be |
1145 // ignored as its too far in the past relative to the first animate call's | 1145 // ignored as its too far in the past relative to the first animate call's |
1146 // timestamp. | 1146 // timestamp. |
1147 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1147 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1148 base::TimeTicks time = | 1148 base::TimeTicks time = |
1149 base::TimeTicks() + start_time_offset + base::TimeDelta::FromSeconds(1); | 1149 base::TimeTicks() + start_time_offset + base::TimeDelta::FromSeconds(1); |
1150 input_handler_->Animate(time); | 1150 input_handler_->Animate(time); |
1151 | 1151 |
1152 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1152 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1153 | 1153 |
1154 // Further animation ticks should update the fling as usual. | 1154 // Further animation ticks should update the fling as usual. |
1155 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1155 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1156 EXPECT_CALL(mock_input_handler_, | 1156 EXPECT_CALL(mock_input_handler_, |
1157 ScrollBy(testing::_, | 1157 ScrollBy(testing::_, |
1158 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) | 1158 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) |
1159 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 1159 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
1160 time += base::TimeDelta::FromMilliseconds(10); | 1160 time += base::TimeDelta::FromMilliseconds(10); |
1161 input_handler_->Animate(time); | 1161 input_handler_->Animate(time); |
1162 | 1162 |
1163 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1163 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1164 | 1164 |
1165 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 1165 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
(...skipping 24 matching lines...) Expand all Loading... |
1190 // scrolling. | 1190 // scrolling. |
1191 WebFloatPoint fling_delta = WebFloatPoint(100, 0); | 1191 WebFloatPoint fling_delta = WebFloatPoint(100, 0); |
1192 WebPoint fling_point = WebPoint(7, 13); | 1192 WebPoint fling_point = WebPoint(7, 13); |
1193 WebPoint fling_global_point = WebPoint(17, 23); | 1193 WebPoint fling_global_point = WebPoint(17, 23); |
1194 int modifiers = WebInputEvent::ControlKey | WebInputEvent::AltKey; | 1194 int modifiers = WebInputEvent::ControlKey | WebInputEvent::AltKey; |
1195 gesture_ = CreateFling(blink::WebGestureDeviceTouchscreen, | 1195 gesture_ = CreateFling(blink::WebGestureDeviceTouchscreen, |
1196 fling_delta, | 1196 fling_delta, |
1197 fling_point, | 1197 fling_point, |
1198 fling_global_point, | 1198 fling_global_point, |
1199 modifiers); | 1199 modifiers); |
1200 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1200 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1201 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 1201 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
1202 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); | 1202 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
1203 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1203 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1204 | 1204 |
1205 // |gesture_scroll_on_impl_thread_| should still be true after | 1205 // |gesture_scroll_on_impl_thread_| should still be true after |
1206 // a GestureFlingStart is sent. | 1206 // a GestureFlingStart is sent. |
1207 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 1207 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
1208 | 1208 |
1209 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1209 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1210 // The first animate call should let us pick up an animation start time, but | 1210 // The first animate call should let us pick up an animation start time, but |
1211 // we shouldn't actually move anywhere just yet. The first frame after the | 1211 // we shouldn't actually move anywhere just yet. The first frame after the |
1212 // fling start will typically include the last scroll from the gesture that | 1212 // fling start will typically include the last scroll from the gesture that |
1213 // lead to the scroll (either wheel or gesture scroll), so there should be no | 1213 // lead to the scroll (either wheel or gesture scroll), so there should be no |
1214 // visible hitch. | 1214 // visible hitch. |
1215 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1215 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1216 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); | 1216 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); |
1217 input_handler_->Animate(time); | 1217 input_handler_->Animate(time); |
1218 | 1218 |
1219 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1219 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1220 | 1220 |
1221 // The second call should start scrolling in the -X direction. | 1221 // The second call should start scrolling in the -X direction. |
1222 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1222 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1223 EXPECT_CALL(mock_input_handler_, | 1223 EXPECT_CALL(mock_input_handler_, |
1224 ScrollBy(testing::_, | 1224 ScrollBy(testing::_, |
1225 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) | 1225 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) |
1226 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 1226 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
1227 time += base::TimeDelta::FromMilliseconds(100); | 1227 time += base::TimeDelta::FromMilliseconds(100); |
1228 input_handler_->Animate(time); | 1228 input_handler_->Animate(time); |
1229 | 1229 |
1230 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1230 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1231 | 1231 |
1232 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 1232 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
1233 gesture_.type = WebInputEvent::GestureFlingCancel; | 1233 gesture_.type = WebInputEvent::GestureFlingCancel; |
1234 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1234 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1235 | 1235 |
1236 // |gesture_scroll_on_impl_thread_| should be false once | 1236 // |gesture_scroll_on_impl_thread_| should be false once |
1237 // the fling has finished (note no GestureScrollEnd has been sent). | 1237 // the fling has finished (note no GestureScrollEnd has been sent). |
1238 EXPECT_TRUE(!input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 1238 EXPECT_TRUE(!input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
1239 } | 1239 } |
1240 | 1240 |
| 1241 TEST_F(InputHandlerProxyTest, |
| 1242 BeginScrollWhenGestureScrollOnImplThreadFlagIsSet) { |
| 1243 // We shouldn't send any events to the widget for this gesture. |
| 1244 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
| 1245 VERIFY_AND_RESET_MOCKS(); |
| 1246 |
| 1247 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 1248 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
| 1249 |
| 1250 gesture_.type = WebInputEvent::GestureScrollBegin; |
| 1251 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 1252 |
| 1253 // After sending a GestureScrollBegin, the member variable |
| 1254 // |gesture_scroll_on_impl_thread_| should be true. |
| 1255 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
| 1256 |
| 1257 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
| 1258 VERIFY_AND_RESET_MOCKS(); |
| 1259 |
| 1260 // On the fling start, we should schedule an animation but not actually start |
| 1261 // scrolling. |
| 1262 WebFloatPoint fling_delta = WebFloatPoint(100, 0); |
| 1263 WebPoint fling_point = WebPoint(7, 13); |
| 1264 WebPoint fling_global_point = WebPoint(17, 23); |
| 1265 int modifiers = WebInputEvent::ControlKey | WebInputEvent::AltKey; |
| 1266 gesture_ = CreateFling(blink::WebGestureDeviceTouchscreen, fling_delta, |
| 1267 fling_point, fling_global_point, modifiers); |
| 1268 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
| 1269 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
| 1270 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
| 1271 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 1272 |
| 1273 // |gesture_scroll_on_impl_thread_| should still be true after |
| 1274 // a GestureFlingStart is sent. |
| 1275 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
| 1276 |
| 1277 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1278 |
| 1279 // gesture_scroll_on_impl_thread_ is still true when this scroll begins. As a |
| 1280 // result, this scroll begin will cancel the previous fling. |
| 1281 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
| 1282 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 1283 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
| 1284 |
| 1285 gesture_.type = WebInputEvent::GestureScrollBegin; |
| 1286 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 1287 |
| 1288 // After sending a GestureScrollBegin, the member variable |
| 1289 // |gesture_scroll_on_impl_thread_| should be true. |
| 1290 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
| 1291 VERIFY_AND_RESET_MOCKS(); |
| 1292 } |
| 1293 |
1241 TEST_F(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) { | 1294 TEST_F(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) { |
1242 // We shouldn't send any events to the widget for this gesture. | 1295 // We shouldn't send any events to the widget for this gesture. |
1243 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 1296 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
1244 VERIFY_AND_RESET_MOCKS(); | 1297 VERIFY_AND_RESET_MOCKS(); |
1245 | 1298 |
1246 // On the fling start, we should schedule an animation but not actually start | 1299 // On the fling start, we should schedule an animation but not actually start |
1247 // scrolling. | 1300 // scrolling. |
1248 gesture_.type = WebInputEvent::GestureFlingStart; | 1301 gesture_.type = WebInputEvent::GestureFlingStart; |
1249 WebFloatPoint fling_delta = WebFloatPoint(100, 100); | 1302 WebFloatPoint fling_delta = WebFloatPoint(100, 100); |
1250 gesture_.data.flingStart.velocityX = fling_delta.x; | 1303 gesture_.data.flingStart.velocityX = fling_delta.x; |
1251 gesture_.data.flingStart.velocityY = fling_delta.y; | 1304 gesture_.data.flingStart.velocityY = fling_delta.y; |
1252 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1305 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1253 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); | 1306 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
1254 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 1307 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
1255 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1308 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1256 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1309 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1257 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1310 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1258 | 1311 |
1259 // The first animate doesn't cause any scrolling. | 1312 // The first animate doesn't cause any scrolling. |
1260 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1313 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1261 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); | 1314 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); |
1262 input_handler_->Animate(time); | 1315 input_handler_->Animate(time); |
1263 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1316 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1264 | 1317 |
1265 // The second animate starts scrolling in the positive X and Y directions. | 1318 // The second animate starts scrolling in the positive X and Y directions. |
1266 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1319 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1267 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); | 1320 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
1268 EXPECT_CALL(mock_input_handler_, | 1321 EXPECT_CALL(mock_input_handler_, |
1269 ScrollBy(testing::_, | 1322 ScrollBy(testing::_, |
1270 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))) | 1323 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))) |
1271 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 1324 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
1272 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 1325 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
1273 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1326 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1274 time += base::TimeDelta::FromMilliseconds(100); | 1327 time += base::TimeDelta::FromMilliseconds(100); |
1275 input_handler_->Animate(time); | 1328 input_handler_->Animate(time); |
1276 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1329 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1277 | 1330 |
1278 // The third animate overscrolls in the positive Y direction but scrolls | 1331 // The third animate overscrolls in the positive Y direction but scrolls |
1279 // somewhat. | 1332 // somewhat. |
1280 cc::InputHandlerScrollResult overscroll; | 1333 cc::InputHandlerScrollResult overscroll; |
1281 overscroll.did_scroll = true; | 1334 overscroll.did_scroll = true; |
1282 overscroll.did_overscroll_root = true; | 1335 overscroll.did_overscroll_root = true; |
1283 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100); | 1336 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100); |
(...skipping 10 matching lines...) Expand all Loading... |
1294 testing::Field( | 1347 testing::Field( |
1295 &DidOverscrollParams::accumulated_overscroll, | 1348 &DidOverscrollParams::accumulated_overscroll, |
1296 testing::Eq(overscroll.accumulated_root_overscroll)), | 1349 testing::Eq(overscroll.accumulated_root_overscroll)), |
1297 testing::Field( | 1350 testing::Field( |
1298 &DidOverscrollParams::latest_overscroll_delta, | 1351 &DidOverscrollParams::latest_overscroll_delta, |
1299 testing::Eq(overscroll.unused_scroll_delta)), | 1352 testing::Eq(overscroll.unused_scroll_delta)), |
1300 testing::Field( | 1353 testing::Field( |
1301 &DidOverscrollParams::current_fling_velocity, | 1354 &DidOverscrollParams::current_fling_velocity, |
1302 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))))); | 1355 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))))); |
1303 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 1356 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
1304 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1357 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1305 time += base::TimeDelta::FromMilliseconds(100); | 1358 time += base::TimeDelta::FromMilliseconds(100); |
1306 input_handler_->Animate(time); | 1359 input_handler_->Animate(time); |
1307 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1360 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1308 | 1361 |
1309 // The next call to animate will no longer scroll vertically. | 1362 // The next call to animate will no longer scroll vertically. |
1310 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1363 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1311 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1364 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1312 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); | 1365 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
1313 EXPECT_CALL(mock_input_handler_, | 1366 EXPECT_CALL(mock_input_handler_, |
1314 ScrollBy(testing::_, | 1367 ScrollBy(testing::_, |
1315 testing::Property(&gfx::Vector2dF::y, testing::Eq(0)))) | 1368 testing::Property(&gfx::Vector2dF::y, testing::Eq(0)))) |
1316 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 1369 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
1317 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 1370 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
1318 time += base::TimeDelta::FromMilliseconds(100); | 1371 time += base::TimeDelta::FromMilliseconds(100); |
1319 input_handler_->Animate(time); | 1372 input_handler_->Animate(time); |
1320 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1373 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
(...skipping 20 matching lines...) Expand all Loading... |
1341 WebFloatPoint fling_delta = WebFloatPoint(100, 0); | 1394 WebFloatPoint fling_delta = WebFloatPoint(100, 0); |
1342 WebPoint fling_point = WebPoint(7, 13); | 1395 WebPoint fling_point = WebPoint(7, 13); |
1343 WebPoint fling_global_point = WebPoint(17, 23); | 1396 WebPoint fling_global_point = WebPoint(17, 23); |
1344 int modifiers = WebInputEvent::ControlKey; | 1397 int modifiers = WebInputEvent::ControlKey; |
1345 gesture_ = CreateFling(time, | 1398 gesture_ = CreateFling(time, |
1346 blink::WebGestureDeviceTouchscreen, | 1399 blink::WebGestureDeviceTouchscreen, |
1347 fling_delta, | 1400 fling_delta, |
1348 fling_point, | 1401 fling_point, |
1349 fling_global_point, | 1402 fling_global_point, |
1350 modifiers); | 1403 modifiers); |
1351 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1404 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1352 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 1405 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
1353 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); | 1406 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
1354 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1407 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1355 | 1408 |
1356 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1409 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1357 // With an animation timestamp equivalent to the starting timestamp, the | 1410 // With an animation timestamp equivalent to the starting timestamp, the |
1358 // animation will simply be rescheduled. | 1411 // animation will simply be rescheduled. |
1359 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1412 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1360 input_handler_->Animate(time); | 1413 input_handler_->Animate(time); |
1361 | 1414 |
1362 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1415 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1363 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 1416 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
1364 | 1417 |
1365 // A small time delta should not stop the fling, even if the client | 1418 // A small time delta should not stop the fling, even if the client |
1366 // reports no scrolling. | 1419 // reports no scrolling. |
1367 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1420 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1368 EXPECT_CALL(mock_input_handler_, | 1421 EXPECT_CALL(mock_input_handler_, |
1369 ScrollBy(testing::_, | 1422 ScrollBy(testing::_, |
1370 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) | 1423 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) |
1371 .WillOnce(testing::Return(scroll_result_did_not_scroll_)); | 1424 .WillOnce(testing::Return(scroll_result_did_not_scroll_)); |
1372 time += base::TimeDelta::FromMicroseconds(5); | 1425 time += base::TimeDelta::FromMicroseconds(5); |
1373 input_handler_->Animate(time); | 1426 input_handler_->Animate(time); |
1374 | 1427 |
1375 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1428 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1376 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 1429 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
1377 | 1430 |
1378 // A time delta of zero should not stop the fling, and neither should it | 1431 // A time delta of zero should not stop the fling, and neither should it |
1379 // trigger scrolling on the client. | 1432 // trigger scrolling on the client. |
1380 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1433 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1381 input_handler_->Animate(time); | 1434 input_handler_->Animate(time); |
1382 | 1435 |
1383 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1436 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1384 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 1437 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
1385 | 1438 |
1386 // Lack of movement on the client, with a non-trivial scroll delta, should | 1439 // Lack of movement on the client, with a non-trivial scroll delta, should |
1387 // terminate the fling. | 1440 // terminate the fling. |
1388 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 1441 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
1389 EXPECT_CALL(mock_input_handler_, | 1442 EXPECT_CALL(mock_input_handler_, |
1390 ScrollBy(testing::_, | 1443 ScrollBy(testing::_, |
(...skipping 23 matching lines...) Expand all Loading... |
1414 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1467 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1415 | 1468 |
1416 // On the fling start, we should schedule an animation but not actually start | 1469 // On the fling start, we should schedule an animation but not actually start |
1417 // scrolling. | 1470 // scrolling. |
1418 gesture_.type = WebInputEvent::GestureFlingStart; | 1471 gesture_.type = WebInputEvent::GestureFlingStart; |
1419 WebFloatPoint fling_delta = WebFloatPoint(100, 100); | 1472 WebFloatPoint fling_delta = WebFloatPoint(100, 100); |
1420 gesture_.data.flingStart.velocityX = fling_delta.x; | 1473 gesture_.data.flingStart.velocityX = fling_delta.x; |
1421 gesture_.data.flingStart.velocityY = fling_delta.y; | 1474 gesture_.data.flingStart.velocityY = fling_delta.y; |
1422 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 1475 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
1423 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); | 1476 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
1424 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1477 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1425 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1478 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1426 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1479 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1427 | 1480 |
1428 // The first animate doesn't cause any scrolling. | 1481 // The first animate doesn't cause any scrolling. |
1429 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1482 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1430 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); | 1483 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); |
1431 input_handler_->Animate(time); | 1484 input_handler_->Animate(time); |
1432 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1485 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1433 | 1486 |
1434 // The second animate starts scrolling in the positive X and Y directions. | 1487 // The second animate starts scrolling in the positive X and Y directions. |
1435 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1488 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1436 EXPECT_CALL(mock_input_handler_, | 1489 EXPECT_CALL(mock_input_handler_, |
1437 ScrollBy(testing::_, | 1490 ScrollBy(testing::_, |
1438 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))) | 1491 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))) |
1439 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 1492 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
1440 time += base::TimeDelta::FromMilliseconds(10); | 1493 time += base::TimeDelta::FromMilliseconds(10); |
1441 input_handler_->Animate(time); | 1494 input_handler_->Animate(time); |
1442 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1495 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1443 | 1496 |
1444 // The third animate hits the bottom content edge. | 1497 // The third animate hits the bottom content edge. |
1445 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100); | 1498 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100); |
1446 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 100); | 1499 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 100); |
1447 EXPECT_CALL(mock_input_handler_, | 1500 EXPECT_CALL(mock_input_handler_, |
1448 ScrollBy(testing::_, | 1501 ScrollBy(testing::_, |
1449 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))) | 1502 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))) |
1450 .WillOnce(testing::Return(overscroll)); | 1503 .WillOnce(testing::Return(overscroll)); |
1451 EXPECT_CALL( | 1504 EXPECT_CALL( |
1452 mock_client_, | 1505 mock_client_, |
1453 DidOverscroll(testing::AllOf( | 1506 DidOverscroll(testing::AllOf( |
1454 testing::Field( | 1507 testing::Field( |
1455 &DidOverscrollParams::accumulated_overscroll, | 1508 &DidOverscrollParams::accumulated_overscroll, |
1456 testing::Eq(overscroll.accumulated_root_overscroll)), | 1509 testing::Eq(overscroll.accumulated_root_overscroll)), |
1457 testing::Field( | 1510 testing::Field( |
1458 &DidOverscrollParams::latest_overscroll_delta, | 1511 &DidOverscrollParams::latest_overscroll_delta, |
1459 testing::Eq(overscroll.unused_scroll_delta)), | 1512 testing::Eq(overscroll.unused_scroll_delta)), |
1460 testing::Field( | 1513 testing::Field( |
1461 &DidOverscrollParams::current_fling_velocity, | 1514 &DidOverscrollParams::current_fling_velocity, |
1462 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))))); | 1515 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))))); |
1463 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1516 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1464 time += base::TimeDelta::FromMilliseconds(10); | 1517 time += base::TimeDelta::FromMilliseconds(10); |
1465 input_handler_->Animate(time); | 1518 input_handler_->Animate(time); |
1466 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1519 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1467 | 1520 |
1468 // The next call to animate will no longer scroll vertically. | 1521 // The next call to animate will no longer scroll vertically. |
1469 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1522 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1470 EXPECT_CALL(mock_input_handler_, | 1523 EXPECT_CALL(mock_input_handler_, |
1471 ScrollBy(testing::_, | 1524 ScrollBy(testing::_, |
1472 testing::Property(&gfx::Vector2dF::y, testing::Eq(0)))) | 1525 testing::Property(&gfx::Vector2dF::y, testing::Eq(0)))) |
1473 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 1526 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
1474 time += base::TimeDelta::FromMilliseconds(10); | 1527 time += base::TimeDelta::FromMilliseconds(10); |
1475 input_handler_->Animate(time); | 1528 input_handler_->Animate(time); |
1476 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1529 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1477 | 1530 |
1478 // The next call will hit the right edge. | 1531 // The next call will hit the right edge. |
1479 overscroll.accumulated_root_overscroll = gfx::Vector2dF(100, 100); | 1532 overscroll.accumulated_root_overscroll = gfx::Vector2dF(100, 100); |
(...skipping 14 matching lines...) Expand all Loading... |
1494 testing::Field( | 1547 testing::Field( |
1495 &DidOverscrollParams::current_fling_velocity, | 1548 &DidOverscrollParams::current_fling_velocity, |
1496 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))))); | 1549 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))))); |
1497 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 1550 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
1498 time += base::TimeDelta::FromMilliseconds(10); | 1551 time += base::TimeDelta::FromMilliseconds(10); |
1499 input_handler_->Animate(time); | 1552 input_handler_->Animate(time); |
1500 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1553 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1501 | 1554 |
1502 // The next call to animate will no longer scroll horizontally or vertically, | 1555 // The next call to animate will no longer scroll horizontally or vertically, |
1503 // and the fling should be cancelled. | 1556 // and the fling should be cancelled. |
1504 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()).Times(0); | 1557 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(0); |
1505 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_, testing::_)).Times(0); | 1558 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_, testing::_)).Times(0); |
1506 time += base::TimeDelta::FromMilliseconds(10); | 1559 time += base::TimeDelta::FromMilliseconds(10); |
1507 input_handler_->Animate(time); | 1560 input_handler_->Animate(time); |
1508 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1561 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1509 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 1562 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
1510 } | 1563 } |
1511 | 1564 |
1512 TEST_F(InputHandlerProxyTest, MultiTouchPointHitTestNegative) { | 1565 TEST_F(InputHandlerProxyTest, MultiTouchPointHitTestNegative) { |
1513 // None of the three touch points fall in the touch region. So the event | 1566 // None of the three touch points fall in the touch region. So the event |
1514 // should be dropped. | 1567 // should be dropped. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1582 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 1635 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
1583 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1636 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1584 | 1637 |
1585 // On the fling start, animation should be scheduled, but no scrolling occurs. | 1638 // On the fling start, animation should be scheduled, but no scrolling occurs. |
1586 gesture_.type = WebInputEvent::GestureFlingStart; | 1639 gesture_.type = WebInputEvent::GestureFlingStart; |
1587 WebFloatPoint fling_delta = WebFloatPoint(100, 100); | 1640 WebFloatPoint fling_delta = WebFloatPoint(100, 100); |
1588 gesture_.data.flingStart.velocityX = fling_delta.x; | 1641 gesture_.data.flingStart.velocityX = fling_delta.x; |
1589 gesture_.data.flingStart.velocityY = fling_delta.y; | 1642 gesture_.data.flingStart.velocityY = fling_delta.y; |
1590 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 1643 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
1591 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); | 1644 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
1592 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1645 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1593 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1646 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1594 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 1647 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
1595 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1648 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1596 | 1649 |
1597 // Keyboard events received during a fling should cancel the active fling. | 1650 // Keyboard events received during a fling should cancel the active fling. |
1598 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 1651 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
1599 EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE, | 1652 EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE, |
1600 input_handler_->HandleInputEvent(key_event)); | 1653 input_handler_->HandleInputEvent(key_event)); |
1601 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 1654 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
1602 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1655 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1634 WebFloatPoint fling_delta = WebFloatPoint(100, 0); | 1687 WebFloatPoint fling_delta = WebFloatPoint(100, 0); |
1635 WebPoint fling_point = WebPoint(7, 13); | 1688 WebPoint fling_point = WebPoint(7, 13); |
1636 WebPoint fling_global_point = WebPoint(17, 23); | 1689 WebPoint fling_global_point = WebPoint(17, 23); |
1637 int modifiers = WebInputEvent::ControlKey; | 1690 int modifiers = WebInputEvent::ControlKey; |
1638 gesture_ = CreateFling(time, | 1691 gesture_ = CreateFling(time, |
1639 blink::WebGestureDeviceTouchscreen, | 1692 blink::WebGestureDeviceTouchscreen, |
1640 fling_delta, | 1693 fling_delta, |
1641 fling_point, | 1694 fling_point, |
1642 fling_global_point, | 1695 fling_global_point, |
1643 modifiers); | 1696 modifiers); |
1644 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1697 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1645 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 1698 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
1646 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); | 1699 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
1647 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1700 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1648 | 1701 |
1649 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1702 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1650 | 1703 |
1651 // If we get a negative time delta, that is, the Animation tick time happens | 1704 // If we get a negative time delta, that is, the Animation tick time happens |
1652 // before the fling's start time then we should *not* try scrolling and | 1705 // before the fling's start time then we should *not* try scrolling and |
1653 // instead reset the fling start time. | 1706 // instead reset the fling start time. |
1654 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1707 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1655 EXPECT_CALL(mock_input_handler_, | 1708 EXPECT_CALL(mock_input_handler_, |
1656 ScrollBy(testing::_, | 1709 ScrollBy(testing::_, |
1657 testing::_)).Times(0); | 1710 testing::_)).Times(0); |
1658 time -= base::TimeDelta::FromMilliseconds(5); | 1711 time -= base::TimeDelta::FromMilliseconds(5); |
1659 input_handler_->Animate(time); | 1712 input_handler_->Animate(time); |
1660 | 1713 |
1661 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1714 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1662 | 1715 |
1663 // The first call should have reset the start time so subsequent calls should | 1716 // The first call should have reset the start time so subsequent calls should |
1664 // generate scroll events. | 1717 // generate scroll events. |
1665 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1718 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1666 EXPECT_CALL(mock_input_handler_, | 1719 EXPECT_CALL(mock_input_handler_, |
1667 ScrollBy(testing::_, | 1720 ScrollBy(testing::_, |
1668 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) | 1721 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) |
1669 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 1722 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
1670 | 1723 |
1671 input_handler_->Animate(time + base::TimeDelta::FromMilliseconds(1)); | 1724 input_handler_->Animate(time + base::TimeDelta::FromMilliseconds(1)); |
1672 | 1725 |
1673 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1726 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1674 | 1727 |
1675 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 1728 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
(...skipping 25 matching lines...) Expand all Loading... |
1701 gesture_.timeStampSeconds = InSecondsF(time); | 1754 gesture_.timeStampSeconds = InSecondsF(time); |
1702 gesture_.type = WebInputEvent::GestureScrollBegin; | 1755 gesture_.type = WebInputEvent::GestureScrollBegin; |
1703 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1756 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1704 | 1757 |
1705 VERIFY_AND_RESET_MOCKS(); | 1758 VERIFY_AND_RESET_MOCKS(); |
1706 | 1759 |
1707 // Animate calls within the deferred cancellation window should continue. | 1760 // Animate calls within the deferred cancellation window should continue. |
1708 time += dt; | 1761 time += dt; |
1709 float expected_delta = | 1762 float expected_delta = |
1710 (time - last_animate_time).InSecondsF() * -fling_delta.x; | 1763 (time - last_animate_time).InSecondsF() * -fling_delta.x; |
1711 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1764 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1712 EXPECT_CALL(mock_input_handler_, | 1765 EXPECT_CALL(mock_input_handler_, |
1713 ScrollBy(testing::_, | 1766 ScrollBy(testing::_, |
1714 testing::Property(&gfx::Vector2dF::x, | 1767 testing::Property(&gfx::Vector2dF::x, |
1715 testing::Eq(expected_delta)))) | 1768 testing::Eq(expected_delta)))) |
1716 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 1769 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
1717 input_handler_->Animate(time); | 1770 input_handler_->Animate(time); |
1718 last_animate_time = time; | 1771 last_animate_time = time; |
1719 | 1772 |
1720 VERIFY_AND_RESET_MOCKS(); | 1773 VERIFY_AND_RESET_MOCKS(); |
1721 | 1774 |
1722 // GestureScrollUpdates in the same direction and at sufficient speed should | 1775 // GestureScrollUpdates in the same direction and at sufficient speed should |
1723 // be swallowed by the fling. | 1776 // be swallowed by the fling. |
1724 time += dt; | 1777 time += dt; |
1725 gesture_.timeStampSeconds = InSecondsF(time); | 1778 gesture_.timeStampSeconds = InSecondsF(time); |
1726 gesture_.type = WebInputEvent::GestureScrollUpdate; | 1779 gesture_.type = WebInputEvent::GestureScrollUpdate; |
1727 gesture_.data.scrollUpdate.deltaX = fling_delta.x; | 1780 gesture_.data.scrollUpdate.deltaX = fling_delta.x; |
1728 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1781 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1729 | 1782 |
1730 VERIFY_AND_RESET_MOCKS(); | 1783 VERIFY_AND_RESET_MOCKS(); |
1731 | 1784 |
1732 // Animate calls within the deferred cancellation window should continue. | 1785 // Animate calls within the deferred cancellation window should continue. |
1733 time += dt; | 1786 time += dt; |
1734 expected_delta = (time - last_animate_time).InSecondsF() * -fling_delta.x; | 1787 expected_delta = (time - last_animate_time).InSecondsF() * -fling_delta.x; |
1735 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1788 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1736 EXPECT_CALL(mock_input_handler_, | 1789 EXPECT_CALL(mock_input_handler_, |
1737 ScrollBy(testing::_, | 1790 ScrollBy(testing::_, |
1738 testing::Property(&gfx::Vector2dF::x, | 1791 testing::Property(&gfx::Vector2dF::x, |
1739 testing::Eq(expected_delta)))) | 1792 testing::Eq(expected_delta)))) |
1740 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 1793 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
1741 input_handler_->Animate(time); | 1794 input_handler_->Animate(time); |
1742 last_animate_time = time; | 1795 last_animate_time = time; |
1743 | 1796 |
1744 VERIFY_AND_RESET_MOCKS(); | 1797 VERIFY_AND_RESET_MOCKS(); |
1745 | 1798 |
1746 // GestureFlingStart in the same direction and at sufficient speed should | 1799 // GestureFlingStart in the same direction and at sufficient speed should |
1747 // boost the active fling. | 1800 // boost the active fling. |
1748 | 1801 |
1749 gesture_ = CreateFling(time, | 1802 gesture_ = CreateFling(time, |
1750 blink::WebGestureDeviceTouchscreen, | 1803 blink::WebGestureDeviceTouchscreen, |
1751 fling_delta, | 1804 fling_delta, |
1752 fling_point, | 1805 fling_point, |
1753 fling_point, | 1806 fling_point, |
1754 0); | 1807 0); |
1755 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1808 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1756 VERIFY_AND_RESET_MOCKS(); | 1809 VERIFY_AND_RESET_MOCKS(); |
1757 | 1810 |
1758 time += dt; | 1811 time += dt; |
1759 // Note we get *2x* as much delta because 2 flings have combined. | 1812 // Note we get *2x* as much delta because 2 flings have combined. |
1760 expected_delta = 2 * (time - last_animate_time).InSecondsF() * -fling_delta.x; | 1813 expected_delta = 2 * (time - last_animate_time).InSecondsF() * -fling_delta.x; |
1761 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1814 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1762 EXPECT_CALL(mock_input_handler_, | 1815 EXPECT_CALL(mock_input_handler_, |
1763 ScrollBy(testing::_, | 1816 ScrollBy(testing::_, |
1764 testing::Property(&gfx::Vector2dF::x, | 1817 testing::Property(&gfx::Vector2dF::x, |
1765 testing::Eq(expected_delta)))) | 1818 testing::Eq(expected_delta)))) |
1766 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 1819 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
1767 input_handler_->Animate(time); | 1820 input_handler_->Animate(time); |
1768 last_animate_time = time; | 1821 last_animate_time = time; |
1769 | 1822 |
1770 VERIFY_AND_RESET_MOCKS(); | 1823 VERIFY_AND_RESET_MOCKS(); |
1771 | 1824 |
1772 // Repeated GestureFlingStarts should accumulate. | 1825 // Repeated GestureFlingStarts should accumulate. |
1773 | 1826 |
1774 CancelFling(time); | 1827 CancelFling(time); |
1775 gesture_ = CreateFling(time, | 1828 gesture_ = CreateFling(time, |
1776 blink::WebGestureDeviceTouchscreen, | 1829 blink::WebGestureDeviceTouchscreen, |
1777 fling_delta, | 1830 fling_delta, |
1778 fling_point, | 1831 fling_point, |
1779 fling_point, | 1832 fling_point, |
1780 0); | 1833 0); |
1781 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1834 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1782 VERIFY_AND_RESET_MOCKS(); | 1835 VERIFY_AND_RESET_MOCKS(); |
1783 | 1836 |
1784 time += dt; | 1837 time += dt; |
1785 // Note we get *3x* as much delta because 3 flings have combined. | 1838 // Note we get *3x* as much delta because 3 flings have combined. |
1786 expected_delta = 3 * (time - last_animate_time).InSecondsF() * -fling_delta.x; | 1839 expected_delta = 3 * (time - last_animate_time).InSecondsF() * -fling_delta.x; |
1787 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1840 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1788 EXPECT_CALL(mock_input_handler_, | 1841 EXPECT_CALL(mock_input_handler_, |
1789 ScrollBy(testing::_, | 1842 ScrollBy(testing::_, |
1790 testing::Property(&gfx::Vector2dF::x, | 1843 testing::Property(&gfx::Vector2dF::x, |
1791 testing::Eq(expected_delta)))) | 1844 testing::Eq(expected_delta)))) |
1792 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 1845 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
1793 input_handler_->Animate(time); | 1846 input_handler_->Animate(time); |
1794 last_animate_time = time; | 1847 last_animate_time = time; |
1795 | 1848 |
1796 VERIFY_AND_RESET_MOCKS(); | 1849 VERIFY_AND_RESET_MOCKS(); |
1797 | 1850 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1903 fling_point, | 1956 fling_point, |
1904 0); | 1957 0); |
1905 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1958 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1906 | 1959 |
1907 VERIFY_AND_RESET_MOCKS(); | 1960 VERIFY_AND_RESET_MOCKS(); |
1908 | 1961 |
1909 // Note that the new fling delta uses the orthogonal, unboosted fling | 1962 // Note that the new fling delta uses the orthogonal, unboosted fling |
1910 // velocity. | 1963 // velocity. |
1911 time += dt; | 1964 time += dt; |
1912 float expected_delta = dt.InSecondsF() * -orthogonal_fling_delta.y; | 1965 float expected_delta = dt.InSecondsF() * -orthogonal_fling_delta.y; |
1913 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1966 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1914 EXPECT_CALL(mock_input_handler_, | 1967 EXPECT_CALL(mock_input_handler_, |
1915 ScrollBy(testing::_, | 1968 ScrollBy(testing::_, |
1916 testing::Property(&gfx::Vector2dF::y, | 1969 testing::Property(&gfx::Vector2dF::y, |
1917 testing::Eq(expected_delta)))) | 1970 testing::Eq(expected_delta)))) |
1918 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 1971 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
1919 input_handler_->Animate(time); | 1972 input_handler_->Animate(time); |
1920 | 1973 |
1921 VERIFY_AND_RESET_MOCKS(); | 1974 VERIFY_AND_RESET_MOCKS(); |
1922 } | 1975 } |
1923 | 1976 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1988 fling_point, | 2041 fling_point, |
1989 fling_point, | 2042 fling_point, |
1990 0); | 2043 0); |
1991 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 2044 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1992 | 2045 |
1993 VERIFY_AND_RESET_MOCKS(); | 2046 VERIFY_AND_RESET_MOCKS(); |
1994 | 2047 |
1995 // Note that the new fling delta uses the *slow*, unboosted fling velocity. | 2048 // Note that the new fling delta uses the *slow*, unboosted fling velocity. |
1996 time += dt; | 2049 time += dt; |
1997 float expected_delta = dt.InSecondsF() * -small_fling_delta.x; | 2050 float expected_delta = dt.InSecondsF() * -small_fling_delta.x; |
1998 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 2051 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
1999 EXPECT_CALL(mock_input_handler_, | 2052 EXPECT_CALL(mock_input_handler_, |
2000 ScrollBy(testing::_, | 2053 ScrollBy(testing::_, |
2001 testing::Property(&gfx::Vector2dF::x, | 2054 testing::Property(&gfx::Vector2dF::x, |
2002 testing::Eq(expected_delta)))) | 2055 testing::Eq(expected_delta)))) |
2003 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 2056 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
2004 input_handler_->Animate(time); | 2057 input_handler_->Animate(time); |
2005 | 2058 |
2006 VERIFY_AND_RESET_MOCKS(); | 2059 VERIFY_AND_RESET_MOCKS(); |
2007 } | 2060 } |
2008 | 2061 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2099 TEST_F(InputHandlerProxyTest, DidReceiveInputEvent_ForFling) { | 2152 TEST_F(InputHandlerProxyTest, DidReceiveInputEvent_ForFling) { |
2100 testing::StrictMock<MockInputHandlerProxyClientWithDidAnimateForInput> | 2153 testing::StrictMock<MockInputHandlerProxyClientWithDidAnimateForInput> |
2101 mock_client; | 2154 mock_client; |
2102 input_handler_.reset( | 2155 input_handler_.reset( |
2103 new content::InputHandlerProxy(&mock_input_handler_, &mock_client)); | 2156 new content::InputHandlerProxy(&mock_input_handler_, &mock_client)); |
2104 | 2157 |
2105 gesture_.type = WebInputEvent::GestureFlingStart; | 2158 gesture_.type = WebInputEvent::GestureFlingStart; |
2106 WebFloatPoint fling_delta = WebFloatPoint(100, 100); | 2159 WebFloatPoint fling_delta = WebFloatPoint(100, 100); |
2107 gesture_.data.flingStart.velocityX = fling_delta.x; | 2160 gesture_.data.flingStart.velocityX = fling_delta.x; |
2108 gesture_.data.flingStart.velocityY = fling_delta.y; | 2161 gesture_.data.flingStart.velocityY = fling_delta.y; |
2109 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 2162 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
2110 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 2163 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
2111 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); | 2164 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
2112 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 2165 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
2113 EXPECT_EQ(InputHandlerProxy::DID_HANDLE, | 2166 EXPECT_EQ(InputHandlerProxy::DID_HANDLE, |
2114 input_handler_->HandleInputEvent(gesture_)); | 2167 input_handler_->HandleInputEvent(gesture_)); |
2115 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 2168 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
2116 testing::Mock::VerifyAndClearExpectations(&mock_client); | 2169 testing::Mock::VerifyAndClearExpectations(&mock_client); |
2117 | 2170 |
2118 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 2171 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()); |
2119 EXPECT_CALL(mock_client, DidAnimateForInput()); | 2172 EXPECT_CALL(mock_client, DidAnimateForInput()); |
2120 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); | 2173 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); |
2121 input_handler_->Animate(time); | 2174 input_handler_->Animate(time); |
2122 | 2175 |
2123 testing::Mock::VerifyAndClearExpectations(&mock_client); | 2176 testing::Mock::VerifyAndClearExpectations(&mock_client); |
2124 } | 2177 } |
2125 | 2178 |
2126 } // namespace | 2179 } // namespace |
2127 } // namespace content | 2180 } // namespace content |
OLD | NEW |