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

Side by Side Diff: content/renderer/input/input_handler_proxy_unittest.cc

Issue 1063853005: Unify Android Webview and Chrome's fling (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: for review Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/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
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
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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 } 535 }
536 536
537 TEST_F(InputHandlerProxyTest, GestureFlingStartedTouchpad) { 537 TEST_F(InputHandlerProxyTest, GestureFlingStartedTouchpad) {
538 // We shouldn't send any events to the widget for this gesture. 538 // We shouldn't send any events to the widget for this gesture.
539 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 539 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
540 VERIFY_AND_RESET_MOCKS(); 540 VERIFY_AND_RESET_MOCKS();
541 541
542 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 542 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
543 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 543 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
544 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 544 EXPECT_CALL(mock_input_handler_, ScrollEnd());
545 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 545 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
546 546
547 gesture_.type = WebInputEvent::GestureFlingStart; 547 gesture_.type = WebInputEvent::GestureFlingStart;
548 gesture_.data.flingStart.velocityX = 10; 548 gesture_.data.flingStart.velocityX = 10;
549 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; 549 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad;
550 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 550 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
551 551
552 VERIFY_AND_RESET_MOCKS(); 552 VERIFY_AND_RESET_MOCKS();
553 553
554 // Verify that a GestureFlingCancel during an animation cancels it. 554 // Verify that a GestureFlingCancel during an animation cancels it.
555 gesture_.type = WebInputEvent::GestureFlingCancel; 555 gesture_.type = WebInputEvent::GestureFlingCancel;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 WebPoint fling_point = WebPoint(7, 13); 615 WebPoint fling_point = WebPoint(7, 13);
616 WebPoint fling_global_point = WebPoint(17, 23); 616 WebPoint fling_global_point = WebPoint(17, 23);
617 // Note that for trackpad, wheel events with the Control modifier are 617 // Note that for trackpad, wheel events with the Control modifier are
618 // special (reserved for zoom), so don't set that here. 618 // special (reserved for zoom), so don't set that here.
619 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; 619 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey;
620 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, 620 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad,
621 fling_delta, 621 fling_delta,
622 fling_point, 622 fling_point,
623 fling_global_point, 623 fling_global_point,
624 modifiers); 624 modifiers);
625 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 625 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
626 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 626 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
627 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 627 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
628 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 628 EXPECT_CALL(mock_input_handler_, ScrollEnd());
629 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 629 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
630 630
631 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 631 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
632 // The first animate call should let us pick up an animation start time, but 632 // The first animate call should let us pick up an animation start time, but
633 // we shouldn't actually move anywhere just yet. The first frame after the 633 // we shouldn't actually move anywhere just yet. The first frame after the
634 // fling start will typically include the last scroll from the gesture that 634 // fling start will typically include the last scroll from the gesture that
635 // lead to the scroll (either wheel or gesture scroll), so there should be no 635 // lead to the scroll (either wheel or gesture scroll), so there should be no
636 // visible hitch. 636 // visible hitch.
637 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 637 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
638 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 638 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
639 .Times(0); 639 .Times(0);
640 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); 640 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
641 input_handler_->Animate(time); 641 input_handler_->Animate(time);
642 642
643 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 643 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
644 644
645 // The second call should start scrolling in the -X direction. 645 // The second call should start scrolling in the -X direction.
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 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 648 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
649 EXPECT_CALL(mock_input_handler_, 649 EXPECT_CALL(mock_input_handler_,
650 ScrollBy(testing::_, 650 ScrollBy(testing::_,
651 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) 651 testing::Property(&gfx::Vector2dF::x, testing::Lt(0))))
652 .WillOnce(testing::Return(scroll_result_did_scroll_)); 652 .WillOnce(testing::Return(scroll_result_did_scroll_));
653 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 653 EXPECT_CALL(mock_input_handler_, ScrollEnd());
654 time += base::TimeDelta::FromMilliseconds(100); 654 time += base::TimeDelta::FromMilliseconds(100);
655 input_handler_->Animate(time); 655 input_handler_->Animate(time);
656 656
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 testing::Field(&WebSize::width, testing::Gt(0)))))); 689 testing::Field(&WebSize::width, testing::Gt(0))))));
690 time += base::TimeDelta::FromMilliseconds(100); 690 time += base::TimeDelta::FromMilliseconds(100);
691 input_handler_->Animate(time); 691 input_handler_->Animate(time);
692 692
693 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 693 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
694 testing::Mock::VerifyAndClearExpectations(&mock_client_); 694 testing::Mock::VerifyAndClearExpectations(&mock_client_);
695 695
696 // Since we've aborted the fling, the next animation should be a no-op and 696 // Since we've aborted the fling, the next animation should be a no-op and
697 // should not result in another 697 // should not result in another
698 // frame being requested. 698 // frame being requested.
699 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()).Times(0); 699 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(0);
700 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 700 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
701 .Times(0); 701 .Times(0);
702 time += base::TimeDelta::FromMilliseconds(100); 702 time += base::TimeDelta::FromMilliseconds(100);
703 input_handler_->Animate(time); 703 input_handler_->Animate(time);
704 704
705 // Since we've transferred the fling to the main thread, we need to pass the 705 // Since we've transferred the fling to the main thread, we need to pass the
706 // next GestureFlingCancel to the main 706 // next GestureFlingCancel to the main
707 // thread as well. 707 // thread as well.
708 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; 708 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
709 gesture_.type = WebInputEvent::GestureFlingCancel; 709 gesture_.type = WebInputEvent::GestureFlingCancel;
(...skipping 10 matching lines...) Expand all
720 WebPoint fling_point = WebPoint(7, 13); 720 WebPoint fling_point = WebPoint(7, 13);
721 WebPoint fling_global_point = WebPoint(17, 23); 721 WebPoint fling_global_point = WebPoint(17, 23);
722 // Note that for trackpad, wheel events with the Control modifier are 722 // Note that for trackpad, wheel events with the Control modifier are
723 // special (reserved for zoom), so don't set that here. 723 // special (reserved for zoom), so don't set that here.
724 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; 724 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey;
725 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, 725 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad,
726 fling_delta, 726 fling_delta,
727 fling_point, 727 fling_point,
728 fling_global_point, 728 fling_global_point,
729 modifiers); 729 modifiers);
730 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 730 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
731 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 731 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
732 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 732 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
733 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 733 EXPECT_CALL(mock_input_handler_, ScrollEnd());
734 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 734 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
735 735
736 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 736 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
737 737
738 // Start the fling animation at time 10. This shouldn't actually scroll, just 738 // Start the fling animation at time 10. This shouldn't actually scroll, just
739 // establish a start time. 739 // establish a start time.
740 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 740 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
741 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 741 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
742 .Times(0); 742 .Times(0);
743 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); 743 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
744 input_handler_->Animate(time); 744 input_handler_->Animate(time);
745 745
746 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 746 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
747 747
748 // The second call should start scrolling in the -X direction. 748 // The second call should start scrolling in the -X direction.
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 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 751 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
752 EXPECT_CALL(mock_input_handler_, 752 EXPECT_CALL(mock_input_handler_,
753 ScrollBy(testing::_, 753 ScrollBy(testing::_,
754 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) 754 testing::Property(&gfx::Vector2dF::x, testing::Lt(0))))
755 .WillOnce(testing::Return(scroll_result_did_scroll_)); 755 .WillOnce(testing::Return(scroll_result_did_scroll_));
756 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 756 EXPECT_CALL(mock_input_handler_, ScrollEnd());
757 time += base::TimeDelta::FromMilliseconds(100); 757 time += base::TimeDelta::FromMilliseconds(100);
758 input_handler_->Animate(time); 758 input_handler_->Animate(time);
759 759
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 testing::Field(&WebSize::width, testing::Gt(0)))))); 793 testing::Field(&WebSize::width, testing::Gt(0))))));
794 time += base::TimeDelta::FromMilliseconds(100); 794 time += base::TimeDelta::FromMilliseconds(100);
795 input_handler_->Animate(time); 795 input_handler_->Animate(time);
796 796
797 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 797 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
798 testing::Mock::VerifyAndClearExpectations(&mock_client_); 798 testing::Mock::VerifyAndClearExpectations(&mock_client_);
799 799
800 // Since we've aborted the fling, the next animation should be a no-op and 800 // Since we've aborted the fling, the next animation should be a no-op and
801 // should not result in another 801 // should not result in another
802 // frame being requested. 802 // frame being requested.
803 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()).Times(0); 803 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(0);
804 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 804 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
805 .Times(0); 805 .Times(0);
806 time += base::TimeDelta::FromMilliseconds(100); 806 time += base::TimeDelta::FromMilliseconds(100);
807 input_handler_->Animate(time); 807 input_handler_->Animate(time);
808 808
809 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 809 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
810 810
811 // Since we've transferred the fling to the main thread, we need to pass the 811 // Since we've transferred the fling to the main thread, we need to pass the
812 // next GestureFlingCancel to the main 812 // next GestureFlingCancel to the main
813 // thread as well. 813 // thread as well.
814 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; 814 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
815 gesture_.type = WebInputEvent::GestureFlingCancel; 815 gesture_.type = WebInputEvent::GestureFlingCancel;
816 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 816 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
817 817
818 VERIFY_AND_RESET_MOCKS(); 818 VERIFY_AND_RESET_MOCKS();
819 input_handler_->MainThreadHasStoppedFlinging(); 819 input_handler_->MainThreadHasStoppedFlinging();
820 820
821 // Start a second gesture fling, this time in the +Y direction with no X. 821 // Start a second gesture fling, this time in the +Y direction with no X.
822 fling_delta = WebFloatPoint(0, -1000); 822 fling_delta = WebFloatPoint(0, -1000);
823 fling_point = WebPoint(95, 87); 823 fling_point = WebPoint(95, 87);
824 fling_global_point = WebPoint(32, 71); 824 fling_global_point = WebPoint(32, 71);
825 modifiers = WebInputEvent::AltKey; 825 modifiers = WebInputEvent::AltKey;
826 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, 826 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad,
827 fling_delta, 827 fling_delta,
828 fling_point, 828 fling_point,
829 fling_global_point, 829 fling_global_point,
830 modifiers); 830 modifiers);
831 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 831 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
832 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 832 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
833 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 833 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
834 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 834 EXPECT_CALL(mock_input_handler_, ScrollEnd());
835 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 835 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
836 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 836 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
837 837
838 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 838 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
839 839
840 // Start the second fling animation at time 30. 840 // Start the second fling animation at time 30.
841 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 841 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
842 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 842 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
843 .Times(0); 843 .Times(0);
844 time = base::TimeTicks() + base::TimeDelta::FromSeconds(30); 844 time = base::TimeTicks() + base::TimeDelta::FromSeconds(30);
845 input_handler_->Animate(time); 845 input_handler_->Animate(time);
846 846
847 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 847 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
848 848
849 // Tick the second fling once normally. 849 // Tick the second fling once normally.
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 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 852 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
853 EXPECT_CALL(mock_input_handler_, 853 EXPECT_CALL(mock_input_handler_,
854 ScrollBy(testing::_, 854 ScrollBy(testing::_,
855 testing::Property(&gfx::Vector2dF::y, testing::Gt(0)))) 855 testing::Property(&gfx::Vector2dF::y, testing::Gt(0))))
856 .WillOnce(testing::Return(scroll_result_did_scroll_)); 856 .WillOnce(testing::Return(scroll_result_did_scroll_));
857 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 857 EXPECT_CALL(mock_input_handler_, ScrollEnd());
858 time += base::TimeDelta::FromMilliseconds(100); 858 time += base::TimeDelta::FromMilliseconds(100);
859 input_handler_->Animate(time); 859 input_handler_->Animate(time);
860 860
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 895 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
896 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 896 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
897 gesture_.type = WebInputEvent::GestureScrollBegin; 897 gesture_.type = WebInputEvent::GestureScrollBegin;
898 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; 898 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
899 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 899 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
900 900
901 VERIFY_AND_RESET_MOCKS(); 901 VERIFY_AND_RESET_MOCKS();
902 902
903 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 903 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
904 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 904 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
905 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 905 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
906 906
907 gesture_.type = WebInputEvent::GestureFlingStart; 907 gesture_.type = WebInputEvent::GestureFlingStart;
908 gesture_.data.flingStart.velocityX = 10; 908 gesture_.data.flingStart.velocityX = 10;
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_, ScrollEnd()); 914 EXPECT_CALL(mock_input_handler_, ScrollEnd());
915 915
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 WebFloatPoint fling_delta = WebFloatPoint(100, 0); 1001 WebFloatPoint fling_delta = WebFloatPoint(100, 0);
1002 WebPoint fling_point = WebPoint(7, 13); 1002 WebPoint fling_point = WebPoint(7, 13);
1003 WebPoint fling_global_point = WebPoint(17, 23); 1003 WebPoint fling_global_point = WebPoint(17, 23);
1004 // Note that for touchscreen the control modifier is not special. 1004 // Note that for touchscreen the control modifier is not special.
1005 int modifiers = WebInputEvent::ControlKey; 1005 int modifiers = WebInputEvent::ControlKey;
1006 gesture_ = CreateFling(blink::WebGestureDeviceTouchscreen, 1006 gesture_ = CreateFling(blink::WebGestureDeviceTouchscreen,
1007 fling_delta, 1007 fling_delta,
1008 fling_point, 1008 fling_point,
1009 fling_global_point, 1009 fling_global_point,
1010 modifiers); 1010 modifiers);
1011 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1011 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1012 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 1012 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
1013 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 1013 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
1014 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1014 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1015 1015
1016 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1016 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1017 // The first animate call should let us pick up an animation start time, but 1017 // The first animate call should let us pick up an animation start time, but
1018 // we shouldn't actually move anywhere just yet. The first frame after the 1018 // we shouldn't actually move anywhere just yet. The first frame after the
1019 // fling start will typically include the last scroll from the gesture that 1019 // fling start will typically include the last scroll from the gesture that
1020 // lead to the scroll (either wheel or gesture scroll), so there should be no 1020 // lead to the scroll (either wheel or gesture scroll), so there should be no
1021 // visible hitch. 1021 // visible hitch.
1022 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1022 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1023 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); 1023 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
1024 input_handler_->Animate(time); 1024 input_handler_->Animate(time);
1025 1025
1026 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1026 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1027 1027
1028 // The second call should start scrolling in the -X direction. 1028 // The second call should start scrolling in the -X direction.
1029 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1029 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1030 EXPECT_CALL(mock_input_handler_, 1030 EXPECT_CALL(mock_input_handler_,
1031 ScrollBy(testing::_, 1031 ScrollBy(testing::_,
1032 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) 1032 testing::Property(&gfx::Vector2dF::x, testing::Lt(0))))
1033 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1033 .WillOnce(testing::Return(scroll_result_did_scroll_));
1034 time += base::TimeDelta::FromMilliseconds(100); 1034 time += base::TimeDelta::FromMilliseconds(100);
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 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1039 EXPECT_CALL(mock_input_handler_, ScrollEnd());
(...skipping 22 matching lines...) Expand all
1062 WebFloatPoint fling_delta = WebFloatPoint(100, 0); 1062 WebFloatPoint fling_delta = WebFloatPoint(100, 0);
1063 WebPoint fling_point = WebPoint(7, 13); 1063 WebPoint fling_point = WebPoint(7, 13);
1064 WebPoint fling_global_point = WebPoint(17, 23); 1064 WebPoint fling_global_point = WebPoint(17, 23);
1065 int modifiers = WebInputEvent::ControlKey; 1065 int modifiers = WebInputEvent::ControlKey;
1066 gesture_ = CreateFling(time, 1066 gesture_ = CreateFling(time,
1067 blink::WebGestureDeviceTouchscreen, 1067 blink::WebGestureDeviceTouchscreen,
1068 fling_delta, 1068 fling_delta,
1069 fling_point, 1069 fling_point,
1070 fling_global_point, 1070 fling_global_point,
1071 modifiers); 1071 modifiers);
1072 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1072 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1073 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 1073 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
1074 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 1074 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
1075 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1075 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1076 1076
1077 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1077 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1078 // With a valid time stamp, the first animate call should skip start time 1078 // With a valid time stamp, the first animate call should skip start time
1079 // initialization and immediately begin scroll update production. This reduces 1079 // initialization and immediately begin scroll update production. This reduces
1080 // the likelihood of a hitch between the scroll preceding the fling and 1080 // the likelihood of a hitch between the scroll preceding the fling and
1081 // the first scroll generated by the fling. 1081 // the first scroll generated by the fling.
1082 // Scrolling should start in the -X direction. 1082 // Scrolling should start in the -X direction.
1083 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1083 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1084 EXPECT_CALL(mock_input_handler_, 1084 EXPECT_CALL(mock_input_handler_,
1085 ScrollBy(testing::_, 1085 ScrollBy(testing::_,
1086 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) 1086 testing::Property(&gfx::Vector2dF::x, testing::Lt(0))))
1087 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1087 .WillOnce(testing::Return(scroll_result_did_scroll_));
1088 time += dt; 1088 time += dt;
1089 input_handler_->Animate(time); 1089 input_handler_->Animate(time);
1090 1090
1091 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1091 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1092 1092
1093 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1093 EXPECT_CALL(mock_input_handler_, ScrollEnd());
(...skipping 25 matching lines...) Expand all
1119 int modifiers = WebInputEvent::ControlKey; 1119 int modifiers = WebInputEvent::ControlKey;
1120 gesture_.timeStampSeconds = start_time_offset.InSecondsF(); 1120 gesture_.timeStampSeconds = start_time_offset.InSecondsF();
1121 gesture_.data.flingStart.velocityX = fling_delta.x; 1121 gesture_.data.flingStart.velocityX = fling_delta.x;
1122 gesture_.data.flingStart.velocityY = fling_delta.y; 1122 gesture_.data.flingStart.velocityY = fling_delta.y;
1123 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; 1123 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
1124 gesture_.x = fling_point.x; 1124 gesture_.x = fling_point.x;
1125 gesture_.y = fling_point.y; 1125 gesture_.y = fling_point.y;
1126 gesture_.globalX = fling_global_point.x; 1126 gesture_.globalX = fling_global_point.x;
1127 gesture_.globalY = fling_global_point.y; 1127 gesture_.globalY = fling_global_point.y;
1128 gesture_.modifiers = modifiers; 1128 gesture_.modifiers = modifiers;
1129 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1129 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1130 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 1130 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
1131 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 1131 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
1132 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1132 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1133 1133
1134 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1134 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1135 // Event though a time stamp was provided for the fling event, it will be 1135 // Event though a time stamp was provided for the fling event, it will be
1136 // ignored as its too far in the past relative to the first animate call's 1136 // ignored as its too far in the past relative to the first animate call's
1137 // timestamp. 1137 // timestamp.
1138 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1138 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1139 base::TimeTicks time = 1139 base::TimeTicks time =
1140 base::TimeTicks() + start_time_offset + base::TimeDelta::FromSeconds(1); 1140 base::TimeTicks() + start_time_offset + base::TimeDelta::FromSeconds(1);
1141 input_handler_->Animate(time); 1141 input_handler_->Animate(time);
1142 1142
1143 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1143 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1144 1144
1145 // Further animation ticks should update the fling as usual. 1145 // Further animation ticks should update the fling as usual.
1146 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1146 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1147 EXPECT_CALL(mock_input_handler_, 1147 EXPECT_CALL(mock_input_handler_,
1148 ScrollBy(testing::_, 1148 ScrollBy(testing::_,
1149 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) 1149 testing::Property(&gfx::Vector2dF::x, testing::Lt(0))))
1150 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1150 .WillOnce(testing::Return(scroll_result_did_scroll_));
1151 time += base::TimeDelta::FromMilliseconds(10); 1151 time += base::TimeDelta::FromMilliseconds(10);
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 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1156 EXPECT_CALL(mock_input_handler_, ScrollEnd());
(...skipping 24 matching lines...) Expand all
1181 // scrolling. 1181 // scrolling.
1182 WebFloatPoint fling_delta = WebFloatPoint(100, 0); 1182 WebFloatPoint fling_delta = WebFloatPoint(100, 0);
1183 WebPoint fling_point = WebPoint(7, 13); 1183 WebPoint fling_point = WebPoint(7, 13);
1184 WebPoint fling_global_point = WebPoint(17, 23); 1184 WebPoint fling_global_point = WebPoint(17, 23);
1185 int modifiers = WebInputEvent::ControlKey | WebInputEvent::AltKey; 1185 int modifiers = WebInputEvent::ControlKey | WebInputEvent::AltKey;
1186 gesture_ = CreateFling(blink::WebGestureDeviceTouchscreen, 1186 gesture_ = CreateFling(blink::WebGestureDeviceTouchscreen,
1187 fling_delta, 1187 fling_delta,
1188 fling_point, 1188 fling_point,
1189 fling_global_point, 1189 fling_global_point,
1190 modifiers); 1190 modifiers);
1191 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1191 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1192 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 1192 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
1193 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 1193 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
1194 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1194 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1195 1195
1196 // |gesture_scroll_on_impl_thread_| should still be true after 1196 // |gesture_scroll_on_impl_thread_| should still be true after
1197 // a GestureFlingStart is sent. 1197 // a GestureFlingStart is sent.
1198 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1198 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1199 1199
1200 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1200 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1201 // The first animate call should let us pick up an animation start time, but 1201 // The first animate call should let us pick up an animation start time, but
1202 // we shouldn't actually move anywhere just yet. The first frame after the 1202 // we shouldn't actually move anywhere just yet. The first frame after the
1203 // fling start will typically include the last scroll from the gesture that 1203 // fling start will typically include the last scroll from the gesture that
1204 // lead to the scroll (either wheel or gesture scroll), so there should be no 1204 // lead to the scroll (either wheel or gesture scroll), so there should be no
1205 // visible hitch. 1205 // visible hitch.
1206 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1206 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1207 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); 1207 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
1208 input_handler_->Animate(time); 1208 input_handler_->Animate(time);
1209 1209
1210 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1210 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1211 1211
1212 // The second call should start scrolling in the -X direction. 1212 // The second call should start scrolling in the -X direction.
1213 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1213 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1214 EXPECT_CALL(mock_input_handler_, 1214 EXPECT_CALL(mock_input_handler_,
1215 ScrollBy(testing::_, 1215 ScrollBy(testing::_,
1216 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) 1216 testing::Property(&gfx::Vector2dF::x, testing::Lt(0))))
1217 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1217 .WillOnce(testing::Return(scroll_result_did_scroll_));
1218 time += base::TimeDelta::FromMilliseconds(100); 1218 time += base::TimeDelta::FromMilliseconds(100);
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 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1223 EXPECT_CALL(mock_input_handler_, ScrollEnd());
(...skipping 12 matching lines...) Expand all
1236 1236
1237 // On the fling start, we should schedule an animation but not actually start 1237 // On the fling start, we should schedule an animation but not actually start
1238 // scrolling. 1238 // scrolling.
1239 gesture_.type = WebInputEvent::GestureFlingStart; 1239 gesture_.type = WebInputEvent::GestureFlingStart;
1240 WebFloatPoint fling_delta = WebFloatPoint(100, 100); 1240 WebFloatPoint fling_delta = WebFloatPoint(100, 100);
1241 gesture_.data.flingStart.velocityX = fling_delta.x; 1241 gesture_.data.flingStart.velocityX = fling_delta.x;
1242 gesture_.data.flingStart.velocityY = fling_delta.y; 1242 gesture_.data.flingStart.velocityY = fling_delta.y;
1243 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1243 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1244 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 1244 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
1245 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1245 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1246 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1246 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1247 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1247 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1248 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1248 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1249 1249
1250 // The first animate doesn't cause any scrolling. 1250 // The first animate doesn't cause any scrolling.
1251 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1251 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1252 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); 1252 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
1253 input_handler_->Animate(time); 1253 input_handler_->Animate(time);
1254 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1254 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1255 1255
1256 // The second animate starts scrolling in the positive X and Y directions. 1256 // The second animate starts scrolling in the positive X and Y directions.
1257 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1257 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1258 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 1258 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
1259 EXPECT_CALL(mock_input_handler_, 1259 EXPECT_CALL(mock_input_handler_,
1260 ScrollBy(testing::_, 1260 ScrollBy(testing::_,
1261 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))) 1261 testing::Property(&gfx::Vector2dF::y, testing::Lt(0))))
1262 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1262 .WillOnce(testing::Return(scroll_result_did_scroll_));
1263 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1263 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1264 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1264 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1265 time += base::TimeDelta::FromMilliseconds(100); 1265 time += base::TimeDelta::FromMilliseconds(100);
1266 input_handler_->Animate(time); 1266 input_handler_->Animate(time);
1267 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1267 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1268 1268
1269 // The third animate overscrolls in the positive Y direction but scrolls 1269 // The third animate overscrolls in the positive Y direction but scrolls
1270 // somewhat. 1270 // somewhat.
1271 cc::InputHandlerScrollResult overscroll; 1271 cc::InputHandlerScrollResult overscroll;
1272 overscroll.did_scroll = true; 1272 overscroll.did_scroll = true;
1273 overscroll.did_overscroll_root = true; 1273 overscroll.did_overscroll_root = true;
1274 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100); 1274 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100);
(...skipping 10 matching lines...) Expand all
1285 testing::Field( 1285 testing::Field(
1286 &DidOverscrollParams::accumulated_overscroll, 1286 &DidOverscrollParams::accumulated_overscroll,
1287 testing::Eq(overscroll.accumulated_root_overscroll)), 1287 testing::Eq(overscroll.accumulated_root_overscroll)),
1288 testing::Field( 1288 testing::Field(
1289 &DidOverscrollParams::latest_overscroll_delta, 1289 &DidOverscrollParams::latest_overscroll_delta,
1290 testing::Eq(overscroll.unused_scroll_delta)), 1290 testing::Eq(overscroll.unused_scroll_delta)),
1291 testing::Field( 1291 testing::Field(
1292 &DidOverscrollParams::current_fling_velocity, 1292 &DidOverscrollParams::current_fling_velocity,
1293 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))))); 1293 testing::Property(&gfx::Vector2dF::y, testing::Lt(0))))));
1294 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1294 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1295 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1295 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1296 time += base::TimeDelta::FromMilliseconds(100); 1296 time += base::TimeDelta::FromMilliseconds(100);
1297 input_handler_->Animate(time); 1297 input_handler_->Animate(time);
1298 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1298 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1299 1299
1300 // The next call to animate will no longer scroll vertically. 1300 // The next call to animate will no longer scroll vertically.
1301 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1301 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1302 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1302 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1303 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 1303 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
1304 EXPECT_CALL(mock_input_handler_, 1304 EXPECT_CALL(mock_input_handler_,
1305 ScrollBy(testing::_, 1305 ScrollBy(testing::_,
1306 testing::Property(&gfx::Vector2dF::y, testing::Eq(0)))) 1306 testing::Property(&gfx::Vector2dF::y, testing::Eq(0))))
1307 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1307 .WillOnce(testing::Return(scroll_result_did_scroll_));
1308 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1308 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1309 time += base::TimeDelta::FromMilliseconds(100); 1309 time += base::TimeDelta::FromMilliseconds(100);
1310 input_handler_->Animate(time); 1310 input_handler_->Animate(time);
1311 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1311 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
(...skipping 20 matching lines...) Expand all
1332 WebFloatPoint fling_delta = WebFloatPoint(100, 0); 1332 WebFloatPoint fling_delta = WebFloatPoint(100, 0);
1333 WebPoint fling_point = WebPoint(7, 13); 1333 WebPoint fling_point = WebPoint(7, 13);
1334 WebPoint fling_global_point = WebPoint(17, 23); 1334 WebPoint fling_global_point = WebPoint(17, 23);
1335 int modifiers = WebInputEvent::ControlKey; 1335 int modifiers = WebInputEvent::ControlKey;
1336 gesture_ = CreateFling(time, 1336 gesture_ = CreateFling(time,
1337 blink::WebGestureDeviceTouchscreen, 1337 blink::WebGestureDeviceTouchscreen,
1338 fling_delta, 1338 fling_delta,
1339 fling_point, 1339 fling_point,
1340 fling_global_point, 1340 fling_global_point,
1341 modifiers); 1341 modifiers);
1342 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1342 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1343 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 1343 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
1344 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 1344 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
1345 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1345 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1346 1346
1347 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1347 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1348 // With an animation timestamp equivalent to the starting timestamp, the 1348 // With an animation timestamp equivalent to the starting timestamp, the
1349 // animation will simply be rescheduled. 1349 // animation will simply be rescheduled.
1350 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1350 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1351 input_handler_->Animate(time); 1351 input_handler_->Animate(time);
1352 1352
1353 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1353 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1354 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1354 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1355 1355
1356 // A small time delta should not stop the fling, even if the client 1356 // A small time delta should not stop the fling, even if the client
1357 // reports no scrolling. 1357 // reports no scrolling.
1358 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1358 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1359 EXPECT_CALL(mock_input_handler_, 1359 EXPECT_CALL(mock_input_handler_,
1360 ScrollBy(testing::_, 1360 ScrollBy(testing::_,
1361 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) 1361 testing::Property(&gfx::Vector2dF::x, testing::Lt(0))))
1362 .WillOnce(testing::Return(scroll_result_did_not_scroll_)); 1362 .WillOnce(testing::Return(scroll_result_did_not_scroll_));
1363 time += base::TimeDelta::FromMicroseconds(5); 1363 time += base::TimeDelta::FromMicroseconds(5);
1364 input_handler_->Animate(time); 1364 input_handler_->Animate(time);
1365 1365
1366 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1366 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1367 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1367 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1368 1368
1369 // A time delta of zero should not stop the fling, and neither should it 1369 // A time delta of zero should not stop the fling, and neither should it
1370 // trigger scrolling on the client. 1370 // trigger scrolling on the client.
1371 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1371 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1372 input_handler_->Animate(time); 1372 input_handler_->Animate(time);
1373 1373
1374 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1374 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1375 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1375 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1376 1376
1377 // Lack of movement on the client, with a non-trivial scroll delta, should 1377 // Lack of movement on the client, with a non-trivial scroll delta, should
1378 // terminate the fling. 1378 // terminate the fling.
1379 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1379 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1380 EXPECT_CALL(mock_input_handler_, 1380 EXPECT_CALL(mock_input_handler_,
1381 ScrollBy(testing::_, 1381 ScrollBy(testing::_,
(...skipping 23 matching lines...) Expand all
1405 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1405 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1406 1406
1407 // On the fling start, we should schedule an animation but not actually start 1407 // On the fling start, we should schedule an animation but not actually start
1408 // scrolling. 1408 // scrolling.
1409 gesture_.type = WebInputEvent::GestureFlingStart; 1409 gesture_.type = WebInputEvent::GestureFlingStart;
1410 WebFloatPoint fling_delta = WebFloatPoint(100, 100); 1410 WebFloatPoint fling_delta = WebFloatPoint(100, 100);
1411 gesture_.data.flingStart.velocityX = fling_delta.x; 1411 gesture_.data.flingStart.velocityX = fling_delta.x;
1412 gesture_.data.flingStart.velocityY = fling_delta.y; 1412 gesture_.data.flingStart.velocityY = fling_delta.y;
1413 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 1413 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
1414 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 1414 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
1415 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1415 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1416 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1416 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1417 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1417 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1418 1418
1419 // The first animate doesn't cause any scrolling. 1419 // The first animate doesn't cause any scrolling.
1420 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1420 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1421 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); 1421 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
1422 input_handler_->Animate(time); 1422 input_handler_->Animate(time);
1423 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1423 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1424 1424
1425 // The second animate starts scrolling in the positive X and Y directions. 1425 // The second animate starts scrolling in the positive X and Y directions.
1426 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1426 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1427 EXPECT_CALL(mock_input_handler_, 1427 EXPECT_CALL(mock_input_handler_,
1428 ScrollBy(testing::_, 1428 ScrollBy(testing::_,
1429 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))) 1429 testing::Property(&gfx::Vector2dF::y, testing::Lt(0))))
1430 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1430 .WillOnce(testing::Return(scroll_result_did_scroll_));
1431 time += base::TimeDelta::FromMilliseconds(10); 1431 time += base::TimeDelta::FromMilliseconds(10);
1432 input_handler_->Animate(time); 1432 input_handler_->Animate(time);
1433 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1433 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1434 1434
1435 // The third animate hits the bottom content edge. 1435 // The third animate hits the bottom content edge.
1436 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100); 1436 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100);
1437 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 100); 1437 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 100);
1438 EXPECT_CALL(mock_input_handler_, 1438 EXPECT_CALL(mock_input_handler_,
1439 ScrollBy(testing::_, 1439 ScrollBy(testing::_,
1440 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))) 1440 testing::Property(&gfx::Vector2dF::y, testing::Lt(0))))
1441 .WillOnce(testing::Return(overscroll)); 1441 .WillOnce(testing::Return(overscroll));
1442 EXPECT_CALL( 1442 EXPECT_CALL(
1443 mock_client_, 1443 mock_client_,
1444 DidOverscroll(testing::AllOf( 1444 DidOverscroll(testing::AllOf(
1445 testing::Field( 1445 testing::Field(
1446 &DidOverscrollParams::accumulated_overscroll, 1446 &DidOverscrollParams::accumulated_overscroll,
1447 testing::Eq(overscroll.accumulated_root_overscroll)), 1447 testing::Eq(overscroll.accumulated_root_overscroll)),
1448 testing::Field( 1448 testing::Field(
1449 &DidOverscrollParams::latest_overscroll_delta, 1449 &DidOverscrollParams::latest_overscroll_delta,
1450 testing::Eq(overscroll.unused_scroll_delta)), 1450 testing::Eq(overscroll.unused_scroll_delta)),
1451 testing::Field( 1451 testing::Field(
1452 &DidOverscrollParams::current_fling_velocity, 1452 &DidOverscrollParams::current_fling_velocity,
1453 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))))); 1453 testing::Property(&gfx::Vector2dF::y, testing::Lt(0))))));
1454 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1454 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1455 time += base::TimeDelta::FromMilliseconds(10); 1455 time += base::TimeDelta::FromMilliseconds(10);
1456 input_handler_->Animate(time); 1456 input_handler_->Animate(time);
1457 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1457 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1458 1458
1459 // The next call to animate will no longer scroll vertically. 1459 // The next call to animate will no longer scroll vertically.
1460 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1460 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1461 EXPECT_CALL(mock_input_handler_, 1461 EXPECT_CALL(mock_input_handler_,
1462 ScrollBy(testing::_, 1462 ScrollBy(testing::_,
1463 testing::Property(&gfx::Vector2dF::y, testing::Eq(0)))) 1463 testing::Property(&gfx::Vector2dF::y, testing::Eq(0))))
1464 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1464 .WillOnce(testing::Return(scroll_result_did_scroll_));
1465 time += base::TimeDelta::FromMilliseconds(10); 1465 time += base::TimeDelta::FromMilliseconds(10);
1466 input_handler_->Animate(time); 1466 input_handler_->Animate(time);
1467 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1467 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1468 1468
1469 // The next call will hit the right edge. 1469 // The next call will hit the right edge.
1470 overscroll.accumulated_root_overscroll = gfx::Vector2dF(100, 100); 1470 overscroll.accumulated_root_overscroll = gfx::Vector2dF(100, 100);
(...skipping 14 matching lines...) Expand all
1485 testing::Field( 1485 testing::Field(
1486 &DidOverscrollParams::current_fling_velocity, 1486 &DidOverscrollParams::current_fling_velocity,
1487 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))))); 1487 testing::Property(&gfx::Vector2dF::x, testing::Lt(0))))));
1488 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1488 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1489 time += base::TimeDelta::FromMilliseconds(10); 1489 time += base::TimeDelta::FromMilliseconds(10);
1490 input_handler_->Animate(time); 1490 input_handler_->Animate(time);
1491 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1491 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1492 1492
1493 // The next call to animate will no longer scroll horizontally or vertically, 1493 // The next call to animate will no longer scroll horizontally or vertically,
1494 // and the fling should be cancelled. 1494 // and the fling should be cancelled.
1495 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()).Times(0); 1495 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(0);
1496 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_, testing::_)).Times(0); 1496 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_, testing::_)).Times(0);
1497 time += base::TimeDelta::FromMilliseconds(10); 1497 time += base::TimeDelta::FromMilliseconds(10);
1498 input_handler_->Animate(time); 1498 input_handler_->Animate(time);
1499 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1499 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1500 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1500 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1501 } 1501 }
1502 1502
1503 TEST_F(InputHandlerProxyTest, MultiTouchPointHitTestNegative) { 1503 TEST_F(InputHandlerProxyTest, MultiTouchPointHitTestNegative) {
1504 // None of the three touch points fall in the touch region. So the event 1504 // None of the three touch points fall in the touch region. So the event
1505 // should be dropped. 1505 // should be dropped.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1573 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1573 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1574 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1574 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1575 1575
1576 // On the fling start, animation should be scheduled, but no scrolling occurs. 1576 // On the fling start, animation should be scheduled, but no scrolling occurs.
1577 gesture_.type = WebInputEvent::GestureFlingStart; 1577 gesture_.type = WebInputEvent::GestureFlingStart;
1578 WebFloatPoint fling_delta = WebFloatPoint(100, 100); 1578 WebFloatPoint fling_delta = WebFloatPoint(100, 100);
1579 gesture_.data.flingStart.velocityX = fling_delta.x; 1579 gesture_.data.flingStart.velocityX = fling_delta.x;
1580 gesture_.data.flingStart.velocityY = fling_delta.y; 1580 gesture_.data.flingStart.velocityY = fling_delta.y;
1581 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 1581 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
1582 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 1582 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
1583 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1583 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1584 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1584 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1585 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1585 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1586 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1586 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1587 1587
1588 // Keyboard events received during a fling should cancel the active fling. 1588 // Keyboard events received during a fling should cancel the active fling.
1589 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1589 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1590 EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE, 1590 EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE,
1591 input_handler_->HandleInputEvent(key_event)); 1591 input_handler_->HandleInputEvent(key_event));
1592 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1592 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1593 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1593 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 WebFloatPoint fling_delta = WebFloatPoint(100, 0); 1625 WebFloatPoint fling_delta = WebFloatPoint(100, 0);
1626 WebPoint fling_point = WebPoint(7, 13); 1626 WebPoint fling_point = WebPoint(7, 13);
1627 WebPoint fling_global_point = WebPoint(17, 23); 1627 WebPoint fling_global_point = WebPoint(17, 23);
1628 int modifiers = WebInputEvent::ControlKey; 1628 int modifiers = WebInputEvent::ControlKey;
1629 gesture_ = CreateFling(time, 1629 gesture_ = CreateFling(time,
1630 blink::WebGestureDeviceTouchscreen, 1630 blink::WebGestureDeviceTouchscreen,
1631 fling_delta, 1631 fling_delta,
1632 fling_point, 1632 fling_point,
1633 fling_global_point, 1633 fling_global_point,
1634 modifiers); 1634 modifiers);
1635 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1635 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1636 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 1636 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
1637 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 1637 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
1638 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1638 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1639 1639
1640 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1640 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1641 1641
1642 // If we get a negative time delta, that is, the Animation tick time happens 1642 // If we get a negative time delta, that is, the Animation tick time happens
1643 // before the fling's start time then we should *not* try scrolling and 1643 // before the fling's start time then we should *not* try scrolling and
1644 // instead reset the fling start time. 1644 // instead reset the fling start time.
1645 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1645 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1646 EXPECT_CALL(mock_input_handler_, 1646 EXPECT_CALL(mock_input_handler_,
1647 ScrollBy(testing::_, 1647 ScrollBy(testing::_,
1648 testing::_)).Times(0); 1648 testing::_)).Times(0);
1649 time -= base::TimeDelta::FromMilliseconds(5); 1649 time -= base::TimeDelta::FromMilliseconds(5);
1650 input_handler_->Animate(time); 1650 input_handler_->Animate(time);
1651 1651
1652 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1652 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1653 1653
1654 // The first call should have reset the start time so subsequent calls should 1654 // The first call should have reset the start time so subsequent calls should
1655 // generate scroll events. 1655 // generate scroll events.
1656 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1656 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1657 EXPECT_CALL(mock_input_handler_, 1657 EXPECT_CALL(mock_input_handler_,
1658 ScrollBy(testing::_, 1658 ScrollBy(testing::_,
1659 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) 1659 testing::Property(&gfx::Vector2dF::x, testing::Lt(0))))
1660 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1660 .WillOnce(testing::Return(scroll_result_did_scroll_));
1661 1661
1662 input_handler_->Animate(time + base::TimeDelta::FromMilliseconds(1)); 1662 input_handler_->Animate(time + base::TimeDelta::FromMilliseconds(1));
1663 1663
1664 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1664 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1665 1665
1666 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1666 EXPECT_CALL(mock_input_handler_, ScrollEnd());
(...skipping 25 matching lines...) Expand all
1692 gesture_.timeStampSeconds = InSecondsF(time); 1692 gesture_.timeStampSeconds = InSecondsF(time);
1693 gesture_.type = WebInputEvent::GestureScrollBegin; 1693 gesture_.type = WebInputEvent::GestureScrollBegin;
1694 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1694 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1695 1695
1696 VERIFY_AND_RESET_MOCKS(); 1696 VERIFY_AND_RESET_MOCKS();
1697 1697
1698 // Animate calls within the deferred cancellation window should continue. 1698 // Animate calls within the deferred cancellation window should continue.
1699 time += dt; 1699 time += dt;
1700 float expected_delta = 1700 float expected_delta =
1701 (time - last_animate_time).InSecondsF() * -fling_delta.x; 1701 (time - last_animate_time).InSecondsF() * -fling_delta.x;
1702 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1702 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1703 EXPECT_CALL(mock_input_handler_, 1703 EXPECT_CALL(mock_input_handler_,
1704 ScrollBy(testing::_, 1704 ScrollBy(testing::_,
1705 testing::Property(&gfx::Vector2dF::x, 1705 testing::Property(&gfx::Vector2dF::x,
1706 testing::Eq(expected_delta)))) 1706 testing::Eq(expected_delta))))
1707 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1707 .WillOnce(testing::Return(scroll_result_did_scroll_));
1708 input_handler_->Animate(time); 1708 input_handler_->Animate(time);
1709 last_animate_time = time; 1709 last_animate_time = time;
1710 1710
1711 VERIFY_AND_RESET_MOCKS(); 1711 VERIFY_AND_RESET_MOCKS();
1712 1712
1713 // GestureScrollUpdates in the same direction and at sufficient speed should 1713 // GestureScrollUpdates in the same direction and at sufficient speed should
1714 // be swallowed by the fling. 1714 // be swallowed by the fling.
1715 time += dt; 1715 time += dt;
1716 gesture_.timeStampSeconds = InSecondsF(time); 1716 gesture_.timeStampSeconds = InSecondsF(time);
1717 gesture_.type = WebInputEvent::GestureScrollUpdate; 1717 gesture_.type = WebInputEvent::GestureScrollUpdate;
1718 gesture_.data.scrollUpdate.deltaX = fling_delta.x; 1718 gesture_.data.scrollUpdate.deltaX = fling_delta.x;
1719 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1719 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1720 1720
1721 VERIFY_AND_RESET_MOCKS(); 1721 VERIFY_AND_RESET_MOCKS();
1722 1722
1723 // Animate calls within the deferred cancellation window should continue. 1723 // Animate calls within the deferred cancellation window should continue.
1724 time += dt; 1724 time += dt;
1725 expected_delta = (time - last_animate_time).InSecondsF() * -fling_delta.x; 1725 expected_delta = (time - last_animate_time).InSecondsF() * -fling_delta.x;
1726 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1726 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1727 EXPECT_CALL(mock_input_handler_, 1727 EXPECT_CALL(mock_input_handler_,
1728 ScrollBy(testing::_, 1728 ScrollBy(testing::_,
1729 testing::Property(&gfx::Vector2dF::x, 1729 testing::Property(&gfx::Vector2dF::x,
1730 testing::Eq(expected_delta)))) 1730 testing::Eq(expected_delta))))
1731 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1731 .WillOnce(testing::Return(scroll_result_did_scroll_));
1732 input_handler_->Animate(time); 1732 input_handler_->Animate(time);
1733 last_animate_time = time; 1733 last_animate_time = time;
1734 1734
1735 VERIFY_AND_RESET_MOCKS(); 1735 VERIFY_AND_RESET_MOCKS();
1736 1736
1737 // GestureFlingStart in the same direction and at sufficient speed should 1737 // GestureFlingStart in the same direction and at sufficient speed should
1738 // boost the active fling. 1738 // boost the active fling.
1739 1739
1740 gesture_ = CreateFling(time, 1740 gesture_ = CreateFling(time,
1741 blink::WebGestureDeviceTouchscreen, 1741 blink::WebGestureDeviceTouchscreen,
1742 fling_delta, 1742 fling_delta,
1743 fling_point, 1743 fling_point,
1744 fling_point, 1744 fling_point,
1745 0); 1745 0);
1746 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1746 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1747 VERIFY_AND_RESET_MOCKS(); 1747 VERIFY_AND_RESET_MOCKS();
1748 1748
1749 time += dt; 1749 time += dt;
1750 // Note we get *2x* as much delta because 2 flings have combined. 1750 // Note we get *2x* as much delta because 2 flings have combined.
1751 expected_delta = 2 * (time - last_animate_time).InSecondsF() * -fling_delta.x; 1751 expected_delta = 2 * (time - last_animate_time).InSecondsF() * -fling_delta.x;
1752 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1752 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1753 EXPECT_CALL(mock_input_handler_, 1753 EXPECT_CALL(mock_input_handler_,
1754 ScrollBy(testing::_, 1754 ScrollBy(testing::_,
1755 testing::Property(&gfx::Vector2dF::x, 1755 testing::Property(&gfx::Vector2dF::x,
1756 testing::Eq(expected_delta)))) 1756 testing::Eq(expected_delta))))
1757 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1757 .WillOnce(testing::Return(scroll_result_did_scroll_));
1758 input_handler_->Animate(time); 1758 input_handler_->Animate(time);
1759 last_animate_time = time; 1759 last_animate_time = time;
1760 1760
1761 VERIFY_AND_RESET_MOCKS(); 1761 VERIFY_AND_RESET_MOCKS();
1762 1762
1763 // Repeated GestureFlingStarts should accumulate. 1763 // Repeated GestureFlingStarts should accumulate.
1764 1764
1765 CancelFling(time); 1765 CancelFling(time);
1766 gesture_ = CreateFling(time, 1766 gesture_ = CreateFling(time,
1767 blink::WebGestureDeviceTouchscreen, 1767 blink::WebGestureDeviceTouchscreen,
1768 fling_delta, 1768 fling_delta,
1769 fling_point, 1769 fling_point,
1770 fling_point, 1770 fling_point,
1771 0); 1771 0);
1772 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1772 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1773 VERIFY_AND_RESET_MOCKS(); 1773 VERIFY_AND_RESET_MOCKS();
1774 1774
1775 time += dt; 1775 time += dt;
1776 // Note we get *3x* as much delta because 3 flings have combined. 1776 // Note we get *3x* as much delta because 3 flings have combined.
1777 expected_delta = 3 * (time - last_animate_time).InSecondsF() * -fling_delta.x; 1777 expected_delta = 3 * (time - last_animate_time).InSecondsF() * -fling_delta.x;
1778 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1778 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1779 EXPECT_CALL(mock_input_handler_, 1779 EXPECT_CALL(mock_input_handler_,
1780 ScrollBy(testing::_, 1780 ScrollBy(testing::_,
1781 testing::Property(&gfx::Vector2dF::x, 1781 testing::Property(&gfx::Vector2dF::x,
1782 testing::Eq(expected_delta)))) 1782 testing::Eq(expected_delta))))
1783 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1783 .WillOnce(testing::Return(scroll_result_did_scroll_));
1784 input_handler_->Animate(time); 1784 input_handler_->Animate(time);
1785 last_animate_time = time; 1785 last_animate_time = time;
1786 1786
1787 VERIFY_AND_RESET_MOCKS(); 1787 VERIFY_AND_RESET_MOCKS();
1788 1788
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1894 fling_point, 1894 fling_point,
1895 0); 1895 0);
1896 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1896 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1897 1897
1898 VERIFY_AND_RESET_MOCKS(); 1898 VERIFY_AND_RESET_MOCKS();
1899 1899
1900 // Note that the new fling delta uses the orthogonal, unboosted fling 1900 // Note that the new fling delta uses the orthogonal, unboosted fling
1901 // velocity. 1901 // velocity.
1902 time += dt; 1902 time += dt;
1903 float expected_delta = dt.InSecondsF() * -orthogonal_fling_delta.y; 1903 float expected_delta = dt.InSecondsF() * -orthogonal_fling_delta.y;
1904 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1904 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1905 EXPECT_CALL(mock_input_handler_, 1905 EXPECT_CALL(mock_input_handler_,
1906 ScrollBy(testing::_, 1906 ScrollBy(testing::_,
1907 testing::Property(&gfx::Vector2dF::y, 1907 testing::Property(&gfx::Vector2dF::y,
1908 testing::Eq(expected_delta)))) 1908 testing::Eq(expected_delta))))
1909 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1909 .WillOnce(testing::Return(scroll_result_did_scroll_));
1910 input_handler_->Animate(time); 1910 input_handler_->Animate(time);
1911 1911
1912 VERIFY_AND_RESET_MOCKS(); 1912 VERIFY_AND_RESET_MOCKS();
1913 } 1913 }
1914 1914
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1979 fling_point, 1979 fling_point,
1980 fling_point, 1980 fling_point,
1981 0); 1981 0);
1982 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1982 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1983 1983
1984 VERIFY_AND_RESET_MOCKS(); 1984 VERIFY_AND_RESET_MOCKS();
1985 1985
1986 // Note that the new fling delta uses the *slow*, unboosted fling velocity. 1986 // Note that the new fling delta uses the *slow*, unboosted fling velocity.
1987 time += dt; 1987 time += dt;
1988 float expected_delta = dt.InSecondsF() * -small_fling_delta.x; 1988 float expected_delta = dt.InSecondsF() * -small_fling_delta.x;
1989 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1989 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
1990 EXPECT_CALL(mock_input_handler_, 1990 EXPECT_CALL(mock_input_handler_,
1991 ScrollBy(testing::_, 1991 ScrollBy(testing::_,
1992 testing::Property(&gfx::Vector2dF::x, 1992 testing::Property(&gfx::Vector2dF::x,
1993 testing::Eq(expected_delta)))) 1993 testing::Eq(expected_delta))))
1994 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1994 .WillOnce(testing::Return(scroll_result_did_scroll_));
1995 input_handler_->Animate(time); 1995 input_handler_->Animate(time);
1996 1996
1997 VERIFY_AND_RESET_MOCKS(); 1997 VERIFY_AND_RESET_MOCKS();
1998 } 1998 }
1999 1999
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2109 TEST_F(InputHandlerProxyTest, DidReceiveInputEvent_ForFling) { 2109 TEST_F(InputHandlerProxyTest, DidReceiveInputEvent_ForFling) {
2110 testing::StrictMock< 2110 testing::StrictMock<
2111 MockInputHandlerProxyClientWithDidReceiveInputEvent> mock_client; 2111 MockInputHandlerProxyClientWithDidReceiveInputEvent> mock_client;
2112 input_handler_.reset( 2112 input_handler_.reset(
2113 new content::InputHandlerProxy(&mock_input_handler_, &mock_client)); 2113 new content::InputHandlerProxy(&mock_input_handler_, &mock_client));
2114 2114
2115 gesture_.type = WebInputEvent::GestureFlingStart; 2115 gesture_.type = WebInputEvent::GestureFlingStart;
2116 WebFloatPoint fling_delta = WebFloatPoint(100, 100); 2116 WebFloatPoint fling_delta = WebFloatPoint(100, 100);
2117 gesture_.data.flingStart.velocityX = fling_delta.x; 2117 gesture_.data.flingStart.velocityX = fling_delta.x;
2118 gesture_.data.flingStart.velocityY = fling_delta.y; 2118 gesture_.data.flingStart.velocityY = fling_delta.y;
2119 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 2119 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
2120 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 2120 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
2121 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 2121 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
2122 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 2122 EXPECT_CALL(mock_input_handler_, ScrollEnd());
2123 EXPECT_CALL(mock_client, 2123 EXPECT_CALL(mock_client,
2124 DidReceiveInputEvent(Field(&WebInputEvent::type, 2124 DidReceiveInputEvent(Field(&WebInputEvent::type,
2125 WebInputEvent::GestureFlingStart))); 2125 WebInputEvent::GestureFlingStart)));
2126 EXPECT_EQ(InputHandlerProxy::DID_HANDLE, 2126 EXPECT_EQ(InputHandlerProxy::DID_HANDLE,
2127 input_handler_->HandleInputEvent(gesture_)); 2127 input_handler_->HandleInputEvent(gesture_));
2128 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 2128 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
2129 testing::Mock::VerifyAndClearExpectations(&mock_client); 2129 testing::Mock::VerifyAndClearExpectations(&mock_client);
2130 2130
2131 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 2131 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
2132 EXPECT_CALL(mock_client, DidAnimateForInput()); 2132 EXPECT_CALL(mock_client, DidAnimateForInput());
2133 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); 2133 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
2134 input_handler_->Animate(time); 2134 input_handler_->Animate(time);
2135 2135
2136 testing::Mock::VerifyAndClearExpectations(&mock_client); 2136 testing::Mock::VerifyAndClearExpectations(&mock_client);
2137 } 2137 }
2138 2138
2139 } // namespace 2139 } // namespace
2140 } // namespace content 2140 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698