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

Side by Side Diff: content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc

Issue 1545243002: Convert Pass()→std::move() in //content/browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h"
6
5 #include <stddef.h> 7 #include <stddef.h>
6 #include <stdint.h> 8 #include <stdint.h>
9 #include <utility>
7 10
8 #include "base/bind.h" 11 #include "base/bind.h"
9 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
10 #include "base/time/time.h" 13 #include "base/time/time.h"
11 #include "content/browser/renderer_host/input/synthetic_gesture.h" 14 #include "content/browser/renderer_host/input/synthetic_gesture.h"
12 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h"
13 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" 15 #include "content/browser/renderer_host/input/synthetic_gesture_target.h"
14 #include "content/browser/renderer_host/input/synthetic_pinch_gesture.h" 16 #include "content/browser/renderer_host/input/synthetic_pinch_gesture.h"
15 #include "content/browser/renderer_host/input/synthetic_pointer_action.h" 17 #include "content/browser/renderer_host/input/synthetic_pointer_action.h"
16 #include "content/browser/renderer_host/input/synthetic_smooth_drag_gesture.h" 18 #include "content/browser/renderer_host/input/synthetic_smooth_drag_gesture.h"
17 #include "content/browser/renderer_host/input/synthetic_smooth_move_gesture.h" 19 #include "content/browser/renderer_host/input/synthetic_smooth_move_gesture.h"
18 #include "content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.h" 20 #include "content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.h"
19 #include "content/browser/renderer_host/input/synthetic_tap_gesture.h" 21 #include "content/browser/renderer_host/input/synthetic_tap_gesture.h"
20 #include "content/browser/renderer_host/input/synthetic_touch_pointer.h" 22 #include "content/browser/renderer_host/input/synthetic_touch_pointer.h"
21 #include "content/browser/renderer_host/input/synthetic_touchpad_pinch_gesture.h " 23 #include "content/browser/renderer_host/input/synthetic_touchpad_pinch_gesture.h "
22 #include "content/browser/renderer_host/input/synthetic_touchscreen_pinch_gestur e.h" 24 #include "content/browser/renderer_host/input/synthetic_touchscreen_pinch_gestur e.h"
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 protected: 518 protected:
517 template<typename MockGestureTarget> 519 template<typename MockGestureTarget>
518 void CreateControllerAndTarget() { 520 void CreateControllerAndTarget() {
519 target_ = new MockGestureTarget(); 521 target_ = new MockGestureTarget();
520 controller_.reset(new SyntheticGestureController( 522 controller_.reset(new SyntheticGestureController(
521 scoped_ptr<SyntheticGestureTarget>(target_))); 523 scoped_ptr<SyntheticGestureTarget>(target_)));
522 } 524 }
523 525
524 void QueueSyntheticGesture(scoped_ptr<SyntheticGesture> gesture) { 526 void QueueSyntheticGesture(scoped_ptr<SyntheticGesture> gesture) {
525 controller_->QueueSyntheticGesture( 527 controller_->QueueSyntheticGesture(
526 gesture.Pass(), 528 std::move(gesture),
527 base::Bind( 529 base::Bind(
528 &SyntheticGestureControllerTestBase::OnSyntheticGestureCompleted, 530 &SyntheticGestureControllerTestBase::OnSyntheticGestureCompleted,
529 base::Unretained(this))); 531 base::Unretained(this)));
530 } 532 }
531 533
532 void FlushInputUntilComplete() { 534 void FlushInputUntilComplete() {
533 while (target_->flush_requested()) { 535 while (target_->flush_requested()) {
534 while (target_->flush_requested()) { 536 while (target_->flush_requested()) {
535 target_->ClearFlushRequest(); 537 target_->ClearFlushRequest();
536 time_ += base::TimeDelta::FromMilliseconds(kFlushInputRateInMs); 538 time_ += base::TimeDelta::FromMilliseconds(kFlushInputRateInMs);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 time_ = base::TimeTicks(); 595 time_ = base::TimeTicks();
594 } 596 }
595 }; 597 };
596 598
597 TEST_F(SyntheticGestureControllerTest, SingleGesture) { 599 TEST_F(SyntheticGestureControllerTest, SingleGesture) {
598 CreateControllerAndTarget<MockSyntheticGestureTarget>(); 600 CreateControllerAndTarget<MockSyntheticGestureTarget>();
599 601
600 bool finished = false; 602 bool finished = false;
601 scoped_ptr<MockSyntheticGesture> gesture( 603 scoped_ptr<MockSyntheticGesture> gesture(
602 new MockSyntheticGesture(&finished, 3)); 604 new MockSyntheticGesture(&finished, 3));
603 QueueSyntheticGesture(gesture.Pass()); 605 QueueSyntheticGesture(std::move(gesture));
604 FlushInputUntilComplete(); 606 FlushInputUntilComplete();
605 607
606 EXPECT_TRUE(finished); 608 EXPECT_TRUE(finished);
607 EXPECT_EQ(1, num_success_); 609 EXPECT_EQ(1, num_success_);
608 EXPECT_EQ(0, num_failure_); 610 EXPECT_EQ(0, num_failure_);
609 } 611 }
610 612
611 TEST_F(SyntheticGestureControllerTest, GestureFailed) { 613 TEST_F(SyntheticGestureControllerTest, GestureFailed) {
612 CreateControllerAndTarget<MockSyntheticGestureTarget>(); 614 CreateControllerAndTarget<MockSyntheticGestureTarget>();
613 615
614 bool finished = false; 616 bool finished = false;
615 scoped_ptr<MockSyntheticGesture> gesture( 617 scoped_ptr<MockSyntheticGesture> gesture(
616 new MockSyntheticGesture(&finished, 0)); 618 new MockSyntheticGesture(&finished, 0));
617 QueueSyntheticGesture(gesture.Pass()); 619 QueueSyntheticGesture(std::move(gesture));
618 FlushInputUntilComplete(); 620 FlushInputUntilComplete();
619 621
620 EXPECT_TRUE(finished); 622 EXPECT_TRUE(finished);
621 EXPECT_EQ(1, num_failure_); 623 EXPECT_EQ(1, num_failure_);
622 EXPECT_EQ(0, num_success_); 624 EXPECT_EQ(0, num_success_);
623 } 625 }
624 626
625 TEST_F(SyntheticGestureControllerTest, SuccessiveGestures) { 627 TEST_F(SyntheticGestureControllerTest, SuccessiveGestures) {
626 CreateControllerAndTarget<MockSyntheticGestureTarget>(); 628 CreateControllerAndTarget<MockSyntheticGestureTarget>();
627 629
628 bool finished_1 = false; 630 bool finished_1 = false;
629 scoped_ptr<MockSyntheticGesture> gesture_1( 631 scoped_ptr<MockSyntheticGesture> gesture_1(
630 new MockSyntheticGesture(&finished_1, 2)); 632 new MockSyntheticGesture(&finished_1, 2));
631 bool finished_2 = false; 633 bool finished_2 = false;
632 scoped_ptr<MockSyntheticGesture> gesture_2( 634 scoped_ptr<MockSyntheticGesture> gesture_2(
633 new MockSyntheticGesture(&finished_2, 4)); 635 new MockSyntheticGesture(&finished_2, 4));
634 636
635 // Queue first gesture and wait for it to finish 637 // Queue first gesture and wait for it to finish
636 QueueSyntheticGesture(gesture_1.Pass()); 638 QueueSyntheticGesture(std::move(gesture_1));
637 FlushInputUntilComplete(); 639 FlushInputUntilComplete();
638 640
639 EXPECT_TRUE(finished_1); 641 EXPECT_TRUE(finished_1);
640 EXPECT_EQ(1, num_success_); 642 EXPECT_EQ(1, num_success_);
641 EXPECT_EQ(0, num_failure_); 643 EXPECT_EQ(0, num_failure_);
642 644
643 // Queue second gesture. 645 // Queue second gesture.
644 QueueSyntheticGesture(gesture_2.Pass()); 646 QueueSyntheticGesture(std::move(gesture_2));
645 FlushInputUntilComplete(); 647 FlushInputUntilComplete();
646 648
647 EXPECT_TRUE(finished_2); 649 EXPECT_TRUE(finished_2);
648 EXPECT_EQ(2, num_success_); 650 EXPECT_EQ(2, num_success_);
649 EXPECT_EQ(0, num_failure_); 651 EXPECT_EQ(0, num_failure_);
650 } 652 }
651 653
652 TEST_F(SyntheticGestureControllerTest, TwoGesturesInFlight) { 654 TEST_F(SyntheticGestureControllerTest, TwoGesturesInFlight) {
653 CreateControllerAndTarget<MockSyntheticGestureTarget>(); 655 CreateControllerAndTarget<MockSyntheticGestureTarget>();
654 656
655 bool finished_1 = false; 657 bool finished_1 = false;
656 scoped_ptr<MockSyntheticGesture> gesture_1( 658 scoped_ptr<MockSyntheticGesture> gesture_1(
657 new MockSyntheticGesture(&finished_1, 2)); 659 new MockSyntheticGesture(&finished_1, 2));
658 bool finished_2 = false; 660 bool finished_2 = false;
659 scoped_ptr<MockSyntheticGesture> gesture_2( 661 scoped_ptr<MockSyntheticGesture> gesture_2(
660 new MockSyntheticGesture(&finished_2, 4)); 662 new MockSyntheticGesture(&finished_2, 4));
661 663
662 QueueSyntheticGesture(gesture_1.Pass()); 664 QueueSyntheticGesture(std::move(gesture_1));
663 QueueSyntheticGesture(gesture_2.Pass()); 665 QueueSyntheticGesture(std::move(gesture_2));
664 FlushInputUntilComplete(); 666 FlushInputUntilComplete();
665 667
666 EXPECT_TRUE(finished_1); 668 EXPECT_TRUE(finished_1);
667 EXPECT_TRUE(finished_2); 669 EXPECT_TRUE(finished_2);
668 670
669 EXPECT_EQ(2, num_success_); 671 EXPECT_EQ(2, num_success_);
670 EXPECT_EQ(0, num_failure_); 672 EXPECT_EQ(0, num_failure_);
671 } 673 }
672 674
673 TEST_F(SyntheticGestureControllerTest, GestureCompletedOnDidFlushInput) { 675 TEST_F(SyntheticGestureControllerTest, GestureCompletedOnDidFlushInput) {
674 CreateControllerAndTarget<MockSyntheticGestureTarget>(); 676 CreateControllerAndTarget<MockSyntheticGestureTarget>();
675 677
676 bool finished_1, finished_2; 678 bool finished_1, finished_2;
677 scoped_ptr<MockSyntheticGesture> gesture_1( 679 scoped_ptr<MockSyntheticGesture> gesture_1(
678 new MockSyntheticGesture(&finished_1, 2)); 680 new MockSyntheticGesture(&finished_1, 2));
679 scoped_ptr<MockSyntheticGesture> gesture_2( 681 scoped_ptr<MockSyntheticGesture> gesture_2(
680 new MockSyntheticGesture(&finished_2, 4)); 682 new MockSyntheticGesture(&finished_2, 4));
681 683
682 QueueSyntheticGesture(gesture_1.Pass()); 684 QueueSyntheticGesture(std::move(gesture_1));
683 QueueSyntheticGesture(gesture_2.Pass()); 685 QueueSyntheticGesture(std::move(gesture_2));
684 686
685 while (target_->flush_requested()) { 687 while (target_->flush_requested()) {
686 target_->ClearFlushRequest(); 688 target_->ClearFlushRequest();
687 time_ += base::TimeDelta::FromMilliseconds(kFlushInputRateInMs); 689 time_ += base::TimeDelta::FromMilliseconds(kFlushInputRateInMs);
688 controller_->Flush(time_); 690 controller_->Flush(time_);
689 } 691 }
690 EXPECT_EQ(0, num_success_); 692 EXPECT_EQ(0, num_success_);
691 controller_->OnDidFlushInput(); 693 controller_->OnDidFlushInput();
692 EXPECT_EQ(1, num_success_); 694 EXPECT_EQ(1, num_success_);
693 695
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 SyntheticSmoothMoveGestureParams params; 729 SyntheticSmoothMoveGestureParams params;
728 params.input_type = SyntheticSmoothMoveGestureParams::TOUCH_INPUT; 730 params.input_type = SyntheticSmoothMoveGestureParams::TOUCH_INPUT;
729 if (GetParam() == TOUCH_DRAG) { 731 if (GetParam() == TOUCH_DRAG) {
730 params.add_slop = false; 732 params.add_slop = false;
731 } 733 }
732 params.start_point.SetPoint(89, 32); 734 params.start_point.SetPoint(89, 32);
733 params.distances.push_back(gfx::Vector2d(0, 123)); 735 params.distances.push_back(gfx::Vector2d(0, 123));
734 736
735 scoped_ptr<SyntheticSmoothMoveGesture> gesture( 737 scoped_ptr<SyntheticSmoothMoveGesture> gesture(
736 new SyntheticSmoothMoveGesture(params)); 738 new SyntheticSmoothMoveGesture(params));
737 QueueSyntheticGesture(gesture.Pass()); 739 QueueSyntheticGesture(std::move(gesture));
738 FlushInputUntilComplete(); 740 FlushInputUntilComplete();
739 741
740 MockMoveGestureTarget* scroll_target = 742 MockMoveGestureTarget* scroll_target =
741 static_cast<MockMoveGestureTarget*>(target_); 743 static_cast<MockMoveGestureTarget*>(target_);
742 EXPECT_EQ(1, num_success_); 744 EXPECT_EQ(1, num_success_);
743 EXPECT_EQ(0, num_failure_); 745 EXPECT_EQ(0, num_failure_);
744 if (GetParam() == TOUCH_SCROLL) { 746 if (GetParam() == TOUCH_SCROLL) {
745 EXPECT_EQ(AddTouchSlopToVector(params.distances[0], target_), 747 EXPECT_EQ(AddTouchSlopToVector(params.distances[0], target_),
746 scroll_target->start_to_end_distance()); 748 scroll_target->start_to_end_distance());
747 } else { 749 } else {
748 EXPECT_EQ(params.distances[0], scroll_target->start_to_end_distance()); 750 EXPECT_EQ(params.distances[0], scroll_target->start_to_end_distance());
749 } 751 }
750 } 752 }
751 753
752 TEST_P(SyntheticGestureControllerTestWithParam, 754 TEST_P(SyntheticGestureControllerTestWithParam,
753 SingleScrollGestureTouchHorizontal) { 755 SingleScrollGestureTouchHorizontal) {
754 CreateControllerAndTarget<MockMoveTouchTarget>(); 756 CreateControllerAndTarget<MockMoveTouchTarget>();
755 757
756 SyntheticSmoothMoveGestureParams params; 758 SyntheticSmoothMoveGestureParams params;
757 params.input_type = SyntheticSmoothMoveGestureParams::TOUCH_INPUT; 759 params.input_type = SyntheticSmoothMoveGestureParams::TOUCH_INPUT;
758 if (GetParam() == TOUCH_DRAG) { 760 if (GetParam() == TOUCH_DRAG) {
759 params.add_slop = false; 761 params.add_slop = false;
760 } 762 }
761 params.start_point.SetPoint(12, -23); 763 params.start_point.SetPoint(12, -23);
762 params.distances.push_back(gfx::Vector2d(-234, 0)); 764 params.distances.push_back(gfx::Vector2d(-234, 0));
763 765
764 scoped_ptr<SyntheticSmoothMoveGesture> gesture( 766 scoped_ptr<SyntheticSmoothMoveGesture> gesture(
765 new SyntheticSmoothMoveGesture(params)); 767 new SyntheticSmoothMoveGesture(params));
766 QueueSyntheticGesture(gesture.Pass()); 768 QueueSyntheticGesture(std::move(gesture));
767 FlushInputUntilComplete(); 769 FlushInputUntilComplete();
768 770
769 MockMoveGestureTarget* scroll_target = 771 MockMoveGestureTarget* scroll_target =
770 static_cast<MockMoveGestureTarget*>(target_); 772 static_cast<MockMoveGestureTarget*>(target_);
771 EXPECT_EQ(1, num_success_); 773 EXPECT_EQ(1, num_success_);
772 EXPECT_EQ(0, num_failure_); 774 EXPECT_EQ(0, num_failure_);
773 if (GetParam() == TOUCH_SCROLL) { 775 if (GetParam() == TOUCH_SCROLL) {
774 EXPECT_EQ(AddTouchSlopToVector(params.distances[0], target_), 776 EXPECT_EQ(AddTouchSlopToVector(params.distances[0], target_),
775 scroll_target->start_to_end_distance()); 777 scroll_target->start_to_end_distance());
776 } else { 778 } else {
(...skipping 24 matching lines...) Expand all
801 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureTouchDiagonal) { 803 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureTouchDiagonal) {
802 CreateControllerAndTarget<MockMoveTouchTarget>(); 804 CreateControllerAndTarget<MockMoveTouchTarget>();
803 805
804 SyntheticSmoothMoveGestureParams params; 806 SyntheticSmoothMoveGestureParams params;
805 params.input_type = SyntheticSmoothMoveGestureParams::TOUCH_INPUT; 807 params.input_type = SyntheticSmoothMoveGestureParams::TOUCH_INPUT;
806 params.start_point.SetPoint(0, 7); 808 params.start_point.SetPoint(0, 7);
807 params.distances.push_back(gfx::Vector2d(413, -83)); 809 params.distances.push_back(gfx::Vector2d(413, -83));
808 810
809 scoped_ptr<SyntheticSmoothMoveGesture> gesture( 811 scoped_ptr<SyntheticSmoothMoveGesture> gesture(
810 new SyntheticSmoothMoveGesture(params)); 812 new SyntheticSmoothMoveGesture(params));
811 QueueSyntheticGesture(gesture.Pass()); 813 QueueSyntheticGesture(std::move(gesture));
812 FlushInputUntilComplete(); 814 FlushInputUntilComplete();
813 815
814 MockMoveGestureTarget* scroll_target = 816 MockMoveGestureTarget* scroll_target =
815 static_cast<MockMoveGestureTarget*>(target_); 817 static_cast<MockMoveGestureTarget*>(target_);
816 EXPECT_EQ(1, num_success_); 818 EXPECT_EQ(1, num_success_);
817 EXPECT_EQ(0, num_failure_); 819 EXPECT_EQ(0, num_failure_);
818 CheckSingleScrollDistanceIsWithinRange( 820 CheckSingleScrollDistanceIsWithinRange(
819 scroll_target->start_to_end_distance(), params.distances[0], target_); 821 scroll_target->start_to_end_distance(), params.distances[0], target_);
820 } 822 }
821 823
822 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureTouchLongStop) { 824 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureTouchLongStop) {
823 CreateControllerAndTarget<MockMoveTouchTarget>(); 825 CreateControllerAndTarget<MockMoveTouchTarget>();
824 826
825 // Create a smooth scroll with a short distance and set the pointer assumed 827 // Create a smooth scroll with a short distance and set the pointer assumed
826 // stopped time high, so that the stopping should dominate the time the 828 // stopped time high, so that the stopping should dominate the time the
827 // gesture is active. 829 // gesture is active.
828 SyntheticSmoothMoveGestureParams params; 830 SyntheticSmoothMoveGestureParams params;
829 params.input_type = SyntheticSmoothMoveGestureParams::TOUCH_INPUT; 831 params.input_type = SyntheticSmoothMoveGestureParams::TOUCH_INPUT;
830 params.start_point.SetPoint(-98, -23); 832 params.start_point.SetPoint(-98, -23);
831 params.distances.push_back(gfx::Vector2d(21, -12)); 833 params.distances.push_back(gfx::Vector2d(21, -12));
832 params.prevent_fling = true; 834 params.prevent_fling = true;
833 target_->set_pointer_assumed_stopped_time_ms(543); 835 target_->set_pointer_assumed_stopped_time_ms(543);
834 836
835 scoped_ptr<SyntheticSmoothMoveGesture> gesture( 837 scoped_ptr<SyntheticSmoothMoveGesture> gesture(
836 new SyntheticSmoothMoveGesture(params)); 838 new SyntheticSmoothMoveGesture(params));
837 QueueSyntheticGesture(gesture.Pass()); 839 QueueSyntheticGesture(std::move(gesture));
838 FlushInputUntilComplete(); 840 FlushInputUntilComplete();
839 841
840 MockMoveGestureTarget* scroll_target = 842 MockMoveGestureTarget* scroll_target =
841 static_cast<MockMoveGestureTarget*>(target_); 843 static_cast<MockMoveGestureTarget*>(target_);
842 EXPECT_EQ(1, num_success_); 844 EXPECT_EQ(1, num_success_);
843 EXPECT_EQ(0, num_failure_); 845 EXPECT_EQ(0, num_failure_);
844 CheckSingleScrollDistanceIsWithinRange( 846 CheckSingleScrollDistanceIsWithinRange(
845 scroll_target->start_to_end_distance(), params.distances[0], target_); 847 scroll_target->start_to_end_distance(), params.distances[0], target_);
846 EXPECT_GE(GetTotalTime(), target_->PointerAssumedStoppedTime()); 848 EXPECT_GE(GetTotalTime(), target_->PointerAssumedStoppedTime());
847 } 849 }
848 850
849 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureTouchFling) { 851 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureTouchFling) {
850 CreateControllerAndTarget<MockMoveTouchTarget>(); 852 CreateControllerAndTarget<MockMoveTouchTarget>();
851 853
852 // Create a smooth scroll with a short distance and set the pointer assumed 854 // Create a smooth scroll with a short distance and set the pointer assumed
853 // stopped time high. Disable 'prevent_fling' and check that the gesture 855 // stopped time high. Disable 'prevent_fling' and check that the gesture
854 // finishes without waiting before it stops. 856 // finishes without waiting before it stops.
855 SyntheticSmoothMoveGestureParams params; 857 SyntheticSmoothMoveGestureParams params;
856 params.input_type = SyntheticSmoothMoveGestureParams::TOUCH_INPUT; 858 params.input_type = SyntheticSmoothMoveGestureParams::TOUCH_INPUT;
857 params.start_point.SetPoint(-89, 78); 859 params.start_point.SetPoint(-89, 78);
858 params.distances.push_back(gfx::Vector2d(-43, 19)); 860 params.distances.push_back(gfx::Vector2d(-43, 19));
859 params.prevent_fling = false; 861 params.prevent_fling = false;
860 862
861 target_->set_pointer_assumed_stopped_time_ms(543); 863 target_->set_pointer_assumed_stopped_time_ms(543);
862 864
863 scoped_ptr<SyntheticSmoothMoveGesture> gesture( 865 scoped_ptr<SyntheticSmoothMoveGesture> gesture(
864 new SyntheticSmoothMoveGesture(params)); 866 new SyntheticSmoothMoveGesture(params));
865 QueueSyntheticGesture(gesture.Pass()); 867 QueueSyntheticGesture(std::move(gesture));
866 FlushInputUntilComplete(); 868 FlushInputUntilComplete();
867 869
868 MockMoveGestureTarget* scroll_target = 870 MockMoveGestureTarget* scroll_target =
869 static_cast<MockMoveGestureTarget*>(target_); 871 static_cast<MockMoveGestureTarget*>(target_);
870 EXPECT_EQ(1, num_success_); 872 EXPECT_EQ(1, num_success_);
871 EXPECT_EQ(0, num_failure_); 873 EXPECT_EQ(0, num_failure_);
872 CheckSingleScrollDistanceIsWithinRange( 874 CheckSingleScrollDistanceIsWithinRange(
873 scroll_target->start_to_end_distance(), params.distances[0], target_); 875 scroll_target->start_to_end_distance(), params.distances[0], target_);
874 EXPECT_LE(GetTotalTime(), target_->PointerAssumedStoppedTime()); 876 EXPECT_LE(GetTotalTime(), target_->PointerAssumedStoppedTime());
875 } 877 }
876 878
877 TEST_P(SyntheticGestureControllerTestWithParam, 879 TEST_P(SyntheticGestureControllerTestWithParam,
878 SingleScrollGestureTouchZeroDistance) { 880 SingleScrollGestureTouchZeroDistance) {
879 CreateControllerAndTarget<MockMoveTouchTarget>(); 881 CreateControllerAndTarget<MockMoveTouchTarget>();
880 882
881 SyntheticSmoothMoveGestureParams params; 883 SyntheticSmoothMoveGestureParams params;
882 params.input_type = SyntheticSmoothMoveGestureParams::TOUCH_INPUT; 884 params.input_type = SyntheticSmoothMoveGestureParams::TOUCH_INPUT;
883 if (GetParam() == TOUCH_DRAG) { 885 if (GetParam() == TOUCH_DRAG) {
884 params.add_slop = false; 886 params.add_slop = false;
885 } 887 }
886 params.start_point.SetPoint(-32, 43); 888 params.start_point.SetPoint(-32, 43);
887 params.distances.push_back(gfx::Vector2d(0, 0)); 889 params.distances.push_back(gfx::Vector2d(0, 0));
888 890
889 scoped_ptr<SyntheticSmoothMoveGesture> gesture( 891 scoped_ptr<SyntheticSmoothMoveGesture> gesture(
890 new SyntheticSmoothMoveGesture(params)); 892 new SyntheticSmoothMoveGesture(params));
891 QueueSyntheticGesture(gesture.Pass()); 893 QueueSyntheticGesture(std::move(gesture));
892 FlushInputUntilComplete(); 894 FlushInputUntilComplete();
893 895
894 MockMoveGestureTarget* scroll_target = 896 MockMoveGestureTarget* scroll_target =
895 static_cast<MockMoveGestureTarget*>(target_); 897 static_cast<MockMoveGestureTarget*>(target_);
896 EXPECT_EQ(1, num_success_); 898 EXPECT_EQ(1, num_success_);
897 EXPECT_EQ(0, num_failure_); 899 EXPECT_EQ(0, num_failure_);
898 EXPECT_EQ(gfx::Vector2dF(0, 0), scroll_target->start_to_end_distance()); 900 EXPECT_EQ(gfx::Vector2dF(0, 0), scroll_target->start_to_end_distance());
899 } 901 }
900 902
901 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureMouseVertical) { 903 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureMouseVertical) {
902 CreateControllerAndTarget<MockScrollMouseTarget>(); 904 CreateControllerAndTarget<MockScrollMouseTarget>();
903 905
904 SyntheticSmoothMoveGestureParams params; 906 SyntheticSmoothMoveGestureParams params;
905 params.input_type = SyntheticSmoothMoveGestureParams::MOUSE_WHEEL_INPUT; 907 params.input_type = SyntheticSmoothMoveGestureParams::MOUSE_WHEEL_INPUT;
906 params.start_point.SetPoint(432, 89); 908 params.start_point.SetPoint(432, 89);
907 params.distances.push_back(gfx::Vector2d(0, -234)); 909 params.distances.push_back(gfx::Vector2d(0, -234));
908 910
909 scoped_ptr<SyntheticSmoothMoveGesture> gesture( 911 scoped_ptr<SyntheticSmoothMoveGesture> gesture(
910 new SyntheticSmoothMoveGesture(params)); 912 new SyntheticSmoothMoveGesture(params));
911 QueueSyntheticGesture(gesture.Pass()); 913 QueueSyntheticGesture(std::move(gesture));
912 FlushInputUntilComplete(); 914 FlushInputUntilComplete();
913 915
914 MockMoveGestureTarget* scroll_target = 916 MockMoveGestureTarget* scroll_target =
915 static_cast<MockMoveGestureTarget*>(target_); 917 static_cast<MockMoveGestureTarget*>(target_);
916 EXPECT_EQ(1, num_success_); 918 EXPECT_EQ(1, num_success_);
917 EXPECT_EQ(0, num_failure_); 919 EXPECT_EQ(0, num_failure_);
918 EXPECT_EQ(params.distances[0], scroll_target->start_to_end_distance()); 920 EXPECT_EQ(params.distances[0], scroll_target->start_to_end_distance());
919 } 921 }
920 922
921 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureMouseHorizontal) { 923 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureMouseHorizontal) {
922 CreateControllerAndTarget<MockScrollMouseTarget>(); 924 CreateControllerAndTarget<MockScrollMouseTarget>();
923 925
924 SyntheticSmoothMoveGestureParams params; 926 SyntheticSmoothMoveGestureParams params;
925 params.input_type = SyntheticSmoothMoveGestureParams::MOUSE_WHEEL_INPUT; 927 params.input_type = SyntheticSmoothMoveGestureParams::MOUSE_WHEEL_INPUT;
926 params.start_point.SetPoint(90, 12); 928 params.start_point.SetPoint(90, 12);
927 params.distances.push_back(gfx::Vector2d(345, 0)); 929 params.distances.push_back(gfx::Vector2d(345, 0));
928 930
929 scoped_ptr<SyntheticSmoothMoveGesture> gesture( 931 scoped_ptr<SyntheticSmoothMoveGesture> gesture(
930 new SyntheticSmoothMoveGesture(params)); 932 new SyntheticSmoothMoveGesture(params));
931 QueueSyntheticGesture(gesture.Pass()); 933 QueueSyntheticGesture(std::move(gesture));
932 FlushInputUntilComplete(); 934 FlushInputUntilComplete();
933 935
934 MockMoveGestureTarget* scroll_target = 936 MockMoveGestureTarget* scroll_target =
935 static_cast<MockMoveGestureTarget*>(target_); 937 static_cast<MockMoveGestureTarget*>(target_);
936 EXPECT_EQ(1, num_success_); 938 EXPECT_EQ(1, num_success_);
937 EXPECT_EQ(0, num_failure_); 939 EXPECT_EQ(0, num_failure_);
938 EXPECT_EQ(params.distances[0], scroll_target->start_to_end_distance()); 940 EXPECT_EQ(params.distances[0], scroll_target->start_to_end_distance());
939 } 941 }
940 942
941 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureMouseDiagonal) { 943 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureMouseDiagonal) {
942 CreateControllerAndTarget<MockScrollMouseTarget>(); 944 CreateControllerAndTarget<MockScrollMouseTarget>();
943 945
944 SyntheticSmoothMoveGestureParams params; 946 SyntheticSmoothMoveGestureParams params;
945 params.input_type = SyntheticSmoothMoveGestureParams::MOUSE_WHEEL_INPUT; 947 params.input_type = SyntheticSmoothMoveGestureParams::MOUSE_WHEEL_INPUT;
946 params.start_point.SetPoint(90, 12); 948 params.start_point.SetPoint(90, 12);
947 params.distances.push_back(gfx::Vector2d(-194, 303)); 949 params.distances.push_back(gfx::Vector2d(-194, 303));
948 950
949 scoped_ptr<SyntheticSmoothMoveGesture> gesture( 951 scoped_ptr<SyntheticSmoothMoveGesture> gesture(
950 new SyntheticSmoothMoveGesture(params)); 952 new SyntheticSmoothMoveGesture(params));
951 QueueSyntheticGesture(gesture.Pass()); 953 QueueSyntheticGesture(std::move(gesture));
952 FlushInputUntilComplete(); 954 FlushInputUntilComplete();
953 955
954 MockMoveGestureTarget* scroll_target = 956 MockMoveGestureTarget* scroll_target =
955 static_cast<MockMoveGestureTarget*>(target_); 957 static_cast<MockMoveGestureTarget*>(target_);
956 EXPECT_EQ(1, num_success_); 958 EXPECT_EQ(1, num_success_);
957 EXPECT_EQ(0, num_failure_); 959 EXPECT_EQ(0, num_failure_);
958 EXPECT_EQ(params.distances[0], scroll_target->start_to_end_distance()); 960 EXPECT_EQ(params.distances[0], scroll_target->start_to_end_distance());
959 } 961 }
960 962
961 TEST_F(SyntheticGestureControllerTest, MultiScrollGestureMouse) { 963 TEST_F(SyntheticGestureControllerTest, MultiScrollGestureMouse) {
962 CreateControllerAndTarget<MockScrollMouseTarget>(); 964 CreateControllerAndTarget<MockScrollMouseTarget>();
963 965
964 SyntheticSmoothMoveGestureParams params; 966 SyntheticSmoothMoveGestureParams params;
965 params.input_type = SyntheticSmoothMoveGestureParams::MOUSE_WHEEL_INPUT; 967 params.input_type = SyntheticSmoothMoveGestureParams::MOUSE_WHEEL_INPUT;
966 params.start_point.SetPoint(90, 12); 968 params.start_point.SetPoint(90, 12);
967 params.distances.push_back(gfx::Vector2d(-129, 212)); 969 params.distances.push_back(gfx::Vector2d(-129, 212));
968 params.distances.push_back(gfx::Vector2d(8, -9)); 970 params.distances.push_back(gfx::Vector2d(8, -9));
969 971
970 scoped_ptr<SyntheticSmoothMoveGesture> gesture( 972 scoped_ptr<SyntheticSmoothMoveGesture> gesture(
971 new SyntheticSmoothMoveGesture(params)); 973 new SyntheticSmoothMoveGesture(params));
972 QueueSyntheticGesture(gesture.Pass()); 974 QueueSyntheticGesture(std::move(gesture));
973 FlushInputUntilComplete(); 975 FlushInputUntilComplete();
974 976
975 MockMoveGestureTarget* scroll_target = 977 MockMoveGestureTarget* scroll_target =
976 static_cast<MockMoveGestureTarget*>(target_); 978 static_cast<MockMoveGestureTarget*>(target_);
977 EXPECT_EQ(1, num_success_); 979 EXPECT_EQ(1, num_success_);
978 EXPECT_EQ(0, num_failure_); 980 EXPECT_EQ(0, num_failure_);
979 EXPECT_EQ(params.distances[0] + params.distances[1], 981 EXPECT_EQ(params.distances[0] + params.distances[1],
980 scroll_target->start_to_end_distance()); 982 scroll_target->start_to_end_distance());
981 } 983 }
982 984
983 TEST_F(SyntheticGestureControllerTest, MultiScrollGestureMouseHorizontal) { 985 TEST_F(SyntheticGestureControllerTest, MultiScrollGestureMouseHorizontal) {
984 CreateControllerAndTarget<MockScrollMouseTarget>(); 986 CreateControllerAndTarget<MockScrollMouseTarget>();
985 987
986 SyntheticSmoothMoveGestureParams params; 988 SyntheticSmoothMoveGestureParams params;
987 params.input_type = SyntheticSmoothMoveGestureParams::MOUSE_WHEEL_INPUT; 989 params.input_type = SyntheticSmoothMoveGestureParams::MOUSE_WHEEL_INPUT;
988 params.start_point.SetPoint(90, 12); 990 params.start_point.SetPoint(90, 12);
989 params.distances.push_back(gfx::Vector2d(-129, 0)); 991 params.distances.push_back(gfx::Vector2d(-129, 0));
990 params.distances.push_back(gfx::Vector2d(79, 0)); 992 params.distances.push_back(gfx::Vector2d(79, 0));
991 993
992 scoped_ptr<SyntheticSmoothMoveGesture> gesture( 994 scoped_ptr<SyntheticSmoothMoveGesture> gesture(
993 new SyntheticSmoothMoveGesture(params)); 995 new SyntheticSmoothMoveGesture(params));
994 QueueSyntheticGesture(gesture.Pass()); 996 QueueSyntheticGesture(std::move(gesture));
995 FlushInputUntilComplete(); 997 FlushInputUntilComplete();
996 998
997 MockMoveGestureTarget* scroll_target = 999 MockMoveGestureTarget* scroll_target =
998 static_cast<MockMoveGestureTarget*>(target_); 1000 static_cast<MockMoveGestureTarget*>(target_);
999 EXPECT_EQ(1, num_success_); 1001 EXPECT_EQ(1, num_success_);
1000 EXPECT_EQ(0, num_failure_); 1002 EXPECT_EQ(0, num_failure_);
1001 // This check only works for horizontal or vertical scrolls because of 1003 // This check only works for horizontal or vertical scrolls because of
1002 // floating point precision issues with diagonal scrolls. 1004 // floating point precision issues with diagonal scrolls.
1003 EXPECT_FLOAT_EQ(params.distances[0].Length() + params.distances[1].Length(), 1005 EXPECT_FLOAT_EQ(params.distances[0].Length() + params.distances[1].Length(),
1004 scroll_target->total_abs_move_distance_length()); 1006 scroll_target->total_abs_move_distance_length());
(...skipping 25 matching lines...) Expand all
1030 CreateControllerAndTarget<MockMoveTouchTarget>(); 1032 CreateControllerAndTarget<MockMoveTouchTarget>();
1031 1033
1032 SyntheticSmoothMoveGestureParams params; 1034 SyntheticSmoothMoveGestureParams params;
1033 params.input_type = SyntheticSmoothMoveGestureParams::TOUCH_INPUT; 1035 params.input_type = SyntheticSmoothMoveGestureParams::TOUCH_INPUT;
1034 params.start_point.SetPoint(8, -13); 1036 params.start_point.SetPoint(8, -13);
1035 params.distances.push_back(gfx::Vector2d(234, 133)); 1037 params.distances.push_back(gfx::Vector2d(234, 133));
1036 params.distances.push_back(gfx::Vector2d(-9, 78)); 1038 params.distances.push_back(gfx::Vector2d(-9, 78));
1037 1039
1038 scoped_ptr<SyntheticSmoothMoveGesture> gesture( 1040 scoped_ptr<SyntheticSmoothMoveGesture> gesture(
1039 new SyntheticSmoothMoveGesture(params)); 1041 new SyntheticSmoothMoveGesture(params));
1040 QueueSyntheticGesture(gesture.Pass()); 1042 QueueSyntheticGesture(std::move(gesture));
1041 FlushInputUntilComplete(); 1043 FlushInputUntilComplete();
1042 1044
1043 MockMoveGestureTarget* scroll_target = 1045 MockMoveGestureTarget* scroll_target =
1044 static_cast<MockMoveGestureTarget*>(target_); 1046 static_cast<MockMoveGestureTarget*>(target_);
1045 EXPECT_EQ(1, num_success_); 1047 EXPECT_EQ(1, num_success_);
1046 EXPECT_EQ(0, num_failure_); 1048 EXPECT_EQ(0, num_failure_);
1047 CheckMultiScrollDistanceIsWithinRange( 1049 CheckMultiScrollDistanceIsWithinRange(
1048 scroll_target->start_to_end_distance(), 1050 scroll_target->start_to_end_distance(),
1049 params.distances[0] + params.distances[1], 1051 params.distances[0] + params.distances[1],
1050 target_); 1052 target_);
1051 } 1053 }
1052 1054
1053 TEST_P(SyntheticGestureControllerTestWithParam, 1055 TEST_P(SyntheticGestureControllerTestWithParam,
1054 MultiScrollGestureTouchVertical) { 1056 MultiScrollGestureTouchVertical) {
1055 CreateControllerAndTarget<MockMoveTouchTarget>(); 1057 CreateControllerAndTarget<MockMoveTouchTarget>();
1056 1058
1057 SyntheticSmoothMoveGestureParams params; 1059 SyntheticSmoothMoveGestureParams params;
1058 params.input_type = SyntheticSmoothMoveGestureParams::TOUCH_INPUT; 1060 params.input_type = SyntheticSmoothMoveGestureParams::TOUCH_INPUT;
1059 if (GetParam() == TOUCH_DRAG) { 1061 if (GetParam() == TOUCH_DRAG) {
1060 params.add_slop = false; 1062 params.add_slop = false;
1061 } 1063 }
1062 params.start_point.SetPoint(234, -13); 1064 params.start_point.SetPoint(234, -13);
1063 params.distances.push_back(gfx::Vector2d(0, 133)); 1065 params.distances.push_back(gfx::Vector2d(0, 133));
1064 params.distances.push_back(gfx::Vector2d(0, 78)); 1066 params.distances.push_back(gfx::Vector2d(0, 78));
1065 1067
1066 scoped_ptr<SyntheticSmoothMoveGesture> gesture( 1068 scoped_ptr<SyntheticSmoothMoveGesture> gesture(
1067 new SyntheticSmoothMoveGesture(params)); 1069 new SyntheticSmoothMoveGesture(params));
1068 QueueSyntheticGesture(gesture.Pass()); 1070 QueueSyntheticGesture(std::move(gesture));
1069 FlushInputUntilComplete(); 1071 FlushInputUntilComplete();
1070 1072
1071 MockMoveGestureTarget* scroll_target = 1073 MockMoveGestureTarget* scroll_target =
1072 static_cast<MockMoveGestureTarget*>(target_); 1074 static_cast<MockMoveGestureTarget*>(target_);
1073 EXPECT_EQ(1, num_success_); 1075 EXPECT_EQ(1, num_success_);
1074 EXPECT_EQ(0, num_failure_); 1076 EXPECT_EQ(0, num_failure_);
1075 if (GetParam() == TOUCH_SCROLL) { 1077 if (GetParam() == TOUCH_SCROLL) {
1076 EXPECT_FLOAT_EQ(params.distances[0].Length() + 1078 EXPECT_FLOAT_EQ(params.distances[0].Length() +
1077 params.distances[1].Length() + 1079 params.distances[1].Length() +
1078 target_->GetTouchSlopInDips(), 1080 target_->GetTouchSlopInDips(),
(...skipping 16 matching lines...) Expand all
1095 TEST_F(SyntheticGestureControllerTest, SingleDragGestureMouseDiagonal) { 1097 TEST_F(SyntheticGestureControllerTest, SingleDragGestureMouseDiagonal) {
1096 CreateControllerAndTarget<MockDragMouseTarget>(); 1098 CreateControllerAndTarget<MockDragMouseTarget>();
1097 1099
1098 SyntheticSmoothMoveGestureParams params; 1100 SyntheticSmoothMoveGestureParams params;
1099 params.input_type = SyntheticSmoothMoveGestureParams::MOUSE_DRAG_INPUT; 1101 params.input_type = SyntheticSmoothMoveGestureParams::MOUSE_DRAG_INPUT;
1100 params.start_point.SetPoint(0, 7); 1102 params.start_point.SetPoint(0, 7);
1101 params.distances.push_back(gfx::Vector2d(413, -83)); 1103 params.distances.push_back(gfx::Vector2d(413, -83));
1102 1104
1103 scoped_ptr<SyntheticSmoothMoveGesture> gesture( 1105 scoped_ptr<SyntheticSmoothMoveGesture> gesture(
1104 new SyntheticSmoothMoveGesture(params)); 1106 new SyntheticSmoothMoveGesture(params));
1105 QueueSyntheticGesture(gesture.Pass()); 1107 QueueSyntheticGesture(std::move(gesture));
1106 FlushInputUntilComplete(); 1108 FlushInputUntilComplete();
1107 1109
1108 MockMoveGestureTarget* drag_target = 1110 MockMoveGestureTarget* drag_target =
1109 static_cast<MockMoveGestureTarget*>(target_); 1111 static_cast<MockMoveGestureTarget*>(target_);
1110 EXPECT_EQ(1, num_success_); 1112 EXPECT_EQ(1, num_success_);
1111 EXPECT_EQ(0, num_failure_); 1113 EXPECT_EQ(0, num_failure_);
1112 EXPECT_EQ(drag_target->start_to_end_distance(), params.distances[0]); 1114 EXPECT_EQ(drag_target->start_to_end_distance(), params.distances[0]);
1113 } 1115 }
1114 1116
1115 TEST_F(SyntheticGestureControllerTest, SingleDragGestureMouseZeroDistance) { 1117 TEST_F(SyntheticGestureControllerTest, SingleDragGestureMouseZeroDistance) {
1116 CreateControllerAndTarget<MockDragMouseTarget>(); 1118 CreateControllerAndTarget<MockDragMouseTarget>();
1117 1119
1118 SyntheticSmoothMoveGestureParams params; 1120 SyntheticSmoothMoveGestureParams params;
1119 params.input_type = SyntheticSmoothMoveGestureParams::MOUSE_DRAG_INPUT; 1121 params.input_type = SyntheticSmoothMoveGestureParams::MOUSE_DRAG_INPUT;
1120 params.start_point.SetPoint(-32, 43); 1122 params.start_point.SetPoint(-32, 43);
1121 params.distances.push_back(gfx::Vector2d(0, 0)); 1123 params.distances.push_back(gfx::Vector2d(0, 0));
1122 1124
1123 scoped_ptr<SyntheticSmoothMoveGesture> gesture( 1125 scoped_ptr<SyntheticSmoothMoveGesture> gesture(
1124 new SyntheticSmoothMoveGesture(params)); 1126 new SyntheticSmoothMoveGesture(params));
1125 QueueSyntheticGesture(gesture.Pass()); 1127 QueueSyntheticGesture(std::move(gesture));
1126 FlushInputUntilComplete(); 1128 FlushInputUntilComplete();
1127 1129
1128 MockMoveGestureTarget* drag_target = 1130 MockMoveGestureTarget* drag_target =
1129 static_cast<MockMoveGestureTarget*>(target_); 1131 static_cast<MockMoveGestureTarget*>(target_);
1130 EXPECT_EQ(1, num_success_); 1132 EXPECT_EQ(1, num_success_);
1131 EXPECT_EQ(0, num_failure_); 1133 EXPECT_EQ(0, num_failure_);
1132 EXPECT_EQ(gfx::Vector2dF(0, 0), drag_target->start_to_end_distance()); 1134 EXPECT_EQ(gfx::Vector2dF(0, 0), drag_target->start_to_end_distance());
1133 } 1135 }
1134 1136
1135 TEST_F(SyntheticGestureControllerTest, MultiDragGestureMouse) { 1137 TEST_F(SyntheticGestureControllerTest, MultiDragGestureMouse) {
1136 CreateControllerAndTarget<MockDragMouseTarget>(); 1138 CreateControllerAndTarget<MockDragMouseTarget>();
1137 1139
1138 SyntheticSmoothMoveGestureParams params; 1140 SyntheticSmoothMoveGestureParams params;
1139 params.input_type = SyntheticSmoothMoveGestureParams::MOUSE_DRAG_INPUT; 1141 params.input_type = SyntheticSmoothMoveGestureParams::MOUSE_DRAG_INPUT;
1140 params.start_point.SetPoint(8, -13); 1142 params.start_point.SetPoint(8, -13);
1141 params.distances.push_back(gfx::Vector2d(234, 133)); 1143 params.distances.push_back(gfx::Vector2d(234, 133));
1142 params.distances.push_back(gfx::Vector2d(-9, 78)); 1144 params.distances.push_back(gfx::Vector2d(-9, 78));
1143 1145
1144 scoped_ptr<SyntheticSmoothMoveGesture> gesture( 1146 scoped_ptr<SyntheticSmoothMoveGesture> gesture(
1145 new SyntheticSmoothMoveGesture(params)); 1147 new SyntheticSmoothMoveGesture(params));
1146 QueueSyntheticGesture(gesture.Pass()); 1148 QueueSyntheticGesture(std::move(gesture));
1147 FlushInputUntilComplete(); 1149 FlushInputUntilComplete();
1148 1150
1149 MockMoveGestureTarget* drag_target = 1151 MockMoveGestureTarget* drag_target =
1150 static_cast<MockMoveGestureTarget*>(target_); 1152 static_cast<MockMoveGestureTarget*>(target_);
1151 EXPECT_EQ(1, num_success_); 1153 EXPECT_EQ(1, num_success_);
1152 EXPECT_EQ(0, num_failure_); 1154 EXPECT_EQ(0, num_failure_);
1153 EXPECT_EQ(drag_target->start_to_end_distance(), 1155 EXPECT_EQ(drag_target->start_to_end_distance(),
1154 params.distances[0] + params.distances[1]); 1156 params.distances[0] + params.distances[1]);
1155 } 1157 }
1156 1158
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 TouchscreenTouchpadPinchGestureTouchZoomIn) { 1220 TouchscreenTouchpadPinchGestureTouchZoomIn) {
1219 CreateControllerAndTarget<MockSyntheticTouchscreenPinchTouchTarget>(); 1221 CreateControllerAndTarget<MockSyntheticTouchscreenPinchTouchTarget>();
1220 1222
1221 SyntheticPinchGestureParams params; 1223 SyntheticPinchGestureParams params;
1222 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; 1224 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
1223 params.scale_factor = 2.3f; 1225 params.scale_factor = 2.3f;
1224 params.anchor.SetPoint(54, 89); 1226 params.anchor.SetPoint(54, 89);
1225 1227
1226 scoped_ptr<SyntheticTouchscreenPinchGesture> gesture( 1228 scoped_ptr<SyntheticTouchscreenPinchGesture> gesture(
1227 new SyntheticTouchscreenPinchGesture(params)); 1229 new SyntheticTouchscreenPinchGesture(params));
1228 QueueSyntheticGesture(gesture.Pass()); 1230 QueueSyntheticGesture(std::move(gesture));
1229 FlushInputUntilComplete(); 1231 FlushInputUntilComplete();
1230 1232
1231 MockSyntheticTouchscreenPinchTouchTarget* pinch_target = 1233 MockSyntheticTouchscreenPinchTouchTarget* pinch_target =
1232 static_cast<MockSyntheticTouchscreenPinchTouchTarget*>(target_); 1234 static_cast<MockSyntheticTouchscreenPinchTouchTarget*>(target_);
1233 EXPECT_EQ(1, num_success_); 1235 EXPECT_EQ(1, num_success_);
1234 EXPECT_EQ(0, num_failure_); 1236 EXPECT_EQ(0, num_failure_);
1235 EXPECT_EQ(pinch_target->zoom_direction(), 1237 EXPECT_EQ(pinch_target->zoom_direction(),
1236 MockSyntheticTouchscreenPinchTouchTarget::ZOOM_IN); 1238 MockSyntheticTouchscreenPinchTouchTarget::ZOOM_IN);
1237 EXPECT_FLOAT_EQ(params.scale_factor, pinch_target->ComputeScaleFactor()); 1239 EXPECT_FLOAT_EQ(params.scale_factor, pinch_target->ComputeScaleFactor());
1238 } 1240 }
1239 1241
1240 TEST_F(SyntheticGestureControllerTest, 1242 TEST_F(SyntheticGestureControllerTest,
1241 TouchscreenTouchpadPinchGestureTouchZoomOut) { 1243 TouchscreenTouchpadPinchGestureTouchZoomOut) {
1242 CreateControllerAndTarget<MockSyntheticTouchscreenPinchTouchTarget>(); 1244 CreateControllerAndTarget<MockSyntheticTouchscreenPinchTouchTarget>();
1243 1245
1244 SyntheticPinchGestureParams params; 1246 SyntheticPinchGestureParams params;
1245 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; 1247 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
1246 params.scale_factor = 0.4f; 1248 params.scale_factor = 0.4f;
1247 params.anchor.SetPoint(-12, 93); 1249 params.anchor.SetPoint(-12, 93);
1248 1250
1249 scoped_ptr<SyntheticTouchscreenPinchGesture> gesture( 1251 scoped_ptr<SyntheticTouchscreenPinchGesture> gesture(
1250 new SyntheticTouchscreenPinchGesture(params)); 1252 new SyntheticTouchscreenPinchGesture(params));
1251 QueueSyntheticGesture(gesture.Pass()); 1253 QueueSyntheticGesture(std::move(gesture));
1252 FlushInputUntilComplete(); 1254 FlushInputUntilComplete();
1253 1255
1254 MockSyntheticTouchscreenPinchTouchTarget* pinch_target = 1256 MockSyntheticTouchscreenPinchTouchTarget* pinch_target =
1255 static_cast<MockSyntheticTouchscreenPinchTouchTarget*>(target_); 1257 static_cast<MockSyntheticTouchscreenPinchTouchTarget*>(target_);
1256 EXPECT_EQ(1, num_success_); 1258 EXPECT_EQ(1, num_success_);
1257 EXPECT_EQ(0, num_failure_); 1259 EXPECT_EQ(0, num_failure_);
1258 EXPECT_EQ(pinch_target->zoom_direction(), 1260 EXPECT_EQ(pinch_target->zoom_direction(),
1259 MockSyntheticTouchscreenPinchTouchTarget::ZOOM_OUT); 1261 MockSyntheticTouchscreenPinchTouchTarget::ZOOM_OUT);
1260 EXPECT_FLOAT_EQ(params.scale_factor, pinch_target->ComputeScaleFactor()); 1262 EXPECT_FLOAT_EQ(params.scale_factor, pinch_target->ComputeScaleFactor());
1261 } 1263 }
1262 1264
1263 TEST_F(SyntheticGestureControllerTest, 1265 TEST_F(SyntheticGestureControllerTest,
1264 TouchscreenTouchpadPinchGestureTouchNoScaling) { 1266 TouchscreenTouchpadPinchGestureTouchNoScaling) {
1265 CreateControllerAndTarget<MockSyntheticTouchscreenPinchTouchTarget>(); 1267 CreateControllerAndTarget<MockSyntheticTouchscreenPinchTouchTarget>();
1266 1268
1267 SyntheticPinchGestureParams params; 1269 SyntheticPinchGestureParams params;
1268 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; 1270 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
1269 params.scale_factor = 1.0f; 1271 params.scale_factor = 1.0f;
1270 1272
1271 scoped_ptr<SyntheticTouchscreenPinchGesture> gesture( 1273 scoped_ptr<SyntheticTouchscreenPinchGesture> gesture(
1272 new SyntheticTouchscreenPinchGesture(params)); 1274 new SyntheticTouchscreenPinchGesture(params));
1273 QueueSyntheticGesture(gesture.Pass()); 1275 QueueSyntheticGesture(std::move(gesture));
1274 FlushInputUntilComplete(); 1276 FlushInputUntilComplete();
1275 1277
1276 MockSyntheticTouchscreenPinchTouchTarget* pinch_target = 1278 MockSyntheticTouchscreenPinchTouchTarget* pinch_target =
1277 static_cast<MockSyntheticTouchscreenPinchTouchTarget*>(target_); 1279 static_cast<MockSyntheticTouchscreenPinchTouchTarget*>(target_);
1278 EXPECT_EQ(1, num_success_); 1280 EXPECT_EQ(1, num_success_);
1279 EXPECT_EQ(0, num_failure_); 1281 EXPECT_EQ(0, num_failure_);
1280 EXPECT_EQ(pinch_target->zoom_direction(), 1282 EXPECT_EQ(pinch_target->zoom_direction(),
1281 MockSyntheticTouchscreenPinchTouchTarget::ZOOM_DIRECTION_UNKNOWN); 1283 MockSyntheticTouchscreenPinchTouchTarget::ZOOM_DIRECTION_UNKNOWN);
1282 EXPECT_EQ(params.scale_factor, pinch_target->ComputeScaleFactor()); 1284 EXPECT_EQ(params.scale_factor, pinch_target->ComputeScaleFactor());
1283 } 1285 }
1284 1286
1285 TEST_F(SyntheticGestureControllerTest, TouchpadPinchGestureTouchZoomIn) { 1287 TEST_F(SyntheticGestureControllerTest, TouchpadPinchGestureTouchZoomIn) {
1286 CreateControllerAndTarget<MockSyntheticTouchpadPinchTouchTarget>(); 1288 CreateControllerAndTarget<MockSyntheticTouchpadPinchTouchTarget>();
1287 1289
1288 SyntheticPinchGestureParams params; 1290 SyntheticPinchGestureParams params;
1289 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; 1291 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT;
1290 params.scale_factor = 2.3f; 1292 params.scale_factor = 2.3f;
1291 params.anchor.SetPoint(54, 89); 1293 params.anchor.SetPoint(54, 89);
1292 1294
1293 scoped_ptr<SyntheticTouchpadPinchGesture> gesture( 1295 scoped_ptr<SyntheticTouchpadPinchGesture> gesture(
1294 new SyntheticTouchpadPinchGesture(params)); 1296 new SyntheticTouchpadPinchGesture(params));
1295 QueueSyntheticGesture(gesture.Pass()); 1297 QueueSyntheticGesture(std::move(gesture));
1296 FlushInputUntilComplete(); 1298 FlushInputUntilComplete();
1297 1299
1298 MockSyntheticTouchpadPinchTouchTarget* pinch_target = 1300 MockSyntheticTouchpadPinchTouchTarget* pinch_target =
1299 static_cast<MockSyntheticTouchpadPinchTouchTarget*>(target_); 1301 static_cast<MockSyntheticTouchpadPinchTouchTarget*>(target_);
1300 EXPECT_EQ(1, num_success_); 1302 EXPECT_EQ(1, num_success_);
1301 EXPECT_EQ(0, num_failure_); 1303 EXPECT_EQ(0, num_failure_);
1302 EXPECT_EQ(pinch_target->zoom_direction(), 1304 EXPECT_EQ(pinch_target->zoom_direction(),
1303 MockSyntheticTouchpadPinchTouchTarget::ZOOM_IN); 1305 MockSyntheticTouchpadPinchTouchTarget::ZOOM_IN);
1304 EXPECT_FLOAT_EQ(params.scale_factor, pinch_target->scale_factor()); 1306 EXPECT_FLOAT_EQ(params.scale_factor, pinch_target->scale_factor());
1305 } 1307 }
1306 1308
1307 TEST_F(SyntheticGestureControllerTest, TouchpadPinchGestureTouchZoomOut) { 1309 TEST_F(SyntheticGestureControllerTest, TouchpadPinchGestureTouchZoomOut) {
1308 CreateControllerAndTarget<MockSyntheticTouchpadPinchTouchTarget>(); 1310 CreateControllerAndTarget<MockSyntheticTouchpadPinchTouchTarget>();
1309 1311
1310 SyntheticPinchGestureParams params; 1312 SyntheticPinchGestureParams params;
1311 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; 1313 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT;
1312 params.scale_factor = 0.4f; 1314 params.scale_factor = 0.4f;
1313 params.anchor.SetPoint(-12, 93); 1315 params.anchor.SetPoint(-12, 93);
1314 1316
1315 scoped_ptr<SyntheticTouchpadPinchGesture> gesture( 1317 scoped_ptr<SyntheticTouchpadPinchGesture> gesture(
1316 new SyntheticTouchpadPinchGesture(params)); 1318 new SyntheticTouchpadPinchGesture(params));
1317 QueueSyntheticGesture(gesture.Pass()); 1319 QueueSyntheticGesture(std::move(gesture));
1318 FlushInputUntilComplete(); 1320 FlushInputUntilComplete();
1319 1321
1320 MockSyntheticTouchpadPinchTouchTarget* pinch_target = 1322 MockSyntheticTouchpadPinchTouchTarget* pinch_target =
1321 static_cast<MockSyntheticTouchpadPinchTouchTarget*>(target_); 1323 static_cast<MockSyntheticTouchpadPinchTouchTarget*>(target_);
1322 EXPECT_EQ(1, num_success_); 1324 EXPECT_EQ(1, num_success_);
1323 EXPECT_EQ(0, num_failure_); 1325 EXPECT_EQ(0, num_failure_);
1324 EXPECT_EQ(pinch_target->zoom_direction(), 1326 EXPECT_EQ(pinch_target->zoom_direction(),
1325 MockSyntheticTouchpadPinchTouchTarget::ZOOM_OUT); 1327 MockSyntheticTouchpadPinchTouchTarget::ZOOM_OUT);
1326 EXPECT_FLOAT_EQ(params.scale_factor, pinch_target->scale_factor()); 1328 EXPECT_FLOAT_EQ(params.scale_factor, pinch_target->scale_factor());
1327 } 1329 }
1328 1330
1329 TEST_F(SyntheticGestureControllerTest, TouchpadPinchGestureTouchNoScaling) { 1331 TEST_F(SyntheticGestureControllerTest, TouchpadPinchGestureTouchNoScaling) {
1330 CreateControllerAndTarget<MockSyntheticTouchpadPinchTouchTarget>(); 1332 CreateControllerAndTarget<MockSyntheticTouchpadPinchTouchTarget>();
1331 1333
1332 SyntheticPinchGestureParams params; 1334 SyntheticPinchGestureParams params;
1333 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; 1335 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT;
1334 params.scale_factor = 1.0f; 1336 params.scale_factor = 1.0f;
1335 1337
1336 scoped_ptr<SyntheticTouchpadPinchGesture> gesture( 1338 scoped_ptr<SyntheticTouchpadPinchGesture> gesture(
1337 new SyntheticTouchpadPinchGesture(params)); 1339 new SyntheticTouchpadPinchGesture(params));
1338 QueueSyntheticGesture(gesture.Pass()); 1340 QueueSyntheticGesture(std::move(gesture));
1339 FlushInputUntilComplete(); 1341 FlushInputUntilComplete();
1340 1342
1341 MockSyntheticTouchpadPinchTouchTarget* pinch_target = 1343 MockSyntheticTouchpadPinchTouchTarget* pinch_target =
1342 static_cast<MockSyntheticTouchpadPinchTouchTarget*>(target_); 1344 static_cast<MockSyntheticTouchpadPinchTouchTarget*>(target_);
1343 EXPECT_EQ(1, num_success_); 1345 EXPECT_EQ(1, num_success_);
1344 EXPECT_EQ(0, num_failure_); 1346 EXPECT_EQ(0, num_failure_);
1345 EXPECT_EQ(pinch_target->zoom_direction(), 1347 EXPECT_EQ(pinch_target->zoom_direction(),
1346 MockSyntheticTouchpadPinchTouchTarget::ZOOM_DIRECTION_UNKNOWN); 1348 MockSyntheticTouchpadPinchTouchTarget::ZOOM_DIRECTION_UNKNOWN);
1347 EXPECT_EQ(params.scale_factor, pinch_target->scale_factor()); 1349 EXPECT_EQ(params.scale_factor, pinch_target->scale_factor());
1348 } 1350 }
1349 1351
1350 // Ensure that if SyntheticPinchGesture is instantiated with TOUCH_INPUT it 1352 // Ensure that if SyntheticPinchGesture is instantiated with TOUCH_INPUT it
1351 // correctly creates a touchscreen gesture. 1353 // correctly creates a touchscreen gesture.
1352 TEST_F(SyntheticGestureControllerTest, PinchGestureExplicitTouch) { 1354 TEST_F(SyntheticGestureControllerTest, PinchGestureExplicitTouch) {
1353 CreateControllerAndTarget<MockSyntheticTouchscreenPinchTouchTarget>(); 1355 CreateControllerAndTarget<MockSyntheticTouchscreenPinchTouchTarget>();
1354 1356
1355 SyntheticPinchGestureParams params; 1357 SyntheticPinchGestureParams params;
1356 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; 1358 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
1357 params.scale_factor = 2.3f; 1359 params.scale_factor = 2.3f;
1358 params.anchor.SetPoint(54, 89); 1360 params.anchor.SetPoint(54, 89);
1359 1361
1360 scoped_ptr<SyntheticPinchGesture> gesture(new SyntheticPinchGesture(params)); 1362 scoped_ptr<SyntheticPinchGesture> gesture(new SyntheticPinchGesture(params));
1361 QueueSyntheticGesture(gesture.Pass()); 1363 QueueSyntheticGesture(std::move(gesture));
1362 FlushInputUntilComplete(); 1364 FlushInputUntilComplete();
1363 1365
1364 // Gesture target will fail expectations if the wrong underlying 1366 // Gesture target will fail expectations if the wrong underlying
1365 // SyntheticPinch*Gesture was instantiated. 1367 // SyntheticPinch*Gesture was instantiated.
1366 } 1368 }
1367 1369
1368 // Ensure that if SyntheticPinchGesture is instantiated with MOUSE_INPUT it 1370 // Ensure that if SyntheticPinchGesture is instantiated with MOUSE_INPUT it
1369 // correctly creates a touchpad gesture. 1371 // correctly creates a touchpad gesture.
1370 TEST_F(SyntheticGestureControllerTest, PinchGestureExplicitMouse) { 1372 TEST_F(SyntheticGestureControllerTest, PinchGestureExplicitMouse) {
1371 CreateControllerAndTarget<MockSyntheticTouchpadPinchTouchTarget>(); 1373 CreateControllerAndTarget<MockSyntheticTouchpadPinchTouchTarget>();
1372 1374
1373 SyntheticPinchGestureParams params; 1375 SyntheticPinchGestureParams params;
1374 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; 1376 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT;
1375 params.scale_factor = 2.3f; 1377 params.scale_factor = 2.3f;
1376 params.anchor.SetPoint(54, 89); 1378 params.anchor.SetPoint(54, 89);
1377 1379
1378 scoped_ptr<SyntheticPinchGesture> gesture(new SyntheticPinchGesture(params)); 1380 scoped_ptr<SyntheticPinchGesture> gesture(new SyntheticPinchGesture(params));
1379 QueueSyntheticGesture(gesture.Pass()); 1381 QueueSyntheticGesture(std::move(gesture));
1380 FlushInputUntilComplete(); 1382 FlushInputUntilComplete();
1381 1383
1382 // Gesture target will fail expectations if the wrong underlying 1384 // Gesture target will fail expectations if the wrong underlying
1383 // SyntheticPinch*Gesture was instantiated. 1385 // SyntheticPinch*Gesture was instantiated.
1384 } 1386 }
1385 1387
1386 // Ensure that if SyntheticPinchGesture is instantiated with DEFAULT_INPUT it 1388 // Ensure that if SyntheticPinchGesture is instantiated with DEFAULT_INPUT it
1387 // correctly creates a touchscreen gesture for a touchscreen controller. 1389 // correctly creates a touchscreen gesture for a touchscreen controller.
1388 TEST_F(SyntheticGestureControllerTest, PinchGestureDefaultTouch) { 1390 TEST_F(SyntheticGestureControllerTest, PinchGestureDefaultTouch) {
1389 CreateControllerAndTarget<MockSyntheticTouchscreenPinchTouchTarget>(); 1391 CreateControllerAndTarget<MockSyntheticTouchscreenPinchTouchTarget>();
1390 1392
1391 SyntheticPinchGestureParams params; 1393 SyntheticPinchGestureParams params;
1392 params.gesture_source_type = SyntheticGestureParams::DEFAULT_INPUT; 1394 params.gesture_source_type = SyntheticGestureParams::DEFAULT_INPUT;
1393 params.scale_factor = 2.3f; 1395 params.scale_factor = 2.3f;
1394 params.anchor.SetPoint(54, 89); 1396 params.anchor.SetPoint(54, 89);
1395 1397
1396 scoped_ptr<SyntheticPinchGesture> gesture(new SyntheticPinchGesture(params)); 1398 scoped_ptr<SyntheticPinchGesture> gesture(new SyntheticPinchGesture(params));
1397 QueueSyntheticGesture(gesture.Pass()); 1399 QueueSyntheticGesture(std::move(gesture));
1398 FlushInputUntilComplete(); 1400 FlushInputUntilComplete();
1399 1401
1400 // Gesture target will fail expectations if the wrong underlying 1402 // Gesture target will fail expectations if the wrong underlying
1401 // SyntheticPinch*Gesture was instantiated. 1403 // SyntheticPinch*Gesture was instantiated.
1402 } 1404 }
1403 1405
1404 // Ensure that if SyntheticPinchGesture is instantiated with DEFAULT_INPUT it 1406 // Ensure that if SyntheticPinchGesture is instantiated with DEFAULT_INPUT it
1405 // correctly creates a touchpad gesture for a touchpad controller. 1407 // correctly creates a touchpad gesture for a touchpad controller.
1406 TEST_F(SyntheticGestureControllerTest, PinchGestureDefaultMouse) { 1408 TEST_F(SyntheticGestureControllerTest, PinchGestureDefaultMouse) {
1407 CreateControllerAndTarget<MockSyntheticTouchpadPinchTouchTarget>(); 1409 CreateControllerAndTarget<MockSyntheticTouchpadPinchTouchTarget>();
1408 1410
1409 SyntheticPinchGestureParams params; 1411 SyntheticPinchGestureParams params;
1410 params.gesture_source_type = SyntheticGestureParams::DEFAULT_INPUT; 1412 params.gesture_source_type = SyntheticGestureParams::DEFAULT_INPUT;
1411 params.scale_factor = 2.3f; 1413 params.scale_factor = 2.3f;
1412 params.anchor.SetPoint(54, 89); 1414 params.anchor.SetPoint(54, 89);
1413 1415
1414 scoped_ptr<SyntheticPinchGesture> gesture(new SyntheticPinchGesture(params)); 1416 scoped_ptr<SyntheticPinchGesture> gesture(new SyntheticPinchGesture(params));
1415 QueueSyntheticGesture(gesture.Pass()); 1417 QueueSyntheticGesture(std::move(gesture));
1416 FlushInputUntilComplete(); 1418 FlushInputUntilComplete();
1417 1419
1418 // Gesture target will fail expectations if the wrong underlying 1420 // Gesture target will fail expectations if the wrong underlying
1419 // SyntheticPinch*Gesture was instantiated. 1421 // SyntheticPinch*Gesture was instantiated.
1420 } 1422 }
1421 1423
1422 TEST_F(SyntheticGestureControllerTest, TapGestureTouch) { 1424 TEST_F(SyntheticGestureControllerTest, TapGestureTouch) {
1423 CreateControllerAndTarget<MockSyntheticTapTouchTarget>(); 1425 CreateControllerAndTarget<MockSyntheticTapTouchTarget>();
1424 1426
1425 SyntheticTapGestureParams params; 1427 SyntheticTapGestureParams params;
1426 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; 1428 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
1427 params.duration_ms = 123; 1429 params.duration_ms = 123;
1428 params.position.SetPoint(87, -124); 1430 params.position.SetPoint(87, -124);
1429 1431
1430 scoped_ptr<SyntheticTapGesture> gesture(new SyntheticTapGesture(params)); 1432 scoped_ptr<SyntheticTapGesture> gesture(new SyntheticTapGesture(params));
1431 QueueSyntheticGesture(gesture.Pass()); 1433 QueueSyntheticGesture(std::move(gesture));
1432 FlushInputUntilComplete(); 1434 FlushInputUntilComplete();
1433 1435
1434 MockSyntheticTapTouchTarget* tap_target = 1436 MockSyntheticTapTouchTarget* tap_target =
1435 static_cast<MockSyntheticTapTouchTarget*>(target_); 1437 static_cast<MockSyntheticTapTouchTarget*>(target_);
1436 EXPECT_EQ(1, num_success_); 1438 EXPECT_EQ(1, num_success_);
1437 EXPECT_EQ(0, num_failure_); 1439 EXPECT_EQ(0, num_failure_);
1438 EXPECT_TRUE(tap_target->GestureFinished()); 1440 EXPECT_TRUE(tap_target->GestureFinished());
1439 EXPECT_EQ(tap_target->position(), params.position); 1441 EXPECT_EQ(tap_target->position(), params.position);
1440 EXPECT_EQ(tap_target->GetDuration().InMilliseconds(), params.duration_ms); 1442 EXPECT_EQ(tap_target->GetDuration().InMilliseconds(), params.duration_ms);
1441 EXPECT_GE(GetTotalTime(), 1443 EXPECT_GE(GetTotalTime(),
1442 base::TimeDelta::FromMilliseconds(params.duration_ms)); 1444 base::TimeDelta::FromMilliseconds(params.duration_ms));
1443 } 1445 }
1444 1446
1445 TEST_F(SyntheticGestureControllerTest, TapGestureMouse) { 1447 TEST_F(SyntheticGestureControllerTest, TapGestureMouse) {
1446 CreateControllerAndTarget<MockSyntheticTapMouseTarget>(); 1448 CreateControllerAndTarget<MockSyntheticTapMouseTarget>();
1447 1449
1448 SyntheticTapGestureParams params; 1450 SyntheticTapGestureParams params;
1449 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; 1451 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT;
1450 params.duration_ms = 79; 1452 params.duration_ms = 79;
1451 params.position.SetPoint(98, 123); 1453 params.position.SetPoint(98, 123);
1452 1454
1453 scoped_ptr<SyntheticTapGesture> gesture(new SyntheticTapGesture(params)); 1455 scoped_ptr<SyntheticTapGesture> gesture(new SyntheticTapGesture(params));
1454 QueueSyntheticGesture(gesture.Pass()); 1456 QueueSyntheticGesture(std::move(gesture));
1455 FlushInputUntilComplete(); 1457 FlushInputUntilComplete();
1456 1458
1457 MockSyntheticTapMouseTarget* tap_target = 1459 MockSyntheticTapMouseTarget* tap_target =
1458 static_cast<MockSyntheticTapMouseTarget*>(target_); 1460 static_cast<MockSyntheticTapMouseTarget*>(target_);
1459 EXPECT_EQ(1, num_success_); 1461 EXPECT_EQ(1, num_success_);
1460 EXPECT_EQ(0, num_failure_); 1462 EXPECT_EQ(0, num_failure_);
1461 EXPECT_TRUE(tap_target->GestureFinished()); 1463 EXPECT_TRUE(tap_target->GestureFinished());
1462 EXPECT_EQ(tap_target->position(), params.position); 1464 EXPECT_EQ(tap_target->position(), params.position);
1463 EXPECT_EQ(tap_target->GetDuration().InMilliseconds(), params.duration_ms); 1465 EXPECT_EQ(tap_target->GetDuration().InMilliseconds(), params.duration_ms);
1464 EXPECT_GE(GetTotalTime(), 1466 EXPECT_GE(GetTotalTime(),
1465 base::TimeDelta::FromMilliseconds(params.duration_ms)); 1467 base::TimeDelta::FromMilliseconds(params.duration_ms));
1466 } 1468 }
1467 1469
1468 TEST_F(SyntheticGestureControllerTest, PointerTouchAction) { 1470 TEST_F(SyntheticGestureControllerTest, PointerTouchAction) {
1469 CreateControllerAndTarget<MockSyntheticPointerTouchActionTarget>(); 1471 CreateControllerAndTarget<MockSyntheticPointerTouchActionTarget>();
1470 1472
1471 SyntheticTouchPointer synthetic_pointer; 1473 SyntheticTouchPointer synthetic_pointer;
1472 1474
1473 gfx::PointF position(54, 89); 1475 gfx::PointF position(54, 89);
1474 scoped_ptr<SyntheticPointerAction> gesture(new SyntheticPointerAction( 1476 scoped_ptr<SyntheticPointerAction> gesture(new SyntheticPointerAction(
1475 SyntheticGestureParams::TOUCH_INPUT, SyntheticGesture::PRESS, 1477 SyntheticGestureParams::TOUCH_INPUT, SyntheticGesture::PRESS,
1476 &synthetic_pointer, position)); 1478 &synthetic_pointer, position));
1477 QueueSyntheticGesture(gesture.Pass()); 1479 QueueSyntheticGesture(std::move(gesture));
1478 FlushInputUntilComplete(); 1480 FlushInputUntilComplete();
1479 1481
1480 MockSyntheticPointerTouchActionTarget* pointer_touch_target = 1482 MockSyntheticPointerTouchActionTarget* pointer_touch_target =
1481 static_cast<MockSyntheticPointerTouchActionTarget*>(target_); 1483 static_cast<MockSyntheticPointerTouchActionTarget*>(target_);
1482 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart); 1484 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart);
1483 EXPECT_EQ(pointer_touch_target->positions(0), position); 1485 EXPECT_EQ(pointer_touch_target->positions(0), position);
1484 EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StatePressed); 1486 EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StatePressed);
1485 ASSERT_EQ(pointer_touch_target->touch_length(), 1U); 1487 ASSERT_EQ(pointer_touch_target->touch_length(), 1U);
1486 1488
1487 position.SetPoint(79, 132); 1489 position.SetPoint(79, 132);
1488 gesture.reset(new SyntheticPointerAction(SyntheticGestureParams::TOUCH_INPUT, 1490 gesture.reset(new SyntheticPointerAction(SyntheticGestureParams::TOUCH_INPUT,
1489 SyntheticGesture::PRESS, 1491 SyntheticGesture::PRESS,
1490 &synthetic_pointer, position)); 1492 &synthetic_pointer, position));
1491 QueueSyntheticGesture(gesture.Pass()); 1493 QueueSyntheticGesture(std::move(gesture));
1492 FlushInputUntilComplete(); 1494 FlushInputUntilComplete();
1493 1495
1494 pointer_touch_target = 1496 pointer_touch_target =
1495 static_cast<MockSyntheticPointerTouchActionTarget*>(target_); 1497 static_cast<MockSyntheticPointerTouchActionTarget*>(target_);
1496 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart); 1498 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart);
1497 EXPECT_EQ(pointer_touch_target->indexes(1), 1); 1499 EXPECT_EQ(pointer_touch_target->indexes(1), 1);
1498 EXPECT_EQ(pointer_touch_target->positions(1), position); 1500 EXPECT_EQ(pointer_touch_target->positions(1), position);
1499 EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StatePressed); 1501 EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StatePressed);
1500 ASSERT_EQ(pointer_touch_target->touch_length(), 2U); 1502 ASSERT_EQ(pointer_touch_target->touch_length(), 2U);
1501 1503
1502 int index = 1; 1504 int index = 1;
1503 position.SetPoint(133, 156); 1505 position.SetPoint(133, 156);
1504 gesture.reset(new SyntheticPointerAction( 1506 gesture.reset(new SyntheticPointerAction(
1505 SyntheticGestureParams::TOUCH_INPUT, SyntheticGesture::MOVE, 1507 SyntheticGestureParams::TOUCH_INPUT, SyntheticGesture::MOVE,
1506 &synthetic_pointer, position, index)); 1508 &synthetic_pointer, position, index));
1507 QueueSyntheticGesture(gesture.Pass()); 1509 QueueSyntheticGesture(std::move(gesture));
1508 FlushInputUntilComplete(); 1510 FlushInputUntilComplete();
1509 1511
1510 pointer_touch_target = 1512 pointer_touch_target =
1511 static_cast<MockSyntheticPointerTouchActionTarget*>(target_); 1513 static_cast<MockSyntheticPointerTouchActionTarget*>(target_);
1512 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchMove); 1514 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchMove);
1513 EXPECT_EQ(pointer_touch_target->positions(1), position); 1515 EXPECT_EQ(pointer_touch_target->positions(1), position);
1514 EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StateMoved); 1516 EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StateMoved);
1515 ASSERT_EQ(pointer_touch_target->touch_length(), 2U); 1517 ASSERT_EQ(pointer_touch_target->touch_length(), 2U);
1516 1518
1517 gesture.reset(new SyntheticPointerAction( 1519 gesture.reset(new SyntheticPointerAction(
1518 SyntheticGestureParams::TOUCH_INPUT, SyntheticGesture::RELEASE, 1520 SyntheticGestureParams::TOUCH_INPUT, SyntheticGesture::RELEASE,
1519 &synthetic_pointer, position, index)); 1521 &synthetic_pointer, position, index));
1520 QueueSyntheticGesture(gesture.Pass()); 1522 QueueSyntheticGesture(std::move(gesture));
1521 FlushInputUntilComplete(); 1523 FlushInputUntilComplete();
1522 1524
1523 pointer_touch_target = 1525 pointer_touch_target =
1524 static_cast<MockSyntheticPointerTouchActionTarget*>(target_); 1526 static_cast<MockSyntheticPointerTouchActionTarget*>(target_);
1525 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchEnd); 1527 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchEnd);
1526 EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StateReleased); 1528 EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StateReleased);
1527 } 1529 }
1528 1530
1529 } // namespace 1531 } // namespace
1530 1532
1531 } // namespace content 1533 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698