| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/input/input_handler_proxy.h" | 5 #include "content/renderer/input/input_handler_proxy.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "cc/base/swap_promise_monitor.h" | 9 #include "cc/base/swap_promise_monitor.h" |
| 10 #include "content/common/input/did_overscroll_params.h" | 10 #include "content/common/input/did_overscroll_params.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 class MockInputHandler : public cc::InputHandler { | 36 class MockInputHandler : public cc::InputHandler { |
| 37 public: | 37 public: |
| 38 MockInputHandler() {} | 38 MockInputHandler() {} |
| 39 virtual ~MockInputHandler() {} | 39 virtual ~MockInputHandler() {} |
| 40 | 40 |
| 41 MOCK_METHOD0(PinchGestureBegin, void()); | 41 MOCK_METHOD0(PinchGestureBegin, void()); |
| 42 MOCK_METHOD2(PinchGestureUpdate, | 42 MOCK_METHOD2(PinchGestureUpdate, |
| 43 void(float magnify_delta, const gfx::Point& anchor)); | 43 void(float magnify_delta, const gfx::Point& anchor)); |
| 44 MOCK_METHOD0(PinchGestureEnd, void()); | 44 MOCK_METHOD0(PinchGestureEnd, void()); |
| 45 | 45 |
| 46 MOCK_METHOD0(ScheduleAnimation, void()); | 46 MOCK_METHOD0(SetNeedsAnimate, void()); |
| 47 | 47 |
| 48 MOCK_METHOD2(ScrollBegin, | 48 MOCK_METHOD2(ScrollBegin, |
| 49 ScrollStatus(const gfx::Point& viewport_point, | 49 ScrollStatus(const gfx::Point& viewport_point, |
| 50 cc::InputHandler::ScrollInputType type)); | 50 cc::InputHandler::ScrollInputType type)); |
| 51 MOCK_METHOD2(ScrollBy, | 51 MOCK_METHOD2(ScrollBy, |
| 52 bool(const gfx::Point& viewport_point, | 52 bool(const gfx::Point& viewport_point, |
| 53 const gfx::Vector2dF& scroll_delta)); | 53 const gfx::Vector2dF& scroll_delta)); |
| 54 MOCK_METHOD2(ScrollVerticallyByPage, | 54 MOCK_METHOD2(ScrollVerticallyByPage, |
| 55 bool(const gfx::Point& viewport_point, | 55 bool(const gfx::Point& viewport_point, |
| 56 cc::ScrollDirection direction)); | 56 cc::ScrollDirection direction)); |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 } | 398 } |
| 399 | 399 |
| 400 TEST_F(InputHandlerProxyTest, GestureFlingStartedTouchpad) { | 400 TEST_F(InputHandlerProxyTest, GestureFlingStartedTouchpad) { |
| 401 // We shouldn't send any events to the widget for this gesture. | 401 // We shouldn't send any events to the widget for this gesture. |
| 402 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 402 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
| 403 VERIFY_AND_RESET_MOCKS(); | 403 VERIFY_AND_RESET_MOCKS(); |
| 404 | 404 |
| 405 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 405 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 406 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 406 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
| 407 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 407 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
| 408 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 408 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 409 | 409 |
| 410 gesture_.type = WebInputEvent::GestureFlingStart; | 410 gesture_.type = WebInputEvent::GestureFlingStart; |
| 411 gesture_.data.flingStart.velocityX = 10; | 411 gesture_.data.flingStart.velocityX = 10; |
| 412 gesture_.sourceDevice = WebGestureEvent::Touchpad; | 412 gesture_.sourceDevice = WebGestureEvent::Touchpad; |
| 413 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 413 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 414 | 414 |
| 415 VERIFY_AND_RESET_MOCKS(); | 415 VERIFY_AND_RESET_MOCKS(); |
| 416 | 416 |
| 417 // Verify that a GestureFlingCancel during an animation cancels it. | 417 // Verify that a GestureFlingCancel during an animation cancels it. |
| 418 gesture_.type = WebInputEvent::GestureFlingCancel; | 418 gesture_.type = WebInputEvent::GestureFlingCancel; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 // special (reserved for zoom), so don't set that here. | 481 // special (reserved for zoom), so don't set that here. |
| 482 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; | 482 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; |
| 483 gesture_.data.flingStart.velocityX = fling_delta.x; | 483 gesture_.data.flingStart.velocityX = fling_delta.x; |
| 484 gesture_.data.flingStart.velocityY = fling_delta.y; | 484 gesture_.data.flingStart.velocityY = fling_delta.y; |
| 485 gesture_.sourceDevice = WebGestureEvent::Touchpad; | 485 gesture_.sourceDevice = WebGestureEvent::Touchpad; |
| 486 gesture_.x = fling_point.x; | 486 gesture_.x = fling_point.x; |
| 487 gesture_.y = fling_point.y; | 487 gesture_.y = fling_point.y; |
| 488 gesture_.globalX = fling_global_point.x; | 488 gesture_.globalX = fling_global_point.x; |
| 489 gesture_.globalY = fling_global_point.y; | 489 gesture_.globalY = fling_global_point.y; |
| 490 gesture_.modifiers = modifiers; | 490 gesture_.modifiers = modifiers; |
| 491 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 491 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 492 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 492 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 493 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 493 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
| 494 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 494 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
| 495 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 495 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 496 | 496 |
| 497 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 497 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 498 // The first animate call should let us pick up an animation start time, but | 498 // The first animate call should let us pick up an animation start time, but |
| 499 // we shouldn't actually move anywhere just yet. The first frame after the | 499 // we shouldn't actually move anywhere just yet. The first frame after the |
| 500 // fling start will typically include the last scroll from the gesture that | 500 // fling start will typically include the last scroll from the gesture that |
| 501 // lead to the scroll (either wheel or gesture scroll), so there should be no | 501 // lead to the scroll (either wheel or gesture scroll), so there should be no |
| 502 // visible hitch. | 502 // visible hitch. |
| 503 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 503 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 504 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 504 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 505 .Times(0); | 505 .Times(0); |
| 506 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); | 506 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); |
| 507 input_handler_->Animate(time); | 507 input_handler_->Animate(time); |
| 508 | 508 |
| 509 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 509 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 510 | 510 |
| 511 // The second call should start scrolling in the -X direction. | 511 // The second call should start scrolling in the -X direction. |
| 512 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 512 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 513 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 513 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 514 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 514 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
| 515 EXPECT_CALL(mock_input_handler_, | 515 EXPECT_CALL(mock_input_handler_, |
| 516 ScrollBy(testing::_, | 516 ScrollBy(testing::_, |
| 517 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) | 517 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) |
| 518 .WillOnce(testing::Return(true)); | 518 .WillOnce(testing::Return(true)); |
| 519 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 519 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
| 520 time += base::TimeDelta::FromMilliseconds(100); | 520 time += base::TimeDelta::FromMilliseconds(100); |
| 521 input_handler_->Animate(time); | 521 input_handler_->Animate(time); |
| 522 | 522 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 testing::Field(&WebSize::width, testing::Gt(0)))))); | 555 testing::Field(&WebSize::width, testing::Gt(0)))))); |
| 556 time += base::TimeDelta::FromMilliseconds(100); | 556 time += base::TimeDelta::FromMilliseconds(100); |
| 557 input_handler_->Animate(time); | 557 input_handler_->Animate(time); |
| 558 | 558 |
| 559 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 559 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 560 testing::Mock::VerifyAndClearExpectations(&mock_client_); | 560 testing::Mock::VerifyAndClearExpectations(&mock_client_); |
| 561 | 561 |
| 562 // Since we've aborted the fling, the next animation should be a no-op and | 562 // Since we've aborted the fling, the next animation should be a no-op and |
| 563 // should not result in another | 563 // should not result in another |
| 564 // frame being requested. | 564 // frame being requested. |
| 565 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()).Times(0); | 565 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()).Times(0); |
| 566 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 566 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 567 .Times(0); | 567 .Times(0); |
| 568 time += base::TimeDelta::FromMilliseconds(100); | 568 time += base::TimeDelta::FromMilliseconds(100); |
| 569 input_handler_->Animate(time); | 569 input_handler_->Animate(time); |
| 570 | 570 |
| 571 // Since we've transferred the fling to the main thread, we need to pass the | 571 // Since we've transferred the fling to the main thread, we need to pass the |
| 572 // next GestureFlingCancel to the main | 572 // next GestureFlingCancel to the main |
| 573 // thread as well. | 573 // thread as well. |
| 574 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; | 574 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; |
| 575 gesture_.type = WebInputEvent::GestureFlingCancel; | 575 gesture_.type = WebInputEvent::GestureFlingCancel; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 590 // special (reserved for zoom), so don't set that here. | 590 // special (reserved for zoom), so don't set that here. |
| 591 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; | 591 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; |
| 592 gesture_.data.flingStart.velocityX = fling_delta.x; | 592 gesture_.data.flingStart.velocityX = fling_delta.x; |
| 593 gesture_.data.flingStart.velocityY = fling_delta.y; | 593 gesture_.data.flingStart.velocityY = fling_delta.y; |
| 594 gesture_.sourceDevice = WebGestureEvent::Touchpad; | 594 gesture_.sourceDevice = WebGestureEvent::Touchpad; |
| 595 gesture_.x = fling_point.x; | 595 gesture_.x = fling_point.x; |
| 596 gesture_.y = fling_point.y; | 596 gesture_.y = fling_point.y; |
| 597 gesture_.globalX = fling_global_point.x; | 597 gesture_.globalX = fling_global_point.x; |
| 598 gesture_.globalY = fling_global_point.y; | 598 gesture_.globalY = fling_global_point.y; |
| 599 gesture_.modifiers = modifiers; | 599 gesture_.modifiers = modifiers; |
| 600 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 600 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 601 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 601 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 602 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 602 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
| 603 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 603 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
| 604 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 604 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 605 | 605 |
| 606 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 606 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 607 | 607 |
| 608 // Start the fling animation at time 10. This shouldn't actually scroll, just | 608 // Start the fling animation at time 10. This shouldn't actually scroll, just |
| 609 // establish a start time. | 609 // establish a start time. |
| 610 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 610 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 611 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 611 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 612 .Times(0); | 612 .Times(0); |
| 613 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); | 613 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); |
| 614 input_handler_->Animate(time); | 614 input_handler_->Animate(time); |
| 615 | 615 |
| 616 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 616 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 617 | 617 |
| 618 // The second call should start scrolling in the -X direction. | 618 // The second call should start scrolling in the -X direction. |
| 619 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 619 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 620 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 620 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 621 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 621 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
| 622 EXPECT_CALL(mock_input_handler_, | 622 EXPECT_CALL(mock_input_handler_, |
| 623 ScrollBy(testing::_, | 623 ScrollBy(testing::_, |
| 624 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) | 624 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) |
| 625 .WillOnce(testing::Return(true)); | 625 .WillOnce(testing::Return(true)); |
| 626 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 626 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
| 627 time += base::TimeDelta::FromMilliseconds(100); | 627 time += base::TimeDelta::FromMilliseconds(100); |
| 628 input_handler_->Animate(time); | 628 input_handler_->Animate(time); |
| 629 | 629 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 testing::Field(&WebSize::width, testing::Gt(0)))))); | 663 testing::Field(&WebSize::width, testing::Gt(0)))))); |
| 664 time += base::TimeDelta::FromMilliseconds(100); | 664 time += base::TimeDelta::FromMilliseconds(100); |
| 665 input_handler_->Animate(time); | 665 input_handler_->Animate(time); |
| 666 | 666 |
| 667 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 667 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 668 testing::Mock::VerifyAndClearExpectations(&mock_client_); | 668 testing::Mock::VerifyAndClearExpectations(&mock_client_); |
| 669 | 669 |
| 670 // Since we've aborted the fling, the next animation should be a no-op and | 670 // Since we've aborted the fling, the next animation should be a no-op and |
| 671 // should not result in another | 671 // should not result in another |
| 672 // frame being requested. | 672 // frame being requested. |
| 673 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()).Times(0); | 673 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()).Times(0); |
| 674 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 674 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 675 .Times(0); | 675 .Times(0); |
| 676 time += base::TimeDelta::FromMilliseconds(100); | 676 time += base::TimeDelta::FromMilliseconds(100); |
| 677 input_handler_->Animate(time); | 677 input_handler_->Animate(time); |
| 678 | 678 |
| 679 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 679 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 680 | 680 |
| 681 // Since we've transferred the fling to the main thread, we need to pass the | 681 // Since we've transferred the fling to the main thread, we need to pass the |
| 682 // next GestureFlingCancel to the main | 682 // next GestureFlingCancel to the main |
| 683 // thread as well. | 683 // thread as well. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 695 fling_global_point = WebPoint(32, 71); | 695 fling_global_point = WebPoint(32, 71); |
| 696 modifiers = WebInputEvent::AltKey; | 696 modifiers = WebInputEvent::AltKey; |
| 697 gesture_.data.flingStart.velocityX = fling_delta.x; | 697 gesture_.data.flingStart.velocityX = fling_delta.x; |
| 698 gesture_.data.flingStart.velocityY = fling_delta.y; | 698 gesture_.data.flingStart.velocityY = fling_delta.y; |
| 699 gesture_.sourceDevice = WebGestureEvent::Touchpad; | 699 gesture_.sourceDevice = WebGestureEvent::Touchpad; |
| 700 gesture_.x = fling_point.x; | 700 gesture_.x = fling_point.x; |
| 701 gesture_.y = fling_point.y; | 701 gesture_.y = fling_point.y; |
| 702 gesture_.globalX = fling_global_point.x; | 702 gesture_.globalX = fling_global_point.x; |
| 703 gesture_.globalY = fling_global_point.y; | 703 gesture_.globalY = fling_global_point.y; |
| 704 gesture_.modifiers = modifiers; | 704 gesture_.modifiers = modifiers; |
| 705 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 705 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 706 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 706 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 707 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 707 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
| 708 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 708 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
| 709 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 709 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
| 710 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 710 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 711 | 711 |
| 712 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 712 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 713 | 713 |
| 714 // Start the second fling animation at time 30. | 714 // Start the second fling animation at time 30. |
| 715 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 715 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 716 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 716 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 717 .Times(0); | 717 .Times(0); |
| 718 time = base::TimeTicks() + base::TimeDelta::FromSeconds(30); | 718 time = base::TimeTicks() + base::TimeDelta::FromSeconds(30); |
| 719 input_handler_->Animate(time); | 719 input_handler_->Animate(time); |
| 720 | 720 |
| 721 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 721 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 722 | 722 |
| 723 // Tick the second fling once normally. | 723 // Tick the second fling once normally. |
| 724 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 724 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 725 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 725 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 726 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 726 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
| 727 EXPECT_CALL(mock_input_handler_, | 727 EXPECT_CALL(mock_input_handler_, |
| 728 ScrollBy(testing::_, | 728 ScrollBy(testing::_, |
| 729 testing::Property(&gfx::Vector2dF::y, testing::Gt(0)))) | 729 testing::Property(&gfx::Vector2dF::y, testing::Gt(0)))) |
| 730 .WillOnce(testing::Return(true)); | 730 .WillOnce(testing::Return(true)); |
| 731 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 731 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
| 732 time += base::TimeDelta::FromMilliseconds(100); | 732 time += base::TimeDelta::FromMilliseconds(100); |
| 733 input_handler_->Animate(time); | 733 input_handler_->Animate(time); |
| 734 | 734 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 769 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 770 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 770 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
| 771 gesture_.type = WebInputEvent::GestureScrollBegin; | 771 gesture_.type = WebInputEvent::GestureScrollBegin; |
| 772 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 772 gesture_.sourceDevice = WebGestureEvent::Touchscreen; |
| 773 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 773 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 774 | 774 |
| 775 VERIFY_AND_RESET_MOCKS(); | 775 VERIFY_AND_RESET_MOCKS(); |
| 776 | 776 |
| 777 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 777 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
| 778 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 778 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
| 779 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 779 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 780 | 780 |
| 781 gesture_.type = WebInputEvent::GestureFlingStart; | 781 gesture_.type = WebInputEvent::GestureFlingStart; |
| 782 gesture_.data.flingStart.velocityX = 10; | 782 gesture_.data.flingStart.velocityX = 10; |
| 783 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 783 gesture_.sourceDevice = WebGestureEvent::Touchscreen; |
| 784 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 784 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 785 | 785 |
| 786 VERIFY_AND_RESET_MOCKS(); | 786 VERIFY_AND_RESET_MOCKS(); |
| 787 | 787 |
| 788 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 788 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
| 789 | 789 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 // Note that for touchscreen the control modifier is not special. | 874 // Note that for touchscreen the control modifier is not special. |
| 875 int modifiers = WebInputEvent::ControlKey; | 875 int modifiers = WebInputEvent::ControlKey; |
| 876 gesture_.data.flingStart.velocityX = fling_delta.x; | 876 gesture_.data.flingStart.velocityX = fling_delta.x; |
| 877 gesture_.data.flingStart.velocityY = fling_delta.y; | 877 gesture_.data.flingStart.velocityY = fling_delta.y; |
| 878 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 878 gesture_.sourceDevice = WebGestureEvent::Touchscreen; |
| 879 gesture_.x = fling_point.x; | 879 gesture_.x = fling_point.x; |
| 880 gesture_.y = fling_point.y; | 880 gesture_.y = fling_point.y; |
| 881 gesture_.globalX = fling_global_point.x; | 881 gesture_.globalX = fling_global_point.x; |
| 882 gesture_.globalY = fling_global_point.y; | 882 gesture_.globalY = fling_global_point.y; |
| 883 gesture_.modifiers = modifiers; | 883 gesture_.modifiers = modifiers; |
| 884 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 884 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 885 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 885 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
| 886 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 886 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
| 887 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 887 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 888 | 888 |
| 889 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 889 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 890 // The first animate call should let us pick up an animation start time, but | 890 // The first animate call should let us pick up an animation start time, but |
| 891 // we shouldn't actually move anywhere just yet. The first frame after the | 891 // we shouldn't actually move anywhere just yet. The first frame after the |
| 892 // fling start will typically include the last scroll from the gesture that | 892 // fling start will typically include the last scroll from the gesture that |
| 893 // lead to the scroll (either wheel or gesture scroll), so there should be no | 893 // lead to the scroll (either wheel or gesture scroll), so there should be no |
| 894 // visible hitch. | 894 // visible hitch. |
| 895 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 895 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 896 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); | 896 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); |
| 897 input_handler_->Animate(time); | 897 input_handler_->Animate(time); |
| 898 | 898 |
| 899 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 899 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 900 | 900 |
| 901 // The second call should start scrolling in the -X direction. | 901 // The second call should start scrolling in the -X direction. |
| 902 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 902 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 903 EXPECT_CALL(mock_input_handler_, | 903 EXPECT_CALL(mock_input_handler_, |
| 904 ScrollBy(testing::_, | 904 ScrollBy(testing::_, |
| 905 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) | 905 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) |
| 906 .WillOnce(testing::Return(true)); | 906 .WillOnce(testing::Return(true)); |
| 907 time += base::TimeDelta::FromMilliseconds(100); | 907 time += base::TimeDelta::FromMilliseconds(100); |
| 908 input_handler_->Animate(time); | 908 input_handler_->Animate(time); |
| 909 | 909 |
| 910 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 910 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 911 | 911 |
| 912 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 912 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 938 int modifiers = WebInputEvent::ControlKey; | 938 int modifiers = WebInputEvent::ControlKey; |
| 939 gesture_.timeStampSeconds = startTimeOffset.InSecondsF(); | 939 gesture_.timeStampSeconds = startTimeOffset.InSecondsF(); |
| 940 gesture_.data.flingStart.velocityX = fling_delta.x; | 940 gesture_.data.flingStart.velocityX = fling_delta.x; |
| 941 gesture_.data.flingStart.velocityY = fling_delta.y; | 941 gesture_.data.flingStart.velocityY = fling_delta.y; |
| 942 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 942 gesture_.sourceDevice = WebGestureEvent::Touchscreen; |
| 943 gesture_.x = fling_point.x; | 943 gesture_.x = fling_point.x; |
| 944 gesture_.y = fling_point.y; | 944 gesture_.y = fling_point.y; |
| 945 gesture_.globalX = fling_global_point.x; | 945 gesture_.globalX = fling_global_point.x; |
| 946 gesture_.globalY = fling_global_point.y; | 946 gesture_.globalY = fling_global_point.y; |
| 947 gesture_.modifiers = modifiers; | 947 gesture_.modifiers = modifiers; |
| 948 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 948 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 949 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 949 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
| 950 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 950 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
| 951 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 951 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 952 | 952 |
| 953 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 953 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 954 // With a valid time stamp, the first animate call should skip start time | 954 // With a valid time stamp, the first animate call should skip start time |
| 955 // initialization and immediately begin scroll update production. This reduces | 955 // initialization and immediately begin scroll update production. This reduces |
| 956 // the likelihood of a hitch between the scroll preceding the fling and | 956 // the likelihood of a hitch between the scroll preceding the fling and |
| 957 // the first scroll generated by the fling. | 957 // the first scroll generated by the fling. |
| 958 // Scrolling should start in the -X direction. | 958 // Scrolling should start in the -X direction. |
| 959 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 959 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 960 EXPECT_CALL(mock_input_handler_, | 960 EXPECT_CALL(mock_input_handler_, |
| 961 ScrollBy(testing::_, | 961 ScrollBy(testing::_, |
| 962 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) | 962 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) |
| 963 .WillOnce(testing::Return(true)); | 963 .WillOnce(testing::Return(true)); |
| 964 base::TimeTicks time = base::TimeTicks() + 2 * startTimeOffset; | 964 base::TimeTicks time = base::TimeTicks() + 2 * startTimeOffset; |
| 965 input_handler_->Animate(time); | 965 input_handler_->Animate(time); |
| 966 | 966 |
| 967 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 967 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 968 | 968 |
| 969 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 969 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 995 int modifiers = WebInputEvent::ControlKey; | 995 int modifiers = WebInputEvent::ControlKey; |
| 996 gesture_.timeStampSeconds = start_time_offset.InSecondsF(); | 996 gesture_.timeStampSeconds = start_time_offset.InSecondsF(); |
| 997 gesture_.data.flingStart.velocityX = fling_delta.x; | 997 gesture_.data.flingStart.velocityX = fling_delta.x; |
| 998 gesture_.data.flingStart.velocityY = fling_delta.y; | 998 gesture_.data.flingStart.velocityY = fling_delta.y; |
| 999 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 999 gesture_.sourceDevice = WebGestureEvent::Touchscreen; |
| 1000 gesture_.x = fling_point.x; | 1000 gesture_.x = fling_point.x; |
| 1001 gesture_.y = fling_point.y; | 1001 gesture_.y = fling_point.y; |
| 1002 gesture_.globalX = fling_global_point.x; | 1002 gesture_.globalX = fling_global_point.x; |
| 1003 gesture_.globalY = fling_global_point.y; | 1003 gesture_.globalY = fling_global_point.y; |
| 1004 gesture_.modifiers = modifiers; | 1004 gesture_.modifiers = modifiers; |
| 1005 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 1005 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 1006 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 1006 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
| 1007 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 1007 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
| 1008 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1008 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 1009 | 1009 |
| 1010 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1010 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1011 // Event though a time stamp was provided for the fling event, it will be | 1011 // Event though a time stamp was provided for the fling event, it will be |
| 1012 // ignored as its too far in the past relative to the first animate call's | 1012 // ignored as its too far in the past relative to the first animate call's |
| 1013 // timestamp. | 1013 // timestamp. |
| 1014 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 1014 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 1015 base::TimeTicks time = | 1015 base::TimeTicks time = |
| 1016 base::TimeTicks() + start_time_offset + base::TimeDelta::FromSeconds(1); | 1016 base::TimeTicks() + start_time_offset + base::TimeDelta::FromSeconds(1); |
| 1017 input_handler_->Animate(time); | 1017 input_handler_->Animate(time); |
| 1018 | 1018 |
| 1019 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1019 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1020 | 1020 |
| 1021 // Further animation ticks should update the fling as usual. | 1021 // Further animation ticks should update the fling as usual. |
| 1022 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 1022 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 1023 EXPECT_CALL(mock_input_handler_, | 1023 EXPECT_CALL(mock_input_handler_, |
| 1024 ScrollBy(testing::_, | 1024 ScrollBy(testing::_, |
| 1025 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) | 1025 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) |
| 1026 .WillOnce(testing::Return(true)); | 1026 .WillOnce(testing::Return(true)); |
| 1027 time += base::TimeDelta::FromMilliseconds(10); | 1027 time += base::TimeDelta::FromMilliseconds(10); |
| 1028 input_handler_->Animate(time); | 1028 input_handler_->Animate(time); |
| 1029 | 1029 |
| 1030 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1030 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1031 | 1031 |
| 1032 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 1032 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1061 WebPoint fling_global_point = WebPoint(17, 23); | 1061 WebPoint fling_global_point = WebPoint(17, 23); |
| 1062 int modifiers = WebInputEvent::ControlKey | WebInputEvent::AltKey; | 1062 int modifiers = WebInputEvent::ControlKey | WebInputEvent::AltKey; |
| 1063 gesture_.data.flingStart.velocityX = fling_delta.x; | 1063 gesture_.data.flingStart.velocityX = fling_delta.x; |
| 1064 gesture_.data.flingStart.velocityY = fling_delta.y; | 1064 gesture_.data.flingStart.velocityY = fling_delta.y; |
| 1065 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 1065 gesture_.sourceDevice = WebGestureEvent::Touchscreen; |
| 1066 gesture_.x = fling_point.x; | 1066 gesture_.x = fling_point.x; |
| 1067 gesture_.y = fling_point.y; | 1067 gesture_.y = fling_point.y; |
| 1068 gesture_.globalX = fling_global_point.x; | 1068 gesture_.globalX = fling_global_point.x; |
| 1069 gesture_.globalY = fling_global_point.y; | 1069 gesture_.globalY = fling_global_point.y; |
| 1070 gesture_.modifiers = modifiers; | 1070 gesture_.modifiers = modifiers; |
| 1071 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 1071 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 1072 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 1072 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
| 1073 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 1073 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
| 1074 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1074 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 1075 | 1075 |
| 1076 // |gesture_scroll_on_impl_thread_| should still be true after | 1076 // |gesture_scroll_on_impl_thread_| should still be true after |
| 1077 // a GestureFlingStart is sent. | 1077 // a GestureFlingStart is sent. |
| 1078 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 1078 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
| 1079 | 1079 |
| 1080 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1080 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1081 // The first animate call should let us pick up an animation start time, but | 1081 // The first animate call should let us pick up an animation start time, but |
| 1082 // we shouldn't actually move anywhere just yet. The first frame after the | 1082 // we shouldn't actually move anywhere just yet. The first frame after the |
| 1083 // fling start will typically include the last scroll from the gesture that | 1083 // fling start will typically include the last scroll from the gesture that |
| 1084 // lead to the scroll (either wheel or gesture scroll), so there should be no | 1084 // lead to the scroll (either wheel or gesture scroll), so there should be no |
| 1085 // visible hitch. | 1085 // visible hitch. |
| 1086 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 1086 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 1087 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); | 1087 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); |
| 1088 input_handler_->Animate(time); | 1088 input_handler_->Animate(time); |
| 1089 | 1089 |
| 1090 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1090 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1091 | 1091 |
| 1092 // The second call should start scrolling in the -X direction. | 1092 // The second call should start scrolling in the -X direction. |
| 1093 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 1093 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 1094 EXPECT_CALL(mock_input_handler_, | 1094 EXPECT_CALL(mock_input_handler_, |
| 1095 ScrollBy(testing::_, | 1095 ScrollBy(testing::_, |
| 1096 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) | 1096 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) |
| 1097 .WillOnce(testing::Return(true)); | 1097 .WillOnce(testing::Return(true)); |
| 1098 time += base::TimeDelta::FromMilliseconds(100); | 1098 time += base::TimeDelta::FromMilliseconds(100); |
| 1099 input_handler_->Animate(time); | 1099 input_handler_->Animate(time); |
| 1100 | 1100 |
| 1101 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1101 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1102 | 1102 |
| 1103 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 1103 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
| 1104 gesture_.type = WebInputEvent::GestureFlingCancel; | 1104 gesture_.type = WebInputEvent::GestureFlingCancel; |
| 1105 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1105 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 1106 | 1106 |
| 1107 // |gesture_scroll_on_impl_thread_| should be false once | 1107 // |gesture_scroll_on_impl_thread_| should be false once |
| 1108 // the fling has finished (note no GestureScrollEnd has been sent). | 1108 // the fling has finished (note no GestureScrollEnd has been sent). |
| 1109 EXPECT_TRUE(!input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 1109 EXPECT_TRUE(!input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
| 1110 } | 1110 } |
| 1111 | 1111 |
| 1112 TEST_F(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) { | 1112 TEST_F(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) { |
| 1113 // We shouldn't send any events to the widget for this gesture. | 1113 // We shouldn't send any events to the widget for this gesture. |
| 1114 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 1114 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
| 1115 VERIFY_AND_RESET_MOCKS(); | 1115 VERIFY_AND_RESET_MOCKS(); |
| 1116 | 1116 |
| 1117 // On the fling start, we should schedule an animation but not actually start | 1117 // On the fling start, we should schedule an animation but not actually start |
| 1118 // scrolling. | 1118 // scrolling. |
| 1119 gesture_.type = WebInputEvent::GestureFlingStart; | 1119 gesture_.type = WebInputEvent::GestureFlingStart; |
| 1120 WebFloatPoint fling_delta = WebFloatPoint(1000, 1000); | 1120 WebFloatPoint fling_delta = WebFloatPoint(1000, 1000); |
| 1121 gesture_.data.flingStart.velocityX = fling_delta.x; | 1121 gesture_.data.flingStart.velocityX = fling_delta.x; |
| 1122 gesture_.data.flingStart.velocityY = fling_delta.y; | 1122 gesture_.data.flingStart.velocityY = fling_delta.y; |
| 1123 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 1123 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 1124 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1124 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 1125 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 1125 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
| 1126 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 1126 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
| 1127 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1127 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 1128 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1128 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1129 | 1129 |
| 1130 // The first animate doesn't cause any scrolling. | 1130 // The first animate doesn't cause any scrolling. |
| 1131 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 1131 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 1132 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); | 1132 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); |
| 1133 input_handler_->Animate(time); | 1133 input_handler_->Animate(time); |
| 1134 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1134 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1135 | 1135 |
| 1136 // The second animate starts scrolling in the positive X and Y directions. | 1136 // The second animate starts scrolling in the positive X and Y directions. |
| 1137 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 1137 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 1138 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1138 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 1139 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 1139 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
| 1140 EXPECT_CALL(mock_input_handler_, | 1140 EXPECT_CALL(mock_input_handler_, |
| 1141 ScrollBy(testing::_, | 1141 ScrollBy(testing::_, |
| 1142 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))) | 1142 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))) |
| 1143 .WillOnce(testing::Return(true)); | 1143 .WillOnce(testing::Return(true)); |
| 1144 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 1144 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
| 1145 time += base::TimeDelta::FromMilliseconds(100); | 1145 time += base::TimeDelta::FromMilliseconds(100); |
| 1146 input_handler_->Animate(time); | 1146 input_handler_->Animate(time); |
| 1147 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1147 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1148 | 1148 |
| 1149 // Simulate hitting the bottom content edge. | 1149 // Simulate hitting the bottom content edge. |
| 1150 gfx::Vector2dF accumulated_overscroll(0, 100); | 1150 gfx::Vector2dF accumulated_overscroll(0, 100); |
| 1151 gfx::Vector2dF latest_overscroll_delta(0, 10); | 1151 gfx::Vector2dF latest_overscroll_delta(0, 10); |
| 1152 EXPECT_CALL(mock_client_, | 1152 EXPECT_CALL(mock_client_, |
| 1153 DidOverscroll(testing::AllOf( | 1153 DidOverscroll(testing::AllOf( |
| 1154 testing::Field(&DidOverscrollParams::accumulated_overscroll, | 1154 testing::Field(&DidOverscrollParams::accumulated_overscroll, |
| 1155 testing::Eq(accumulated_overscroll)), | 1155 testing::Eq(accumulated_overscroll)), |
| 1156 testing::Field(&DidOverscrollParams::latest_overscroll_delta, | 1156 testing::Field(&DidOverscrollParams::latest_overscroll_delta, |
| 1157 testing::Eq(latest_overscroll_delta)), | 1157 testing::Eq(latest_overscroll_delta)), |
| 1158 testing::Field( | 1158 testing::Field( |
| 1159 &DidOverscrollParams::current_fling_velocity, | 1159 &DidOverscrollParams::current_fling_velocity, |
| 1160 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))))); | 1160 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))))); |
| 1161 input_handler_->DidOverscroll(accumulated_overscroll, | 1161 input_handler_->DidOverscroll(accumulated_overscroll, |
| 1162 latest_overscroll_delta); | 1162 latest_overscroll_delta); |
| 1163 | 1163 |
| 1164 // The next call to animate will no longer scroll vertically. | 1164 // The next call to animate will no longer scroll vertically. |
| 1165 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 1165 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 1166 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1166 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 1167 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 1167 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
| 1168 EXPECT_CALL(mock_input_handler_, | 1168 EXPECT_CALL(mock_input_handler_, |
| 1169 ScrollBy(testing::_, | 1169 ScrollBy(testing::_, |
| 1170 testing::Property(&gfx::Vector2dF::y, testing::Eq(0)))) | 1170 testing::Property(&gfx::Vector2dF::y, testing::Eq(0)))) |
| 1171 .WillOnce(testing::Return(true)); | 1171 .WillOnce(testing::Return(true)); |
| 1172 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 1172 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
| 1173 time += base::TimeDelta::FromMilliseconds(100); | 1173 time += base::TimeDelta::FromMilliseconds(100); |
| 1174 input_handler_->Animate(time); | 1174 input_handler_->Animate(time); |
| 1175 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1175 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1200 int modifiers = WebInputEvent::ControlKey; | 1200 int modifiers = WebInputEvent::ControlKey; |
| 1201 gesture_.timeStampSeconds = time_offset.InSecondsF(); | 1201 gesture_.timeStampSeconds = time_offset.InSecondsF(); |
| 1202 gesture_.data.flingStart.velocityX = fling_delta.x; | 1202 gesture_.data.flingStart.velocityX = fling_delta.x; |
| 1203 gesture_.data.flingStart.velocityY = fling_delta.y; | 1203 gesture_.data.flingStart.velocityY = fling_delta.y; |
| 1204 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 1204 gesture_.sourceDevice = WebGestureEvent::Touchscreen; |
| 1205 gesture_.x = fling_point.x; | 1205 gesture_.x = fling_point.x; |
| 1206 gesture_.y = fling_point.y; | 1206 gesture_.y = fling_point.y; |
| 1207 gesture_.globalX = fling_global_point.x; | 1207 gesture_.globalX = fling_global_point.x; |
| 1208 gesture_.globalY = fling_global_point.y; | 1208 gesture_.globalY = fling_global_point.y; |
| 1209 gesture_.modifiers = modifiers; | 1209 gesture_.modifiers = modifiers; |
| 1210 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 1210 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 1211 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 1211 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
| 1212 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 1212 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
| 1213 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1213 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 1214 | 1214 |
| 1215 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1215 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1216 // With an animation timestamp equivalent to the starting timestamp, the | 1216 // With an animation timestamp equivalent to the starting timestamp, the |
| 1217 // animation will simply be rescheduled. | 1217 // animation will simply be rescheduled. |
| 1218 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 1218 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 1219 input_handler_->Animate(time); | 1219 input_handler_->Animate(time); |
| 1220 | 1220 |
| 1221 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1221 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1222 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 1222 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
| 1223 | 1223 |
| 1224 // A small time delta should not stop the fling, even if the client | 1224 // A small time delta should not stop the fling, even if the client |
| 1225 // reports no scrolling. | 1225 // reports no scrolling. |
| 1226 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 1226 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 1227 EXPECT_CALL(mock_input_handler_, | 1227 EXPECT_CALL(mock_input_handler_, |
| 1228 ScrollBy(testing::_, | 1228 ScrollBy(testing::_, |
| 1229 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) | 1229 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) |
| 1230 .WillOnce(testing::Return(false)); | 1230 .WillOnce(testing::Return(false)); |
| 1231 time += base::TimeDelta::FromMicroseconds(5); | 1231 time += base::TimeDelta::FromMicroseconds(5); |
| 1232 input_handler_->Animate(time); | 1232 input_handler_->Animate(time); |
| 1233 | 1233 |
| 1234 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1234 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1235 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 1235 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
| 1236 | 1236 |
| 1237 // A time delta of zero should not stop the fling, and neither should it | 1237 // A time delta of zero should not stop the fling, and neither should it |
| 1238 // trigger scrolling on the client. | 1238 // trigger scrolling on the client. |
| 1239 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 1239 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 1240 input_handler_->Animate(time); | 1240 input_handler_->Animate(time); |
| 1241 | 1241 |
| 1242 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1242 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1243 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 1243 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
| 1244 | 1244 |
| 1245 // Lack of movement on the client, with a non-trivial scroll delta, should | 1245 // Lack of movement on the client, with a non-trivial scroll delta, should |
| 1246 // terminate the fling. | 1246 // terminate the fling. |
| 1247 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 1247 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
| 1248 EXPECT_CALL(mock_input_handler_, | 1248 EXPECT_CALL(mock_input_handler_, |
| 1249 ScrollBy(testing::_, | 1249 ScrollBy(testing::_, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1269 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1269 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1270 | 1270 |
| 1271 // On the fling start, we should schedule an animation but not actually start | 1271 // On the fling start, we should schedule an animation but not actually start |
| 1272 // scrolling. | 1272 // scrolling. |
| 1273 gesture_.type = WebInputEvent::GestureFlingStart; | 1273 gesture_.type = WebInputEvent::GestureFlingStart; |
| 1274 WebFloatPoint fling_delta = WebFloatPoint(1000, 1000); | 1274 WebFloatPoint fling_delta = WebFloatPoint(1000, 1000); |
| 1275 gesture_.data.flingStart.velocityX = fling_delta.x; | 1275 gesture_.data.flingStart.velocityX = fling_delta.x; |
| 1276 gesture_.data.flingStart.velocityY = fling_delta.y; | 1276 gesture_.data.flingStart.velocityY = fling_delta.y; |
| 1277 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 1277 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
| 1278 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 1278 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
| 1279 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 1279 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 1280 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1280 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 1281 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1281 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1282 | 1282 |
| 1283 // The first animate doesn't cause any scrolling. | 1283 // The first animate doesn't cause any scrolling. |
| 1284 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 1284 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 1285 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); | 1285 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); |
| 1286 input_handler_->Animate(time); | 1286 input_handler_->Animate(time); |
| 1287 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1287 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1288 | 1288 |
| 1289 // The second animate starts scrolling in the positive X and Y directions. | 1289 // The second animate starts scrolling in the positive X and Y directions. |
| 1290 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 1290 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 1291 EXPECT_CALL(mock_input_handler_, | 1291 EXPECT_CALL(mock_input_handler_, |
| 1292 ScrollBy(testing::_, | 1292 ScrollBy(testing::_, |
| 1293 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))) | 1293 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))) |
| 1294 .WillOnce(testing::Return(true)); | 1294 .WillOnce(testing::Return(true)); |
| 1295 time += base::TimeDelta::FromMilliseconds(10); | 1295 time += base::TimeDelta::FromMilliseconds(10); |
| 1296 input_handler_->Animate(time); | 1296 input_handler_->Animate(time); |
| 1297 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1297 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1298 | 1298 |
| 1299 // Simulate hitting the bottom content edge. | 1299 // Simulate hitting the bottom content edge. |
| 1300 gfx::Vector2dF accumulated_overscroll(0, 100); | 1300 gfx::Vector2dF accumulated_overscroll(0, 100); |
| 1301 gfx::Vector2dF latest_overscroll_delta(0, 100); | 1301 gfx::Vector2dF latest_overscroll_delta(0, 100); |
| 1302 EXPECT_CALL(mock_client_, | 1302 EXPECT_CALL(mock_client_, |
| 1303 DidOverscroll(testing::AllOf( | 1303 DidOverscroll(testing::AllOf( |
| 1304 testing::Field(&DidOverscrollParams::accumulated_overscroll, | 1304 testing::Field(&DidOverscrollParams::accumulated_overscroll, |
| 1305 testing::Eq(accumulated_overscroll)), | 1305 testing::Eq(accumulated_overscroll)), |
| 1306 testing::Field(&DidOverscrollParams::latest_overscroll_delta, | 1306 testing::Field(&DidOverscrollParams::latest_overscroll_delta, |
| 1307 testing::Eq(latest_overscroll_delta)), | 1307 testing::Eq(latest_overscroll_delta)), |
| 1308 testing::Field( | 1308 testing::Field( |
| 1309 &DidOverscrollParams::current_fling_velocity, | 1309 &DidOverscrollParams::current_fling_velocity, |
| 1310 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))))); | 1310 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))))); |
| 1311 input_handler_->DidOverscroll(accumulated_overscroll, | 1311 input_handler_->DidOverscroll(accumulated_overscroll, |
| 1312 latest_overscroll_delta); | 1312 latest_overscroll_delta); |
| 1313 | 1313 |
| 1314 // The next call to animate will no longer scroll vertically. | 1314 // The next call to animate will no longer scroll vertically. |
| 1315 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 1315 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 1316 EXPECT_CALL(mock_input_handler_, | 1316 EXPECT_CALL(mock_input_handler_, |
| 1317 ScrollBy(testing::_, | 1317 ScrollBy(testing::_, |
| 1318 testing::Property(&gfx::Vector2dF::y, testing::Eq(0)))) | 1318 testing::Property(&gfx::Vector2dF::y, testing::Eq(0)))) |
| 1319 .WillOnce(testing::Return(true)); | 1319 .WillOnce(testing::Return(true)); |
| 1320 time += base::TimeDelta::FromMilliseconds(10); | 1320 time += base::TimeDelta::FromMilliseconds(10); |
| 1321 input_handler_->Animate(time); | 1321 input_handler_->Animate(time); |
| 1322 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1322 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1323 | 1323 |
| 1324 // Simulate hitting the right content edge. | 1324 // Simulate hitting the right content edge. |
| 1325 accumulated_overscroll = gfx::Vector2dF(100, 100); | 1325 accumulated_overscroll = gfx::Vector2dF(100, 100); |
| 1326 latest_overscroll_delta = gfx::Vector2dF(100, 0); | 1326 latest_overscroll_delta = gfx::Vector2dF(100, 0); |
| 1327 EXPECT_CALL(mock_client_, | 1327 EXPECT_CALL(mock_client_, |
| 1328 DidOverscroll(testing::AllOf( | 1328 DidOverscroll(testing::AllOf( |
| 1329 testing::Field(&DidOverscrollParams::accumulated_overscroll, | 1329 testing::Field(&DidOverscrollParams::accumulated_overscroll, |
| 1330 testing::Eq(accumulated_overscroll)), | 1330 testing::Eq(accumulated_overscroll)), |
| 1331 testing::Field(&DidOverscrollParams::latest_overscroll_delta, | 1331 testing::Field(&DidOverscrollParams::latest_overscroll_delta, |
| 1332 testing::Eq(latest_overscroll_delta)), | 1332 testing::Eq(latest_overscroll_delta)), |
| 1333 testing::Field( | 1333 testing::Field( |
| 1334 &DidOverscrollParams::current_fling_velocity, | 1334 &DidOverscrollParams::current_fling_velocity, |
| 1335 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))))); | 1335 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))))); |
| 1336 input_handler_->DidOverscroll(accumulated_overscroll, | 1336 input_handler_->DidOverscroll(accumulated_overscroll, |
| 1337 latest_overscroll_delta); | 1337 latest_overscroll_delta); |
| 1338 // The next call to animate will no longer scroll horizontally or vertically, | 1338 // The next call to animate will no longer scroll horizontally or vertically, |
| 1339 // and the fling should be cancelled. | 1339 // and the fling should be cancelled. |
| 1340 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()).Times(0); | 1340 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()).Times(0); |
| 1341 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_, testing::_)).Times(0); | 1341 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_, testing::_)).Times(0); |
| 1342 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 1342 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
| 1343 time += base::TimeDelta::FromMilliseconds(10); | 1343 time += base::TimeDelta::FromMilliseconds(10); |
| 1344 input_handler_->Animate(time); | 1344 input_handler_->Animate(time); |
| 1345 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1345 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1346 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 1346 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
| 1347 } | 1347 } |
| 1348 | 1348 |
| 1349 TEST_F(InputHandlerProxyTest, MultiTouchPointHitTestNegative) { | 1349 TEST_F(InputHandlerProxyTest, MultiTouchPointHitTestNegative) { |
| 1350 // None of the three touch points fall in the touch region. So the event | 1350 // None of the three touch points fall in the touch region. So the event |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1419 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 1419 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
| 1420 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1420 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1421 | 1421 |
| 1422 // On the fling start, animation should be scheduled, but no scrolling occurs. | 1422 // On the fling start, animation should be scheduled, but no scrolling occurs. |
| 1423 gesture_.type = WebInputEvent::GestureFlingStart; | 1423 gesture_.type = WebInputEvent::GestureFlingStart; |
| 1424 WebFloatPoint fling_delta = WebFloatPoint(1000, 1000); | 1424 WebFloatPoint fling_delta = WebFloatPoint(1000, 1000); |
| 1425 gesture_.data.flingStart.velocityX = fling_delta.x; | 1425 gesture_.data.flingStart.velocityX = fling_delta.x; |
| 1426 gesture_.data.flingStart.velocityY = fling_delta.y; | 1426 gesture_.data.flingStart.velocityY = fling_delta.y; |
| 1427 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 1427 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
| 1428 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 1428 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
| 1429 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 1429 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 1430 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1430 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 1431 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 1431 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
| 1432 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1432 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1433 | 1433 |
| 1434 // Keyboard events received during a fling should cancel the active fling. | 1434 // Keyboard events received during a fling should cancel the active fling. |
| 1435 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 1435 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
| 1436 EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE, | 1436 EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE, |
| 1437 input_handler_->HandleInputEvent(key_event)); | 1437 input_handler_->HandleInputEvent(key_event)); |
| 1438 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 1438 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
| 1439 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1439 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1474 int modifiers = WebInputEvent::ControlKey; | 1474 int modifiers = WebInputEvent::ControlKey; |
| 1475 gesture_.timeStampSeconds = startTimeOffset.InSecondsF(); | 1475 gesture_.timeStampSeconds = startTimeOffset.InSecondsF(); |
| 1476 gesture_.data.flingStart.velocityX = fling_delta.x; | 1476 gesture_.data.flingStart.velocityX = fling_delta.x; |
| 1477 gesture_.data.flingStart.velocityY = fling_delta.y; | 1477 gesture_.data.flingStart.velocityY = fling_delta.y; |
| 1478 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 1478 gesture_.sourceDevice = WebGestureEvent::Touchscreen; |
| 1479 gesture_.x = fling_point.x; | 1479 gesture_.x = fling_point.x; |
| 1480 gesture_.y = fling_point.y; | 1480 gesture_.y = fling_point.y; |
| 1481 gesture_.globalX = fling_global_point.x; | 1481 gesture_.globalX = fling_global_point.x; |
| 1482 gesture_.globalY = fling_global_point.y; | 1482 gesture_.globalY = fling_global_point.y; |
| 1483 gesture_.modifiers = modifiers; | 1483 gesture_.modifiers = modifiers; |
| 1484 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 1484 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 1485 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 1485 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
| 1486 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 1486 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
| 1487 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1487 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 1488 | 1488 |
| 1489 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1489 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1490 | 1490 |
| 1491 // If we get a negative time delta, that is, the Animation tick time happens | 1491 // If we get a negative time delta, that is, the Animation tick time happens |
| 1492 // before the fling's start time then we should *not* try scrolling and | 1492 // before the fling's start time then we should *not* try scrolling and |
| 1493 // instead reset the fling start time. | 1493 // instead reset the fling start time. |
| 1494 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 1494 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 1495 EXPECT_CALL(mock_input_handler_, | 1495 EXPECT_CALL(mock_input_handler_, |
| 1496 ScrollBy(testing::_, | 1496 ScrollBy(testing::_, |
| 1497 testing::_)).Times(0); | 1497 testing::_)).Times(0); |
| 1498 base::TimeTicks time = | 1498 base::TimeTicks time = |
| 1499 base::TimeTicks() + base::TimeDelta::FromMilliseconds(8); | 1499 base::TimeTicks() + base::TimeDelta::FromMilliseconds(8); |
| 1500 input_handler_->Animate(time); | 1500 input_handler_->Animate(time); |
| 1501 | 1501 |
| 1502 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1502 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1503 | 1503 |
| 1504 // The first call should have reset the start time so subsequent calls should | 1504 // The first call should have reset the start time so subsequent calls should |
| 1505 // generate scroll events. | 1505 // generate scroll events. |
| 1506 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 1506 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 1507 EXPECT_CALL(mock_input_handler_, | 1507 EXPECT_CALL(mock_input_handler_, |
| 1508 ScrollBy(testing::_, | 1508 ScrollBy(testing::_, |
| 1509 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) | 1509 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) |
| 1510 .WillOnce(testing::Return(true)); | 1510 .WillOnce(testing::Return(true)); |
| 1511 | 1511 |
| 1512 input_handler_->Animate(time + base::TimeDelta::FromMilliseconds(1)); | 1512 input_handler_->Animate(time + base::TimeDelta::FromMilliseconds(1)); |
| 1513 | 1513 |
| 1514 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1514 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1515 | 1515 |
| 1516 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 1516 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
| 1517 gesture_.type = WebInputEvent::GestureFlingCancel; | 1517 gesture_.type = WebInputEvent::GestureFlingCancel; |
| 1518 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1518 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 1519 } | 1519 } |
| 1520 | 1520 |
| 1521 } // namespace | 1521 } // namespace |
| 1522 } // namespace content | 1522 } // namespace content |
| OLD | NEW |