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

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

Issue 254883004: Revert 266624 "cc: Split animating and drawing into separate act..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « trunk/src/content/renderer/input/input_handler_proxy.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/input/input_handler_proxy.h" 5 #include "content/renderer/input/input_handler_proxy.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "cc/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
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(SetNeedsAnimate, void()); 46 MOCK_METHOD0(ScheduleAnimation, 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
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_, SetNeedsAnimate()); 408 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
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
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_, SetNeedsAnimate()); 491 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
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_, SetNeedsAnimate()); 503 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
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_, SetNeedsAnimate()); 512 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
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
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_, SetNeedsAnimate()).Times(0); 565 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()).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
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_, SetNeedsAnimate()); 600 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
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_, SetNeedsAnimate()); 610 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
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_, SetNeedsAnimate()); 619 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
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
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_, SetNeedsAnimate()).Times(0); 673 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()).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
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_, SetNeedsAnimate()); 705 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
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_, SetNeedsAnimate()); 715 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
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_, SetNeedsAnimate()); 724 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
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
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_, SetNeedsAnimate()); 779 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
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
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_, SetNeedsAnimate()); 884 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
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_, SetNeedsAnimate()); 895 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
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_, SetNeedsAnimate()); 902 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
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
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_, SetNeedsAnimate()); 948 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
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_, SetNeedsAnimate()); 959 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
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 28 matching lines...) Expand all
998 WebPoint fling_global_point = WebPoint(17, 23); 998 WebPoint fling_global_point = WebPoint(17, 23);
999 int modifiers = WebInputEvent::ControlKey | WebInputEvent::AltKey; 999 int modifiers = WebInputEvent::ControlKey | WebInputEvent::AltKey;
1000 gesture_.data.flingStart.velocityX = fling_delta.x; 1000 gesture_.data.flingStart.velocityX = fling_delta.x;
1001 gesture_.data.flingStart.velocityY = fling_delta.y; 1001 gesture_.data.flingStart.velocityY = fling_delta.y;
1002 gesture_.sourceDevice = WebGestureEvent::Touchscreen; 1002 gesture_.sourceDevice = WebGestureEvent::Touchscreen;
1003 gesture_.x = fling_point.x; 1003 gesture_.x = fling_point.x;
1004 gesture_.y = fling_point.y; 1004 gesture_.y = fling_point.y;
1005 gesture_.globalX = fling_global_point.x; 1005 gesture_.globalX = fling_global_point.x;
1006 gesture_.globalY = fling_global_point.y; 1006 gesture_.globalY = fling_global_point.y;
1007 gesture_.modifiers = modifiers; 1007 gesture_.modifiers = modifiers;
1008 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1008 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1009 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 1009 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
1010 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 1010 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1011 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1011 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1012 1012
1013 // |gesture_scroll_on_impl_thread_| should still be true after 1013 // |gesture_scroll_on_impl_thread_| should still be true after
1014 // a GestureFlingStart is sent. 1014 // a GestureFlingStart is sent.
1015 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1015 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1016 1016
1017 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1017 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1018 // The first animate call should let us pick up an animation start time, but 1018 // The first animate call should let us pick up an animation start time, but
1019 // we shouldn't actually move anywhere just yet. The first frame after the 1019 // we shouldn't actually move anywhere just yet. The first frame after the
1020 // fling start will typically include the last scroll from the gesture that 1020 // fling start will typically include the last scroll from the gesture that
1021 // lead to the scroll (either wheel or gesture scroll), so there should be no 1021 // lead to the scroll (either wheel or gesture scroll), so there should be no
1022 // visible hitch. 1022 // visible hitch.
1023 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1023 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1024 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); 1024 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
1025 input_handler_->Animate(time); 1025 input_handler_->Animate(time);
1026 1026
1027 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1027 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1028 1028
1029 // The second call should start scrolling in the -X direction. 1029 // The second call should start scrolling in the -X direction.
1030 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1030 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1031 EXPECT_CALL(mock_input_handler_, 1031 EXPECT_CALL(mock_input_handler_,
1032 ScrollBy(testing::_, 1032 ScrollBy(testing::_,
1033 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) 1033 testing::Property(&gfx::Vector2dF::x, testing::Lt(0))))
1034 .WillOnce(testing::Return(true)); 1034 .WillOnce(testing::Return(true));
1035 time += base::TimeDelta::FromMilliseconds(100); 1035 time += base::TimeDelta::FromMilliseconds(100);
1036 input_handler_->Animate(time); 1036 input_handler_->Animate(time);
1037 1037
1038 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1038 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1039 1039
1040 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1040 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1041 gesture_.type = WebInputEvent::GestureFlingCancel; 1041 gesture_.type = WebInputEvent::GestureFlingCancel;
1042 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1042 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1043 1043
1044 // |gesture_scroll_on_impl_thread_| should be false once 1044 // |gesture_scroll_on_impl_thread_| should be false once
1045 // the fling has finished (note no GestureScrollEnd has been sent). 1045 // the fling has finished (note no GestureScrollEnd has been sent).
1046 EXPECT_TRUE(!input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1046 EXPECT_TRUE(!input_handler_->gesture_scroll_on_impl_thread_for_testing());
1047 } 1047 }
1048 1048
1049 TEST_F(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) { 1049 TEST_F(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) {
1050 // We shouldn't send any events to the widget for this gesture. 1050 // We shouldn't send any events to the widget for this gesture.
1051 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1051 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1052 VERIFY_AND_RESET_MOCKS(); 1052 VERIFY_AND_RESET_MOCKS();
1053 1053
1054 // On the fling start, we should schedule an animation but not actually start 1054 // On the fling start, we should schedule an animation but not actually start
1055 // scrolling. 1055 // scrolling.
1056 gesture_.type = WebInputEvent::GestureFlingStart; 1056 gesture_.type = WebInputEvent::GestureFlingStart;
1057 WebFloatPoint fling_delta = WebFloatPoint(1000, 1000); 1057 WebFloatPoint fling_delta = WebFloatPoint(1000, 1000);
1058 gesture_.data.flingStart.velocityX = fling_delta.x; 1058 gesture_.data.flingStart.velocityX = fling_delta.x;
1059 gesture_.data.flingStart.velocityY = fling_delta.y; 1059 gesture_.data.flingStart.velocityY = fling_delta.y;
1060 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1060 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1061 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1061 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1062 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 1062 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1063 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1063 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1064 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1064 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1065 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1065 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1066 1066
1067 // The first animate doesn't cause any scrolling. 1067 // The first animate doesn't cause any scrolling.
1068 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1068 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1069 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); 1069 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
1070 input_handler_->Animate(time); 1070 input_handler_->Animate(time);
1071 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1071 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1072 1072
1073 // The second animate starts scrolling in the positive X and Y directions. 1073 // The second animate starts scrolling in the positive X and Y directions.
1074 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1074 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1075 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1075 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1076 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 1076 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1077 EXPECT_CALL(mock_input_handler_, 1077 EXPECT_CALL(mock_input_handler_,
1078 ScrollBy(testing::_, 1078 ScrollBy(testing::_,
1079 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))) 1079 testing::Property(&gfx::Vector2dF::y, testing::Lt(0))))
1080 .WillOnce(testing::Return(true)); 1080 .WillOnce(testing::Return(true));
1081 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1081 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1082 time += base::TimeDelta::FromMilliseconds(100); 1082 time += base::TimeDelta::FromMilliseconds(100);
1083 input_handler_->Animate(time); 1083 input_handler_->Animate(time);
1084 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1084 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1085 1085
1086 // Simulate hitting the bottom content edge. 1086 // Simulate hitting the bottom content edge.
1087 gfx::Vector2dF accumulated_overscroll(0, 100); 1087 gfx::Vector2dF accumulated_overscroll(0, 100);
1088 gfx::Vector2dF latest_overscroll_delta(0, 10); 1088 gfx::Vector2dF latest_overscroll_delta(0, 10);
1089 EXPECT_CALL(mock_client_, 1089 EXPECT_CALL(mock_client_,
1090 DidOverscroll(testing::AllOf( 1090 DidOverscroll(testing::AllOf(
1091 testing::Field(&DidOverscrollParams::accumulated_overscroll, 1091 testing::Field(&DidOverscrollParams::accumulated_overscroll,
1092 testing::Eq(accumulated_overscroll)), 1092 testing::Eq(accumulated_overscroll)),
1093 testing::Field(&DidOverscrollParams::latest_overscroll_delta, 1093 testing::Field(&DidOverscrollParams::latest_overscroll_delta,
1094 testing::Eq(latest_overscroll_delta)), 1094 testing::Eq(latest_overscroll_delta)),
1095 testing::Field( 1095 testing::Field(
1096 &DidOverscrollParams::current_fling_velocity, 1096 &DidOverscrollParams::current_fling_velocity,
1097 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))))); 1097 testing::Property(&gfx::Vector2dF::y, testing::Lt(0))))));
1098 input_handler_->DidOverscroll(accumulated_overscroll, 1098 input_handler_->DidOverscroll(accumulated_overscroll,
1099 latest_overscroll_delta); 1099 latest_overscroll_delta);
1100 1100
1101 // The next call to animate will no longer scroll vertically. 1101 // The next call to animate will no longer scroll vertically.
1102 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1102 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1103 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1103 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1104 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 1104 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1105 EXPECT_CALL(mock_input_handler_, 1105 EXPECT_CALL(mock_input_handler_,
1106 ScrollBy(testing::_, 1106 ScrollBy(testing::_,
1107 testing::Property(&gfx::Vector2dF::y, testing::Eq(0)))) 1107 testing::Property(&gfx::Vector2dF::y, testing::Eq(0))))
1108 .WillOnce(testing::Return(true)); 1108 .WillOnce(testing::Return(true));
1109 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1109 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1110 time += base::TimeDelta::FromMilliseconds(100); 1110 time += base::TimeDelta::FromMilliseconds(100);
1111 input_handler_->Animate(time); 1111 input_handler_->Animate(time);
1112 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1112 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
(...skipping 24 matching lines...) Expand all
1137 int modifiers = WebInputEvent::ControlKey; 1137 int modifiers = WebInputEvent::ControlKey;
1138 gesture_.timeStampSeconds = time_offset.InSecondsF(); 1138 gesture_.timeStampSeconds = time_offset.InSecondsF();
1139 gesture_.data.flingStart.velocityX = fling_delta.x; 1139 gesture_.data.flingStart.velocityX = fling_delta.x;
1140 gesture_.data.flingStart.velocityY = fling_delta.y; 1140 gesture_.data.flingStart.velocityY = fling_delta.y;
1141 gesture_.sourceDevice = WebGestureEvent::Touchscreen; 1141 gesture_.sourceDevice = WebGestureEvent::Touchscreen;
1142 gesture_.x = fling_point.x; 1142 gesture_.x = fling_point.x;
1143 gesture_.y = fling_point.y; 1143 gesture_.y = fling_point.y;
1144 gesture_.globalX = fling_global_point.x; 1144 gesture_.globalX = fling_global_point.x;
1145 gesture_.globalY = fling_global_point.y; 1145 gesture_.globalY = fling_global_point.y;
1146 gesture_.modifiers = modifiers; 1146 gesture_.modifiers = modifiers;
1147 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1147 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1148 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 1148 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
1149 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 1149 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1150 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1150 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1151 1151
1152 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1152 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1153 // With an animation timestamp equivalent to the starting timestamp, the 1153 // With an animation timestamp equivalent to the starting timestamp, the
1154 // animation will simply be rescheduled. 1154 // animation will simply be rescheduled.
1155 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1155 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1156 input_handler_->Animate(time); 1156 input_handler_->Animate(time);
1157 1157
1158 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1158 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1159 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1159 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1160 1160
1161 // A small time delta should not stop the fling, even if the client 1161 // A small time delta should not stop the fling, even if the client
1162 // reports no scrolling. 1162 // reports no scrolling.
1163 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1163 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1164 EXPECT_CALL(mock_input_handler_, 1164 EXPECT_CALL(mock_input_handler_,
1165 ScrollBy(testing::_, 1165 ScrollBy(testing::_,
1166 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) 1166 testing::Property(&gfx::Vector2dF::x, testing::Lt(0))))
1167 .WillOnce(testing::Return(false)); 1167 .WillOnce(testing::Return(false));
1168 time += base::TimeDelta::FromMicroseconds(5); 1168 time += base::TimeDelta::FromMicroseconds(5);
1169 input_handler_->Animate(time); 1169 input_handler_->Animate(time);
1170 1170
1171 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1171 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1172 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1172 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1173 1173
1174 // A time delta of zero should not stop the fling, and neither should it 1174 // A time delta of zero should not stop the fling, and neither should it
1175 // trigger scrolling on the client. 1175 // trigger scrolling on the client.
1176 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1176 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1177 input_handler_->Animate(time); 1177 input_handler_->Animate(time);
1178 1178
1179 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1179 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1180 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1180 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1181 1181
1182 // Lack of movement on the client, with a non-trivial scroll delta, should 1182 // Lack of movement on the client, with a non-trivial scroll delta, should
1183 // terminate the fling. 1183 // terminate the fling.
1184 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1184 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1185 EXPECT_CALL(mock_input_handler_, 1185 EXPECT_CALL(mock_input_handler_,
1186 ScrollBy(testing::_, 1186 ScrollBy(testing::_,
(...skipping 19 matching lines...) Expand all
1206 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1206 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1207 1207
1208 // On the fling start, we should schedule an animation but not actually start 1208 // On the fling start, we should schedule an animation but not actually start
1209 // scrolling. 1209 // scrolling.
1210 gesture_.type = WebInputEvent::GestureFlingStart; 1210 gesture_.type = WebInputEvent::GestureFlingStart;
1211 WebFloatPoint fling_delta = WebFloatPoint(1000, 1000); 1211 WebFloatPoint fling_delta = WebFloatPoint(1000, 1000);
1212 gesture_.data.flingStart.velocityX = fling_delta.x; 1212 gesture_.data.flingStart.velocityX = fling_delta.x;
1213 gesture_.data.flingStart.velocityY = fling_delta.y; 1213 gesture_.data.flingStart.velocityY = fling_delta.y;
1214 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 1214 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
1215 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 1215 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1216 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1216 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1217 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1217 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1218 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1218 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1219 1219
1220 // The first animate doesn't cause any scrolling. 1220 // The first animate doesn't cause any scrolling.
1221 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1221 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1222 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); 1222 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
1223 input_handler_->Animate(time); 1223 input_handler_->Animate(time);
1224 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1224 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1225 1225
1226 // The second animate starts scrolling in the positive X and Y directions. 1226 // The second animate starts scrolling in the positive X and Y directions.
1227 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1227 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1228 EXPECT_CALL(mock_input_handler_, 1228 EXPECT_CALL(mock_input_handler_,
1229 ScrollBy(testing::_, 1229 ScrollBy(testing::_,
1230 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))) 1230 testing::Property(&gfx::Vector2dF::y, testing::Lt(0))))
1231 .WillOnce(testing::Return(true)); 1231 .WillOnce(testing::Return(true));
1232 time += base::TimeDelta::FromMilliseconds(10); 1232 time += base::TimeDelta::FromMilliseconds(10);
1233 input_handler_->Animate(time); 1233 input_handler_->Animate(time);
1234 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1234 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1235 1235
1236 // Simulate hitting the bottom content edge. 1236 // Simulate hitting the bottom content edge.
1237 gfx::Vector2dF accumulated_overscroll(0, 100); 1237 gfx::Vector2dF accumulated_overscroll(0, 100);
1238 gfx::Vector2dF latest_overscroll_delta(0, 100); 1238 gfx::Vector2dF latest_overscroll_delta(0, 100);
1239 EXPECT_CALL(mock_client_, 1239 EXPECT_CALL(mock_client_,
1240 DidOverscroll(testing::AllOf( 1240 DidOverscroll(testing::AllOf(
1241 testing::Field(&DidOverscrollParams::accumulated_overscroll, 1241 testing::Field(&DidOverscrollParams::accumulated_overscroll,
1242 testing::Eq(accumulated_overscroll)), 1242 testing::Eq(accumulated_overscroll)),
1243 testing::Field(&DidOverscrollParams::latest_overscroll_delta, 1243 testing::Field(&DidOverscrollParams::latest_overscroll_delta,
1244 testing::Eq(latest_overscroll_delta)), 1244 testing::Eq(latest_overscroll_delta)),
1245 testing::Field( 1245 testing::Field(
1246 &DidOverscrollParams::current_fling_velocity, 1246 &DidOverscrollParams::current_fling_velocity,
1247 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))))); 1247 testing::Property(&gfx::Vector2dF::y, testing::Lt(0))))));
1248 input_handler_->DidOverscroll(accumulated_overscroll, 1248 input_handler_->DidOverscroll(accumulated_overscroll,
1249 latest_overscroll_delta); 1249 latest_overscroll_delta);
1250 1250
1251 // The next call to animate will no longer scroll vertically. 1251 // The next call to animate will no longer scroll vertically.
1252 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1252 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1253 EXPECT_CALL(mock_input_handler_, 1253 EXPECT_CALL(mock_input_handler_,
1254 ScrollBy(testing::_, 1254 ScrollBy(testing::_,
1255 testing::Property(&gfx::Vector2dF::y, testing::Eq(0)))) 1255 testing::Property(&gfx::Vector2dF::y, testing::Eq(0))))
1256 .WillOnce(testing::Return(true)); 1256 .WillOnce(testing::Return(true));
1257 time += base::TimeDelta::FromMilliseconds(10); 1257 time += base::TimeDelta::FromMilliseconds(10);
1258 input_handler_->Animate(time); 1258 input_handler_->Animate(time);
1259 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1259 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1260 1260
1261 // Simulate hitting the right content edge. 1261 // Simulate hitting the right content edge.
1262 accumulated_overscroll = gfx::Vector2dF(100, 100); 1262 accumulated_overscroll = gfx::Vector2dF(100, 100);
1263 latest_overscroll_delta = gfx::Vector2dF(100, 0); 1263 latest_overscroll_delta = gfx::Vector2dF(100, 0);
1264 EXPECT_CALL(mock_client_, 1264 EXPECT_CALL(mock_client_,
1265 DidOverscroll(testing::AllOf( 1265 DidOverscroll(testing::AllOf(
1266 testing::Field(&DidOverscrollParams::accumulated_overscroll, 1266 testing::Field(&DidOverscrollParams::accumulated_overscroll,
1267 testing::Eq(accumulated_overscroll)), 1267 testing::Eq(accumulated_overscroll)),
1268 testing::Field(&DidOverscrollParams::latest_overscroll_delta, 1268 testing::Field(&DidOverscrollParams::latest_overscroll_delta,
1269 testing::Eq(latest_overscroll_delta)), 1269 testing::Eq(latest_overscroll_delta)),
1270 testing::Field( 1270 testing::Field(
1271 &DidOverscrollParams::current_fling_velocity, 1271 &DidOverscrollParams::current_fling_velocity,
1272 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))))); 1272 testing::Property(&gfx::Vector2dF::x, testing::Lt(0))))));
1273 input_handler_->DidOverscroll(accumulated_overscroll, 1273 input_handler_->DidOverscroll(accumulated_overscroll,
1274 latest_overscroll_delta); 1274 latest_overscroll_delta);
1275 // The next call to animate will no longer scroll horizontally or vertically, 1275 // The next call to animate will no longer scroll horizontally or vertically,
1276 // and the fling should be cancelled. 1276 // and the fling should be cancelled.
1277 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()).Times(0); 1277 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()).Times(0);
1278 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_, testing::_)).Times(0); 1278 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_, testing::_)).Times(0);
1279 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1279 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1280 time += base::TimeDelta::FromMilliseconds(10); 1280 time += base::TimeDelta::FromMilliseconds(10);
1281 input_handler_->Animate(time); 1281 input_handler_->Animate(time);
1282 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1282 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1283 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1283 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1284 } 1284 }
1285 1285
1286 TEST_F(InputHandlerProxyTest, MultiTouchPointHitTestNegative) { 1286 TEST_F(InputHandlerProxyTest, MultiTouchPointHitTestNegative) {
1287 // None of the three touch points fall in the touch region. So the event 1287 // 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
1356 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1356 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1357 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1357 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1358 1358
1359 // On the fling start, animation should be scheduled, but no scrolling occurs. 1359 // On the fling start, animation should be scheduled, but no scrolling occurs.
1360 gesture_.type = WebInputEvent::GestureFlingStart; 1360 gesture_.type = WebInputEvent::GestureFlingStart;
1361 WebFloatPoint fling_delta = WebFloatPoint(1000, 1000); 1361 WebFloatPoint fling_delta = WebFloatPoint(1000, 1000);
1362 gesture_.data.flingStart.velocityX = fling_delta.x; 1362 gesture_.data.flingStart.velocityX = fling_delta.x;
1363 gesture_.data.flingStart.velocityY = fling_delta.y; 1363 gesture_.data.flingStart.velocityY = fling_delta.y;
1364 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 1364 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
1365 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 1365 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1366 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1366 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1367 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1367 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1368 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1368 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1369 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1369 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1370 1370
1371 // Keyboard events received during a fling should cancel the active fling. 1371 // Keyboard events received during a fling should cancel the active fling.
1372 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1372 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1373 EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE, 1373 EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE,
1374 input_handler_->HandleInputEvent(key_event)); 1374 input_handler_->HandleInputEvent(key_event));
1375 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1375 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1376 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1376 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 int modifiers = WebInputEvent::ControlKey; 1411 int modifiers = WebInputEvent::ControlKey;
1412 gesture_.timeStampSeconds = startTimeOffset.InSecondsF(); 1412 gesture_.timeStampSeconds = startTimeOffset.InSecondsF();
1413 gesture_.data.flingStart.velocityX = fling_delta.x; 1413 gesture_.data.flingStart.velocityX = fling_delta.x;
1414 gesture_.data.flingStart.velocityY = fling_delta.y; 1414 gesture_.data.flingStart.velocityY = fling_delta.y;
1415 gesture_.sourceDevice = WebGestureEvent::Touchscreen; 1415 gesture_.sourceDevice = WebGestureEvent::Touchscreen;
1416 gesture_.x = fling_point.x; 1416 gesture_.x = fling_point.x;
1417 gesture_.y = fling_point.y; 1417 gesture_.y = fling_point.y;
1418 gesture_.globalX = fling_global_point.x; 1418 gesture_.globalX = fling_global_point.x;
1419 gesture_.globalY = fling_global_point.y; 1419 gesture_.globalY = fling_global_point.y;
1420 gesture_.modifiers = modifiers; 1420 gesture_.modifiers = modifiers;
1421 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1421 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1422 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 1422 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
1423 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 1423 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1424 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1424 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1425 1425
1426 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1426 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1427 1427
1428 // If we get a negative time delta, that is, the Animation tick time happens 1428 // If we get a negative time delta, that is, the Animation tick time happens
1429 // before the fling's start time then we should *not* try scrolling and 1429 // before the fling's start time then we should *not* try scrolling and
1430 // instead reset the fling start time. 1430 // instead reset the fling start time.
1431 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1431 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1432 EXPECT_CALL(mock_input_handler_, 1432 EXPECT_CALL(mock_input_handler_,
1433 ScrollBy(testing::_, 1433 ScrollBy(testing::_,
1434 testing::_)).Times(0); 1434 testing::_)).Times(0);
1435 base::TimeTicks time = 1435 base::TimeTicks time =
1436 base::TimeTicks() + base::TimeDelta::FromMilliseconds(8); 1436 base::TimeTicks() + base::TimeDelta::FromMilliseconds(8);
1437 input_handler_->Animate(time); 1437 input_handler_->Animate(time);
1438 1438
1439 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1439 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1440 1440
1441 // The first call should have reset the start time so subsequent calls should 1441 // The first call should have reset the start time so subsequent calls should
1442 // generate scroll events. 1442 // generate scroll events.
1443 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1443 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1444 EXPECT_CALL(mock_input_handler_, 1444 EXPECT_CALL(mock_input_handler_,
1445 ScrollBy(testing::_, 1445 ScrollBy(testing::_,
1446 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) 1446 testing::Property(&gfx::Vector2dF::x, testing::Lt(0))))
1447 .WillOnce(testing::Return(true)); 1447 .WillOnce(testing::Return(true));
1448 1448
1449 input_handler_->Animate(time + base::TimeDelta::FromMilliseconds(1)); 1449 input_handler_->Animate(time + base::TimeDelta::FromMilliseconds(1));
1450 1450
1451 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1451 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1452 1452
1453 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1453 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1454 gesture_.type = WebInputEvent::GestureFlingCancel; 1454 gesture_.type = WebInputEvent::GestureFlingCancel;
1455 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1455 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1456 } 1456 }
1457 1457
1458 } // namespace 1458 } // namespace
1459 } // namespace content 1459 } // namespace content
OLDNEW
« no previous file with comments | « trunk/src/content/renderer/input/input_handler_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698