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

Side by Side Diff: ui/events/blink/input_handler_proxy_unittest.cc

Issue 2802993003: Event unittests cover both wheel scroll latching and propagating cases. (Closed)
Patch Set: InputHandlerProxyEventQueueTest parameterized. Created 3 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 | « no previous file | 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 "ui/events/blink/input_handler_proxy.h" 5 #include "ui/events/blink/input_handler_proxy.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 cc::InputHandler::ScrollInputType type)); 174 cc::InputHandler::ScrollInputType type));
175 MOCK_METHOD1(ScrollAnimatedBegin, 175 MOCK_METHOD1(ScrollAnimatedBegin,
176 ScrollStatus(const gfx::Point& viewport_point)); 176 ScrollStatus(const gfx::Point& viewport_point));
177 MOCK_METHOD3(ScrollAnimated, 177 MOCK_METHOD3(ScrollAnimated,
178 ScrollStatus(const gfx::Point& viewport_point, 178 ScrollStatus(const gfx::Point& viewport_point,
179 const gfx::Vector2dF& scroll_delta, 179 const gfx::Vector2dF& scroll_delta,
180 base::TimeDelta)); 180 base::TimeDelta));
181 MOCK_METHOD1(ScrollBy, cc::InputHandlerScrollResult(cc::ScrollState*)); 181 MOCK_METHOD1(ScrollBy, cc::InputHandlerScrollResult(cc::ScrollState*));
182 MOCK_METHOD1(ScrollEnd, void(cc::ScrollState*)); 182 MOCK_METHOD1(ScrollEnd, void(cc::ScrollState*));
183 MOCK_METHOD0(FlingScrollBegin, cc::InputHandler::ScrollStatus()); 183 MOCK_METHOD0(FlingScrollBegin, cc::InputHandler::ScrollStatus());
184 MOCK_METHOD0(ScrollingShouldSwitchtoMainThread, bool());
184 185
185 std::unique_ptr<cc::SwapPromiseMonitor> CreateLatencyInfoSwapPromiseMonitor( 186 std::unique_ptr<cc::SwapPromiseMonitor> CreateLatencyInfoSwapPromiseMonitor(
186 ui::LatencyInfo* latency) override { 187 ui::LatencyInfo* latency) override {
187 return nullptr; 188 return nullptr;
188 } 189 }
189 190
190 cc::ScrollElasticityHelper* CreateScrollElasticityHelper() override { 191 cc::ScrollElasticityHelper* CreateScrollElasticityHelper() override {
191 return NULL; 192 return NULL;
192 } 193 }
193 bool GetScrollOffsetForLayer(int layer_id, 194 bool GetScrollOffsetForLayer(int layer_id,
194 gfx::ScrollOffset* offset) override { 195 gfx::ScrollOffset* offset) override {
195 return false; 196 return false;
196 } 197 }
197 bool ScrollLayerTo(int layer_id, const gfx::ScrollOffset& offset) override { 198 bool ScrollLayerTo(int layer_id, const gfx::ScrollOffset& offset) override {
198 return false; 199 return false;
199 } 200 }
200 201
201 bool ScrollingShouldSwitchtoMainThread() override { return false; }
202
203 void BindToClient(cc::InputHandlerClient* client, 202 void BindToClient(cc::InputHandlerClient* client,
204 bool touchpad_and_wheel_scroll_latching_enabled) override {} 203 bool touchpad_and_wheel_scroll_latching_enabled) override {}
205 204
206 void MouseDown() override {} 205 void MouseDown() override {}
207 void MouseUp() override {} 206 void MouseUp() override {}
208 void MouseLeave() override {} 207 void MouseLeave() override {}
209 208
210 void MouseMoveAt(const gfx::Point& mouse_position) override {} 209 void MouseMoveAt(const gfx::Point& mouse_position) override {}
211 210
212 MOCK_CONST_METHOD2(IsCurrentlyScrollingLayerAt, 211 MOCK_CONST_METHOD2(IsCurrentlyScrollingLayerAt,
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 RecordMainThreadScrollingReasons(device, reasons); 363 RecordMainThreadScrollingReasons(device, reasons);
365 } 364 }
366 }; 365 };
367 366
368 } // namespace 367 } // namespace
369 368
370 class InputHandlerProxyTest 369 class InputHandlerProxyTest
371 : public testing::Test, 370 : public testing::Test,
372 public testing::WithParamInterface<InputHandlerProxyTestType> { 371 public testing::WithParamInterface<InputHandlerProxyTestType> {
373 public: 372 public:
374 InputHandlerProxyTest() 373 InputHandlerProxyTest(bool touchpad_and_wheel_scroll_latching_enabled = true)
375 : synchronous_root_scroll_(GetParam() == ROOT_SCROLL_SYNCHRONOUS_HANDLER), 374 : synchronous_root_scroll_(GetParam() == ROOT_SCROLL_SYNCHRONOUS_HANDLER),
376 install_synchronous_handler_( 375 install_synchronous_handler_(
377 GetParam() == ROOT_SCROLL_SYNCHRONOUS_HANDLER || 376 GetParam() == ROOT_SCROLL_SYNCHRONOUS_HANDLER ||
378 GetParam() == CHILD_SCROLL_SYNCHRONOUS_HANDLER), 377 GetParam() == CHILD_SCROLL_SYNCHRONOUS_HANDLER),
379 expected_disposition_(InputHandlerProxy::DID_HANDLE) { 378 expected_disposition_(InputHandlerProxy::DID_HANDLE),
379 touchpad_and_wheel_scroll_latching_enabled_(
380 touchpad_and_wheel_scroll_latching_enabled) {
380 input_handler_.reset( 381 input_handler_.reset(
381 new TestInputHandlerProxy(&mock_input_handler_, &mock_client_, false)); 382 new TestInputHandlerProxy(&mock_input_handler_, &mock_client_,
383 touchpad_and_wheel_scroll_latching_enabled_));
382 scroll_result_did_scroll_.did_scroll = true; 384 scroll_result_did_scroll_.did_scroll = true;
383 scroll_result_did_not_scroll_.did_scroll = false; 385 scroll_result_did_not_scroll_.did_scroll = false;
384 386
385 if (install_synchronous_handler_) { 387 if (install_synchronous_handler_) {
386 EXPECT_CALL(mock_input_handler_, 388 EXPECT_CALL(mock_input_handler_,
387 RequestUpdateForSynchronousInputHandler()) 389 RequestUpdateForSynchronousInputHandler())
388 .Times(1); 390 .Times(1);
389 input_handler_->SetOnlySynchronouslyAnimateRootFlings( 391 input_handler_->SetOnlySynchronouslyAnimateRootFlings(
390 &mock_synchronous_input_handler_); 392 &mock_synchronous_input_handler_);
391 } 393 }
392 394
393 mock_input_handler_.set_is_scrolling_root(synchronous_root_scroll_); 395 mock_input_handler_.set_is_scrolling_root(synchronous_root_scroll_);
394 396
395 // Set a default device so tests don't always have to set this. 397 // Set a default device so tests don't always have to set this.
396 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; 398 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad;
397 } 399 }
398 400
399 ~InputHandlerProxyTest() { 401 virtual ~InputHandlerProxyTest() { input_handler_.reset(); }
400 input_handler_.reset();
401 }
402 402
403 // This is defined as a macro so the line numbers can be traced back to the 403 // This is defined as a macro so the line numbers can be traced back to the
404 // correct spot when it fails. 404 // correct spot when it fails.
405 #define EXPECT_SET_NEEDS_ANIMATE_INPUT(times) \ 405 #define EXPECT_SET_NEEDS_ANIMATE_INPUT(times) \
406 do { \ 406 do { \
407 if (synchronous_root_scroll_) { \ 407 if (synchronous_root_scroll_) { \
408 EXPECT_CALL(mock_synchronous_input_handler_, \ 408 EXPECT_CALL(mock_synchronous_input_handler_, \
409 SetNeedsSynchronousAnimateInput()) \ 409 SetNeedsSynchronousAnimateInput()) \
410 .Times(times); \ 410 .Times(times); \
411 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(0); \ 411 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(0); \
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 474
475 void SetSmoothScrollEnabled(bool value) { 475 void SetSmoothScrollEnabled(bool value) {
476 input_handler_->smooth_scroll_enabled_ = value; 476 input_handler_->smooth_scroll_enabled_ = value;
477 } 477 }
478 478
479 base::HistogramTester& histogram_tester() { 479 base::HistogramTester& histogram_tester() {
480 return histogram_tester_; 480 return histogram_tester_;
481 } 481 }
482 482
483 protected: 483 protected:
484 void GestureFlingAnimatesTouchpad();
485 void DidReceiveInputEvent_ForFling();
486 void GestureScrollStarted();
487 void GestureFlingPassiveListener();
488 void GestureFlingStartedTouchpad();
489 void GestureFlingStopsAtContentEdge();
490 void GestureFlingTransferResetsTouchpad();
491
484 const bool synchronous_root_scroll_; 492 const bool synchronous_root_scroll_;
485 const bool install_synchronous_handler_; 493 const bool install_synchronous_handler_;
486 testing::StrictMock<MockInputHandler> mock_input_handler_; 494 testing::StrictMock<MockInputHandler> mock_input_handler_;
487 testing::StrictMock<MockSynchronousInputHandler> 495 testing::StrictMock<MockSynchronousInputHandler>
488 mock_synchronous_input_handler_; 496 mock_synchronous_input_handler_;
489 std::unique_ptr<TestInputHandlerProxy> input_handler_; 497 std::unique_ptr<TestInputHandlerProxy> input_handler_;
490 testing::StrictMock<MockInputHandlerProxyClient> mock_client_; 498 testing::StrictMock<MockInputHandlerProxyClient> mock_client_;
491 WebGestureEvent gesture_; 499 WebGestureEvent gesture_;
492 InputHandlerProxy::EventDisposition expected_disposition_; 500 InputHandlerProxy::EventDisposition expected_disposition_;
493 base::HistogramTester histogram_tester_; 501 base::HistogramTester histogram_tester_;
494 cc::InputHandlerScrollResult scroll_result_did_scroll_; 502 cc::InputHandlerScrollResult scroll_result_did_scroll_;
495 cc::InputHandlerScrollResult scroll_result_did_not_scroll_; 503 cc::InputHandlerScrollResult scroll_result_did_not_scroll_;
504 bool touchpad_and_wheel_scroll_latching_enabled_;
496 }; 505 };
497 506
498 class InputHandlerProxyEventQueueTest : public testing::Test { 507 class InputHandlerProxyWithoutWheelScrollLatchingTest
508 : public InputHandlerProxyTest {
509 public:
510 InputHandlerProxyWithoutWheelScrollLatchingTest()
511 : InputHandlerProxyTest(false) {}
512 };
513
514 class InputHandlerProxyEventQueueTest : public testing::TestWithParam<bool> {
499 public: 515 public:
500 InputHandlerProxyEventQueueTest() : weak_ptr_factory_(this) { 516 InputHandlerProxyEventQueueTest() : weak_ptr_factory_(this) {
501 feature_list_.InitAndEnableFeature(features::kVsyncAlignedInputEvents); 517 feature_list_.InitAndEnableFeature(features::kVsyncAlignedInputEvents);
502 } 518 }
503 519
504 ~InputHandlerProxyEventQueueTest() { input_handler_proxy_.reset(); } 520 ~InputHandlerProxyEventQueueTest() { input_handler_proxy_.reset(); }
505 521
506 void SetUp() override { 522 void SetUp() override {
523 bool wheel_scroll_latching_enabled = GetParam();
507 event_disposition_recorder_.clear(); 524 event_disposition_recorder_.clear();
508 input_handler_proxy_ = base::MakeUnique<TestInputHandlerProxy>( 525 input_handler_proxy_ = base::MakeUnique<TestInputHandlerProxy>(
509 &mock_input_handler_, &mock_client_, false); 526 &mock_input_handler_, &mock_client_, wheel_scroll_latching_enabled);
510 if (input_handler_proxy_->compositor_event_queue_) 527 if (input_handler_proxy_->compositor_event_queue_)
511 input_handler_proxy_->compositor_event_queue_ = 528 input_handler_proxy_->compositor_event_queue_ =
512 base::MakeUnique<CompositorThreadEventQueue>(); 529 base::MakeUnique<CompositorThreadEventQueue>();
513 } 530 }
514 531
515 void StartTracing() { 532 void StartTracing() {
516 base::trace_event::TraceLog::GetInstance()->SetEnabled( 533 base::trace_event::TraceLog::GetInstance()->SetEnabled(
517 base::trace_event::TraceConfig("*"), 534 base::trace_event::TraceConfig("*"),
518 base::trace_event::TraceLog::RECORDING_MODE); 535 base::trace_event::TraceLog::RECORDING_MODE);
519 } 536 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 EXPECT_CALL(mock_input_handler_, 624 EXPECT_CALL(mock_input_handler_,
608 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) 625 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
609 .WillOnce(testing::Return(cc::EventListenerProperties::kBlocking)); 626 .WillOnce(testing::Return(cc::EventListenerProperties::kBlocking));
610 627
611 WebMouseWheelEvent wheel(WebInputEvent::MouseWheel, WebInputEvent::ControlKey, 628 WebMouseWheelEvent wheel(WebInputEvent::MouseWheel, WebInputEvent::ControlKey,
612 WebInputEvent::TimeStampForTesting); 629 WebInputEvent::TimeStampForTesting);
613 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); 630 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel));
614 VERIFY_AND_RESET_MOCKS(); 631 VERIFY_AND_RESET_MOCKS();
615 } 632 }
616 633
617 TEST_P(InputHandlerProxyTest, GestureScrollStarted) { 634 void InputHandlerProxyTest::GestureScrollStarted() {
618 // We shouldn't send any events to the widget for this gesture. 635 // We shouldn't send any events to the widget for this gesture.
619 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 636 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
620 VERIFY_AND_RESET_MOCKS(); 637 VERIFY_AND_RESET_MOCKS();
621 638
622 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 639 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
623 .WillOnce(testing::Return(kImplThreadScrollState)); 640 .WillOnce(testing::Return(kImplThreadScrollState));
624 641
625 gesture_.setType(WebInputEvent::GestureScrollBegin); 642 gesture_.setType(WebInputEvent::GestureScrollBegin);
626 EXPECT_EQ(expected_disposition_,input_handler_->HandleInputEvent(gesture_)); 643 EXPECT_EQ(expected_disposition_,input_handler_->HandleInputEvent(gesture_));
627 644
628 // The event should not be marked as handled if scrolling is not possible. 645 // The event should not be marked as handled if scrolling is not possible.
629 expected_disposition_ = InputHandlerProxy::DROP_EVENT; 646 expected_disposition_ = InputHandlerProxy::DROP_EVENT;
630 VERIFY_AND_RESET_MOCKS(); 647 VERIFY_AND_RESET_MOCKS();
631 648
632 gesture_.setType(WebInputEvent::GestureScrollUpdate); 649 gesture_.setType(WebInputEvent::GestureScrollUpdate);
633 gesture_.data.scrollUpdate.deltaY = 650 gesture_.data.scrollUpdate.deltaY =
634 -40; // -Y means scroll down - i.e. in the +Y direction. 651 -40; // -Y means scroll down - i.e. in the +Y direction.
635 EXPECT_CALL( 652 EXPECT_CALL(
636 mock_input_handler_, 653 mock_input_handler_,
637 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)))) 654 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0))))
638 .WillOnce(testing::Return(scroll_result_did_not_scroll_)); 655 .WillOnce(testing::Return(scroll_result_did_not_scroll_));
656 EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
657 .WillOnce(testing::Return(false));
639 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 658 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
640 659
641 // Mark the event as handled if scroll happens. 660 // Mark the event as handled if scroll happens.
642 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 661 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
643 VERIFY_AND_RESET_MOCKS(); 662 VERIFY_AND_RESET_MOCKS();
644 663
645 gesture_.setType(WebInputEvent::GestureScrollUpdate); 664 gesture_.setType(WebInputEvent::GestureScrollUpdate);
646 gesture_.data.scrollUpdate.deltaY = 665 gesture_.data.scrollUpdate.deltaY =
647 -40; // -Y means scroll down - i.e. in the +Y direction. 666 -40; // -Y means scroll down - i.e. in the +Y direction.
648 EXPECT_CALL( 667 EXPECT_CALL(
649 mock_input_handler_, 668 mock_input_handler_,
650 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)))) 669 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0))))
651 .WillOnce(testing::Return(scroll_result_did_scroll_)); 670 .WillOnce(testing::Return(scroll_result_did_scroll_));
652 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 671 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
653 672
654 VERIFY_AND_RESET_MOCKS(); 673 VERIFY_AND_RESET_MOCKS();
655 674
656 gesture_.setType(WebInputEvent::GestureScrollEnd); 675 gesture_.setType(WebInputEvent::GestureScrollEnd);
657 gesture_.data.scrollUpdate.deltaY = 0; 676 gesture_.data.scrollUpdate.deltaY = 0;
658 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 677 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
659 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 678 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
660 679
661 VERIFY_AND_RESET_MOCKS(); 680 VERIFY_AND_RESET_MOCKS();
662 } 681 }
682 TEST_P(InputHandlerProxyTest, GestureScrollStarted) {
683 GestureScrollStarted();
684 }
685 TEST_P(InputHandlerProxyWithoutWheelScrollLatchingTest, GestureScrollStarted) {
686 GestureScrollStarted();
687 }
663 688
664 TEST_P(InputHandlerProxyTest, GestureScrollOnMainThread) { 689 TEST_P(InputHandlerProxyTest, GestureScrollOnMainThread) {
665 // We should send all events to the widget for this gesture. 690 // We should send all events to the widget for this gesture.
666 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; 691 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
667 VERIFY_AND_RESET_MOCKS(); 692 VERIFY_AND_RESET_MOCKS();
668 693
669 EXPECT_CALL(mock_input_handler_, ScrollBegin(::testing::_, ::testing::_)) 694 EXPECT_CALL(mock_input_handler_, ScrollBegin(::testing::_, ::testing::_))
670 .WillOnce(testing::Return(kMainThreadScrollState)); 695 .WillOnce(testing::Return(kMainThreadScrollState));
671 696
672 gesture_.setType(WebInputEvent::GestureScrollBegin); 697 gesture_.setType(WebInputEvent::GestureScrollBegin);
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 962
938 gesture_.setType(WebInputEvent::GestureScrollEnd); 963 gesture_.setType(WebInputEvent::GestureScrollEnd);
939 gesture_.data.scrollUpdate.deltaY = 0; 964 gesture_.data.scrollUpdate.deltaY = 0;
940 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)) 965 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_))
941 .WillOnce(testing::Return()); 966 .WillOnce(testing::Return());
942 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 967 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
943 968
944 VERIFY_AND_RESET_MOCKS(); 969 VERIFY_AND_RESET_MOCKS();
945 } 970 }
946 971
947 TEST_P(InputHandlerProxyTest, GestureFlingStartedTouchpad) { 972 void InputHandlerProxyTest::GestureFlingStartedTouchpad() {
948 // We shouldn't send any events to the widget for this gesture. 973 // We shouldn't send any events to the widget for this gesture.
949 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 974 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
950 VERIFY_AND_RESET_MOCKS(); 975 VERIFY_AND_RESET_MOCKS();
951 976
977 EXPECT_CALL(mock_input_handler_, ScrollBegin(::testing::_, ::testing::_))
978 .WillOnce(testing::Return(kImplThreadScrollState));
979
980 // HandleGestureScrollBegin will set gesture_scroll_on_impl_thread_.
981 gesture_.setType(WebInputEvent::GestureScrollBegin);
982 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
983 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
984
985 VERIFY_AND_RESET_MOCKS();
986
952 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 987 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
953 .WillOnce(testing::Return(kImplThreadScrollState)); 988 .WillOnce(testing::Return(kImplThreadScrollState));
954 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 989 if (!touchpad_and_wheel_scroll_latching_enabled_)
990 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
955 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 991 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
956 992
957 gesture_.setType(WebInputEvent::GestureFlingStart); 993 gesture_.setType(WebInputEvent::GestureFlingStart);
958 gesture_.data.flingStart.velocityX = 10; 994 gesture_.data.flingStart.velocityX = 10;
959 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; 995 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad;
960 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 996 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
961 997
962 VERIFY_AND_RESET_MOCKS(); 998 VERIFY_AND_RESET_MOCKS();
963 999
1000 if (touchpad_and_wheel_scroll_latching_enabled_) {
1001 // The fling cancellation shouldn't get deferred because velocityX is less
1002 // than minimum.
1003 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(1);
1004 }
964 // Verify that a GestureFlingCancel during an animation cancels it. 1005 // Verify that a GestureFlingCancel during an animation cancels it.
965 gesture_.setType(WebInputEvent::GestureFlingCancel); 1006 gesture_.setType(WebInputEvent::GestureFlingCancel);
966 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; 1007 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad;
967 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1008 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1009
1010 VERIFY_AND_RESET_MOCKS();
1011 }
1012 TEST_P(InputHandlerProxyTest, GestureFlingStartedTouchpad) {
1013 GestureFlingStartedTouchpad();
1014 }
1015 TEST_P(InputHandlerProxyWithoutWheelScrollLatchingTest,
1016 GestureFlingStartedTouchpad) {
1017 GestureFlingStartedTouchpad();
968 } 1018 }
969 1019
970 TEST_P(InputHandlerProxyTest, GestureFlingTouchpadScrollLatchingEnabled) { 1020 TEST_P(InputHandlerProxyTest, GestureFlingTouchpadScrollLatchingEnabled) {
971 // Reset the input_handler_ with wheel scroll latching enabled. 1021 // Reset the input_handler_ with wheel scroll latching enabled.
972 input_handler_.reset( 1022 input_handler_.reset(
973 new TestInputHandlerProxy(&mock_input_handler_, &mock_client_, true)); 1023 new TestInputHandlerProxy(&mock_input_handler_, &mock_client_, true));
974 if (install_synchronous_handler_) { 1024 if (install_synchronous_handler_) {
975 EXPECT_CALL(mock_input_handler_, RequestUpdateForSynchronousInputHandler()) 1025 EXPECT_CALL(mock_input_handler_, RequestUpdateForSynchronousInputHandler())
976 .Times(1); 1026 .Times(1);
977 input_handler_->SetOnlySynchronouslyAnimateRootFlings( 1027 input_handler_->SetOnlySynchronouslyAnimateRootFlings(
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); 1100 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
1051 1101
1052 // When scroll latching is enabled, ScrollBegin shouldn't get called for 1102 // When scroll latching is enabled, ScrollBegin shouldn't get called for
1053 // every tick. 1103 // every tick.
1054 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1104 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1055 .Times(0); 1105 .Times(0);
1056 EXPECT_CALL( 1106 EXPECT_CALL(
1057 mock_input_handler_, 1107 mock_input_handler_,
1058 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) 1108 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
1059 .WillOnce(testing::Return(scroll_result_did_not_scroll_)); 1109 .WillOnce(testing::Return(scroll_result_did_not_scroll_));
1110 EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
1111 .WillOnce(testing::Return(false));
1060 1112
1061 // When scroll latching is enabled, ScrollEnd gets called when the last 1113 // When scroll latching is enabled, ScrollEnd gets called when the last
1062 // ScrollBy did not scroll. 1114 // ScrollBy did not scroll.
1063 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 1115 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
1064 time += base::TimeDelta::FromMilliseconds(100); 1116 time += base::TimeDelta::FromMilliseconds(100);
1065 Animate(time); 1117 Animate(time);
1066 1118
1067 VERIFY_AND_RESET_MOCKS(); 1119 VERIFY_AND_RESET_MOCKS();
1068 1120
1069 // Fling has ended, the last Animate won't cause any more wheel ticks. 1121 // Fling has ended, the last Animate won't cause any more wheel ticks.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 expected_disposition_ = InputHandlerProxy::DROP_EVENT; 1165 expected_disposition_ = InputHandlerProxy::DROP_EVENT;
1114 VERIFY_AND_RESET_MOCKS(); 1166 VERIFY_AND_RESET_MOCKS();
1115 1167
1116 // Since the previous fling was ignored, we should also be dropping the next 1168 // Since the previous fling was ignored, we should also be dropping the next
1117 // fling_cancel. 1169 // fling_cancel.
1118 gesture_.setType(WebInputEvent::GestureFlingCancel); 1170 gesture_.setType(WebInputEvent::GestureFlingCancel);
1119 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; 1171 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad;
1120 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1172 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1121 } 1173 }
1122 1174
1123 TEST_P(InputHandlerProxyTest, GestureFlingAnimatesTouchpad) { 1175 void InputHandlerProxyTest::GestureFlingAnimatesTouchpad() {
1124 // We shouldn't send any events to the widget for this gesture. 1176 // We shouldn't send any events to the widget for this gesture.
1125 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1177 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1126 VERIFY_AND_RESET_MOCKS(); 1178 VERIFY_AND_RESET_MOCKS();
1127 1179
1180 EXPECT_CALL(mock_input_handler_, ScrollBegin(::testing::_, ::testing::_))
1181 .WillOnce(testing::Return(kImplThreadScrollState));
1182
1183 // HandleGestureScrollBegin will set gesture_scroll_on_impl_thread_.
1184 gesture_.setType(WebInputEvent::GestureScrollBegin);
1185 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1186 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1187
1188 VERIFY_AND_RESET_MOCKS();
1189
1128 // On the fling start, we should schedule an animation but not actually start 1190 // On the fling start, we should schedule an animation but not actually start
1129 // scrolling. 1191 // scrolling.
1130 gesture_.setType(WebInputEvent::GestureFlingStart); 1192 gesture_.setType(WebInputEvent::GestureFlingStart);
1131 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); 1193 WebFloatPoint fling_delta = WebFloatPoint(1000, 0);
1132 WebPoint fling_point = WebPoint(7, 13); 1194 WebPoint fling_point = WebPoint(7, 13);
1133 WebPoint fling_global_point = WebPoint(17, 23); 1195 WebPoint fling_global_point = WebPoint(17, 23);
1134 // Note that for trackpad, wheel events with the Control modifier are 1196 // Note that for trackpad, wheel events with the Control modifier are
1135 // special (reserved for zoom), so don't set that here. 1197 // special (reserved for zoom), so don't set that here.
1136 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; 1198 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey;
1137 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, 1199 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad,
1138 fling_delta, 1200 fling_delta,
1139 fling_point, 1201 fling_point,
1140 fling_global_point, 1202 fling_global_point,
1141 modifiers); 1203 modifiers);
1142 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 1204 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1143 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1205 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1144 .WillOnce(testing::Return(kImplThreadScrollState)); 1206 .WillOnce(testing::Return(kImplThreadScrollState));
1145 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 1207 if (!touchpad_and_wheel_scroll_latching_enabled_)
1208 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
1146 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1209 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1147 1210
1148 VERIFY_AND_RESET_MOCKS(); 1211 VERIFY_AND_RESET_MOCKS();
1149 1212
1150 // The first animate call should let us pick up an animation start time, but 1213 // The first animate call should let us pick up an animation start time, but
1151 // we shouldn't actually move anywhere just yet. The first frame after the 1214 // we shouldn't actually move anywhere just yet. The first frame after the
1152 // fling start will typically include the last scroll from the gesture that 1215 // fling start will typically include the last scroll from the gesture that
1153 // lead to the scroll (either wheel or gesture scroll), so there should be no 1216 // lead to the scroll (either wheel or gesture scroll), so there should be no
1154 // visible hitch. 1217 // visible hitch.
1155 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 1218 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1156 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1219 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1157 .Times(0); 1220 .Times(0);
1158 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); 1221 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
1159 Animate(time); 1222 Animate(time);
1160 1223
1161 VERIFY_AND_RESET_MOCKS(); 1224 VERIFY_AND_RESET_MOCKS();
1162 1225
1163 // The second call should start scrolling in the -X direction. 1226 // The second call should start scrolling in the -X direction.
1164 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 1227 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1165 EXPECT_CALL(mock_input_handler_, 1228 EXPECT_CALL(mock_input_handler_,
1166 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) 1229 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
1167 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); 1230 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
1168 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1231 if (!touchpad_and_wheel_scroll_latching_enabled_) {
1169 .WillOnce(testing::Return(kImplThreadScrollState)); 1232 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1233 .WillOnce(testing::Return(kImplThreadScrollState));
1234 }
1170 EXPECT_CALL( 1235 EXPECT_CALL(
1171 mock_input_handler_, 1236 mock_input_handler_,
1172 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) 1237 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
1173 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1238 .WillOnce(testing::Return(scroll_result_did_scroll_));
1174 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 1239 if (!touchpad_and_wheel_scroll_latching_enabled_)
1240 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
1175 time += base::TimeDelta::FromMilliseconds(100); 1241 time += base::TimeDelta::FromMilliseconds(100);
1176 Animate(time); 1242 Animate(time);
1177 1243
1178 VERIFY_AND_RESET_MOCKS(); 1244 VERIFY_AND_RESET_MOCKS();
1179 1245
1180 // Let's say on the third call we hit a non-scrollable region. We should abort 1246 // Let's say on the third call we hit a non-scrollable region. We should abort
1181 // the fling and not scroll. 1247 // the fling and not scroll.
1182 // We also should pass the current fling parameters out to the client so the 1248 // We also should pass the current fling parameters out to the client so the
1183 // rest of the fling can be 1249 // rest of the fling can be
1184 // transferred to the main thread. 1250 // transferred to the main thread.
1185 EXPECT_CALL(mock_input_handler_, 1251 EXPECT_CALL(mock_input_handler_,
1186 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) 1252 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
1187 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); 1253 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
1188 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1254 if (!touchpad_and_wheel_scroll_latching_enabled_) {
1189 .WillOnce(testing::Return(kMainThreadScrollState)); 1255 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1190 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); 1256 .WillOnce(testing::Return(kMainThreadScrollState));
1191 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0); 1257 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0);
1258 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0);
1259 } else {
1260 EXPECT_CALL(
1261 mock_input_handler_,
1262 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
1263 .WillOnce(testing::Return(scroll_result_did_not_scroll_));
1264 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
1265 EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
1266 .WillOnce(testing::Return(true));
1267 }
1192 // Expected wheel fling animation parameters: 1268 // Expected wheel fling animation parameters:
1193 // *) fling_delta and fling_point should match the original GestureFlingStart 1269 // *) fling_delta and fling_point should match the original GestureFlingStart
1194 // event 1270 // event
1195 // *) startTime should be 10 to match the time parameter of the first 1271 // *) startTime should be 10 to match the time parameter of the first
1196 // Animate() call after the GestureFlingStart 1272 // Animate() call after the GestureFlingStart
1197 // *) cumulativeScroll depends on the curve, but since we've animated in the 1273 // *) cumulativeScroll depends on the curve, but since we've animated in the
1198 // -X direction the X value should be < 0 1274 // -X direction the X value should be < 0
1199 EXPECT_CALL( 1275 EXPECT_CALL(
1200 mock_client_, 1276 mock_client_,
1201 TransferActiveWheelFlingAnimation(testing::AllOf( 1277 TransferActiveWheelFlingAnimation(testing::AllOf(
(...skipping 25 matching lines...) Expand all
1227 1303
1228 // Since we've transferred the fling to the main thread, we need to pass the 1304 // Since we've transferred the fling to the main thread, we need to pass the
1229 // next GestureFlingCancel to the main 1305 // next GestureFlingCancel to the main
1230 // thread as well. 1306 // thread as well.
1231 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; 1307 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
1232 gesture_.setType(WebInputEvent::GestureFlingCancel); 1308 gesture_.setType(WebInputEvent::GestureFlingCancel);
1233 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1309 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1234 1310
1235 VERIFY_AND_RESET_MOCKS(); 1311 VERIFY_AND_RESET_MOCKS();
1236 } 1312 }
1313 TEST_P(InputHandlerProxyTest, GestureFlingAnimatesTouchpad) {
1314 GestureFlingAnimatesTouchpad();
1315 }
1316 TEST_P(InputHandlerProxyWithoutWheelScrollLatchingTest,
1317 GestureFlingAnimatesTouchpad) {
1318 GestureFlingAnimatesTouchpad();
1319 }
1237 1320
1238 TEST_P(InputHandlerProxyTest, GestureFlingPassiveListener) { 1321 void InputHandlerProxyTest::GestureFlingPassiveListener() {
1239 // We shouldn't send any events to the widget for this gesture. 1322 // We shouldn't send any events to the widget for this gesture.
1240 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1323 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1241 VERIFY_AND_RESET_MOCKS(); 1324 VERIFY_AND_RESET_MOCKS();
1242 1325
1326 EXPECT_CALL(mock_input_handler_, ScrollBegin(::testing::_, ::testing::_))
1327 .WillOnce(testing::Return(kImplThreadScrollState));
1328
1329 // HandleGestureScrollBegin will set gesture_scroll_on_impl_thread_.
1330 gesture_.setType(WebInputEvent::GestureScrollBegin);
1331 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1332 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1333
1334 VERIFY_AND_RESET_MOCKS();
1335
1243 // On the fling start, we should schedule an animation but not actually start 1336 // On the fling start, we should schedule an animation but not actually start
1244 // scrolling. 1337 // scrolling.
1245 gesture_.setType(WebInputEvent::GestureFlingStart); 1338 gesture_.setType(WebInputEvent::GestureFlingStart);
1246 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); 1339 WebFloatPoint fling_delta = WebFloatPoint(1000, 0);
1247 WebPoint fling_point = WebPoint(7, 13); 1340 WebPoint fling_point = WebPoint(7, 13);
1248 WebPoint fling_global_point = WebPoint(17, 23); 1341 WebPoint fling_global_point = WebPoint(17, 23);
1249 // Note that for trackpad, wheel events with the Control modifier are 1342 // Note that for trackpad, wheel events with the Control modifier are
1250 // special (reserved for zoom), so don't set that here. 1343 // special (reserved for zoom), so don't set that here.
1251 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; 1344 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey;
1252 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, fling_delta, 1345 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, fling_delta,
1253 fling_point, fling_global_point, modifiers); 1346 fling_point, fling_global_point, modifiers);
1254 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 1347 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1255 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1348 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1256 .WillOnce(testing::Return(kImplThreadScrollState)); 1349 .WillOnce(testing::Return(kImplThreadScrollState));
1257 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 1350 if (!touchpad_and_wheel_scroll_latching_enabled_)
1351 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
1258 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1352 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1259 1353
1260 VERIFY_AND_RESET_MOCKS(); 1354 VERIFY_AND_RESET_MOCKS();
1261 1355
1262 // The first animate call should let us pick up an animation start time, but 1356 // The first animate call should let us pick up an animation start time, but
1263 // we shouldn't actually move anywhere just yet. The first frame after the 1357 // we shouldn't actually move anywhere just yet. The first frame after the
1264 // fling start will typically include the last scroll from the gesture that 1358 // fling start will typically include the last scroll from the gesture that
1265 // lead to the scroll (either wheel or gesture scroll), so there should be no 1359 // lead to the scroll (either wheel or gesture scroll), so there should be no
1266 // visible hitch. 1360 // visible hitch.
1267 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 1361 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1268 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1362 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1269 .Times(0); 1363 .Times(0);
1270 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); 1364 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
1271 Animate(time); 1365 Animate(time);
1272 1366
1273 VERIFY_AND_RESET_MOCKS(); 1367 VERIFY_AND_RESET_MOCKS();
1274 1368
1275 // The second call should punt activate the fling and call the method 1369 // The second call should punt activate the fling and call the method
1276 // dispatching the events for the passive event listeners. 1370 // dispatching the events for the passive event listeners.
1277 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 1371 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1278 EXPECT_CALL(mock_input_handler_, 1372 EXPECT_CALL(mock_input_handler_,
1279 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) 1373 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
1280 .WillOnce(testing::Return(cc::EventListenerProperties::kPassive)); 1374 .WillOnce(testing::Return(cc::EventListenerProperties::kPassive));
1281 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1375 if (!touchpad_and_wheel_scroll_latching_enabled_) {
1282 .WillOnce(testing::Return(kImplThreadScrollState)); 1376 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1377 .WillOnce(testing::Return(kImplThreadScrollState));
1378 }
1283 EXPECT_CALL( 1379 EXPECT_CALL(
1284 mock_input_handler_, 1380 mock_input_handler_,
1285 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) 1381 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
1286 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1382 .WillOnce(testing::Return(scroll_result_did_scroll_));
1287 WebMouseWheelEvent expected_wheel(WebInputEvent::MouseWheel, modifiers, 1383 WebMouseWheelEvent expected_wheel(WebInputEvent::MouseWheel, modifiers,
1288 WebInputEvent::TimeStampForTesting); 1384 WebInputEvent::TimeStampForTesting);
1289 expected_wheel.setPositionInWidget(fling_point.x, fling_point.y); 1385 expected_wheel.setPositionInWidget(fling_point.x, fling_point.y);
1290 expected_wheel.setPositionInScreen(fling_global_point.x, 1386 expected_wheel.setPositionInScreen(fling_global_point.x,
1291 fling_global_point.y); 1387 fling_global_point.y);
1292 expected_wheel.deltaX = fling_delta.x / 10; 1388 expected_wheel.deltaX = fling_delta.x / 10;
1293 expected_wheel.hasPreciseScrollingDeltas = true; 1389 expected_wheel.hasPreciseScrollingDeltas = true;
1294 1390
1295 EXPECT_CALL(mock_client_, DispatchNonBlockingEventToMainThread_( 1391 EXPECT_CALL(mock_client_, DispatchNonBlockingEventToMainThread_(
1296 WheelEventsMatch(expected_wheel))) 1392 WheelEventsMatch(expected_wheel)))
1297 .Times(1); 1393 .Times(1);
1298 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(1); 1394 if (!touchpad_and_wheel_scroll_latching_enabled_)
1395 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(1);
1299 1396
1300 time += base::TimeDelta::FromMilliseconds(100); 1397 time += base::TimeDelta::FromMilliseconds(100);
1301 Animate(time); 1398 Animate(time);
1302 1399
1303 VERIFY_AND_RESET_MOCKS(); 1400 VERIFY_AND_RESET_MOCKS();
1304 1401
1305 // Ensure we can cancel the gesture. 1402 // Ensure we can cancel the gesture.
1306 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1403 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1307 gesture_.setType(WebInputEvent::GestureFlingCancel); 1404 gesture_.setType(WebInputEvent::GestureFlingCancel);
1308 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1405 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1406 if (touchpad_and_wheel_scroll_latching_enabled_) {
1407 // The fling cancellation should be deferred.
1408 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0);
1409 }
1309 1410
1310 VERIFY_AND_RESET_MOCKS(); 1411 VERIFY_AND_RESET_MOCKS();
1311 } 1412 }
1413 TEST_P(InputHandlerProxyTest, GestureFlingPassiveListener) {
1414 GestureFlingPassiveListener();
1415 }
1416 TEST_P(InputHandlerProxyWithoutWheelScrollLatchingTest,
1417 GestureFlingPassiveListener) {
1418 GestureFlingPassiveListener();
1419 }
1312 1420
1313 TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) { 1421 void InputHandlerProxyTest::GestureFlingTransferResetsTouchpad() {
1314 // We shouldn't send any events to the widget for this gesture. 1422 // We shouldn't send any events to the widget for this gesture.
1315 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1423 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1316 VERIFY_AND_RESET_MOCKS(); 1424 VERIFY_AND_RESET_MOCKS();
1317 1425
1426 EXPECT_CALL(mock_input_handler_, ScrollBegin(::testing::_, ::testing::_))
1427 .WillOnce(testing::Return(kImplThreadScrollState));
1428
1429 // HandleGestureScrollBegin will set gesture_scroll_on_impl_thread_.
1430 gesture_.setType(WebInputEvent::GestureScrollBegin);
1431 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1432 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1433
1434 VERIFY_AND_RESET_MOCKS();
1435
1318 // Start a gesture fling in the -X direction with zero Y movement. 1436 // Start a gesture fling in the -X direction with zero Y movement.
1319 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); 1437 WebFloatPoint fling_delta = WebFloatPoint(1000, 0);
1320 WebPoint fling_point = WebPoint(7, 13); 1438 WebPoint fling_point = WebPoint(7, 13);
1321 WebPoint fling_global_point = WebPoint(17, 23); 1439 WebPoint fling_global_point = WebPoint(17, 23);
1322 // Note that for trackpad, wheel events with the Control modifier are 1440 // Note that for trackpad, wheel events with the Control modifier are
1323 // special (reserved for zoom), so don't set that here. 1441 // special (reserved for zoom), so don't set that here.
1324 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; 1442 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey;
1325 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, 1443 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad,
1326 fling_delta, 1444 fling_delta,
1327 fling_point, 1445 fling_point,
1328 fling_global_point, 1446 fling_global_point,
1329 modifiers); 1447 modifiers);
1330 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 1448 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1331 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1449 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1332 .WillOnce(testing::Return(kImplThreadScrollState)); 1450 .WillOnce(testing::Return(kImplThreadScrollState));
1333 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 1451 if (!touchpad_and_wheel_scroll_latching_enabled_)
1452 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
1334 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1453 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1335 VERIFY_AND_RESET_MOCKS(); 1454 VERIFY_AND_RESET_MOCKS();
1336 1455
1337 // Start the fling animation at time 10. This shouldn't actually scroll, just 1456 // Start the fling animation at time 10. This shouldn't actually scroll, just
1338 // establish a start time. 1457 // establish a start time.
1339 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 1458 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1340 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1459 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1341 .Times(0); 1460 .Times(0);
1342 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); 1461 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
1343 Animate(time); 1462 Animate(time);
1344 1463
1345 VERIFY_AND_RESET_MOCKS(); 1464 VERIFY_AND_RESET_MOCKS();
1346 1465
1347 // The second call should start scrolling in the -X direction. 1466 // The second call should start scrolling in the -X direction.
1348 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 1467 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1349 EXPECT_CALL(mock_input_handler_, 1468 EXPECT_CALL(mock_input_handler_,
1350 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) 1469 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
1351 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); 1470 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
1352 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1471 if (!touchpad_and_wheel_scroll_latching_enabled_) {
1353 .WillOnce(testing::Return(kImplThreadScrollState)); 1472 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1473 .WillOnce(testing::Return(kImplThreadScrollState));
1474 }
1354 EXPECT_CALL( 1475 EXPECT_CALL(
1355 mock_input_handler_, 1476 mock_input_handler_,
1356 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) 1477 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
1357 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1478 .WillOnce(testing::Return(scroll_result_did_scroll_));
1358 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 1479 if (!touchpad_and_wheel_scroll_latching_enabled_)
1480 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
1359 time += base::TimeDelta::FromMilliseconds(100); 1481 time += base::TimeDelta::FromMilliseconds(100);
1360 Animate(time); 1482 Animate(time);
1361 1483
1362 VERIFY_AND_RESET_MOCKS(); 1484 VERIFY_AND_RESET_MOCKS();
1363 1485
1364 // Let's say on the third call we hit a non-scrollable region. We should abort 1486 // Let's say on the third call we hit a non-scrollable region. We should abort
1365 // the fling and not scroll. 1487 // the fling and not scroll.
1366 // We also should pass the current fling parameters out to the client so the 1488 // We also should pass the current fling parameters out to the client so the
1367 // rest of the fling can be 1489 // rest of the fling can be
1368 // transferred to the main thread. 1490 // transferred to the main thread.
1369 EXPECT_CALL(mock_input_handler_, 1491 EXPECT_CALL(mock_input_handler_,
1370 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) 1492 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
1371 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); 1493 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
1372 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1494 if (!touchpad_and_wheel_scroll_latching_enabled_) {
1373 .WillOnce(testing::Return(kMainThreadScrollState)); 1495 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1374 1496 .WillOnce(testing::Return(kMainThreadScrollState));
1375 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); 1497 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0);
1376 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0); 1498 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0);
1499 } else {
1500 EXPECT_CALL(
1501 mock_input_handler_,
1502 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
1503 .WillOnce(testing::Return(scroll_result_did_not_scroll_));
1504 EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
1505 .WillOnce(testing::Return(true));
1506 }
1377 1507
1378 // Expected wheel fling animation parameters: 1508 // Expected wheel fling animation parameters:
1379 // *) fling_delta and fling_point should match the original GestureFlingStart 1509 // *) fling_delta and fling_point should match the original GestureFlingStart
1380 // event 1510 // event
1381 // *) startTime should be 10 to match the time parameter of the first 1511 // *) startTime should be 10 to match the time parameter of the first
1382 // Animate() call after the GestureFlingStart 1512 // Animate() call after the GestureFlingStart
1383 // *) cumulativeScroll depends on the curve, but since we've animated in the 1513 // *) cumulativeScroll depends on the curve, but since we've animated in the
1384 // -X direction the X value should be < 0 1514 // -X direction the X value should be < 0
1385 EXPECT_CALL( 1515 EXPECT_CALL(
1386 mock_client_, 1516 mock_client_,
1387 TransferActiveWheelFlingAnimation(testing::AllOf( 1517 TransferActiveWheelFlingAnimation(testing::AllOf(
1388 testing::Field(&WebActiveWheelFlingParameters::delta, 1518 testing::Field(&WebActiveWheelFlingParameters::delta,
1389 testing::Eq(fling_delta)), 1519 testing::Eq(fling_delta)),
1390 testing::Field(&WebActiveWheelFlingParameters::point, 1520 testing::Field(&WebActiveWheelFlingParameters::point,
1391 testing::Eq(fling_point)), 1521 testing::Eq(fling_point)),
1392 testing::Field(&WebActiveWheelFlingParameters::globalPoint, 1522 testing::Field(&WebActiveWheelFlingParameters::globalPoint,
1393 testing::Eq(fling_global_point)), 1523 testing::Eq(fling_global_point)),
1394 testing::Field(&WebActiveWheelFlingParameters::modifiers, 1524 testing::Field(&WebActiveWheelFlingParameters::modifiers,
1395 testing::Eq(modifiers)), 1525 testing::Eq(modifiers)),
1396 testing::Field(&WebActiveWheelFlingParameters::startTime, 1526 testing::Field(&WebActiveWheelFlingParameters::startTime,
1397 testing::Eq(10)), 1527 testing::Eq(10)),
1398 testing::Field(&WebActiveWheelFlingParameters::cumulativeScroll, 1528 testing::Field(&WebActiveWheelFlingParameters::cumulativeScroll,
1399 testing::Field(&WebSize::width, testing::Gt(0)))))); 1529 testing::Field(&WebSize::width, testing::Gt(0))))));
1530 if (touchpad_and_wheel_scroll_latching_enabled_)
1531 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
1532
1400 time += base::TimeDelta::FromMilliseconds(100); 1533 time += base::TimeDelta::FromMilliseconds(100);
1401 Animate(time); 1534 Animate(time);
1402 1535
1403 VERIFY_AND_RESET_MOCKS(); 1536 VERIFY_AND_RESET_MOCKS();
1404 1537
1405 // Since we've aborted the fling, the next animation should be a no-op and 1538 // Since we've aborted the fling, the next animation should be a no-op and
1406 // should not result in another 1539 // should not result in another
1407 // frame being requested. 1540 // frame being requested.
1408 EXPECT_SET_NEEDS_ANIMATE_INPUT(0); 1541 EXPECT_SET_NEEDS_ANIMATE_INPUT(0);
1409 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1542 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1410 .Times(0); 1543 .Times(0);
1411 time += base::TimeDelta::FromMilliseconds(100); 1544 time += base::TimeDelta::FromMilliseconds(100);
1412 Animate(time); 1545 Animate(time);
1413 1546
1414 VERIFY_AND_RESET_MOCKS(); 1547 VERIFY_AND_RESET_MOCKS();
1415 1548
1416 // Since we've transferred the fling to the main thread, we need to pass the 1549 // Since we've transferred the fling to the main thread, we need to pass the
1417 // next GestureFlingCancel to the main 1550 // next GestureFlingCancel to the main
1418 // thread as well. 1551 // thread as well.
1419 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; 1552 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
1420 gesture_.setType(WebInputEvent::GestureFlingCancel); 1553 gesture_.setType(WebInputEvent::GestureFlingCancel);
1421 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1554 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1422 1555
1423 VERIFY_AND_RESET_MOCKS(); 1556 VERIFY_AND_RESET_MOCKS();
1424 input_handler_->MainThreadHasStoppedFlinging(); 1557 input_handler_->MainThreadHasStoppedFlinging();
1425 1558
1559 EXPECT_CALL(mock_input_handler_, ScrollBegin(::testing::_, ::testing::_))
1560 .WillOnce(testing::Return(kImplThreadScrollState));
1561
1562 // HandleGestureScrollBegin will set gesture_scroll_on_impl_thread_.
1563 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1564 gesture_.setType(WebInputEvent::GestureScrollBegin);
1565 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1566 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1567
1568 VERIFY_AND_RESET_MOCKS();
1569
1426 // Start a second gesture fling, this time in the +Y direction with no X. 1570 // Start a second gesture fling, this time in the +Y direction with no X.
1427 fling_delta = WebFloatPoint(0, -1000); 1571 fling_delta = WebFloatPoint(0, -1000);
1428 fling_point = WebPoint(95, 87); 1572 fling_point = WebPoint(95, 87);
1429 fling_global_point = WebPoint(32, 71); 1573 fling_global_point = WebPoint(32, 71);
1430 modifiers = WebInputEvent::AltKey; 1574 modifiers = WebInputEvent::AltKey;
1431 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, 1575 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad,
1432 fling_delta, 1576 fling_delta,
1433 fling_point, 1577 fling_point,
1434 fling_global_point, 1578 fling_global_point,
1435 modifiers); 1579 modifiers);
1436 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 1580 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1437 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1581 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1438 .WillOnce(testing::Return(kImplThreadScrollState)); 1582 .WillOnce(testing::Return(kImplThreadScrollState));
1439 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 1583 if (!touchpad_and_wheel_scroll_latching_enabled_)
1584 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
1440 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1585 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1441 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1586 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1442 1587
1443 VERIFY_AND_RESET_MOCKS(); 1588 VERIFY_AND_RESET_MOCKS();
1444 1589
1445 // Start the second fling animation at time 30. 1590 // Start the second fling animation at time 30.
1446 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 1591 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1447 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1592 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1448 .Times(0); 1593 .Times(0);
1449 time = base::TimeTicks() + base::TimeDelta::FromSeconds(30); 1594 time = base::TimeTicks() + base::TimeDelta::FromSeconds(30);
1450 Animate(time); 1595 Animate(time);
1451 1596
1452 VERIFY_AND_RESET_MOCKS(); 1597 VERIFY_AND_RESET_MOCKS();
1453 1598
1454 // Tick the second fling once normally. 1599 // Tick the second fling once normally.
1455 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 1600 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1456 EXPECT_CALL(mock_input_handler_, 1601 EXPECT_CALL(mock_input_handler_,
1457 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) 1602 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
1458 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); 1603 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
1459 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1604 if (!touchpad_and_wheel_scroll_latching_enabled_) {
1460 .WillOnce(testing::Return(kImplThreadScrollState)); 1605 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1606 .WillOnce(testing::Return(kImplThreadScrollState));
1607 }
1461 EXPECT_CALL( 1608 EXPECT_CALL(
1462 mock_input_handler_, 1609 mock_input_handler_,
1463 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)))) 1610 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0))))
1464 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1611 .WillOnce(testing::Return(scroll_result_did_scroll_));
1465 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 1612 if (!touchpad_and_wheel_scroll_latching_enabled_)
1613 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
1466 time += base::TimeDelta::FromMilliseconds(100); 1614 time += base::TimeDelta::FromMilliseconds(100);
1467 Animate(time); 1615 Animate(time);
1468 1616
1469 VERIFY_AND_RESET_MOCKS(); 1617 VERIFY_AND_RESET_MOCKS();
1470 1618
1471 // Then abort the second fling. 1619 // Then abort the second fling.
1472 EXPECT_CALL(mock_input_handler_, 1620 EXPECT_CALL(mock_input_handler_,
1473 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) 1621 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
1474 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); 1622 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
1475 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1623 if (!touchpad_and_wheel_scroll_latching_enabled_) {
1476 .WillOnce(testing::Return(kMainThreadScrollState)); 1624 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1477 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); 1625 .WillOnce(testing::Return(kMainThreadScrollState));
1478 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0); 1626 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0);
1627 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0);
1628 } else {
1629 EXPECT_CALL(
1630 mock_input_handler_,
1631 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0))))
1632 .WillOnce(testing::Return(scroll_result_did_not_scroll_));
1633 EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
1634 .WillOnce(testing::Return(true));
1635 }
1479 1636
1480 // We should get parameters from the second fling, nothing from the first 1637 // We should get parameters from the second fling, nothing from the first
1481 // fling should "leak". 1638 // fling should "leak".
1482 EXPECT_CALL( 1639 EXPECT_CALL(
1483 mock_client_, 1640 mock_client_,
1484 TransferActiveWheelFlingAnimation(testing::AllOf( 1641 TransferActiveWheelFlingAnimation(testing::AllOf(
1485 testing::Field(&WebActiveWheelFlingParameters::delta, 1642 testing::Field(&WebActiveWheelFlingParameters::delta,
1486 testing::Eq(fling_delta)), 1643 testing::Eq(fling_delta)),
1487 testing::Field(&WebActiveWheelFlingParameters::point, 1644 testing::Field(&WebActiveWheelFlingParameters::point,
1488 testing::Eq(fling_point)), 1645 testing::Eq(fling_point)),
1489 testing::Field(&WebActiveWheelFlingParameters::globalPoint, 1646 testing::Field(&WebActiveWheelFlingParameters::globalPoint,
1490 testing::Eq(fling_global_point)), 1647 testing::Eq(fling_global_point)),
1491 testing::Field(&WebActiveWheelFlingParameters::modifiers, 1648 testing::Field(&WebActiveWheelFlingParameters::modifiers,
1492 testing::Eq(modifiers)), 1649 testing::Eq(modifiers)),
1493 testing::Field(&WebActiveWheelFlingParameters::startTime, 1650 testing::Field(&WebActiveWheelFlingParameters::startTime,
1494 testing::Eq(30)), 1651 testing::Eq(30)),
1495 testing::Field(&WebActiveWheelFlingParameters::cumulativeScroll, 1652 testing::Field(&WebActiveWheelFlingParameters::cumulativeScroll,
1496 testing::Field(&WebSize::height, testing::Lt(0)))))); 1653 testing::Field(&WebSize::height, testing::Lt(0))))));
1654
1655 if (touchpad_and_wheel_scroll_latching_enabled_)
1656 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
1657
1497 time += base::TimeDelta::FromMilliseconds(100); 1658 time += base::TimeDelta::FromMilliseconds(100);
1498 Animate(time); 1659 Animate(time);
1499 1660
1500 VERIFY_AND_RESET_MOCKS(); 1661 VERIFY_AND_RESET_MOCKS();
1501 } 1662 }
1663 TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) {
1664 GestureFlingTransferResetsTouchpad();
1665 }
1666 TEST_P(InputHandlerProxyWithoutWheelScrollLatchingTest,
1667 GestureFlingTransferResetsTouchpad) {
1668 GestureFlingTransferResetsTouchpad();
1669 }
1502 1670
1503 TEST_P(InputHandlerProxyTest, GestureFlingStartedTouchscreen) { 1671 TEST_P(InputHandlerProxyTest, GestureFlingStartedTouchscreen) {
1504 // We shouldn't send any events to the widget for this gesture. 1672 // We shouldn't send any events to the widget for this gesture.
1505 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1673 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1506 VERIFY_AND_RESET_MOCKS(); 1674 VERIFY_AND_RESET_MOCKS();
1507 1675
1508 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1676 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1509 .WillOnce(testing::Return(kImplThreadScrollState)); 1677 .WillOnce(testing::Return(kImplThreadScrollState));
1510 gesture_.setType(WebInputEvent::GestureScrollBegin); 1678 gesture_.setType(WebInputEvent::GestureScrollBegin);
1511 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; 1679 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1899 2067
1900 gesture_.setType(WebInputEvent::GestureScrollBegin); 2068 gesture_.setType(WebInputEvent::GestureScrollBegin);
1901 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 2069 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1902 2070
1903 // After sending a GestureScrollBegin, the member variable 2071 // After sending a GestureScrollBegin, the member variable
1904 // |gesture_scroll_on_impl_thread_| should be true. 2072 // |gesture_scroll_on_impl_thread_| should be true.
1905 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 2073 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1906 VERIFY_AND_RESET_MOCKS(); 2074 VERIFY_AND_RESET_MOCKS();
1907 } 2075 }
1908 2076
1909 TEST_P(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) { 2077 void InputHandlerProxyTest::GestureFlingStopsAtContentEdge() {
1910 // We shouldn't send any events to the widget for this gesture. 2078 // We shouldn't send any events to the widget for this gesture.
1911 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 2079 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1912 VERIFY_AND_RESET_MOCKS(); 2080 VERIFY_AND_RESET_MOCKS();
1913 2081
2082 EXPECT_CALL(mock_input_handler_, ScrollBegin(::testing::_, ::testing::_))
2083 .WillOnce(testing::Return(kImplThreadScrollState));
2084
2085 // HandleGestureScrollBegin will set gesture_scroll_on_impl_thread_.
2086 gesture_.setType(WebInputEvent::GestureScrollBegin);
2087 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
2088 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
2089
2090 VERIFY_AND_RESET_MOCKS();
2091
1914 // On the fling start, we should schedule an animation but not actually start 2092 // On the fling start, we should schedule an animation but not actually start
1915 // scrolling. 2093 // scrolling.
1916 gesture_.setType(WebInputEvent::GestureFlingStart); 2094 gesture_.setType(WebInputEvent::GestureFlingStart);
1917 WebFloatPoint fling_delta = WebFloatPoint(100, 100); 2095 WebFloatPoint fling_delta = WebFloatPoint(100, 100);
1918 gesture_.data.flingStart.velocityX = fling_delta.x; 2096 gesture_.data.flingStart.velocityX = fling_delta.x;
1919 gesture_.data.flingStart.velocityY = fling_delta.y; 2097 gesture_.data.flingStart.velocityY = fling_delta.y;
1920 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 2098 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1921 .WillOnce(testing::Return(kImplThreadScrollState)); 2099 .WillOnce(testing::Return(kImplThreadScrollState));
1922 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 2100 if (!touchpad_and_wheel_scroll_latching_enabled_)
2101 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
1923 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 2102 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1924 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 2103 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1925 VERIFY_AND_RESET_MOCKS(); 2104 VERIFY_AND_RESET_MOCKS();
1926 2105
1927 // The first animate doesn't cause any scrolling. 2106 // The first animate doesn't cause any scrolling.
1928 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 2107 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1929 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); 2108 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
1930 Animate(time); 2109 Animate(time);
1931 VERIFY_AND_RESET_MOCKS(); 2110 VERIFY_AND_RESET_MOCKS();
1932 2111
1933 // The second animate starts scrolling in the positive X and Y directions. 2112 // The second animate starts scrolling in the positive X and Y directions.
1934 EXPECT_CALL(mock_input_handler_, 2113 EXPECT_CALL(mock_input_handler_,
1935 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) 2114 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
1936 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); 2115 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
1937 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 2116 if (!touchpad_and_wheel_scroll_latching_enabled_) {
1938 .WillOnce(testing::Return(kImplThreadScrollState)); 2117 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
2118 .WillOnce(testing::Return(kImplThreadScrollState));
2119 }
1939 EXPECT_CALL( 2120 EXPECT_CALL(
1940 mock_input_handler_, 2121 mock_input_handler_,
1941 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) 2122 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0))))
1942 .WillOnce(testing::Return(scroll_result_did_scroll_)); 2123 .WillOnce(testing::Return(scroll_result_did_scroll_));
1943 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 2124 if (!touchpad_and_wheel_scroll_latching_enabled_)
2125 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
1944 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 2126 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1945 time += base::TimeDelta::FromMilliseconds(100); 2127 time += base::TimeDelta::FromMilliseconds(100);
1946 Animate(time); 2128 Animate(time);
1947 VERIFY_AND_RESET_MOCKS(); 2129 VERIFY_AND_RESET_MOCKS();
1948 2130
1949 // The third animate overscrolls in the positive Y direction but scrolls 2131 // The third animate overscrolls in the positive Y direction but scrolls
1950 // somewhat. 2132 // somewhat.
1951 cc::InputHandlerScrollResult overscroll; 2133 cc::InputHandlerScrollResult overscroll;
1952 overscroll.did_scroll = true; 2134 overscroll.did_scroll = true;
1953 overscroll.did_overscroll_root = true; 2135 overscroll.did_overscroll_root = true;
1954 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100); 2136 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100);
1955 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 10); 2137 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 10);
1956 EXPECT_CALL(mock_input_handler_, 2138 EXPECT_CALL(mock_input_handler_,
1957 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) 2139 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
1958 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); 2140 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
1959 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 2141 if (!touchpad_and_wheel_scroll_latching_enabled_) {
1960 .WillOnce(testing::Return(kImplThreadScrollState)); 2142 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
2143 .WillOnce(testing::Return(kImplThreadScrollState));
2144 }
1961 EXPECT_CALL( 2145 EXPECT_CALL(
1962 mock_input_handler_, 2146 mock_input_handler_,
1963 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) 2147 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0))))
1964 .WillOnce(testing::Return(overscroll)); 2148 .WillOnce(testing::Return(overscroll));
1965 EXPECT_CALL( 2149 EXPECT_CALL(
1966 mock_client_, 2150 mock_client_,
1967 DidOverscroll( 2151 DidOverscroll(
1968 overscroll.accumulated_root_overscroll, 2152 overscroll.accumulated_root_overscroll,
1969 overscroll.unused_scroll_delta, 2153 overscroll.unused_scroll_delta,
1970 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)), 2154 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)),
1971 testing::_)); 2155 testing::_));
1972 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 2156 if (!touchpad_and_wheel_scroll_latching_enabled_)
2157 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
1973 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 2158 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1974 time += base::TimeDelta::FromMilliseconds(100); 2159 time += base::TimeDelta::FromMilliseconds(100);
1975 Animate(time); 2160 Animate(time);
1976 VERIFY_AND_RESET_MOCKS(); 2161 VERIFY_AND_RESET_MOCKS();
1977 2162
1978 // The next call to animate will no longer scroll vertically. 2163 // The next call to animate will no longer scroll vertically.
1979 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 2164 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1980 EXPECT_CALL(mock_input_handler_, 2165 EXPECT_CALL(mock_input_handler_,
1981 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) 2166 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
1982 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); 2167 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
1983 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 2168 if (!touchpad_and_wheel_scroll_latching_enabled_) {
1984 .WillOnce(testing::Return(kImplThreadScrollState)); 2169 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
2170 .WillOnce(testing::Return(kImplThreadScrollState));
2171 }
1985 EXPECT_CALL( 2172 EXPECT_CALL(
1986 mock_input_handler_, 2173 mock_input_handler_,
1987 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Eq(0)))) 2174 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Eq(0))))
1988 .WillOnce(testing::Return(scroll_result_did_scroll_)); 2175 .WillOnce(testing::Return(scroll_result_did_scroll_));
1989 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 2176 if (!touchpad_and_wheel_scroll_latching_enabled_)
2177 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
1990 time += base::TimeDelta::FromMilliseconds(100); 2178 time += base::TimeDelta::FromMilliseconds(100);
1991 Animate(time); 2179 Animate(time);
1992 VERIFY_AND_RESET_MOCKS(); 2180 VERIFY_AND_RESET_MOCKS();
1993 } 2181 }
2182 TEST_P(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) {
2183 GestureFlingStopsAtContentEdge();
2184 }
2185 TEST_P(InputHandlerProxyWithoutWheelScrollLatchingTest,
2186 GestureFlingStopsAtContentEdge) {
2187 GestureFlingStopsAtContentEdge();
2188 }
1994 2189
1995 TEST_P(InputHandlerProxyTest, GestureFlingNotCancelledBySmallTimeDelta) { 2190 TEST_P(InputHandlerProxyTest, GestureFlingNotCancelledBySmallTimeDelta) {
1996 // We shouldn't send any events to the widget for this gesture. 2191 // We shouldn't send any events to the widget for this gesture.
1997 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 2192 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1998 VERIFY_AND_RESET_MOCKS(); 2193 VERIFY_AND_RESET_MOCKS();
1999 2194
2000 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 2195 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
2001 .WillOnce(testing::Return(kImplThreadScrollState)); 2196 .WillOnce(testing::Return(kImplThreadScrollState));
2002 2197
2003 gesture_.setType(WebInputEvent::GestureScrollBegin); 2198 gesture_.setType(WebInputEvent::GestureScrollBegin);
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
2923 3118
2924 // GestureScrollEnd should terminate the resumed scroll properly. 3119 // GestureScrollEnd should terminate the resumed scroll properly.
2925 time += dt; 3120 time += dt;
2926 gesture_.setTimeStampSeconds(InSecondsF(time)); 3121 gesture_.setTimeStampSeconds(InSecondsF(time));
2927 gesture_.setType(WebInputEvent::GestureScrollEnd); 3122 gesture_.setType(WebInputEvent::GestureScrollEnd);
2928 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 3123 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
2929 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 3124 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
2930 3125
2931 VERIFY_AND_RESET_MOCKS(); 3126 VERIFY_AND_RESET_MOCKS();
2932 } 3127 }
2933 3128 void InputHandlerProxyTest::DidReceiveInputEvent_ForFling() {
2934 TEST_P(InputHandlerProxyTest, DidReceiveInputEvent_ForFling) {
2935 testing::StrictMock<MockInputHandlerProxyClientWithDidAnimateForInput> 3129 testing::StrictMock<MockInputHandlerProxyClientWithDidAnimateForInput>
2936 mock_client; 3130 mock_client;
2937 input_handler_.reset( 3131 input_handler_.reset(
2938 new TestInputHandlerProxy(&mock_input_handler_, &mock_client, false)); 3132 new TestInputHandlerProxy(&mock_input_handler_, &mock_client,
3133 touchpad_and_wheel_scroll_latching_enabled_));
2939 if (install_synchronous_handler_) { 3134 if (install_synchronous_handler_) {
2940 EXPECT_CALL(mock_input_handler_, RequestUpdateForSynchronousInputHandler()) 3135 EXPECT_CALL(mock_input_handler_, RequestUpdateForSynchronousInputHandler())
2941 .Times(1); 3136 .Times(1);
2942 input_handler_->SetOnlySynchronouslyAnimateRootFlings( 3137 input_handler_->SetOnlySynchronouslyAnimateRootFlings(
2943 &mock_synchronous_input_handler_); 3138 &mock_synchronous_input_handler_);
2944 } 3139 }
2945 mock_input_handler_.set_is_scrolling_root(synchronous_root_scroll_); 3140 mock_input_handler_.set_is_scrolling_root(synchronous_root_scroll_);
2946 3141
2947 gesture_.setType(WebInputEvent::GestureFlingStart); 3142 gesture_.setType(WebInputEvent::GestureFlingStart);
2948 WebFloatPoint fling_delta = WebFloatPoint(100, 100); 3143 WebFloatPoint fling_delta = WebFloatPoint(100, 100);
2949 gesture_.data.flingStart.velocityX = fling_delta.x; 3144 gesture_.data.flingStart.velocityX = fling_delta.x;
2950 gesture_.data.flingStart.velocityY = fling_delta.y; 3145 gesture_.data.flingStart.velocityY = fling_delta.y;
2951 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 3146 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
2952 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 3147 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
2953 .WillOnce(testing::Return(kImplThreadScrollState)); 3148 .WillOnce(testing::Return(kImplThreadScrollState));
2954 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 3149 if (!touchpad_and_wheel_scroll_latching_enabled_)
3150 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
2955 EXPECT_EQ(InputHandlerProxy::DID_HANDLE, 3151 EXPECT_EQ(InputHandlerProxy::DID_HANDLE,
2956 input_handler_->HandleInputEvent(gesture_)); 3152 input_handler_->HandleInputEvent(gesture_));
2957 VERIFY_AND_RESET_MOCKS(); 3153 VERIFY_AND_RESET_MOCKS();
2958 3154
2959 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 3155 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
2960 EXPECT_CALL(mock_client, DidAnimateForInput()); 3156 EXPECT_CALL(mock_client, DidAnimateForInput());
2961 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); 3157 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
2962 Animate(time); 3158 Animate(time);
2963 3159
2964 VERIFY_AND_RESET_MOCKS(); 3160 VERIFY_AND_RESET_MOCKS();
2965 } 3161 }
3162 TEST_P(InputHandlerProxyTest, DidReceiveInputEvent_ForFling) {
3163 DidReceiveInputEvent_ForFling();
3164 }
3165 TEST_P(InputHandlerProxyWithoutWheelScrollLatchingTest,
3166 DidReceiveInputEvent_ForFling) {
3167 DidReceiveInputEvent_ForFling();
3168 }
2966 3169
2967 TEST(SynchronousInputHandlerProxyTest, StartupShutdown) { 3170 TEST(SynchronousInputHandlerProxyTest, StartupShutdown) {
2968 testing::StrictMock<MockInputHandler> mock_input_handler; 3171 testing::StrictMock<MockInputHandler> mock_input_handler;
2969 testing::StrictMock<MockInputHandlerProxyClient> mock_client; 3172 testing::StrictMock<MockInputHandlerProxyClient> mock_client;
2970 testing::StrictMock<MockSynchronousInputHandler> 3173 testing::StrictMock<MockSynchronousInputHandler>
2971 mock_synchronous_input_handler; 3174 mock_synchronous_input_handler;
2972 ui::InputHandlerProxy proxy(&mock_input_handler, &mock_client, false); 3175 ui::InputHandlerProxy proxy(&mock_input_handler, &mock_client, false);
2973 3176
2974 // When adding a SynchronousInputHandler, immediately request an 3177 // When adding a SynchronousInputHandler, immediately request an
2975 // UpdateRootLayerStateForSynchronousInputHandler() call. 3178 // UpdateRootLayerStateForSynchronousInputHandler() call.
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
3234 base::Bucket(2, 1))); 3437 base::Bucket(2, 1)));
3235 3438
3236 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 3439 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
3237 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; 3440 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
3238 EXPECT_EQ(expected_disposition_, 3441 EXPECT_EQ(expected_disposition_,
3239 input_handler_->HandleInputEvent(gesture_scroll_end)); 3442 input_handler_->HandleInputEvent(gesture_scroll_end));
3240 3443
3241 VERIFY_AND_RESET_MOCKS(); 3444 VERIFY_AND_RESET_MOCKS();
3242 } 3445 }
3243 3446
3244 TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedGestureScroll) { 3447 TEST_P(InputHandlerProxyEventQueueTest, VSyncAlignedGestureScroll) {
3245 base::HistogramTester histogram_tester; 3448 base::HistogramTester histogram_tester;
3246 3449
3247 // Handle scroll on compositor. 3450 // Handle scroll on compositor.
3248 cc::InputHandlerScrollResult scroll_result_did_scroll_; 3451 cc::InputHandlerScrollResult scroll_result_did_scroll_;
3249 scroll_result_did_scroll_.did_scroll = true; 3452 scroll_result_did_scroll_.did_scroll = true;
3250 3453
3251 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 3454 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
3252 .WillOnce(testing::Return(kImplThreadScrollState)); 3455 .WillOnce(testing::Return(kImplThreadScrollState));
3253 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(1); 3456 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(1);
3254 3457
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3297 EXPECT_EQ(0ul, event_queue().size()); 3500 EXPECT_EQ(0ul, event_queue().size());
3298 // Should run callbacks for every original events. 3501 // Should run callbacks for every original events.
3299 EXPECT_EQ(4ul, event_disposition_recorder_.size()); 3502 EXPECT_EQ(4ul, event_disposition_recorder_.size());
3300 EXPECT_EQ(InputHandlerProxy::DID_HANDLE, event_disposition_recorder_[1]); 3503 EXPECT_EQ(InputHandlerProxy::DID_HANDLE, event_disposition_recorder_[1]);
3301 EXPECT_EQ(InputHandlerProxy::DID_HANDLE, event_disposition_recorder_[2]); 3504 EXPECT_EQ(InputHandlerProxy::DID_HANDLE, event_disposition_recorder_[2]);
3302 EXPECT_EQ(InputHandlerProxy::DID_HANDLE, event_disposition_recorder_[3]); 3505 EXPECT_EQ(InputHandlerProxy::DID_HANDLE, event_disposition_recorder_[3]);
3303 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 3506 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
3304 histogram_tester.ExpectUniqueSample(kCoalescedCountHistogram, 2, 1); 3507 histogram_tester.ExpectUniqueSample(kCoalescedCountHistogram, 2, 1);
3305 } 3508 }
3306 3509
3307 TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedGestureScrollPinchScroll) { 3510 TEST_P(InputHandlerProxyEventQueueTest, VSyncAlignedGestureScrollPinchScroll) {
3308 base::HistogramTester histogram_tester; 3511 base::HistogramTester histogram_tester;
3309 3512
3310 // Handle scroll on compositor. 3513 // Handle scroll on compositor.
3311 cc::InputHandlerScrollResult scroll_result_did_scroll_; 3514 cc::InputHandlerScrollResult scroll_result_did_scroll_;
3312 scroll_result_did_scroll_.did_scroll = true; 3515 scroll_result_did_scroll_.did_scroll = true;
3313 3516
3314 // Start scroll in the first frame. 3517 // Start scroll in the first frame.
3315 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 3518 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
3316 .WillOnce(testing::Return(kImplThreadScrollState)); 3519 .WillOnce(testing::Return(kImplThreadScrollState));
3317 EXPECT_CALL( 3520 EXPECT_CALL(
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
3366 3569
3367 input_handler_proxy_->DeliverInputForBeginFrame(); 3570 input_handler_proxy_->DeliverInputForBeginFrame();
3368 3571
3369 EXPECT_EQ(0ul, event_queue().size()); 3572 EXPECT_EQ(0ul, event_queue().size());
3370 EXPECT_EQ(12ul, event_disposition_recorder_.size()); 3573 EXPECT_EQ(12ul, event_disposition_recorder_.size());
3371 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 3574 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
3372 histogram_tester.ExpectBucketCount(kCoalescedCountHistogram, 1, 2); 3575 histogram_tester.ExpectBucketCount(kCoalescedCountHistogram, 1, 2);
3373 histogram_tester.ExpectBucketCount(kCoalescedCountHistogram, 2, 2); 3576 histogram_tester.ExpectBucketCount(kCoalescedCountHistogram, 2, 2);
3374 } 3577 }
3375 3578
3376 TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedQueueingTime) { 3579 TEST_P(InputHandlerProxyEventQueueTest, VSyncAlignedQueueingTime) {
3377 base::HistogramTester histogram_tester; 3580 base::HistogramTester histogram_tester;
3378 std::unique_ptr<base::SimpleTestTickClock> tick_clock = 3581 std::unique_ptr<base::SimpleTestTickClock> tick_clock =
3379 base::MakeUnique<base::SimpleTestTickClock>(); 3582 base::MakeUnique<base::SimpleTestTickClock>();
3380 base::SimpleTestTickClock* tick_clock_ptr = tick_clock.get(); 3583 base::SimpleTestTickClock* tick_clock_ptr = tick_clock.get();
3381 tick_clock_ptr->SetNowTicks(base::TimeTicks::Now()); 3584 tick_clock_ptr->SetNowTicks(base::TimeTicks::Now());
3382 SetInputHandlerProxyTickClockForTesting(std::move(tick_clock)); 3585 SetInputHandlerProxyTickClockForTesting(std::move(tick_clock));
3383 3586
3384 // Handle scroll on compositor. 3587 // Handle scroll on compositor.
3385 cc::InputHandlerScrollResult scroll_result_did_scroll_; 3588 cc::InputHandlerScrollResult scroll_result_did_scroll_;
3386 scroll_result_did_scroll_.did_scroll = true; 3589 scroll_result_did_scroll_.did_scroll = true;
(...skipping 25 matching lines...) Expand all
3412 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 3615 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
3413 histogram_tester.ExpectUniqueSample(kContinuousHeadQueueingTimeHistogram, 140, 3616 histogram_tester.ExpectUniqueSample(kContinuousHeadQueueingTimeHistogram, 140,
3414 1); 3617 1);
3415 histogram_tester.ExpectUniqueSample(kContinuousTailQueueingTimeHistogram, 80, 3618 histogram_tester.ExpectUniqueSample(kContinuousTailQueueingTimeHistogram, 80,
3416 1); 3619 1);
3417 histogram_tester.ExpectBucketCount(kNonContinuousQueueingTimeHistogram, 0, 1); 3620 histogram_tester.ExpectBucketCount(kNonContinuousQueueingTimeHistogram, 0, 1);
3418 histogram_tester.ExpectBucketCount(kNonContinuousQueueingTimeHistogram, 70, 3621 histogram_tester.ExpectBucketCount(kNonContinuousQueueingTimeHistogram, 70,
3419 1); 3622 1);
3420 } 3623 }
3421 3624
3422 TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedCoalesceScrollAndPinch) { 3625 TEST_P(InputHandlerProxyEventQueueTest, VSyncAlignedCoalesceScrollAndPinch) {
3423 // Start scroll in the first frame. 3626 // Start scroll in the first frame.
3424 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 3627 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
3425 .WillOnce(testing::Return(kImplThreadScrollState)); 3628 .WillOnce(testing::Return(kImplThreadScrollState));
3426 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(1); 3629 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(1);
3427 3630
3428 // GSUs and GPUs in one sequence should be coalesced into 1 GSU and 1 GPU. 3631 // GSUs and GPUs in one sequence should be coalesced into 1 GSU and 1 GPU.
3429 HandleGestureEvent(WebInputEvent::GestureScrollBegin); 3632 HandleGestureEvent(WebInputEvent::GestureScrollBegin);
3430 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -20); 3633 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -20);
3431 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -7); 3634 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -7);
3432 HandleGestureEvent(WebInputEvent::GesturePinchUpdate, 2.0f, 13, 10); 3635 HandleGestureEvent(WebInputEvent::GesturePinchUpdate, 2.0f, 13, 10);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
3464 ToWebGestureEvent(event_queue()[4]->event()).data.scrollUpdate.deltaY); 3667 ToWebGestureEvent(event_queue()[4]->event()).data.scrollUpdate.deltaY);
3465 EXPECT_EQ(WebInputEvent::GesturePinchUpdate, 3668 EXPECT_EQ(WebInputEvent::GesturePinchUpdate,
3466 event_queue()[5]->event().type()); 3669 event_queue()[5]->event().type());
3467 EXPECT_EQ( 3670 EXPECT_EQ(
3468 0.5f, 3671 0.5f,
3469 ToWebGestureEvent(event_queue()[5]->event()).data.pinchUpdate.scale); 3672 ToWebGestureEvent(event_queue()[5]->event()).data.pinchUpdate.scale);
3470 EXPECT_EQ(WebInputEvent::GesturePinchEnd, event_queue()[6]->event().type()); 3673 EXPECT_EQ(WebInputEvent::GesturePinchEnd, event_queue()[6]->event().type());
3471 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 3674 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
3472 } 3675 }
3473 3676
3474 TEST_F(InputHandlerProxyEventQueueTest, OriginalEventsTracing) { 3677 TEST_P(InputHandlerProxyEventQueueTest, OriginalEventsTracing) {
3475 // Handle scroll on compositor. 3678 // Handle scroll on compositor.
3476 cc::InputHandlerScrollResult scroll_result_did_scroll_; 3679 cc::InputHandlerScrollResult scroll_result_did_scroll_;
3477 scroll_result_did_scroll_.did_scroll = true; 3680 scroll_result_did_scroll_.did_scroll = true;
3478 3681
3479 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 3682 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
3480 .WillRepeatedly(testing::Return(kImplThreadScrollState)); 3683 .WillRepeatedly(testing::Return(kImplThreadScrollState));
3481 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()) 3684 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput())
3482 .Times(::testing::AtLeast(1)); 3685 .Times(::testing::AtLeast(1));
3483 EXPECT_CALL( 3686 EXPECT_CALL(
3484 mock_input_handler_, 3687 mock_input_handler_,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
3535 // The ScrollUpdate of the pair doesn't carry original events and won't be 3738 // The ScrollUpdate of the pair doesn't carry original events and won't be
3536 // traced. 3739 // traced.
3537 EXPECT_EQ(WebInputEvent::GesturePinchUpdate, 3740 EXPECT_EQ(WebInputEvent::GesturePinchUpdate,
3538 end_events[3]->GetKnownArgAsInt("type")); 3741 end_events[3]->GetKnownArgAsInt("type"));
3539 EXPECT_EQ(4, end_events[3]->GetKnownArgAsInt("coalesced_count")); 3742 EXPECT_EQ(4, end_events[3]->GetKnownArgAsInt("coalesced_count"));
3540 EXPECT_EQ(WebInputEvent::GestureScrollEnd, 3743 EXPECT_EQ(WebInputEvent::GestureScrollEnd,
3541 end_events[4]->GetKnownArgAsInt("type")); 3744 end_events[4]->GetKnownArgAsInt("type"));
3542 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 3745 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
3543 } 3746 }
3544 3747
3545 TEST_F(InputHandlerProxyEventQueueTest, GestureScrollFlingOrder) { 3748 TEST_P(InputHandlerProxyEventQueueTest, GestureScrollFlingOrder) {
3546 // Handle scroll on compositor. 3749 // Handle scroll on compositor.
3547 cc::InputHandlerScrollResult scroll_result_did_scroll_; 3750 cc::InputHandlerScrollResult scroll_result_did_scroll_;
3548 scroll_result_did_scroll_.did_scroll = true; 3751 scroll_result_did_scroll_.did_scroll = true;
3549 3752
3550 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 3753 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
3551 .WillRepeatedly(testing::Return(kImplThreadScrollState)); 3754 .WillRepeatedly(testing::Return(kImplThreadScrollState));
3552 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()) 3755 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput())
3553 .Times(::testing::AtLeast(1)); 3756 .Times(::testing::AtLeast(1));
3554 EXPECT_CALL( 3757 EXPECT_CALL(
3555 mock_input_handler_, 3758 mock_input_handler_,
(...skipping 28 matching lines...) Expand all
3584 EXPECT_EQ(WebInputEvent::GestureFlingCancel, 3787 EXPECT_EQ(WebInputEvent::GestureFlingCancel,
3585 event_queue()[0]->event().type()); 3788 event_queue()[0]->event().type());
3586 input_handler_proxy_->DeliverInputForBeginFrame(); 3789 input_handler_proxy_->DeliverInputForBeginFrame();
3587 EXPECT_EQ(0ul, event_queue().size()); 3790 EXPECT_EQ(0ul, event_queue().size());
3588 EXPECT_EQ(5ul, event_disposition_recorder_.size()); 3791 EXPECT_EQ(5ul, event_disposition_recorder_.size());
3589 // Should stop scrolling. Note that no ScrollEnd was sent. 3792 // Should stop scrolling. Note that no ScrollEnd was sent.
3590 EXPECT_TRUE( 3793 EXPECT_TRUE(
3591 !input_handler_proxy_->gesture_scroll_on_impl_thread_for_testing()); 3794 !input_handler_proxy_->gesture_scroll_on_impl_thread_for_testing());
3592 } 3795 }
3593 3796
3594 TEST_F(InputHandlerProxyEventQueueTest, GestureScrollAfterFling) { 3797 TEST_P(InputHandlerProxyEventQueueTest, GestureScrollAfterFling) {
3595 // Handle scroll on compositor. 3798 // Handle scroll on compositor.
3596 cc::InputHandlerScrollResult scroll_result_did_scroll_; 3799 cc::InputHandlerScrollResult scroll_result_did_scroll_;
3597 scroll_result_did_scroll_.did_scroll = true; 3800 scroll_result_did_scroll_.did_scroll = true;
3598 3801
3599 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 3802 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
3600 .WillRepeatedly(testing::Return(kImplThreadScrollState)); 3803 .WillRepeatedly(testing::Return(kImplThreadScrollState));
3601 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()) 3804 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput())
3602 .Times(::testing::AtLeast(1)); 3805 .Times(::testing::AtLeast(1));
3603 EXPECT_CALL( 3806 EXPECT_CALL(
3604 mock_input_handler_, 3807 mock_input_handler_,
(...skipping 18 matching lines...) Expand all
3623 // New ScrollBegin should be dispatched immediately as there is no on-going 3826 // New ScrollBegin should be dispatched immediately as there is no on-going
3624 // scroll, fling or pinch. 3827 // scroll, fling or pinch.
3625 HandleGestureEvent(WebInputEvent::GestureScrollBegin); 3828 HandleGestureEvent(WebInputEvent::GestureScrollBegin);
3626 EXPECT_EQ(0ul, event_queue().size()); 3829 EXPECT_EQ(0ul, event_queue().size());
3627 } 3830 }
3628 3831
3629 INSTANTIATE_TEST_CASE_P(AnimateInput, 3832 INSTANTIATE_TEST_CASE_P(AnimateInput,
3630 InputHandlerProxyTest, 3833 InputHandlerProxyTest,
3631 testing::ValuesIn(test_types)); 3834 testing::ValuesIn(test_types));
3632 3835
3836 INSTANTIATE_TEST_CASE_P(AnimateInput,
3837 InputHandlerProxyWithoutWheelScrollLatchingTest,
3838 testing::ValuesIn(test_types));
3839
3840 INSTANTIATE_TEST_CASE_P(InputHandlerProxyEventQueueTests,
3841 InputHandlerProxyEventQueueTest,
3842 testing::Bool());
3843
3633 } // namespace test 3844 } // namespace test
3634 } // namespace ui 3845 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698