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

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

Issue 1052773002: cc: Add a rails argument to InputHandler::ScrollBy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comiple Created 5 years, 8 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
« no previous file with comments | « content/renderer/input/input_handler_proxy.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 MOCK_METHOD0(PinchGestureEnd, void()); 83 MOCK_METHOD0(PinchGestureEnd, void());
84 84
85 MOCK_METHOD0(SetNeedsAnimate, void()); 85 MOCK_METHOD0(SetNeedsAnimate, 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_METHOD3(
94 cc::InputHandlerScrollResult( 94 ScrollBy,
95 const gfx::Point& viewport_point, 95 cc::InputHandlerScrollResult(const gfx::Point& viewport_point,
96 const gfx::Vector2dF& scroll_delta)); 96 const gfx::Vector2dF& scroll_delta,
97 cc::InputHandler::RailsMode rails_mode));
97 MOCK_METHOD2(ScrollVerticallyByPage, 98 MOCK_METHOD2(ScrollVerticallyByPage,
98 bool(const gfx::Point& viewport_point, 99 bool(const gfx::Point& viewport_point,
99 cc::ScrollDirection direction)); 100 cc::ScrollDirection direction));
100 MOCK_METHOD0(ScrollEnd, void()); 101 MOCK_METHOD0(ScrollEnd, void());
101 MOCK_METHOD0(FlingScrollBegin, cc::InputHandler::ScrollStatus()); 102 MOCK_METHOD0(FlingScrollBegin, cc::InputHandler::ScrollStatus());
102 103
103 virtual scoped_ptr<cc::SwapPromiseMonitor> 104 virtual scoped_ptr<cc::SwapPromiseMonitor>
104 CreateLatencyInfoSwapPromiseMonitor(ui::LatencyInfo* latency) override { 105 CreateLatencyInfoSwapPromiseMonitor(ui::LatencyInfo* latency) override {
105 return scoped_ptr<cc::SwapPromiseMonitor>(); 106 return scoped_ptr<cc::SwapPromiseMonitor>();
106 } 107 }
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 314
314 // The event should not be marked as handled if scrolling is not possible. 315 // The event should not be marked as handled if scrolling is not possible.
315 expected_disposition_ = InputHandlerProxy::DROP_EVENT; 316 expected_disposition_ = InputHandlerProxy::DROP_EVENT;
316 VERIFY_AND_RESET_MOCKS(); 317 VERIFY_AND_RESET_MOCKS();
317 318
318 gesture_.type = WebInputEvent::GestureScrollUpdate; 319 gesture_.type = WebInputEvent::GestureScrollUpdate;
319 gesture_.data.scrollUpdate.deltaY = 320 gesture_.data.scrollUpdate.deltaY =
320 -40; // -Y means scroll down - i.e. in the +Y direction. 321 -40; // -Y means scroll down - i.e. in the +Y direction.
321 EXPECT_CALL(mock_input_handler_, 322 EXPECT_CALL(mock_input_handler_,
322 ScrollBy(testing::_, 323 ScrollBy(testing::_,
323 testing::Property(&gfx::Vector2dF::y, testing::Gt(0)))) 324 testing::Property(&gfx::Vector2dF::y, testing::Gt(0)),
325 cc::InputHandler::RAILS_MODE_FREE))
324 .WillOnce(testing::Return(scroll_result_did_not_scroll_)); 326 .WillOnce(testing::Return(scroll_result_did_not_scroll_));
325 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 327 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
326 328
327 // Mark the event as handled if scroll happens. 329 // Mark the event as handled if scroll happens.
328 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 330 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
329 VERIFY_AND_RESET_MOCKS(); 331 VERIFY_AND_RESET_MOCKS();
330 332
331 gesture_.type = WebInputEvent::GestureScrollUpdate; 333 gesture_.type = WebInputEvent::GestureScrollUpdate;
332 gesture_.data.scrollUpdate.deltaY = 334 gesture_.data.scrollUpdate.deltaY =
333 -40; // -Y means scroll down - i.e. in the +Y direction. 335 -40; // -Y means scroll down - i.e. in the +Y direction.
334 EXPECT_CALL(mock_input_handler_, 336 EXPECT_CALL(mock_input_handler_,
335 ScrollBy(testing::_, 337 ScrollBy(testing::_,
336 testing::Property(&gfx::Vector2dF::y, testing::Gt(0)))) 338 testing::Property(&gfx::Vector2dF::y, testing::Gt(0)),
339 cc::InputHandler::RAILS_MODE_FREE))
337 .WillOnce(testing::Return(scroll_result_did_scroll_)); 340 .WillOnce(testing::Return(scroll_result_did_scroll_));
338 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 341 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
339 342
340 VERIFY_AND_RESET_MOCKS(); 343 VERIFY_AND_RESET_MOCKS();
341 344
342 gesture_.type = WebInputEvent::GestureScrollEnd; 345 gesture_.type = WebInputEvent::GestureScrollEnd;
343 gesture_.data.scrollUpdate.deltaY = 0; 346 gesture_.data.scrollUpdate.deltaY = 0;
344 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 347 EXPECT_CALL(mock_input_handler_, ScrollEnd());
345 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 348 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
346 } 349 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(1.5, gfx::Point(7, 13))); 499 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(1.5, gfx::Point(7, 13)));
497 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 500 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
498 501
499 VERIFY_AND_RESET_MOCKS(); 502 VERIFY_AND_RESET_MOCKS();
500 503
501 gesture_.type = WebInputEvent::GestureScrollUpdate; 504 gesture_.type = WebInputEvent::GestureScrollUpdate;
502 gesture_.data.scrollUpdate.deltaY = 505 gesture_.data.scrollUpdate.deltaY =
503 -40; // -Y means scroll down - i.e. in the +Y direction. 506 -40; // -Y means scroll down - i.e. in the +Y direction.
504 EXPECT_CALL(mock_input_handler_, 507 EXPECT_CALL(mock_input_handler_,
505 ScrollBy(testing::_, 508 ScrollBy(testing::_,
506 testing::Property(&gfx::Vector2dF::y, testing::Gt(0)))) 509 testing::Property(&gfx::Vector2dF::y, testing::Gt(0)),
510 cc::InputHandler::RAILS_MODE_FREE))
507 .WillOnce(testing::Return(scroll_result_did_scroll_)); 511 .WillOnce(testing::Return(scroll_result_did_scroll_));
508 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 512 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
509 513
510 VERIFY_AND_RESET_MOCKS(); 514 VERIFY_AND_RESET_MOCKS();
511 515
512 gesture_.type = WebInputEvent::GesturePinchUpdate; 516 gesture_.type = WebInputEvent::GesturePinchUpdate;
513 gesture_.data.pinchUpdate.scale = 0.5; 517 gesture_.data.pinchUpdate.scale = 0.5;
514 gesture_.x = 9; 518 gesture_.x = 9;
515 gesture_.y = 6; 519 gesture_.y = 6;
516 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(.5, gfx::Point(9, 6))); 520 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(.5, gfx::Point(9, 6)));
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 input_handler_->Animate(time); 645 input_handler_->Animate(time);
642 646
643 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 647 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
644 648
645 // The second call should start scrolling in the -X direction. 649 // The second call should start scrolling in the -X direction.
646 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 650 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
647 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 651 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
648 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 652 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
649 EXPECT_CALL(mock_input_handler_, 653 EXPECT_CALL(mock_input_handler_,
650 ScrollBy(testing::_, 654 ScrollBy(testing::_,
651 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) 655 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)),
656 cc::InputHandler::RAILS_MODE_FREE))
652 .WillOnce(testing::Return(scroll_result_did_scroll_)); 657 .WillOnce(testing::Return(scroll_result_did_scroll_));
653 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 658 EXPECT_CALL(mock_input_handler_, ScrollEnd());
654 time += base::TimeDelta::FromMilliseconds(100); 659 time += base::TimeDelta::FromMilliseconds(100);
655 input_handler_->Animate(time); 660 input_handler_->Animate(time);
656 661
657 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 662 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
658 663
659 // Let's say on the third call we hit a non-scrollable region. We should abort 664 // Let's say on the third call we hit a non-scrollable region. We should abort
660 // the fling and not scroll. 665 // the fling and not scroll.
661 // We also should pass the current fling parameters out to the client so the 666 // We also should pass the current fling parameters out to the client so the
662 // rest of the fling can be 667 // rest of the fling can be
663 // transferred to the main thread. 668 // transferred to the main thread.
664 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 669 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
665 .WillOnce(testing::Return(cc::InputHandler::SCROLL_ON_MAIN_THREAD)); 670 .WillOnce(testing::Return(cc::InputHandler::SCROLL_ON_MAIN_THREAD));
666 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_, testing::_)).Times(0); 671 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_, testing::_,
672 cc::InputHandler::RAILS_MODE_FREE))
673 .Times(0);
667 EXPECT_CALL(mock_input_handler_, ScrollEnd()).Times(0); 674 EXPECT_CALL(mock_input_handler_, ScrollEnd()).Times(0);
668 // Expected wheel fling animation parameters: 675 // Expected wheel fling animation parameters:
669 // *) fling_delta and fling_point should match the original GestureFlingStart 676 // *) fling_delta and fling_point should match the original GestureFlingStart
670 // event 677 // event
671 // *) startTime should be 10 to match the time parameter of the first 678 // *) startTime should be 10 to match the time parameter of the first
672 // Animate() call after the GestureFlingStart 679 // Animate() call after the GestureFlingStart
673 // *) cumulativeScroll depends on the curve, but since we've animated in the 680 // *) cumulativeScroll depends on the curve, but since we've animated in the
674 // -X direction the X value should be < 0 681 // -X direction the X value should be < 0
675 EXPECT_CALL( 682 EXPECT_CALL(
676 mock_client_, 683 mock_client_,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 input_handler_->Animate(time); 751 input_handler_->Animate(time);
745 752
746 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 753 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
747 754
748 // The second call should start scrolling in the -X direction. 755 // The second call should start scrolling in the -X direction.
749 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 756 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
750 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 757 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
751 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 758 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
752 EXPECT_CALL(mock_input_handler_, 759 EXPECT_CALL(mock_input_handler_,
753 ScrollBy(testing::_, 760 ScrollBy(testing::_,
754 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) 761 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)),
762 cc::InputHandler::RAILS_MODE_FREE))
755 .WillOnce(testing::Return(scroll_result_did_scroll_)); 763 .WillOnce(testing::Return(scroll_result_did_scroll_));
756 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 764 EXPECT_CALL(mock_input_handler_, ScrollEnd());
757 time += base::TimeDelta::FromMilliseconds(100); 765 time += base::TimeDelta::FromMilliseconds(100);
758 input_handler_->Animate(time); 766 input_handler_->Animate(time);
759 767
760 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 768 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
761 769
762 // Let's say on the third call we hit a non-scrollable region. We should abort 770 // Let's say on the third call we hit a non-scrollable region. We should abort
763 // the fling and not scroll. 771 // the fling and not scroll.
764 // We also should pass the current fling parameters out to the client so the 772 // We also should pass the current fling parameters out to the client so the
765 // rest of the fling can be 773 // rest of the fling can be
766 // transferred to the main thread. 774 // transferred to the main thread.
767 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 775 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
768 .WillOnce(testing::Return(cc::InputHandler::SCROLL_ON_MAIN_THREAD)); 776 .WillOnce(testing::Return(cc::InputHandler::SCROLL_ON_MAIN_THREAD));
769 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_, testing::_)).Times(0); 777 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_, testing::_,
778 cc::InputHandler::RAILS_MODE_FREE))
779 .Times(0);
770 EXPECT_CALL(mock_input_handler_, ScrollEnd()).Times(0); 780 EXPECT_CALL(mock_input_handler_, ScrollEnd()).Times(0);
771 781
772 // Expected wheel fling animation parameters: 782 // Expected wheel fling animation parameters:
773 // *) fling_delta and fling_point should match the original GestureFlingStart 783 // *) fling_delta and fling_point should match the original GestureFlingStart
774 // event 784 // event
775 // *) startTime should be 10 to match the time parameter of the first 785 // *) startTime should be 10 to match the time parameter of the first
776 // Animate() call after the GestureFlingStart 786 // Animate() call after the GestureFlingStart
777 // *) cumulativeScroll depends on the curve, but since we've animated in the 787 // *) cumulativeScroll depends on the curve, but since we've animated in the
778 // -X direction the X value should be < 0 788 // -X direction the X value should be < 0
779 EXPECT_CALL( 789 EXPECT_CALL(
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 input_handler_->Animate(time); 855 input_handler_->Animate(time);
846 856
847 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 857 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
848 858
849 // Tick the second fling once normally. 859 // Tick the second fling once normally.
850 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 860 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
851 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 861 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
852 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 862 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
853 EXPECT_CALL(mock_input_handler_, 863 EXPECT_CALL(mock_input_handler_,
854 ScrollBy(testing::_, 864 ScrollBy(testing::_,
855 testing::Property(&gfx::Vector2dF::y, testing::Gt(0)))) 865 testing::Property(&gfx::Vector2dF::y, testing::Gt(0)),
866 cc::InputHandler::RAILS_MODE_FREE))
856 .WillOnce(testing::Return(scroll_result_did_scroll_)); 867 .WillOnce(testing::Return(scroll_result_did_scroll_));
857 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 868 EXPECT_CALL(mock_input_handler_, ScrollEnd());
858 time += base::TimeDelta::FromMilliseconds(100); 869 time += base::TimeDelta::FromMilliseconds(100);
859 input_handler_->Animate(time); 870 input_handler_->Animate(time);
860 871
861 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 872 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
862 873
863 // Then abort the second fling. 874 // Then abort the second fling.
864 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 875 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
865 .WillOnce(testing::Return(cc::InputHandler::SCROLL_ON_MAIN_THREAD)); 876 .WillOnce(testing::Return(cc::InputHandler::SCROLL_ON_MAIN_THREAD));
866 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_, testing::_)).Times(0); 877 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_, testing::_,
878 cc::InputHandler::RAILS_MODE_FREE))
879 .Times(0);
867 EXPECT_CALL(mock_input_handler_, ScrollEnd()).Times(0); 880 EXPECT_CALL(mock_input_handler_, ScrollEnd()).Times(0);
868 881
869 // We should get parameters from the second fling, nothing from the first 882 // We should get parameters from the second fling, nothing from the first
870 // fling should "leak". 883 // fling should "leak".
871 EXPECT_CALL( 884 EXPECT_CALL(
872 mock_client_, 885 mock_client_,
873 TransferActiveWheelFlingAnimation(testing::AllOf( 886 TransferActiveWheelFlingAnimation(testing::AllOf(
874 testing::Field(&WebActiveWheelFlingParameters::delta, 887 testing::Field(&WebActiveWheelFlingParameters::delta,
875 testing::Eq(fling_delta)), 888 testing::Eq(fling_delta)),
876 testing::Field(&WebActiveWheelFlingParameters::point, 889 testing::Field(&WebActiveWheelFlingParameters::point,
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1035 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1023 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); 1036 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
1024 input_handler_->Animate(time); 1037 input_handler_->Animate(time);
1025 1038
1026 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1039 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1027 1040
1028 // The second call should start scrolling in the -X direction. 1041 // The second call should start scrolling in the -X direction.
1029 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1042 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1030 EXPECT_CALL(mock_input_handler_, 1043 EXPECT_CALL(mock_input_handler_,
1031 ScrollBy(testing::_, 1044 ScrollBy(testing::_,
1032 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) 1045 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)),
1046 cc::InputHandler::RAILS_MODE_FREE))
1033 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1047 .WillOnce(testing::Return(scroll_result_did_scroll_));
1034 time += base::TimeDelta::FromMilliseconds(100); 1048 time += base::TimeDelta::FromMilliseconds(100);
1035 input_handler_->Animate(time); 1049 input_handler_->Animate(time);
1036 1050
1037 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1051 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1038 1052
1039 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1053 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1040 gesture_.type = WebInputEvent::GestureFlingCancel; 1054 gesture_.type = WebInputEvent::GestureFlingCancel;
1041 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1055 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1042 } 1056 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 1090
1077 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1091 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1078 // With a valid time stamp, the first animate call should skip start time 1092 // With a valid time stamp, the first animate call should skip start time
1079 // initialization and immediately begin scroll update production. This reduces 1093 // initialization and immediately begin scroll update production. This reduces
1080 // the likelihood of a hitch between the scroll preceding the fling and 1094 // the likelihood of a hitch between the scroll preceding the fling and
1081 // the first scroll generated by the fling. 1095 // the first scroll generated by the fling.
1082 // Scrolling should start in the -X direction. 1096 // Scrolling should start in the -X direction.
1083 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1097 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1084 EXPECT_CALL(mock_input_handler_, 1098 EXPECT_CALL(mock_input_handler_,
1085 ScrollBy(testing::_, 1099 ScrollBy(testing::_,
1086 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) 1100 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)),
1101 cc::InputHandler::RAILS_MODE_FREE))
1087 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1102 .WillOnce(testing::Return(scroll_result_did_scroll_));
1088 time += dt; 1103 time += dt;
1089 input_handler_->Animate(time); 1104 input_handler_->Animate(time);
1090 1105
1091 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1106 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1092 1107
1093 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1108 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1094 gesture_.type = WebInputEvent::GestureFlingCancel; 1109 gesture_.type = WebInputEvent::GestureFlingCancel;
1095 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1110 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1096 } 1111 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 base::TimeTicks time = 1154 base::TimeTicks time =
1140 base::TimeTicks() + start_time_offset + base::TimeDelta::FromSeconds(1); 1155 base::TimeTicks() + start_time_offset + base::TimeDelta::FromSeconds(1);
1141 input_handler_->Animate(time); 1156 input_handler_->Animate(time);
1142 1157
1143 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1158 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1144 1159
1145 // Further animation ticks should update the fling as usual. 1160 // Further animation ticks should update the fling as usual.
1146 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1161 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1147 EXPECT_CALL(mock_input_handler_, 1162 EXPECT_CALL(mock_input_handler_,
1148 ScrollBy(testing::_, 1163 ScrollBy(testing::_,
1149 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) 1164 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)),
1165 cc::InputHandler::RAILS_MODE_FREE))
1150 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1166 .WillOnce(testing::Return(scroll_result_did_scroll_));
1151 time += base::TimeDelta::FromMilliseconds(10); 1167 time += base::TimeDelta::FromMilliseconds(10);
1152 input_handler_->Animate(time); 1168 input_handler_->Animate(time);
1153 1169
1154 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1170 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1155 1171
1156 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1172 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1157 gesture_.type = WebInputEvent::GestureFlingCancel; 1173 gesture_.type = WebInputEvent::GestureFlingCancel;
1158 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1174 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1159 } 1175 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1222 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1207 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); 1223 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
1208 input_handler_->Animate(time); 1224 input_handler_->Animate(time);
1209 1225
1210 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1226 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1211 1227
1212 // The second call should start scrolling in the -X direction. 1228 // The second call should start scrolling in the -X direction.
1213 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1229 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1214 EXPECT_CALL(mock_input_handler_, 1230 EXPECT_CALL(mock_input_handler_,
1215 ScrollBy(testing::_, 1231 ScrollBy(testing::_,
1216 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) 1232 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)),
1233 cc::InputHandler::RAILS_MODE_FREE))
1217 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1234 .WillOnce(testing::Return(scroll_result_did_scroll_));
1218 time += base::TimeDelta::FromMilliseconds(100); 1235 time += base::TimeDelta::FromMilliseconds(100);
1219 input_handler_->Animate(time); 1236 input_handler_->Animate(time);
1220 1237
1221 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1238 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1222 1239
1223 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1240 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1224 gesture_.type = WebInputEvent::GestureFlingCancel; 1241 gesture_.type = WebInputEvent::GestureFlingCancel;
1225 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1242 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1226 1243
(...skipping 24 matching lines...) Expand all
1251 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1268 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1252 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); 1269 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
1253 input_handler_->Animate(time); 1270 input_handler_->Animate(time);
1254 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1271 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1255 1272
1256 // The second animate starts scrolling in the positive X and Y directions. 1273 // The second animate starts scrolling in the positive X and Y directions.
1257 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1274 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1258 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 1275 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
1259 EXPECT_CALL(mock_input_handler_, 1276 EXPECT_CALL(mock_input_handler_,
1260 ScrollBy(testing::_, 1277 ScrollBy(testing::_,
1261 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))) 1278 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)),
1279 cc::InputHandler::RAILS_MODE_FREE))
1262 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1280 .WillOnce(testing::Return(scroll_result_did_scroll_));
1263 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1281 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1264 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1282 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1265 time += base::TimeDelta::FromMilliseconds(100); 1283 time += base::TimeDelta::FromMilliseconds(100);
1266 input_handler_->Animate(time); 1284 input_handler_->Animate(time);
1267 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1285 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1268 1286
1269 // The third animate overscrolls in the positive Y direction but scrolls 1287 // The third animate overscrolls in the positive Y direction but scrolls
1270 // somewhat. 1288 // somewhat.
1271 cc::InputHandlerScrollResult overscroll; 1289 cc::InputHandlerScrollResult overscroll;
1272 overscroll.did_scroll = true; 1290 overscroll.did_scroll = true;
1273 overscroll.did_overscroll_root = true; 1291 overscroll.did_overscroll_root = true;
1274 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100); 1292 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100);
1275 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 10); 1293 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 10);
1276 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1294 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1277 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 1295 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
1278 EXPECT_CALL(mock_input_handler_, 1296 EXPECT_CALL(mock_input_handler_,
1279 ScrollBy(testing::_, 1297 ScrollBy(testing::_,
1280 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))) 1298 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)),
1299 cc::InputHandler::RAILS_MODE_FREE))
1281 .WillOnce(testing::Return(overscroll)); 1300 .WillOnce(testing::Return(overscroll));
1282 EXPECT_CALL( 1301 EXPECT_CALL(
1283 mock_client_, 1302 mock_client_,
1284 DidOverscroll(testing::AllOf( 1303 DidOverscroll(testing::AllOf(
1285 testing::Field( 1304 testing::Field(
1286 &DidOverscrollParams::accumulated_overscroll, 1305 &DidOverscrollParams::accumulated_overscroll,
1287 testing::Eq(overscroll.accumulated_root_overscroll)), 1306 testing::Eq(overscroll.accumulated_root_overscroll)),
1288 testing::Field( 1307 testing::Field(
1289 &DidOverscrollParams::latest_overscroll_delta, 1308 &DidOverscrollParams::latest_overscroll_delta,
1290 testing::Eq(overscroll.unused_scroll_delta)), 1309 testing::Eq(overscroll.unused_scroll_delta)),
1291 testing::Field( 1310 testing::Field(
1292 &DidOverscrollParams::current_fling_velocity, 1311 &DidOverscrollParams::current_fling_velocity,
1293 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))))); 1312 testing::Property(&gfx::Vector2dF::y, testing::Lt(0))))));
1294 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1313 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1295 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1314 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1296 time += base::TimeDelta::FromMilliseconds(100); 1315 time += base::TimeDelta::FromMilliseconds(100);
1297 input_handler_->Animate(time); 1316 input_handler_->Animate(time);
1298 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1317 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1299 1318
1300 // The next call to animate will no longer scroll vertically. 1319 // The next call to animate will no longer scroll vertically.
1301 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1320 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1302 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1321 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1303 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 1322 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
1304 EXPECT_CALL(mock_input_handler_, 1323 EXPECT_CALL(mock_input_handler_,
1305 ScrollBy(testing::_, 1324 ScrollBy(testing::_,
1306 testing::Property(&gfx::Vector2dF::y, testing::Eq(0)))) 1325 testing::Property(&gfx::Vector2dF::y, testing::Eq(0)),
1326 cc::InputHandler::RAILS_MODE_FREE))
1307 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1327 .WillOnce(testing::Return(scroll_result_did_scroll_));
1308 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1328 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1309 time += base::TimeDelta::FromMilliseconds(100); 1329 time += base::TimeDelta::FromMilliseconds(100);
1310 input_handler_->Animate(time); 1330 input_handler_->Animate(time);
1311 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1331 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1312 } 1332 }
1313 1333
1314 TEST_F(InputHandlerProxyTest, GestureFlingNotCancelledBySmallTimeDelta) { 1334 TEST_F(InputHandlerProxyTest, GestureFlingNotCancelledBySmallTimeDelta) {
1315 // We shouldn't send any events to the widget for this gesture. 1335 // We shouldn't send any events to the widget for this gesture.
1316 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1336 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 input_handler_->Animate(time); 1371 input_handler_->Animate(time);
1352 1372
1353 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1373 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1354 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1374 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1355 1375
1356 // A small time delta should not stop the fling, even if the client 1376 // A small time delta should not stop the fling, even if the client
1357 // reports no scrolling. 1377 // reports no scrolling.
1358 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1378 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1359 EXPECT_CALL(mock_input_handler_, 1379 EXPECT_CALL(mock_input_handler_,
1360 ScrollBy(testing::_, 1380 ScrollBy(testing::_,
1361 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) 1381 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)),
1382 cc::InputHandler::RAILS_MODE_FREE))
1362 .WillOnce(testing::Return(scroll_result_did_not_scroll_)); 1383 .WillOnce(testing::Return(scroll_result_did_not_scroll_));
1363 time += base::TimeDelta::FromMicroseconds(5); 1384 time += base::TimeDelta::FromMicroseconds(5);
1364 input_handler_->Animate(time); 1385 input_handler_->Animate(time);
1365 1386
1366 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1387 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1367 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1388 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1368 1389
1369 // A time delta of zero should not stop the fling, and neither should it 1390 // A time delta of zero should not stop the fling, and neither should it
1370 // trigger scrolling on the client. 1391 // trigger scrolling on the client.
1371 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1392 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1372 input_handler_->Animate(time); 1393 input_handler_->Animate(time);
1373 1394
1374 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1395 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1375 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1396 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1376 1397
1377 // Lack of movement on the client, with a non-trivial scroll delta, should 1398 // Lack of movement on the client, with a non-trivial scroll delta, should
1378 // terminate the fling. 1399 // terminate the fling.
1379 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1400 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1380 EXPECT_CALL(mock_input_handler_, 1401 EXPECT_CALL(mock_input_handler_,
1381 ScrollBy(testing::_, 1402 ScrollBy(testing::_,
1382 testing::Property(&gfx::Vector2dF::x, testing::Lt(1)))) 1403 testing::Property(&gfx::Vector2dF::x, testing::Lt(1)),
1404 cc::InputHandler::RAILS_MODE_FREE))
1383 .WillOnce(testing::Return(scroll_result_did_not_scroll_)); 1405 .WillOnce(testing::Return(scroll_result_did_not_scroll_));
1384 time += base::TimeDelta::FromMilliseconds(100); 1406 time += base::TimeDelta::FromMilliseconds(100);
1385 input_handler_->Animate(time); 1407 input_handler_->Animate(time);
1386 1408
1387 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1409 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1388 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1410 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1389 } 1411 }
1390 1412
1391 TEST_F(InputHandlerProxyTest, GestureFlingCancelledAfterBothAxesStopScrolling) { 1413 TEST_F(InputHandlerProxyTest, GestureFlingCancelledAfterBothAxesStopScrolling) {
1392 cc::InputHandlerScrollResult overscroll; 1414 cc::InputHandlerScrollResult overscroll;
(...skipping 26 matching lines...) Expand all
1419 // The first animate doesn't cause any scrolling. 1441 // The first animate doesn't cause any scrolling.
1420 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1442 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1421 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); 1443 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
1422 input_handler_->Animate(time); 1444 input_handler_->Animate(time);
1423 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1445 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1424 1446
1425 // The second animate starts scrolling in the positive X and Y directions. 1447 // The second animate starts scrolling in the positive X and Y directions.
1426 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1448 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1427 EXPECT_CALL(mock_input_handler_, 1449 EXPECT_CALL(mock_input_handler_,
1428 ScrollBy(testing::_, 1450 ScrollBy(testing::_,
1429 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))) 1451 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)),
1452 cc::InputHandler::RAILS_MODE_FREE))
1430 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1453 .WillOnce(testing::Return(scroll_result_did_scroll_));
1431 time += base::TimeDelta::FromMilliseconds(10); 1454 time += base::TimeDelta::FromMilliseconds(10);
1432 input_handler_->Animate(time); 1455 input_handler_->Animate(time);
1433 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1456 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1434 1457
1435 // The third animate hits the bottom content edge. 1458 // The third animate hits the bottom content edge.
1436 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100); 1459 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100);
1437 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 100); 1460 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 100);
1438 EXPECT_CALL(mock_input_handler_, 1461 EXPECT_CALL(mock_input_handler_,
1439 ScrollBy(testing::_, 1462 ScrollBy(testing::_,
1440 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))) 1463 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)),
1464 cc::InputHandler::RAILS_MODE_FREE))
1441 .WillOnce(testing::Return(overscroll)); 1465 .WillOnce(testing::Return(overscroll));
1442 EXPECT_CALL( 1466 EXPECT_CALL(
1443 mock_client_, 1467 mock_client_,
1444 DidOverscroll(testing::AllOf( 1468 DidOverscroll(testing::AllOf(
1445 testing::Field( 1469 testing::Field(
1446 &DidOverscrollParams::accumulated_overscroll, 1470 &DidOverscrollParams::accumulated_overscroll,
1447 testing::Eq(overscroll.accumulated_root_overscroll)), 1471 testing::Eq(overscroll.accumulated_root_overscroll)),
1448 testing::Field( 1472 testing::Field(
1449 &DidOverscrollParams::latest_overscroll_delta, 1473 &DidOverscrollParams::latest_overscroll_delta,
1450 testing::Eq(overscroll.unused_scroll_delta)), 1474 testing::Eq(overscroll.unused_scroll_delta)),
1451 testing::Field( 1475 testing::Field(
1452 &DidOverscrollParams::current_fling_velocity, 1476 &DidOverscrollParams::current_fling_velocity,
1453 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))))); 1477 testing::Property(&gfx::Vector2dF::y, testing::Lt(0))))));
1454 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1478 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1455 time += base::TimeDelta::FromMilliseconds(10); 1479 time += base::TimeDelta::FromMilliseconds(10);
1456 input_handler_->Animate(time); 1480 input_handler_->Animate(time);
1457 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1481 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1458 1482
1459 // The next call to animate will no longer scroll vertically. 1483 // The next call to animate will no longer scroll vertically.
1460 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1484 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1461 EXPECT_CALL(mock_input_handler_, 1485 EXPECT_CALL(mock_input_handler_,
1462 ScrollBy(testing::_, 1486 ScrollBy(testing::_,
1463 testing::Property(&gfx::Vector2dF::y, testing::Eq(0)))) 1487 testing::Property(&gfx::Vector2dF::y, testing::Eq(0)),
1488 cc::InputHandler::RAILS_MODE_FREE))
1464 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1489 .WillOnce(testing::Return(scroll_result_did_scroll_));
1465 time += base::TimeDelta::FromMilliseconds(10); 1490 time += base::TimeDelta::FromMilliseconds(10);
1466 input_handler_->Animate(time); 1491 input_handler_->Animate(time);
1467 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1492 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1468 1493
1469 // The next call will hit the right edge. 1494 // The next call will hit the right edge.
1470 overscroll.accumulated_root_overscroll = gfx::Vector2dF(100, 100); 1495 overscroll.accumulated_root_overscroll = gfx::Vector2dF(100, 100);
1471 overscroll.unused_scroll_delta = gfx::Vector2dF(100, 0); 1496 overscroll.unused_scroll_delta = gfx::Vector2dF(100, 0);
1472 EXPECT_CALL(mock_input_handler_, 1497 EXPECT_CALL(mock_input_handler_,
1473 ScrollBy(testing::_, 1498 ScrollBy(testing::_,
1474 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) 1499 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)),
1500 cc::InputHandler::RAILS_MODE_FREE))
1475 .WillOnce(testing::Return(overscroll)); 1501 .WillOnce(testing::Return(overscroll));
1476 EXPECT_CALL( 1502 EXPECT_CALL(
1477 mock_client_, 1503 mock_client_,
1478 DidOverscroll(testing::AllOf( 1504 DidOverscroll(testing::AllOf(
1479 testing::Field( 1505 testing::Field(
1480 &DidOverscrollParams::accumulated_overscroll, 1506 &DidOverscrollParams::accumulated_overscroll,
1481 testing::Eq(overscroll.accumulated_root_overscroll)), 1507 testing::Eq(overscroll.accumulated_root_overscroll)),
1482 testing::Field( 1508 testing::Field(
1483 &DidOverscrollParams::latest_overscroll_delta, 1509 &DidOverscrollParams::latest_overscroll_delta,
1484 testing::Eq(overscroll.unused_scroll_delta)), 1510 testing::Eq(overscroll.unused_scroll_delta)),
1485 testing::Field( 1511 testing::Field(
1486 &DidOverscrollParams::current_fling_velocity, 1512 &DidOverscrollParams::current_fling_velocity,
1487 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))))); 1513 testing::Property(&gfx::Vector2dF::x, testing::Lt(0))))));
1488 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1514 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1489 time += base::TimeDelta::FromMilliseconds(10); 1515 time += base::TimeDelta::FromMilliseconds(10);
1490 input_handler_->Animate(time); 1516 input_handler_->Animate(time);
1491 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1517 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1492 1518
1493 // The next call to animate will no longer scroll horizontally or vertically, 1519 // The next call to animate will no longer scroll horizontally or vertically,
1494 // and the fling should be cancelled. 1520 // and the fling should be cancelled.
1495 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()).Times(0); 1521 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()).Times(0);
1496 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_, testing::_)).Times(0); 1522 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_, testing::_,
1523 cc::InputHandler::RAILS_MODE_FREE))
1524 .Times(0);
1497 time += base::TimeDelta::FromMilliseconds(10); 1525 time += base::TimeDelta::FromMilliseconds(10);
1498 input_handler_->Animate(time); 1526 input_handler_->Animate(time);
1499 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1527 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1500 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1528 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1501 } 1529 }
1502 1530
1503 TEST_F(InputHandlerProxyTest, MultiTouchPointHitTestNegative) { 1531 TEST_F(InputHandlerProxyTest, MultiTouchPointHitTestNegative) {
1504 // None of the three touch points fall in the touch region. So the event 1532 // None of the three touch points fall in the touch region. So the event
1505 // should be dropped. 1533 // should be dropped.
1506 expected_disposition_ = InputHandlerProxy::DROP_EVENT; 1534 expected_disposition_ = InputHandlerProxy::DROP_EVENT;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 1664 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
1637 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 1665 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
1638 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1666 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1639 1667
1640 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1668 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1641 1669
1642 // If we get a negative time delta, that is, the Animation tick time happens 1670 // 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 1671 // before the fling's start time then we should *not* try scrolling and
1644 // instead reset the fling start time. 1672 // instead reset the fling start time.
1645 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1673 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1646 EXPECT_CALL(mock_input_handler_, 1674 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_, testing::_,
1647 ScrollBy(testing::_, 1675 cc::InputHandler::RAILS_MODE_FREE))
1648 testing::_)).Times(0); 1676 .Times(0);
1649 time -= base::TimeDelta::FromMilliseconds(5); 1677 time -= base::TimeDelta::FromMilliseconds(5);
1650 input_handler_->Animate(time); 1678 input_handler_->Animate(time);
1651 1679
1652 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1680 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1653 1681
1654 // The first call should have reset the start time so subsequent calls should 1682 // The first call should have reset the start time so subsequent calls should
1655 // generate scroll events. 1683 // generate scroll events.
1656 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1684 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1657 EXPECT_CALL(mock_input_handler_, 1685 EXPECT_CALL(mock_input_handler_,
1658 ScrollBy(testing::_, 1686 ScrollBy(testing::_,
1659 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) 1687 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)),
1688 cc::InputHandler::RAILS_MODE_FREE))
1660 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1689 .WillOnce(testing::Return(scroll_result_did_scroll_));
1661 1690
1662 input_handler_->Animate(time + base::TimeDelta::FromMilliseconds(1)); 1691 input_handler_->Animate(time + base::TimeDelta::FromMilliseconds(1));
1663 1692
1664 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1693 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1665 1694
1666 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1695 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1667 gesture_.type = WebInputEvent::GestureFlingCancel; 1696 gesture_.type = WebInputEvent::GestureFlingCancel;
1668 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1697 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1669 } 1698 }
(...skipping 23 matching lines...) Expand all
1693 gesture_.type = WebInputEvent::GestureScrollBegin; 1722 gesture_.type = WebInputEvent::GestureScrollBegin;
1694 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1723 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1695 1724
1696 VERIFY_AND_RESET_MOCKS(); 1725 VERIFY_AND_RESET_MOCKS();
1697 1726
1698 // Animate calls within the deferred cancellation window should continue. 1727 // Animate calls within the deferred cancellation window should continue.
1699 time += dt; 1728 time += dt;
1700 float expected_delta = 1729 float expected_delta =
1701 (time - last_animate_time).InSecondsF() * -fling_delta.x; 1730 (time - last_animate_time).InSecondsF() * -fling_delta.x;
1702 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1731 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1703 EXPECT_CALL(mock_input_handler_, 1732 EXPECT_CALL(
1704 ScrollBy(testing::_, 1733 mock_input_handler_,
1705 testing::Property(&gfx::Vector2dF::x, 1734 ScrollBy(testing::_, testing::Property(&gfx::Vector2dF::x,
1706 testing::Eq(expected_delta)))) 1735 testing::Eq(expected_delta)),
1736 cc::InputHandler::RAILS_MODE_FREE))
1707 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1737 .WillOnce(testing::Return(scroll_result_did_scroll_));
1708 input_handler_->Animate(time); 1738 input_handler_->Animate(time);
1709 last_animate_time = time; 1739 last_animate_time = time;
1710 1740
1711 VERIFY_AND_RESET_MOCKS(); 1741 VERIFY_AND_RESET_MOCKS();
1712 1742
1713 // GestureScrollUpdates in the same direction and at sufficient speed should 1743 // GestureScrollUpdates in the same direction and at sufficient speed should
1714 // be swallowed by the fling. 1744 // be swallowed by the fling.
1715 time += dt; 1745 time += dt;
1716 gesture_.timeStampSeconds = InSecondsF(time); 1746 gesture_.timeStampSeconds = InSecondsF(time);
1717 gesture_.type = WebInputEvent::GestureScrollUpdate; 1747 gesture_.type = WebInputEvent::GestureScrollUpdate;
1718 gesture_.data.scrollUpdate.deltaX = fling_delta.x; 1748 gesture_.data.scrollUpdate.deltaX = fling_delta.x;
1719 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1749 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1720 1750
1721 VERIFY_AND_RESET_MOCKS(); 1751 VERIFY_AND_RESET_MOCKS();
1722 1752
1723 // Animate calls within the deferred cancellation window should continue. 1753 // Animate calls within the deferred cancellation window should continue.
1724 time += dt; 1754 time += dt;
1725 expected_delta = (time - last_animate_time).InSecondsF() * -fling_delta.x; 1755 expected_delta = (time - last_animate_time).InSecondsF() * -fling_delta.x;
1726 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1756 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1727 EXPECT_CALL(mock_input_handler_, 1757 EXPECT_CALL(
1728 ScrollBy(testing::_, 1758 mock_input_handler_,
1729 testing::Property(&gfx::Vector2dF::x, 1759 ScrollBy(testing::_, testing::Property(&gfx::Vector2dF::x,
1730 testing::Eq(expected_delta)))) 1760 testing::Eq(expected_delta)),
1761 cc::InputHandler::RAILS_MODE_FREE))
1731 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1762 .WillOnce(testing::Return(scroll_result_did_scroll_));
1732 input_handler_->Animate(time); 1763 input_handler_->Animate(time);
1733 last_animate_time = time; 1764 last_animate_time = time;
1734 1765
1735 VERIFY_AND_RESET_MOCKS(); 1766 VERIFY_AND_RESET_MOCKS();
1736 1767
1737 // GestureFlingStart in the same direction and at sufficient speed should 1768 // GestureFlingStart in the same direction and at sufficient speed should
1738 // boost the active fling. 1769 // boost the active fling.
1739 1770
1740 gesture_ = CreateFling(time, 1771 gesture_ = CreateFling(time,
1741 blink::WebGestureDeviceTouchscreen, 1772 blink::WebGestureDeviceTouchscreen,
1742 fling_delta, 1773 fling_delta,
1743 fling_point, 1774 fling_point,
1744 fling_point, 1775 fling_point,
1745 0); 1776 0);
1746 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1777 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1747 VERIFY_AND_RESET_MOCKS(); 1778 VERIFY_AND_RESET_MOCKS();
1748 1779
1749 time += dt; 1780 time += dt;
1750 // Note we get *2x* as much delta because 2 flings have combined. 1781 // Note we get *2x* as much delta because 2 flings have combined.
1751 expected_delta = 2 * (time - last_animate_time).InSecondsF() * -fling_delta.x; 1782 expected_delta = 2 * (time - last_animate_time).InSecondsF() * -fling_delta.x;
1752 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1783 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1753 EXPECT_CALL(mock_input_handler_, 1784 EXPECT_CALL(
1754 ScrollBy(testing::_, 1785 mock_input_handler_,
1755 testing::Property(&gfx::Vector2dF::x, 1786 ScrollBy(testing::_, testing::Property(&gfx::Vector2dF::x,
1756 testing::Eq(expected_delta)))) 1787 testing::Eq(expected_delta)),
1788 cc::InputHandler::RAILS_MODE_FREE))
1757 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1789 .WillOnce(testing::Return(scroll_result_did_scroll_));
1758 input_handler_->Animate(time); 1790 input_handler_->Animate(time);
1759 last_animate_time = time; 1791 last_animate_time = time;
1760 1792
1761 VERIFY_AND_RESET_MOCKS(); 1793 VERIFY_AND_RESET_MOCKS();
1762 1794
1763 // Repeated GestureFlingStarts should accumulate. 1795 // Repeated GestureFlingStarts should accumulate.
1764 1796
1765 CancelFling(time); 1797 CancelFling(time);
1766 gesture_ = CreateFling(time, 1798 gesture_ = CreateFling(time,
1767 blink::WebGestureDeviceTouchscreen, 1799 blink::WebGestureDeviceTouchscreen,
1768 fling_delta, 1800 fling_delta,
1769 fling_point, 1801 fling_point,
1770 fling_point, 1802 fling_point,
1771 0); 1803 0);
1772 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1804 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1773 VERIFY_AND_RESET_MOCKS(); 1805 VERIFY_AND_RESET_MOCKS();
1774 1806
1775 time += dt; 1807 time += dt;
1776 // Note we get *3x* as much delta because 3 flings have combined. 1808 // Note we get *3x* as much delta because 3 flings have combined.
1777 expected_delta = 3 * (time - last_animate_time).InSecondsF() * -fling_delta.x; 1809 expected_delta = 3 * (time - last_animate_time).InSecondsF() * -fling_delta.x;
1778 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1810 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1779 EXPECT_CALL(mock_input_handler_, 1811 EXPECT_CALL(
1780 ScrollBy(testing::_, 1812 mock_input_handler_,
1781 testing::Property(&gfx::Vector2dF::x, 1813 ScrollBy(testing::_, testing::Property(&gfx::Vector2dF::x,
1782 testing::Eq(expected_delta)))) 1814 testing::Eq(expected_delta)),
1815 cc::InputHandler::RAILS_MODE_FREE))
1783 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1816 .WillOnce(testing::Return(scroll_result_did_scroll_));
1784 input_handler_->Animate(time); 1817 input_handler_->Animate(time);
1785 last_animate_time = time; 1818 last_animate_time = time;
1786 1819
1787 VERIFY_AND_RESET_MOCKS(); 1820 VERIFY_AND_RESET_MOCKS();
1788 1821
1789 // GestureFlingCancel should terminate the fling if no boosting gestures are 1822 // GestureFlingCancel should terminate the fling if no boosting gestures are
1790 // received within the timeout window. 1823 // received within the timeout window.
1791 1824
1792 time += dt; 1825 time += dt;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1895 0); 1928 0);
1896 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1929 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1897 1930
1898 VERIFY_AND_RESET_MOCKS(); 1931 VERIFY_AND_RESET_MOCKS();
1899 1932
1900 // Note that the new fling delta uses the orthogonal, unboosted fling 1933 // Note that the new fling delta uses the orthogonal, unboosted fling
1901 // velocity. 1934 // velocity.
1902 time += dt; 1935 time += dt;
1903 float expected_delta = dt.InSecondsF() * -orthogonal_fling_delta.y; 1936 float expected_delta = dt.InSecondsF() * -orthogonal_fling_delta.y;
1904 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1937 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1905 EXPECT_CALL(mock_input_handler_, 1938 EXPECT_CALL(
1906 ScrollBy(testing::_, 1939 mock_input_handler_,
1907 testing::Property(&gfx::Vector2dF::y, 1940 ScrollBy(testing::_, testing::Property(&gfx::Vector2dF::y,
1908 testing::Eq(expected_delta)))) 1941 testing::Eq(expected_delta)),
1942 cc::InputHandler::RAILS_MODE_FREE))
1909 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1943 .WillOnce(testing::Return(scroll_result_did_scroll_));
1910 input_handler_->Animate(time); 1944 input_handler_->Animate(time);
1911 1945
1912 VERIFY_AND_RESET_MOCKS(); 1946 VERIFY_AND_RESET_MOCKS();
1913 } 1947 }
1914 1948
1915 TEST_F(InputHandlerProxyTest, NoFlingBoostIfScrollInDifferentDirection) { 1949 TEST_F(InputHandlerProxyTest, NoFlingBoostIfScrollInDifferentDirection) {
1916 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); 1950 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10);
1917 base::TimeTicks time = base::TimeTicks() + dt; 1951 base::TimeTicks time = base::TimeTicks() + dt;
1918 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); 1952 WebFloatPoint fling_delta = WebFloatPoint(1000, 0);
(...skipping 21 matching lines...) Expand all
1940 1974
1941 // If the GestureScrollUpdate is in a different direction than the fling, 1975 // If the GestureScrollUpdate is in a different direction than the fling,
1942 // the fling should be cancelled and scrolling should resume. 1976 // the fling should be cancelled and scrolling should resume.
1943 time += dt; 1977 time += dt;
1944 gesture_.timeStampSeconds = InSecondsF(time); 1978 gesture_.timeStampSeconds = InSecondsF(time);
1945 gesture_.type = WebInputEvent::GestureScrollUpdate; 1979 gesture_.type = WebInputEvent::GestureScrollUpdate;
1946 gesture_.data.scrollUpdate.deltaX = -fling_delta.x; 1980 gesture_.data.scrollUpdate.deltaX = -fling_delta.x;
1947 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1981 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1948 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1982 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1949 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 1983 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
1950 EXPECT_CALL(mock_input_handler_, 1984 EXPECT_CALL(
1951 ScrollBy(testing::_, 1985 mock_input_handler_,
1952 testing::Property(&gfx::Vector2dF::x, 1986 ScrollBy(testing::_, testing::Property(&gfx::Vector2dF::x,
1953 testing::Eq(fling_delta.x)))) 1987 testing::Eq(fling_delta.x)),
1988 cc::InputHandler::RAILS_MODE_FREE))
1954 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1989 .WillOnce(testing::Return(scroll_result_did_scroll_));
1955 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1990 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1956 1991
1957 VERIFY_AND_RESET_MOCKS(); 1992 VERIFY_AND_RESET_MOCKS();
1958 } 1993 }
1959 1994
1960 TEST_F(InputHandlerProxyTest, NoFlingBoostIfFlingTooSlow) { 1995 TEST_F(InputHandlerProxyTest, NoFlingBoostIfFlingTooSlow) {
1961 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); 1996 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10);
1962 base::TimeTicks time = base::TimeTicks() + dt; 1997 base::TimeTicks time = base::TimeTicks() + dt;
1963 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); 1998 WebFloatPoint fling_delta = WebFloatPoint(1000, 0);
(...skipping 16 matching lines...) Expand all
1980 fling_point, 2015 fling_point,
1981 0); 2016 0);
1982 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 2017 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1983 2018
1984 VERIFY_AND_RESET_MOCKS(); 2019 VERIFY_AND_RESET_MOCKS();
1985 2020
1986 // Note that the new fling delta uses the *slow*, unboosted fling velocity. 2021 // Note that the new fling delta uses the *slow*, unboosted fling velocity.
1987 time += dt; 2022 time += dt;
1988 float expected_delta = dt.InSecondsF() * -small_fling_delta.x; 2023 float expected_delta = dt.InSecondsF() * -small_fling_delta.x;
1989 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 2024 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1990 EXPECT_CALL(mock_input_handler_, 2025 EXPECT_CALL(
1991 ScrollBy(testing::_, 2026 mock_input_handler_,
1992 testing::Property(&gfx::Vector2dF::x, 2027 ScrollBy(testing::_, testing::Property(&gfx::Vector2dF::x,
1993 testing::Eq(expected_delta)))) 2028 testing::Eq(expected_delta)),
2029 cc::InputHandler::RAILS_MODE_FREE))
1994 .WillOnce(testing::Return(scroll_result_did_scroll_)); 2030 .WillOnce(testing::Return(scroll_result_did_scroll_));
1995 input_handler_->Animate(time); 2031 input_handler_->Animate(time);
1996 2032
1997 VERIFY_AND_RESET_MOCKS(); 2033 VERIFY_AND_RESET_MOCKS();
1998 } 2034 }
1999 2035
2000 TEST_F(InputHandlerProxyTest, NoFlingBoostIfPreventBoostingFlagIsSet) { 2036 TEST_F(InputHandlerProxyTest, NoFlingBoostIfPreventBoostingFlagIsSet) {
2001 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); 2037 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10);
2002 base::TimeTicks time = base::TimeTicks() + dt; 2038 base::TimeTicks time = base::TimeTicks() + dt;
2003 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); 2039 WebFloatPoint fling_delta = WebFloatPoint(1000, 0);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2042 2078
2043 VERIFY_AND_RESET_MOCKS(); 2079 VERIFY_AND_RESET_MOCKS();
2044 2080
2045 // Now animate the fling to completion (in this case, the fling should 2081 // Now animate the fling to completion (in this case, the fling should
2046 // terminate because the input handler reports a failed scroll). As the fling 2082 // terminate because the input handler reports a failed scroll). As the fling
2047 // was cancelled during an active scroll sequence, a synthetic 2083 // was cancelled during an active scroll sequence, a synthetic
2048 // GestureScrollBegin should be processed, resuming the scroll. 2084 // GestureScrollBegin should be processed, resuming the scroll.
2049 time += dt; 2085 time += dt;
2050 float expected_delta = 2086 float expected_delta =
2051 (time - last_animate_time).InSecondsF() * -fling_delta.x; 2087 (time - last_animate_time).InSecondsF() * -fling_delta.x;
2052 EXPECT_CALL(mock_input_handler_, 2088 EXPECT_CALL(
2053 ScrollBy(testing::_, 2089 mock_input_handler_,
2054 testing::Property(&gfx::Vector2dF::x, 2090 ScrollBy(testing::_, testing::Property(&gfx::Vector2dF::x,
2055 testing::Eq(expected_delta)))) 2091 testing::Eq(expected_delta)),
2092 cc::InputHandler::RAILS_MODE_FREE))
2056 .WillOnce(testing::Return(scroll_result_did_not_scroll_)); 2093 .WillOnce(testing::Return(scroll_result_did_not_scroll_));
2057 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 2094 EXPECT_CALL(mock_input_handler_, ScrollEnd());
2058 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 2095 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
2059 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); 2096 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
2060 input_handler_->Animate(time); 2097 input_handler_->Animate(time);
2061 2098
2062 VERIFY_AND_RESET_MOCKS(); 2099 VERIFY_AND_RESET_MOCKS();
2063 2100
2064 // Subsequent GestureScrollUpdates after the cancelled, boosted fling should 2101 // Subsequent GestureScrollUpdates after the cancelled, boosted fling should
2065 // cause scrolling as usual. 2102 // cause scrolling as usual.
2066 time += dt; 2103 time += dt;
2067 expected_delta = 7.3f; 2104 expected_delta = 7.3f;
2068 gesture_.timeStampSeconds = InSecondsF(time); 2105 gesture_.timeStampSeconds = InSecondsF(time);
2069 gesture_.type = WebInputEvent::GestureScrollUpdate; 2106 gesture_.type = WebInputEvent::GestureScrollUpdate;
2070 gesture_.data.scrollUpdate.deltaX = -expected_delta; 2107 gesture_.data.scrollUpdate.deltaX = -expected_delta;
2071 EXPECT_CALL(mock_input_handler_, 2108 EXPECT_CALL(
2072 ScrollBy(testing::_, 2109 mock_input_handler_,
2073 testing::Property(&gfx::Vector2dF::x, 2110 ScrollBy(testing::_, testing::Property(&gfx::Vector2dF::x,
2074 testing::Eq(expected_delta)))) 2111 testing::Eq(expected_delta)),
2112 cc::InputHandler::RAILS_MODE_FREE))
2075 .WillOnce(testing::Return(scroll_result_did_scroll_)); 2113 .WillOnce(testing::Return(scroll_result_did_scroll_));
2076 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 2114 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
2077 2115
2078 VERIFY_AND_RESET_MOCKS(); 2116 VERIFY_AND_RESET_MOCKS();
2079 2117
2080 // GestureScrollEnd should terminate the resumed scroll properly. 2118 // GestureScrollEnd should terminate the resumed scroll properly.
2081 time += dt; 2119 time += dt;
2082 gesture_.timeStampSeconds = InSecondsF(time); 2120 gesture_.timeStampSeconds = InSecondsF(time);
2083 gesture_.type = WebInputEvent::GestureScrollEnd; 2121 gesture_.type = WebInputEvent::GestureScrollEnd;
2084 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 2122 EXPECT_CALL(mock_input_handler_, ScrollEnd());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2129 testing::Mock::VerifyAndClearExpectations(&mock_client); 2167 testing::Mock::VerifyAndClearExpectations(&mock_client);
2130 2168
2131 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 2169 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
2132 EXPECT_CALL(mock_client, DidAnimateForInput()); 2170 EXPECT_CALL(mock_client, DidAnimateForInput());
2133 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); 2171 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
2134 input_handler_->Animate(time); 2172 input_handler_->Animate(time);
2135 2173
2136 testing::Mock::VerifyAndClearExpectations(&mock_client); 2174 testing::Mock::VerifyAndClearExpectations(&mock_client);
2137 } 2175 }
2138 2176
2177 TEST_F(InputHandlerProxyTest, WheelRailsModes) {
2178 WebMouseWheelEvent wheel;
2179 wheel.type = WebInputEvent::MouseWheel;
2180 wheel.deltaX = 1;
2181 wheel.deltaY = 2;
2182
2183 // We shouldn't send any events to the widget for this gesture.
2184 VERIFY_AND_RESET_MOCKS();
2185
2186 // Begin the scroll gesture
2187 wheel.phase = WebMouseWheelEvent::PhaseBegan;
2188 wheel.railsMode = WebInputEvent::RailsModeFree;
2189 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
2190 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
2191 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_, testing::_,
2192 cc::InputHandler::RAILS_MODE_FREE))
2193 .WillOnce(testing::Return(scroll_result_did_scroll_));
2194 EXPECT_CALL(mock_input_handler_, ScrollEnd());
2195 EXPECT_EQ(InputHandlerProxy::DID_HANDLE,
2196 input_handler_->HandleInputEvent(wheel));
2197 VERIFY_AND_RESET_MOCKS();
2198
2199 // Scroll with no rails.
2200 wheel.phase = WebMouseWheelEvent::PhaseChanged;
2201 wheel.railsMode = WebInputEvent::RailsModeFree;
2202 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
2203 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
2204 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_, testing::_,
2205 cc::InputHandler::RAILS_MODE_FREE))
2206 .WillOnce(testing::Return(scroll_result_did_scroll_));
2207 EXPECT_CALL(mock_input_handler_, ScrollEnd());
2208 EXPECT_EQ(InputHandlerProxy::DID_HANDLE,
2209 input_handler_->HandleInputEvent(wheel));
2210 VERIFY_AND_RESET_MOCKS();
2211
2212 // Scroll with horizontal rails.
2213 wheel.phase = WebMouseWheelEvent::PhaseChanged;
2214 wheel.railsMode = WebInputEvent::RailsModeHorizontal;
2215 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
2216 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
2217 EXPECT_CALL(
2218 mock_input_handler_,
2219 ScrollBy(testing::_, testing::_, cc::InputHandler::RAILS_MODE_HORIZONTAL))
2220 .WillOnce(testing::Return(scroll_result_did_scroll_));
2221 EXPECT_CALL(mock_input_handler_, ScrollEnd());
2222 EXPECT_EQ(InputHandlerProxy::DID_HANDLE,
2223 input_handler_->HandleInputEvent(wheel));
2224 VERIFY_AND_RESET_MOCKS();
2225
2226 // Scroll with vertical rails.
2227 wheel.phase = WebMouseWheelEvent::PhaseChanged;
2228 wheel.railsMode = WebInputEvent::RailsModeVertical;
2229 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
2230 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
2231 EXPECT_CALL(
2232 mock_input_handler_,
2233 ScrollBy(testing::_, testing::_, cc::InputHandler::RAILS_MODE_VERTICAL))
2234 .WillOnce(testing::Return(scroll_result_did_scroll_));
2235 EXPECT_CALL(mock_input_handler_, ScrollEnd());
2236 EXPECT_EQ(InputHandlerProxy::DID_HANDLE,
2237 input_handler_->HandleInputEvent(wheel));
2238 VERIFY_AND_RESET_MOCKS();
2239
2240 // Scroll with no rails.
2241 wheel.phase = WebMouseWheelEvent::PhaseChanged;
2242 wheel.railsMode = WebInputEvent::RailsModeFree;
2243 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
2244 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
2245 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_, testing::_,
2246 cc::InputHandler::RAILS_MODE_FREE))
2247 .WillOnce(testing::Return(scroll_result_did_scroll_));
2248 EXPECT_CALL(mock_input_handler_, ScrollEnd());
2249 EXPECT_EQ(InputHandlerProxy::DID_HANDLE,
2250 input_handler_->HandleInputEvent(wheel));
2251 VERIFY_AND_RESET_MOCKS();
2252
2253 // Stop the scroll gesture.
2254 wheel.phase = WebMouseWheelEvent::PhaseEnded;
2255 wheel.railsMode = WebInputEvent::RailsModeFree;
2256 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
2257 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED));
2258 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_, testing::_,
2259 cc::InputHandler::RAILS_MODE_FREE))
2260 .WillOnce(testing::Return(scroll_result_did_scroll_));
2261 EXPECT_CALL(mock_input_handler_, ScrollEnd());
2262 EXPECT_EQ(InputHandlerProxy::DID_HANDLE,
2263 input_handler_->HandleInputEvent(wheel));
2264 VERIFY_AND_RESET_MOCKS();
2265 }
2266
2139 } // namespace 2267 } // namespace
2140 } // namespace content 2268 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/input/input_handler_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698