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