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

Side by Side Diff: ui/aura/gestures/gesture_recognizer_unittest.cc

Issue 1372253002: gfx: Make conversions from gfx::Point to PointF explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pointfconvert-gfx: . Created 5 years, 2 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <list> 5 #include <list>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/timer/timer.h" 10 #include "base/timer/timer.h"
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 case ui::ET_TOUCH_RELEASED: 555 case ui::ET_TOUCH_RELEASED:
556 touch_released_count_++; 556 touch_released_count_++;
557 break; 557 break;
558 case ui::ET_TOUCH_PRESSED: 558 case ui::ET_TOUCH_PRESSED:
559 touch_pressed_count_++; 559 touch_pressed_count_++;
560 break; 560 break;
561 case ui::ET_TOUCH_MOVED: 561 case ui::ET_TOUCH_MOVED:
562 touch_moved_count_++; 562 touch_moved_count_++;
563 break; 563 break;
564 case ui::ET_TOUCH_CANCELLED: 564 case ui::ET_TOUCH_CANCELLED:
565 cancelled_touch_points_.push_back(event->location()); 565 cancelled_touch_points_.push_back(event->location_f());
566 break; 566 break;
567 default: 567 default:
568 break; 568 break;
569 } 569 }
570 } 570 }
571 571
572 void Reset() { 572 void Reset() {
573 touch_released_count_ = 0; 573 touch_released_count_ = 0;
574 touch_pressed_count_ = 0; 574 touch_pressed_count_ = 0;
575 touch_moved_count_ = 0; 575 touch_moved_count_ = 0;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 new GestureEventConsumeDelegate()); 673 new GestureEventConsumeDelegate());
674 TimedEvents tes; 674 TimedEvents tes;
675 const int kWindowWidth = 123; 675 const int kWindowWidth = 123;
676 const int kWindowHeight = 45; 676 const int kWindowHeight = 45;
677 const int kTouchId = 2; 677 const int kTouchId = 2;
678 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 678 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
679 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 679 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
680 delegate.get(), -1234, bounds, root_window())); 680 delegate.get(), -1234, bounds, root_window()));
681 681
682 delegate->Reset(); 682 delegate->Reset();
683 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 683 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
684 kTouchId, tes.Now()); 684 kTouchId, tes.Now());
685 DispatchEventUsingWindowDispatcher(&press); 685 DispatchEventUsingWindowDispatcher(&press);
686 EXPECT_FALSE(delegate->tap()); 686 EXPECT_FALSE(delegate->tap());
687 EXPECT_FALSE(delegate->show_press()); 687 EXPECT_FALSE(delegate->show_press());
688 EXPECT_TRUE(delegate->tap_down()); 688 EXPECT_TRUE(delegate->tap_down());
689 EXPECT_FALSE(delegate->tap_cancel()); 689 EXPECT_FALSE(delegate->tap_cancel());
690 EXPECT_TRUE(delegate->begin()); 690 EXPECT_TRUE(delegate->begin());
691 EXPECT_FALSE(delegate->scroll_begin()); 691 EXPECT_FALSE(delegate->scroll_begin());
692 EXPECT_FALSE(delegate->scroll_update()); 692 EXPECT_FALSE(delegate->scroll_update());
693 EXPECT_FALSE(delegate->scroll_end()); 693 EXPECT_FALSE(delegate->scroll_end());
694 EXPECT_FALSE(delegate->long_press()); 694 EXPECT_FALSE(delegate->long_press());
695 695
696 delegate->Reset(); 696 delegate->Reset();
697 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_SHOW_PRESS); 697 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_SHOW_PRESS);
698 EXPECT_TRUE(delegate->show_press()); 698 EXPECT_TRUE(delegate->show_press());
699 EXPECT_FALSE(delegate->tap_down()); 699 EXPECT_FALSE(delegate->tap_down());
700 700
701 // Make sure there is enough delay before the touch is released so that it is 701 // Make sure there is enough delay before the touch is released so that it is
702 // recognized as a tap. 702 // recognized as a tap.
703 delegate->Reset(); 703 delegate->Reset();
704 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 704 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
705 kTouchId, tes.LeapForward(50)); 705 kTouchId, tes.LeapForward(50));
706 706
707 DispatchEventUsingWindowDispatcher(&release); 707 DispatchEventUsingWindowDispatcher(&release);
708 EXPECT_TRUE(delegate->tap()); 708 EXPECT_TRUE(delegate->tap());
709 EXPECT_FALSE(delegate->tap_down()); 709 EXPECT_FALSE(delegate->tap_down());
710 EXPECT_FALSE(delegate->tap_cancel()); 710 EXPECT_FALSE(delegate->tap_cancel());
711 EXPECT_FALSE(delegate->begin()); 711 EXPECT_FALSE(delegate->begin());
712 EXPECT_TRUE(delegate->end()); 712 EXPECT_TRUE(delegate->end());
713 EXPECT_FALSE(delegate->scroll_begin()); 713 EXPECT_FALSE(delegate->scroll_begin());
714 EXPECT_FALSE(delegate->scroll_update()); 714 EXPECT_FALSE(delegate->scroll_update());
(...skipping 11 matching lines...) Expand all
726 const int kWindowWidth = 800; 726 const int kWindowWidth = 800;
727 const int kWindowHeight = 600; 727 const int kWindowHeight = 600;
728 const int kTouchId = 2; 728 const int kTouchId = 2;
729 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); 729 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight);
730 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 730 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
731 delegate.get(), -1234, bounds, root_window())); 731 delegate.get(), -1234, bounds, root_window()));
732 732
733 // Test with no ET_TOUCH_MOVED events. 733 // Test with no ET_TOUCH_MOVED events.
734 { 734 {
735 delegate->Reset(); 735 delegate->Reset();
736 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 736 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
737 kTouchId, tes.Now()); 737 kTouchId, tes.Now());
738 press.set_radius_x(5); 738 press.set_radius_x(5);
739 press.set_radius_y(12); 739 press.set_radius_y(12);
740 DispatchEventUsingWindowDispatcher(&press); 740 DispatchEventUsingWindowDispatcher(&press);
741 EXPECT_FALSE(delegate->tap()); 741 EXPECT_FALSE(delegate->tap());
742 EXPECT_TRUE(delegate->tap_down()); 742 EXPECT_TRUE(delegate->tap_down());
743 EXPECT_FALSE(delegate->tap_cancel()); 743 EXPECT_FALSE(delegate->tap_cancel());
744 EXPECT_TRUE(delegate->begin()); 744 EXPECT_TRUE(delegate->begin());
745 EXPECT_FALSE(delegate->scroll_begin()); 745 EXPECT_FALSE(delegate->scroll_begin());
746 EXPECT_FALSE(delegate->scroll_update()); 746 EXPECT_FALSE(delegate->scroll_update());
747 EXPECT_FALSE(delegate->scroll_end()); 747 EXPECT_FALSE(delegate->scroll_end());
748 EXPECT_FALSE(delegate->long_press()); 748 EXPECT_FALSE(delegate->long_press());
749 749
750 // Make sure there is enough delay before the touch is released so that it 750 // Make sure there is enough delay before the touch is released so that it
751 // is recognized as a tap. 751 // is recognized as a tap.
752 delegate->Reset(); 752 delegate->Reset();
753 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 753 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
754 kTouchId, tes.LeapForward(50)); 754 kTouchId, tes.LeapForward(50));
755 release.set_radius_x(5); 755 release.set_radius_x(5);
756 release.set_radius_y(12); 756 release.set_radius_y(12);
757 757
758 DispatchEventUsingWindowDispatcher(&release); 758 DispatchEventUsingWindowDispatcher(&release);
759 EXPECT_TRUE(delegate->tap()); 759 EXPECT_TRUE(delegate->tap());
760 EXPECT_FALSE(delegate->tap_down()); 760 EXPECT_FALSE(delegate->tap_down());
761 EXPECT_FALSE(delegate->tap_cancel()); 761 EXPECT_FALSE(delegate->tap_cancel());
762 EXPECT_FALSE(delegate->begin()); 762 EXPECT_FALSE(delegate->begin());
763 EXPECT_TRUE(delegate->end()); 763 EXPECT_TRUE(delegate->end());
764 EXPECT_FALSE(delegate->scroll_begin()); 764 EXPECT_FALSE(delegate->scroll_begin());
765 EXPECT_FALSE(delegate->scroll_update()); 765 EXPECT_FALSE(delegate->scroll_update());
766 EXPECT_FALSE(delegate->scroll_end()); 766 EXPECT_FALSE(delegate->scroll_end());
767 767
768 EXPECT_EQ(1, delegate->tap_count()); 768 EXPECT_EQ(1, delegate->tap_count());
769 gfx::Point actual_point(delegate->tap_location()); 769 gfx::Point actual_point(delegate->tap_location());
770 EXPECT_EQ(24, delegate->bounding_box().width()); 770 EXPECT_EQ(24, delegate->bounding_box().width());
771 EXPECT_EQ(24, delegate->bounding_box().height()); 771 EXPECT_EQ(24, delegate->bounding_box().height());
772 EXPECT_EQ(101, actual_point.x()); 772 EXPECT_EQ(101, actual_point.x());
773 EXPECT_EQ(201, actual_point.y()); 773 EXPECT_EQ(201, actual_point.y());
774 } 774 }
775 775
776 // Test with no ET_TOUCH_MOVED events but different touch points and radii. 776 // Test with no ET_TOUCH_MOVED events but different touch points and radii.
777 { 777 {
778 delegate->Reset(); 778 delegate->Reset();
779 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(365, 290), 779 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(365.f, 290.f),
780 kTouchId, tes.Now()); 780 kTouchId, tes.Now());
781 press.set_radius_x(8); 781 press.set_radius_x(8);
782 press.set_radius_y(14); 782 press.set_radius_y(14);
783 DispatchEventUsingWindowDispatcher(&press); 783 DispatchEventUsingWindowDispatcher(&press);
784 EXPECT_FALSE(delegate->tap()); 784 EXPECT_FALSE(delegate->tap());
785 EXPECT_TRUE(delegate->tap_down()); 785 EXPECT_TRUE(delegate->tap_down());
786 EXPECT_FALSE(delegate->tap_cancel()); 786 EXPECT_FALSE(delegate->tap_cancel());
787 EXPECT_TRUE(delegate->begin()); 787 EXPECT_TRUE(delegate->begin());
788 EXPECT_FALSE(delegate->scroll_begin()); 788 EXPECT_FALSE(delegate->scroll_begin());
789 EXPECT_FALSE(delegate->scroll_update()); 789 EXPECT_FALSE(delegate->scroll_update());
790 EXPECT_FALSE(delegate->scroll_end()); 790 EXPECT_FALSE(delegate->scroll_end());
791 EXPECT_FALSE(delegate->long_press()); 791 EXPECT_FALSE(delegate->long_press());
792 792
793 delegate->Reset(); 793 delegate->Reset();
794 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(367, 291), 794 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(367.f, 291.f),
795 kTouchId, tes.LeapForward(50)); 795 kTouchId, tes.LeapForward(50));
796 release.set_radius_x(20); 796 release.set_radius_x(20);
797 release.set_radius_y(13); 797 release.set_radius_y(13);
798 798
799 DispatchEventUsingWindowDispatcher(&release); 799 DispatchEventUsingWindowDispatcher(&release);
800 EXPECT_TRUE(delegate->tap()); 800 EXPECT_TRUE(delegate->tap());
801 EXPECT_FALSE(delegate->tap_down()); 801 EXPECT_FALSE(delegate->tap_down());
802 EXPECT_FALSE(delegate->tap_cancel()); 802 EXPECT_FALSE(delegate->tap_cancel());
803 EXPECT_FALSE(delegate->begin()); 803 EXPECT_FALSE(delegate->begin());
804 EXPECT_TRUE(delegate->end()); 804 EXPECT_TRUE(delegate->end());
805 EXPECT_FALSE(delegate->scroll_begin()); 805 EXPECT_FALSE(delegate->scroll_begin());
806 EXPECT_FALSE(delegate->scroll_update()); 806 EXPECT_FALSE(delegate->scroll_update());
807 EXPECT_FALSE(delegate->scroll_end()); 807 EXPECT_FALSE(delegate->scroll_end());
808 808
809 EXPECT_EQ(1, delegate->tap_count()); 809 EXPECT_EQ(1, delegate->tap_count());
810 gfx::Point actual_point(delegate->tap_location()); 810 gfx::Point actual_point(delegate->tap_location());
811 EXPECT_EQ(40, delegate->bounding_box().width()); 811 EXPECT_EQ(40, delegate->bounding_box().width());
812 EXPECT_EQ(40, delegate->bounding_box().height()); 812 EXPECT_EQ(40, delegate->bounding_box().height());
813 EXPECT_EQ(367, actual_point.x()); 813 EXPECT_EQ(367, actual_point.x());
814 EXPECT_EQ(291, actual_point.y()); 814 EXPECT_EQ(291, actual_point.y());
815 } 815 }
816 816
817 // Test with a single ET_TOUCH_MOVED event. 817 // Test with a single ET_TOUCH_MOVED event.
818 { 818 {
819 delegate->Reset(); 819 delegate->Reset();
820 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(46, 205), 820 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(46.f, 205.f),
821 kTouchId, tes.Now()); 821 kTouchId, tes.Now());
822 press.set_radius_x(6); 822 press.set_radius_x(6);
823 press.set_radius_y(10); 823 press.set_radius_y(10);
824 DispatchEventUsingWindowDispatcher(&press); 824 DispatchEventUsingWindowDispatcher(&press);
825 EXPECT_FALSE(delegate->tap()); 825 EXPECT_FALSE(delegate->tap());
826 EXPECT_TRUE(delegate->tap_down()); 826 EXPECT_TRUE(delegate->tap_down());
827 EXPECT_FALSE(delegate->tap_cancel()); 827 EXPECT_FALSE(delegate->tap_cancel());
828 EXPECT_TRUE(delegate->begin()); 828 EXPECT_TRUE(delegate->begin());
829 EXPECT_FALSE(delegate->tap_cancel()); 829 EXPECT_FALSE(delegate->tap_cancel());
830 EXPECT_FALSE(delegate->scroll_begin()); 830 EXPECT_FALSE(delegate->scroll_begin());
831 EXPECT_FALSE(delegate->scroll_update()); 831 EXPECT_FALSE(delegate->scroll_update());
832 EXPECT_FALSE(delegate->scroll_end()); 832 EXPECT_FALSE(delegate->scroll_end());
833 EXPECT_FALSE(delegate->long_press()); 833 EXPECT_FALSE(delegate->long_press());
834 834
835 delegate->Reset(); 835 delegate->Reset();
836 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(49, 204), 836 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(49.f, 204.f), kTouchId,
837 kTouchId, tes.LeapForward(50)); 837 tes.LeapForward(50));
838 move.set_radius_x(8); 838 move.set_radius_x(8);
839 move.set_radius_y(12); 839 move.set_radius_y(12);
840 DispatchEventUsingWindowDispatcher(&move); 840 DispatchEventUsingWindowDispatcher(&move);
841 EXPECT_FALSE(delegate->tap()); 841 EXPECT_FALSE(delegate->tap());
842 EXPECT_FALSE(delegate->tap_down()); 842 EXPECT_FALSE(delegate->tap_down());
843 EXPECT_FALSE(delegate->tap_cancel()); 843 EXPECT_FALSE(delegate->tap_cancel());
844 EXPECT_FALSE(delegate->begin()); 844 EXPECT_FALSE(delegate->begin());
845 EXPECT_FALSE(delegate->scroll_begin()); 845 EXPECT_FALSE(delegate->scroll_begin());
846 EXPECT_FALSE(delegate->scroll_update()); 846 EXPECT_FALSE(delegate->scroll_update());
847 EXPECT_FALSE(delegate->scroll_end()); 847 EXPECT_FALSE(delegate->scroll_end());
848 EXPECT_FALSE(delegate->long_press()); 848 EXPECT_FALSE(delegate->long_press());
849 849
850 delegate->Reset(); 850 delegate->Reset();
851 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(49, 204), 851 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(49.f, 204.f),
852 kTouchId, tes.LeapForward(50)); 852 kTouchId, tes.LeapForward(50));
853 release.set_radius_x(4); 853 release.set_radius_x(4);
854 release.set_radius_y(8); 854 release.set_radius_y(8);
855 855
856 DispatchEventUsingWindowDispatcher(&release); 856 DispatchEventUsingWindowDispatcher(&release);
857 EXPECT_TRUE(delegate->tap()); 857 EXPECT_TRUE(delegate->tap());
858 EXPECT_FALSE(delegate->tap_down()); 858 EXPECT_FALSE(delegate->tap_down());
859 EXPECT_FALSE(delegate->tap_cancel()); 859 EXPECT_FALSE(delegate->tap_cancel());
860 EXPECT_FALSE(delegate->begin()); 860 EXPECT_FALSE(delegate->begin());
861 EXPECT_TRUE(delegate->end()); 861 EXPECT_TRUE(delegate->end());
862 EXPECT_FALSE(delegate->scroll_begin()); 862 EXPECT_FALSE(delegate->scroll_begin());
863 EXPECT_FALSE(delegate->scroll_update()); 863 EXPECT_FALSE(delegate->scroll_update());
864 EXPECT_FALSE(delegate->scroll_end()); 864 EXPECT_FALSE(delegate->scroll_end());
865 865
866 EXPECT_EQ(1, delegate->tap_count()); 866 EXPECT_EQ(1, delegate->tap_count());
867 gfx::Point actual_point(delegate->tap_location()); 867 gfx::Point actual_point(delegate->tap_location());
868 EXPECT_EQ(16, delegate->bounding_box().width()); 868 EXPECT_EQ(16, delegate->bounding_box().width());
869 EXPECT_EQ(16, delegate->bounding_box().height()); 869 EXPECT_EQ(16, delegate->bounding_box().height());
870 EXPECT_EQ(49, actual_point.x()); 870 EXPECT_EQ(49, actual_point.x());
871 EXPECT_EQ(204, actual_point.y()); 871 EXPECT_EQ(204, actual_point.y());
872 } 872 }
873 873
874 // Test with a few ET_TOUCH_MOVED events. 874 // Test with a few ET_TOUCH_MOVED events.
875 { 875 {
876 delegate->Reset(); 876 delegate->Reset();
877 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(400, 150), 877 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(400.f, 150.f),
878 kTouchId, tes.Now()); 878 kTouchId, tes.Now());
879 press.set_radius_x(7); 879 press.set_radius_x(7);
880 press.set_radius_y(10); 880 press.set_radius_y(10);
881 DispatchEventUsingWindowDispatcher(&press); 881 DispatchEventUsingWindowDispatcher(&press);
882 EXPECT_FALSE(delegate->tap()); 882 EXPECT_FALSE(delegate->tap());
883 EXPECT_TRUE(delegate->tap_down()); 883 EXPECT_TRUE(delegate->tap_down());
884 EXPECT_FALSE(delegate->tap_cancel()); 884 EXPECT_FALSE(delegate->tap_cancel());
885 EXPECT_TRUE(delegate->begin()); 885 EXPECT_TRUE(delegate->begin());
886 EXPECT_FALSE(delegate->scroll_begin()); 886 EXPECT_FALSE(delegate->scroll_begin());
887 EXPECT_FALSE(delegate->scroll_update()); 887 EXPECT_FALSE(delegate->scroll_update());
888 EXPECT_FALSE(delegate->scroll_end()); 888 EXPECT_FALSE(delegate->scroll_end());
889 EXPECT_FALSE(delegate->long_press()); 889 EXPECT_FALSE(delegate->long_press());
890 890
891 delegate->Reset(); 891 delegate->Reset();
892 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(397, 151), 892 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(397.f, 151.f),
893 kTouchId, tes.LeapForward(50)); 893 kTouchId, tes.LeapForward(50));
894 move.set_radius_x(13); 894 move.set_radius_x(13);
895 move.set_radius_y(12); 895 move.set_radius_y(12);
896 DispatchEventUsingWindowDispatcher(&move); 896 DispatchEventUsingWindowDispatcher(&move);
897 EXPECT_FALSE(delegate->tap()); 897 EXPECT_FALSE(delegate->tap());
898 EXPECT_FALSE(delegate->tap_down()); 898 EXPECT_FALSE(delegate->tap_down());
899 EXPECT_FALSE(delegate->tap_cancel()); 899 EXPECT_FALSE(delegate->tap_cancel());
900 EXPECT_FALSE(delegate->begin()); 900 EXPECT_FALSE(delegate->begin());
901 EXPECT_FALSE(delegate->scroll_begin()); 901 EXPECT_FALSE(delegate->scroll_begin());
902 EXPECT_FALSE(delegate->scroll_update()); 902 EXPECT_FALSE(delegate->scroll_update());
903 EXPECT_FALSE(delegate->scroll_end()); 903 EXPECT_FALSE(delegate->scroll_end());
904 EXPECT_FALSE(delegate->long_press()); 904 EXPECT_FALSE(delegate->long_press());
905 905
906 delegate->Reset(); 906 delegate->Reset();
907 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(397, 149), 907 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::PointF(397.f, 149.f),
908 kTouchId, tes.LeapForward(50)); 908 kTouchId, tes.LeapForward(50));
909 move1.set_radius_x(16); 909 move1.set_radius_x(16);
910 move1.set_radius_y(16); 910 move1.set_radius_y(16);
911 DispatchEventUsingWindowDispatcher(&move1); 911 DispatchEventUsingWindowDispatcher(&move1);
912 EXPECT_FALSE(delegate->tap()); 912 EXPECT_FALSE(delegate->tap());
913 EXPECT_FALSE(delegate->tap_down()); 913 EXPECT_FALSE(delegate->tap_down());
914 EXPECT_FALSE(delegate->tap_cancel()); 914 EXPECT_FALSE(delegate->tap_cancel());
915 EXPECT_FALSE(delegate->begin()); 915 EXPECT_FALSE(delegate->begin());
916 EXPECT_FALSE(delegate->scroll_begin()); 916 EXPECT_FALSE(delegate->scroll_begin());
917 EXPECT_FALSE(delegate->scroll_update()); 917 EXPECT_FALSE(delegate->scroll_update());
918 EXPECT_FALSE(delegate->scroll_end()); 918 EXPECT_FALSE(delegate->scroll_end());
919 EXPECT_FALSE(delegate->long_press()); 919 EXPECT_FALSE(delegate->long_press());
920 920
921 delegate->Reset(); 921 delegate->Reset();
922 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(400, 150), 922 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::PointF(400.f, 150.f),
923 kTouchId, tes.LeapForward(50)); 923 kTouchId, tes.LeapForward(50));
924 move2.set_radius_x(14); 924 move2.set_radius_x(14);
925 move2.set_radius_y(10); 925 move2.set_radius_y(10);
926 DispatchEventUsingWindowDispatcher(&move2); 926 DispatchEventUsingWindowDispatcher(&move2);
927 EXPECT_FALSE(delegate->tap()); 927 EXPECT_FALSE(delegate->tap());
928 EXPECT_FALSE(delegate->tap_down()); 928 EXPECT_FALSE(delegate->tap_down());
929 EXPECT_FALSE(delegate->tap_cancel()); 929 EXPECT_FALSE(delegate->tap_cancel());
930 EXPECT_FALSE(delegate->begin()); 930 EXPECT_FALSE(delegate->begin());
931 EXPECT_FALSE(delegate->scroll_begin()); 931 EXPECT_FALSE(delegate->scroll_begin());
932 EXPECT_FALSE(delegate->scroll_update()); 932 EXPECT_FALSE(delegate->scroll_update());
933 EXPECT_FALSE(delegate->scroll_end()); 933 EXPECT_FALSE(delegate->scroll_end());
934 EXPECT_FALSE(delegate->long_press()); 934 EXPECT_FALSE(delegate->long_press());
935 935
936 delegate->Reset(); 936 delegate->Reset();
937 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(401, 149), 937 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(401.f, 149.f),
938 kTouchId, tes.LeapForward(50)); 938 kTouchId, tes.LeapForward(50));
939 release.set_radius_x(8); 939 release.set_radius_x(8);
940 release.set_radius_y(9); 940 release.set_radius_y(9);
941 941
942 DispatchEventUsingWindowDispatcher(&release); 942 DispatchEventUsingWindowDispatcher(&release);
943 EXPECT_TRUE(delegate->tap()); 943 EXPECT_TRUE(delegate->tap());
944 EXPECT_FALSE(delegate->tap_down()); 944 EXPECT_FALSE(delegate->tap_down());
945 EXPECT_FALSE(delegate->tap_cancel()); 945 EXPECT_FALSE(delegate->tap_cancel());
946 EXPECT_FALSE(delegate->begin()); 946 EXPECT_FALSE(delegate->begin());
947 EXPECT_TRUE(delegate->end()); 947 EXPECT_TRUE(delegate->end());
(...skipping 21 matching lines...) Expand all
969 new GestureEventConsumeDelegate()); 969 new GestureEventConsumeDelegate());
970 TimedEvents tes; 970 TimedEvents tes;
971 const int kWindowWidth = 123; 971 const int kWindowWidth = 123;
972 const int kWindowHeight = 45; 972 const int kWindowHeight = 45;
973 const int kTouchId = 5; 973 const int kTouchId = 5;
974 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 974 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
975 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 975 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
976 delegate.get(), -1234, bounds, root_window())); 976 delegate.get(), -1234, bounds, root_window()));
977 977
978 delegate->Reset(); 978 delegate->Reset();
979 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 979 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
980 kTouchId, tes.Now()); 980 kTouchId, tes.Now());
981 DispatchEventUsingWindowDispatcher(&press); 981 DispatchEventUsingWindowDispatcher(&press);
982 EXPECT_2_EVENTS(delegate->events(), 982 EXPECT_2_EVENTS(delegate->events(),
983 ui::ET_GESTURE_BEGIN, 983 ui::ET_GESTURE_BEGIN,
984 ui::ET_GESTURE_TAP_DOWN); 984 ui::ET_GESTURE_TAP_DOWN);
985 985
986 // Move the touch-point enough so that it is considered as a scroll. This 986 // Move the touch-point enough so that it is considered as a scroll. This
987 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. 987 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures.
988 // The first movement is diagonal, to ensure that we have a free scroll, 988 // The first movement is diagonal, to ensure that we have a free scroll,
989 // and not a rail scroll. 989 // and not a rail scroll.
(...skipping 22 matching lines...) Expand all
1012 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); 1012 EXPECT_TRUE(delegate->bounding_box().IsEmpty());
1013 1013
1014 tes.SendScrollEvent(event_processor(), 50, 124, kTouchId, delegate.get()); 1014 tes.SendScrollEvent(event_processor(), 50, 124, kTouchId, delegate.get());
1015 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); 1015 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE);
1016 EXPECT_EQ(30, delegate->scroll_x()); 1016 EXPECT_EQ(30, delegate->scroll_x());
1017 EXPECT_EQ(4, delegate->scroll_y()); 1017 EXPECT_EQ(4, delegate->scroll_y());
1018 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); 1018 EXPECT_TRUE(delegate->bounding_box().IsEmpty());
1019 1019
1020 // Release the touch. This should end the scroll. 1020 // Release the touch. This should end the scroll.
1021 delegate->Reset(); 1021 delegate->Reset();
1022 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 1022 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
1023 kTouchId, 1023 kTouchId, tes.LeapForward(50));
1024 tes.LeapForward(50));
1025 DispatchEventUsingWindowDispatcher(&release); 1024 DispatchEventUsingWindowDispatcher(&release);
1026 EXPECT_2_EVENTS(delegate->events(), 1025 EXPECT_2_EVENTS(delegate->events(),
1027 ui::ET_SCROLL_FLING_START, 1026 ui::ET_SCROLL_FLING_START,
1028 ui::ET_GESTURE_END); 1027 ui::ET_GESTURE_END);
1029 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); 1028 EXPECT_TRUE(delegate->bounding_box().IsEmpty());
1030 } 1029 }
1031 1030
1032 // Check that predicted scroll update positions are correct. 1031 // Check that predicted scroll update positions are correct.
1033 TEST_F(GestureRecognizerTest, GestureEventScrollPrediction) { 1032 TEST_F(GestureRecognizerTest, GestureEventScrollPrediction) {
1034 // We'll start by moving the touch point by (5, 5). We want all of that 1033 // We'll start by moving the touch point by (5, 5). We want all of that
1035 // distance to be consumed by the slop, so we set the slop radius to 1034 // distance to be consumed by the slop, so we set the slop radius to
1036 // sqrt(5 * 5 + 5 * 5). 1035 // sqrt(5 * 5 + 5 * 5).
1037 ui::GestureConfiguration::GetInstance() 1036 ui::GestureConfiguration::GetInstance()
1038 ->set_max_touch_move_in_pixels_for_click(sqrt(5.f * 5 + 5 * 5)); 1037 ->set_max_touch_move_in_pixels_for_click(sqrt(5.f * 5 + 5 * 5));
1039 1038
1040 scoped_ptr<GestureEventConsumeDelegate> delegate( 1039 scoped_ptr<GestureEventConsumeDelegate> delegate(
1041 new GestureEventConsumeDelegate()); 1040 new GestureEventConsumeDelegate());
1042 TimedEvents tes; 1041 TimedEvents tes;
1043 const int kWindowWidth = 123; 1042 const int kWindowWidth = 123;
1044 const int kWindowHeight = 45; 1043 const int kWindowHeight = 45;
1045 const int kTouchId = 5; 1044 const int kTouchId = 5;
1046 gfx::Rect bounds(95, 195, kWindowWidth, kWindowHeight); 1045 gfx::Rect bounds(95, 195, kWindowWidth, kWindowHeight);
1047 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1046 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1048 delegate.get(), -1234, bounds, root_window())); 1047 delegate.get(), -1234, bounds, root_window()));
1049 1048
1050 delegate->Reset(); 1049 delegate->Reset();
1051 // Tracks the total scroll since we want to verify that the correct position 1050 // Tracks the total scroll since we want to verify that the correct position
1052 // will be scrolled to throughout the prediction. 1051 // will be scrolled to throughout the prediction.
1053 gfx::Vector2dF total_scroll; 1052 gfx::Vector2dF total_scroll;
1054 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(96, 196), 1053 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(96.f, 196.f), kTouchId,
1055 kTouchId, tes.Now()); 1054 tes.Now());
1056 DispatchEventUsingWindowDispatcher(&press); 1055 DispatchEventUsingWindowDispatcher(&press);
1057 EXPECT_2_EVENTS(delegate->events(), 1056 EXPECT_2_EVENTS(delegate->events(),
1058 ui::ET_GESTURE_BEGIN, 1057 ui::ET_GESTURE_BEGIN,
1059 ui::ET_GESTURE_TAP_DOWN); 1058 ui::ET_GESTURE_TAP_DOWN);
1060 delegate->Reset(); 1059 delegate->Reset();
1061 1060
1062 // Get rid of touch slop. 1061 // Get rid of touch slop.
1063 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(111, 211), 1062 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(111.f, 211.f), kTouchId,
1064 kTouchId, tes.Now()); 1063 tes.Now());
1065 DispatchEventUsingWindowDispatcher(&move); 1064 DispatchEventUsingWindowDispatcher(&move);
1066 EXPECT_3_EVENTS(delegate->events(), 1065 EXPECT_3_EVENTS(delegate->events(),
1067 ui::ET_GESTURE_TAP_CANCEL, 1066 ui::ET_GESTURE_TAP_CANCEL,
1068 ui::ET_GESTURE_SCROLL_BEGIN, 1067 ui::ET_GESTURE_SCROLL_BEGIN,
1069 ui::ET_GESTURE_SCROLL_UPDATE); 1068 ui::ET_GESTURE_SCROLL_UPDATE);
1070 total_scroll.set_x(total_scroll.x() + delegate->scroll_x()); 1069 total_scroll.set_x(total_scroll.x() + delegate->scroll_x());
1071 total_scroll.set_y(total_scroll.y() + delegate->scroll_y()); 1070 total_scroll.set_y(total_scroll.y() + delegate->scroll_y());
1072 1071
1073 // Move the touch-point enough so that it is considered as a scroll. This 1072 // Move the touch-point enough so that it is considered as a scroll. This
1074 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. 1073 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures.
(...skipping 14 matching lines...) Expand all
1089 total_scroll.set_y(total_scroll.y() + delegate->scroll_y()); 1088 total_scroll.set_y(total_scroll.y() + delegate->scroll_y());
1090 1089
1091 tes.LeapForward(30); 1090 tes.LeapForward(30);
1092 tes.SendScrollEvent(event_processor(), 140, 215, kTouchId, delegate.get()); 1091 tes.SendScrollEvent(event_processor(), 140, 215, kTouchId, delegate.get());
1093 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); 1092 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE);
1094 total_scroll.set_x(total_scroll.x() + delegate->scroll_x()); 1093 total_scroll.set_x(total_scroll.x() + delegate->scroll_x());
1095 total_scroll.set_y(total_scroll.y() + delegate->scroll_y()); 1094 total_scroll.set_y(total_scroll.y() + delegate->scroll_y());
1096 1095
1097 // Release the touch. This should end the scroll. 1096 // Release the touch. This should end the scroll.
1098 delegate->Reset(); 1097 delegate->Reset();
1099 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 1098 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
1100 kTouchId, 1099 kTouchId, tes.LeapForward(50));
1101 tes.LeapForward(50));
1102 DispatchEventUsingWindowDispatcher(&release); 1100 DispatchEventUsingWindowDispatcher(&release);
1103 } 1101 }
1104 1102
1105 // Check that the bounding box during a scroll event is correct. 1103 // Check that the bounding box during a scroll event is correct.
1106 TEST_F(GestureRecognizerTest, GestureEventScrollBoundingBox) { 1104 TEST_F(GestureRecognizerTest, GestureEventScrollBoundingBox) {
1107 TimedEvents tes; 1105 TimedEvents tes;
1108 for (int radius = 1; radius <= 10; ++radius) { 1106 for (int radius = 1; radius <= 10; ++radius) {
1109 ui::GestureConfiguration::GetInstance()->set_default_radius(radius); 1107 ui::GestureConfiguration::GetInstance()->set_default_radius(radius);
1110 scoped_ptr<GestureEventConsumeDelegate> delegate( 1108 scoped_ptr<GestureEventConsumeDelegate> delegate(
1111 new GestureEventConsumeDelegate()); 1109 new GestureEventConsumeDelegate());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 // if the user was on a horizontal rail 1156 // if the user was on a horizontal rail
1159 TEST_F(GestureRecognizerTest, GestureEventHorizontalRailFling) { 1157 TEST_F(GestureRecognizerTest, GestureEventHorizontalRailFling) {
1160 scoped_ptr<GestureEventConsumeDelegate> delegate( 1158 scoped_ptr<GestureEventConsumeDelegate> delegate(
1161 new GestureEventConsumeDelegate()); 1159 new GestureEventConsumeDelegate());
1162 TimedEvents tes; 1160 TimedEvents tes;
1163 const int kTouchId = 7; 1161 const int kTouchId = 7;
1164 gfx::Rect bounds(0, 0, 1000, 1000); 1162 gfx::Rect bounds(0, 0, 1000, 1000);
1165 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1163 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1166 delegate.get(), -1234, bounds, root_window())); 1164 delegate.get(), -1234, bounds, root_window()));
1167 1165
1168 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 1166 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(), kTouchId,
1169 kTouchId, tes.Now()); 1167 tes.Now());
1170 DispatchEventUsingWindowDispatcher(&press); 1168 DispatchEventUsingWindowDispatcher(&press);
1171 1169
1172 // Get rid of touch slop. 1170 // Get rid of touch slop.
1173 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(10, 0), 1171 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(10.f, 0.f), kTouchId,
1174 kTouchId, tes.Now()); 1172 tes.Now());
1175 DispatchEventUsingWindowDispatcher(&move); 1173 DispatchEventUsingWindowDispatcher(&move);
1176 delegate->Reset(); 1174 delegate->Reset();
1177 1175
1178 1176
1179 // Move the touch-point horizontally enough that it is considered a 1177 // Move the touch-point horizontally enough that it is considered a
1180 // horizontal scroll. 1178 // horizontal scroll.
1181 tes.SendScrollEvent(event_processor(), 30, 1, kTouchId, delegate.get()); 1179 tes.SendScrollEvent(event_processor(), 30, 1, kTouchId, delegate.get());
1182 EXPECT_FLOAT_EQ(0, delegate->scroll_y()); 1180 EXPECT_FLOAT_EQ(0, delegate->scroll_y());
1183 EXPECT_FLOAT_EQ(20, delegate->scroll_x()); 1181 EXPECT_FLOAT_EQ(20, delegate->scroll_x());
1184 1182
1185 // Get a high x velocity, while still staying on the rail 1183 // Get a high x velocity, while still staying on the rail
1186 const int kScrollAmount = 8; 1184 const int kScrollAmount = 8;
1187 tes.SendScrollEvents(event_processor(), 1185 tes.SendScrollEvents(event_processor(),
1188 1, 1186 1,
1189 1, 1187 1,
1190 100, 1188 100,
1191 10, 1189 10,
1192 kTouchId, 1190 kTouchId,
1193 1, 1191 1,
1194 kScrollAmount, 1192 kScrollAmount,
1195 delegate.get()); 1193 delegate.get());
1196 1194
1197 delegate->Reset(); 1195 delegate->Reset();
1198 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 1196 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
1199 kTouchId, tes.Now()); 1197 kTouchId, tes.Now());
1200 DispatchEventUsingWindowDispatcher(&release); 1198 DispatchEventUsingWindowDispatcher(&release);
1201 1199
1202 EXPECT_TRUE(delegate->fling()); 1200 EXPECT_TRUE(delegate->fling());
1203 EXPECT_FALSE(delegate->scroll_end()); 1201 EXPECT_FALSE(delegate->scroll_end());
1204 EXPECT_GT(delegate->velocity_x(), 0); 1202 EXPECT_GT(delegate->velocity_x(), 0);
1205 EXPECT_EQ(0, delegate->velocity_y()); 1203 EXPECT_EQ(0, delegate->velocity_y());
1206 } 1204 }
1207 1205
1208 // Check Scroll End Events report correct velocities 1206 // Check Scroll End Events report correct velocities
1209 // if the user was on a vertical rail 1207 // if the user was on a vertical rail
1210 TEST_F(GestureRecognizerTest, GestureEventVerticalRailFling) { 1208 TEST_F(GestureRecognizerTest, GestureEventVerticalRailFling) {
1211 scoped_ptr<GestureEventConsumeDelegate> delegate( 1209 scoped_ptr<GestureEventConsumeDelegate> delegate(
1212 new GestureEventConsumeDelegate()); 1210 new GestureEventConsumeDelegate());
1213 TimedEvents tes; 1211 TimedEvents tes;
1214 const int kTouchId = 7; 1212 const int kTouchId = 7;
1215 gfx::Rect bounds(0, 0, 1000, 1000); 1213 gfx::Rect bounds(0, 0, 1000, 1000);
1216 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1214 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1217 delegate.get(), -1234, bounds, root_window())); 1215 delegate.get(), -1234, bounds, root_window()));
1218 1216
1219 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 1217 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(), kTouchId,
1220 kTouchId, tes.Now()); 1218 tes.Now());
1221 DispatchEventUsingWindowDispatcher(&press); 1219 DispatchEventUsingWindowDispatcher(&press);
1222 1220
1223 // Get rid of touch slop. 1221 // Get rid of touch slop.
1224 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(0, 10), 1222 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(0.f, 10.f), kTouchId,
1225 kTouchId, tes.Now()); 1223 tes.Now());
1226 DispatchEventUsingWindowDispatcher(&move); 1224 DispatchEventUsingWindowDispatcher(&move);
1227 delegate->Reset(); 1225 delegate->Reset();
1228 1226
1229 // Move the touch-point vertically enough that it is considered a 1227 // Move the touch-point vertically enough that it is considered a
1230 // vertical scroll. 1228 // vertical scroll.
1231 tes.SendScrollEvent(event_processor(), 1, 30, kTouchId, delegate.get()); 1229 tes.SendScrollEvent(event_processor(), 1, 30, kTouchId, delegate.get());
1232 EXPECT_EQ(20, delegate->scroll_y()); 1230 EXPECT_EQ(20, delegate->scroll_y());
1233 EXPECT_EQ(0, delegate->scroll_x()); 1231 EXPECT_EQ(0, delegate->scroll_x());
1234 EXPECT_EQ(0, delegate->scroll_velocity_x()); 1232 EXPECT_EQ(0, delegate->scroll_velocity_x());
1235 1233
1236 // Get a high y velocity, while still staying on the rail 1234 // Get a high y velocity, while still staying on the rail
1237 const int kScrollAmount = 8; 1235 const int kScrollAmount = 8;
1238 tes.SendScrollEvents(event_processor(), 1236 tes.SendScrollEvents(event_processor(),
1239 1, 1237 1,
1240 6, 1238 6,
1241 10, 1239 10,
1242 100, 1240 100,
1243 kTouchId, 1241 kTouchId,
1244 1, 1242 1,
1245 kScrollAmount, 1243 kScrollAmount,
1246 delegate.get()); 1244 delegate.get());
1247 EXPECT_EQ(0, delegate->scroll_velocity_x()); 1245 EXPECT_EQ(0, delegate->scroll_velocity_x());
1248 1246
1249 delegate->Reset(); 1247 delegate->Reset();
1250 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 206), 1248 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 206.f),
1251 kTouchId, tes.Now()); 1249 kTouchId, tes.Now());
1252 DispatchEventUsingWindowDispatcher(&release); 1250 DispatchEventUsingWindowDispatcher(&release);
1253 1251
1254 EXPECT_TRUE(delegate->fling()); 1252 EXPECT_TRUE(delegate->fling());
1255 EXPECT_FALSE(delegate->scroll_end()); 1253 EXPECT_FALSE(delegate->scroll_end());
1256 EXPECT_EQ(0, delegate->velocity_x()); 1254 EXPECT_EQ(0, delegate->velocity_x());
1257 EXPECT_GT(delegate->velocity_y(), 0); 1255 EXPECT_GT(delegate->velocity_y(), 0);
1258 } 1256 }
1259 1257
1260 // Check Scroll End Events report non-zero velocities if the user is not on a 1258 // Check Scroll End Events report non-zero velocities if the user is not on a
1261 // rail 1259 // rail
1262 TEST_F(GestureRecognizerTest, GestureEventNonRailFling) { 1260 TEST_F(GestureRecognizerTest, GestureEventNonRailFling) {
1263 ui::GestureConfiguration::GetInstance() 1261 ui::GestureConfiguration::GetInstance()
1264 ->set_max_touch_move_in_pixels_for_click(0); 1262 ->set_max_touch_move_in_pixels_for_click(0);
1265 scoped_ptr<GestureEventConsumeDelegate> delegate( 1263 scoped_ptr<GestureEventConsumeDelegate> delegate(
1266 new GestureEventConsumeDelegate()); 1264 new GestureEventConsumeDelegate());
1267 TimedEvents tes; 1265 TimedEvents tes;
1268 const int kTouchId = 7; 1266 const int kTouchId = 7;
1269 gfx::Rect bounds(0, 0, 1000, 1000); 1267 gfx::Rect bounds(0, 0, 1000, 1000);
1270 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1268 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1271 delegate.get(), -1234, bounds, root_window())); 1269 delegate.get(), -1234, bounds, root_window()));
1272 1270
1273 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 1271 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(), kTouchId,
1274 kTouchId, tes.Now()); 1272 tes.Now());
1275 DispatchEventUsingWindowDispatcher(&press); 1273 DispatchEventUsingWindowDispatcher(&press);
1276 1274
1277 // Move the touch-point such that a non-rail scroll begins, and we're outside 1275 // Move the touch-point such that a non-rail scroll begins, and we're outside
1278 // the snap channel for the unified GR. 1276 // the snap channel for the unified GR.
1279 tes.SendScrollEvent(event_processor(), 50, 50, kTouchId, delegate.get()); 1277 tes.SendScrollEvent(event_processor(), 50, 50, kTouchId, delegate.get());
1280 EXPECT_EQ(50, delegate->scroll_y()); 1278 EXPECT_EQ(50, delegate->scroll_y());
1281 EXPECT_EQ(50, delegate->scroll_x()); 1279 EXPECT_EQ(50, delegate->scroll_x());
1282 1280
1283 const int kScrollAmount = 8; 1281 const int kScrollAmount = 8;
1284 tes.SendScrollEvents(event_processor(), 1282 tes.SendScrollEvents(event_processor(),
1285 1, 1283 1,
1286 1, 1284 1,
1287 10, 1285 10,
1288 100, 1286 100,
1289 kTouchId, 1287 kTouchId,
1290 1, 1288 1,
1291 kScrollAmount, 1289 kScrollAmount,
1292 delegate.get()); 1290 delegate.get());
1293 1291
1294 delegate->Reset(); 1292 delegate->Reset();
1295 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 1293 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
1296 kTouchId, tes.Now()); 1294 kTouchId, tes.Now());
1297 DispatchEventUsingWindowDispatcher(&release); 1295 DispatchEventUsingWindowDispatcher(&release);
1298 1296
1299 EXPECT_TRUE(delegate->fling()); 1297 EXPECT_TRUE(delegate->fling());
1300 EXPECT_FALSE(delegate->scroll_end()); 1298 EXPECT_FALSE(delegate->scroll_end());
1301 EXPECT_GT(delegate->velocity_x(), 0); 1299 EXPECT_GT(delegate->velocity_x(), 0);
1302 EXPECT_GT(delegate->velocity_y(), 0); 1300 EXPECT_GT(delegate->velocity_y(), 0);
1303 } 1301 }
1304 1302
1305 // Check that appropriate touch events generate long press events 1303 // Check that appropriate touch events generate long press events
1306 TEST_F(GestureRecognizerTest, GestureEventLongPress) { 1304 TEST_F(GestureRecognizerTest, GestureEventLongPress) {
1307 scoped_ptr<GestureEventConsumeDelegate> delegate( 1305 scoped_ptr<GestureEventConsumeDelegate> delegate(
1308 new GestureEventConsumeDelegate()); 1306 new GestureEventConsumeDelegate());
1309 const int kWindowWidth = 123; 1307 const int kWindowWidth = 123;
1310 const int kWindowHeight = 45; 1308 const int kWindowHeight = 45;
1311 const int kTouchId = 2; 1309 const int kTouchId = 2;
1312 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 1310 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
1313 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1311 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1314 delegate.get(), -1234, bounds, root_window())); 1312 delegate.get(), -1234, bounds, root_window()));
1315 1313
1316 delegate->Reset(); 1314 delegate->Reset();
1317 1315
1318 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, 1316 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
1319 gfx::Point(101, 201), 1317 kTouchId, ui::EventTimeForNow());
1320 kTouchId,
1321 ui::EventTimeForNow());
1322 DispatchEventUsingWindowDispatcher(&press1); 1318 DispatchEventUsingWindowDispatcher(&press1);
1323 EXPECT_TRUE(delegate->tap_down()); 1319 EXPECT_TRUE(delegate->tap_down());
1324 EXPECT_TRUE(delegate->begin()); 1320 EXPECT_TRUE(delegate->begin());
1325 EXPECT_FALSE(delegate->tap_cancel()); 1321 EXPECT_FALSE(delegate->tap_cancel());
1326 1322
1327 // We haven't pressed long enough for a long press to occur 1323 // We haven't pressed long enough for a long press to occur
1328 EXPECT_FALSE(delegate->long_press()); 1324 EXPECT_FALSE(delegate->long_press());
1329 1325
1330 // Wait until the timer runs out 1326 // Wait until the timer runs out
1331 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS); 1327 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS);
1332 EXPECT_TRUE(delegate->long_press()); 1328 EXPECT_TRUE(delegate->long_press());
1333 EXPECT_FALSE(delegate->tap_cancel()); 1329 EXPECT_FALSE(delegate->tap_cancel());
1334 1330
1335 delegate->Reset(); 1331 delegate->Reset();
1336 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, 1332 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
1337 gfx::Point(101, 201), 1333 kTouchId, ui::EventTimeForNow());
1338 kTouchId,
1339 ui::EventTimeForNow());
1340 DispatchEventUsingWindowDispatcher(&release1); 1334 DispatchEventUsingWindowDispatcher(&release1);
1341 EXPECT_FALSE(delegate->long_press()); 1335 EXPECT_FALSE(delegate->long_press());
1342 1336
1343 // Note the tap cancel isn't dispatched until the release 1337 // Note the tap cancel isn't dispatched until the release
1344 EXPECT_TRUE(delegate->tap_cancel()); 1338 EXPECT_TRUE(delegate->tap_cancel());
1345 EXPECT_FALSE(delegate->tap()); 1339 EXPECT_FALSE(delegate->tap());
1346 } 1340 }
1347 1341
1348 // Check that scrolling prevents a long press. 1342 // Check that scrolling prevents a long press.
1349 TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByScroll) { 1343 TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByScroll) {
1350 scoped_ptr<GestureEventConsumeDelegate> delegate( 1344 scoped_ptr<GestureEventConsumeDelegate> delegate(
1351 new GestureEventConsumeDelegate()); 1345 new GestureEventConsumeDelegate());
1352 TimedEvents tes; 1346 TimedEvents tes;
1353 const int kWindowWidth = 123; 1347 const int kWindowWidth = 123;
1354 const int kWindowHeight = 45; 1348 const int kWindowHeight = 45;
1355 const int kTouchId = 6; 1349 const int kTouchId = 6;
1356 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 1350 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
1357 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1351 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1358 delegate.get(), -1234, bounds, root_window())); 1352 delegate.get(), -1234, bounds, root_window()));
1359 1353
1360 delegate->Reset(); 1354 delegate->Reset();
1361 1355
1362 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 1356 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
1363 kTouchId, tes.Now()); 1357 kTouchId, tes.Now());
1364 DispatchEventUsingWindowDispatcher(&press1); 1358 DispatchEventUsingWindowDispatcher(&press1);
1365 EXPECT_TRUE(delegate->tap_down()); 1359 EXPECT_TRUE(delegate->tap_down());
1366 1360
1367 // We haven't pressed long enough for a long press to occur 1361 // We haven't pressed long enough for a long press to occur
1368 EXPECT_FALSE(delegate->long_press()); 1362 EXPECT_FALSE(delegate->long_press());
1369 EXPECT_FALSE(delegate->tap_cancel()); 1363 EXPECT_FALSE(delegate->tap_cancel());
1370 1364
1371 // Scroll around, to cancel the long press 1365 // Scroll around, to cancel the long press
1372 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId, delegate.get()); 1366 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId, delegate.get());
1373 1367
1374 // Wait until a long press event would have fired, if it hadn't been 1368 // Wait until a long press event would have fired, if it hadn't been
1375 // cancelled. 1369 // cancelled.
1376 DelayByLongPressTimeout(); 1370 DelayByLongPressTimeout();
1377 1371
1378 EXPECT_FALSE(delegate->long_press()); 1372 EXPECT_FALSE(delegate->long_press());
1379 EXPECT_TRUE(delegate->tap_cancel()); 1373 EXPECT_TRUE(delegate->tap_cancel());
1380 1374
1381 delegate->Reset(); 1375 delegate->Reset();
1382 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 1376 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
1383 kTouchId, tes.LeapForward(10)); 1377 kTouchId, tes.LeapForward(10));
1384 DispatchEventUsingWindowDispatcher(&release1); 1378 DispatchEventUsingWindowDispatcher(&release1);
1385 EXPECT_FALSE(delegate->long_press()); 1379 EXPECT_FALSE(delegate->long_press());
1386 EXPECT_FALSE(delegate->tap_cancel()); 1380 EXPECT_FALSE(delegate->tap_cancel());
1387 } 1381 }
1388 1382
1389 // Check that appropriate touch events generate long tap events 1383 // Check that appropriate touch events generate long tap events
1390 TEST_F(GestureRecognizerTest, GestureEventLongTap) { 1384 TEST_F(GestureRecognizerTest, GestureEventLongTap) {
1391 ui::GestureConfiguration::GetInstance() 1385 ui::GestureConfiguration::GetInstance()
1392 ->set_max_touch_down_duration_for_click_in_ms(3); 1386 ->set_max_touch_down_duration_for_click_in_ms(3);
1393 scoped_ptr<GestureEventConsumeDelegate> delegate( 1387 scoped_ptr<GestureEventConsumeDelegate> delegate(
1394 new GestureEventConsumeDelegate()); 1388 new GestureEventConsumeDelegate());
1395 const int kWindowWidth = 123; 1389 const int kWindowWidth = 123;
1396 const int kWindowHeight = 45; 1390 const int kWindowHeight = 45;
1397 const int kTouchId = 2; 1391 const int kTouchId = 2;
1398 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 1392 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
1399 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1393 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1400 delegate.get(), -1234, bounds, root_window())); 1394 delegate.get(), -1234, bounds, root_window()));
1401 1395
1402 delegate->Reset(); 1396 delegate->Reset();
1403 1397
1404 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, 1398 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
1405 gfx::Point(101, 201), 1399 kTouchId, ui::EventTimeForNow());
1406 kTouchId,
1407 ui::EventTimeForNow());
1408 DispatchEventUsingWindowDispatcher(&press1); 1400 DispatchEventUsingWindowDispatcher(&press1);
1409 EXPECT_TRUE(delegate->tap_down()); 1401 EXPECT_TRUE(delegate->tap_down());
1410 EXPECT_TRUE(delegate->begin()); 1402 EXPECT_TRUE(delegate->begin());
1411 EXPECT_FALSE(delegate->tap_cancel()); 1403 EXPECT_FALSE(delegate->tap_cancel());
1412 1404
1413 // We haven't pressed long enough for a long press to occur 1405 // We haven't pressed long enough for a long press to occur
1414 EXPECT_FALSE(delegate->long_press()); 1406 EXPECT_FALSE(delegate->long_press());
1415 1407
1416 // Wait until the timer runs out 1408 // Wait until the timer runs out
1417 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS); 1409 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS);
1418 EXPECT_TRUE(delegate->long_press()); 1410 EXPECT_TRUE(delegate->long_press());
1419 EXPECT_FALSE(delegate->tap_cancel()); 1411 EXPECT_FALSE(delegate->tap_cancel());
1420 1412
1421 delegate->Reset(); 1413 delegate->Reset();
1422 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, 1414 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
1423 gfx::Point(101, 201), 1415 kTouchId, ui::EventTimeForNow());
1424 kTouchId,
1425 ui::EventTimeForNow());
1426 DispatchEventUsingWindowDispatcher(&release1); 1416 DispatchEventUsingWindowDispatcher(&release1);
1427 EXPECT_FALSE(delegate->long_press()); 1417 EXPECT_FALSE(delegate->long_press());
1428 EXPECT_TRUE(delegate->long_tap()); 1418 EXPECT_TRUE(delegate->long_tap());
1429 1419
1430 // Note the tap cancel isn't dispatched until the release 1420 // Note the tap cancel isn't dispatched until the release
1431 EXPECT_TRUE(delegate->tap_cancel()); 1421 EXPECT_TRUE(delegate->tap_cancel());
1432 EXPECT_FALSE(delegate->tap()); 1422 EXPECT_FALSE(delegate->tap());
1433 } 1423 }
1434 1424
1435 // Check that second tap cancels a long press 1425 // Check that second tap cancels a long press
1436 TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledBySecondTap) { 1426 TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledBySecondTap) {
1437 scoped_ptr<GestureEventConsumeDelegate> delegate( 1427 scoped_ptr<GestureEventConsumeDelegate> delegate(
1438 new GestureEventConsumeDelegate()); 1428 new GestureEventConsumeDelegate());
1439 TimedEvents tes; 1429 TimedEvents tes;
1440 const int kWindowWidth = 300; 1430 const int kWindowWidth = 300;
1441 const int kWindowHeight = 400; 1431 const int kWindowHeight = 400;
1442 const int kTouchId1 = 8; 1432 const int kTouchId1 = 8;
1443 const int kTouchId2 = 2; 1433 const int kTouchId2 = 2;
1444 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); 1434 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight);
1445 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1435 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1446 delegate.get(), -1234, bounds, root_window())); 1436 delegate.get(), -1234, bounds, root_window()));
1447 1437
1448 delegate->Reset(); 1438 delegate->Reset();
1449 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 1439 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
1450 kTouchId1, tes.Now()); 1440 kTouchId1, tes.Now());
1451 DispatchEventUsingWindowDispatcher(&press); 1441 DispatchEventUsingWindowDispatcher(&press);
1452 EXPECT_TRUE(delegate->tap_down()); 1442 EXPECT_TRUE(delegate->tap_down());
1453 EXPECT_TRUE(delegate->begin()); 1443 EXPECT_TRUE(delegate->begin());
1454 1444
1455 // We haven't pressed long enough for a long press to occur 1445 // We haven't pressed long enough for a long press to occur
1456 EXPECT_FALSE(delegate->long_press()); 1446 EXPECT_FALSE(delegate->long_press());
1457 1447
1458 // Second tap, to cancel the long press 1448 // Second tap, to cancel the long press
1459 delegate->Reset(); 1449 delegate->Reset();
1460 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1450 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(10.f, 10.f),
1461 kTouchId2, tes.Now()); 1451 kTouchId2, tes.Now());
1462 DispatchEventUsingWindowDispatcher(&press2); 1452 DispatchEventUsingWindowDispatcher(&press2);
1463 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap. 1453 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap.
1464 EXPECT_TRUE(delegate->tap_cancel()); 1454 EXPECT_TRUE(delegate->tap_cancel());
1465 EXPECT_TRUE(delegate->begin()); 1455 EXPECT_TRUE(delegate->begin());
1466 1456
1467 // Wait until the timer runs out 1457 // Wait until the timer runs out
1468 DelayByLongPressTimeout(); 1458 DelayByLongPressTimeout();
1469 1459
1470 // No long press occurred 1460 // No long press occurred
1471 EXPECT_FALSE(delegate->long_press()); 1461 EXPECT_FALSE(delegate->long_press());
1472 1462
1473 delegate->Reset(); 1463 delegate->Reset();
1474 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 1464 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
1475 kTouchId1, tes.Now()); 1465 kTouchId1, tes.Now());
1476 DispatchEventUsingWindowDispatcher(&release1); 1466 DispatchEventUsingWindowDispatcher(&release1);
1477 EXPECT_FALSE(delegate->long_press()); 1467 EXPECT_FALSE(delegate->long_press());
1478 EXPECT_TRUE(delegate->two_finger_tap()); 1468 EXPECT_TRUE(delegate->two_finger_tap());
1479 EXPECT_FALSE(delegate->tap_cancel()); 1469 EXPECT_FALSE(delegate->tap_cancel());
1480 } 1470 }
1481 1471
1482 // Check that horizontal scroll gestures cause scrolls on horizontal rails. 1472 // Check that horizontal scroll gestures cause scrolls on horizontal rails.
1483 // Also tests that horizontal rails can be broken. 1473 // Also tests that horizontal rails can be broken.
1484 TEST_F(GestureRecognizerTest, GestureEventHorizontalRailScroll) { 1474 TEST_F(GestureRecognizerTest, GestureEventHorizontalRailScroll) {
1485 scoped_ptr<GestureEventConsumeDelegate> delegate( 1475 scoped_ptr<GestureEventConsumeDelegate> delegate(
1486 new GestureEventConsumeDelegate()); 1476 new GestureEventConsumeDelegate());
1487 TimedEvents tes; 1477 TimedEvents tes;
1488 const int kTouchId = 7; 1478 const int kTouchId = 7;
1489 gfx::Rect bounds(0, 0, 1000, 1000); 1479 gfx::Rect bounds(0, 0, 1000, 1000);
1490 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1480 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1491 delegate.get(), -1234, bounds, root_window())); 1481 delegate.get(), -1234, bounds, root_window()));
1492 1482
1493 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 1483 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(), kTouchId,
1494 kTouchId, tes.Now()); 1484 tes.Now());
1495 DispatchEventUsingWindowDispatcher(&press); 1485 DispatchEventUsingWindowDispatcher(&press);
1496 1486
1497 // Get rid of touch slop. 1487 // Get rid of touch slop.
1498 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(5, 0), 1488 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(5.f, 0.f), kTouchId,
1499 kTouchId, tes.Now()); 1489 tes.Now());
1500 1490
1501 DispatchEventUsingWindowDispatcher(&move); 1491 DispatchEventUsingWindowDispatcher(&move);
1502 delegate->Reset(); 1492 delegate->Reset();
1503 1493
1504 // Move the touch-point horizontally enough that it is considered a 1494 // Move the touch-point horizontally enough that it is considered a
1505 // horizontal scroll. 1495 // horizontal scroll.
1506 tes.SendScrollEvent(event_processor(), 25, 0, kTouchId, delegate.get()); 1496 tes.SendScrollEvent(event_processor(), 25, 0, kTouchId, delegate.get());
1507 EXPECT_EQ(0, delegate->scroll_y()); 1497 EXPECT_EQ(0, delegate->scroll_y());
1508 EXPECT_EQ(20, delegate->scroll_x()); 1498 EXPECT_EQ(20, delegate->scroll_x());
1509 1499
(...skipping 29 matching lines...) Expand all
1539 // Also tests that vertical rails can be broken. 1529 // Also tests that vertical rails can be broken.
1540 TEST_F(GestureRecognizerTest, GestureEventVerticalRailScroll) { 1530 TEST_F(GestureRecognizerTest, GestureEventVerticalRailScroll) {
1541 scoped_ptr<GestureEventConsumeDelegate> delegate( 1531 scoped_ptr<GestureEventConsumeDelegate> delegate(
1542 new GestureEventConsumeDelegate()); 1532 new GestureEventConsumeDelegate());
1543 TimedEvents tes; 1533 TimedEvents tes;
1544 const int kTouchId = 7; 1534 const int kTouchId = 7;
1545 gfx::Rect bounds(0, 0, 1000, 1000); 1535 gfx::Rect bounds(0, 0, 1000, 1000);
1546 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1536 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1547 delegate.get(), -1234, bounds, root_window())); 1537 delegate.get(), -1234, bounds, root_window()));
1548 1538
1549 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 1539 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(), kTouchId,
1550 kTouchId, tes.Now()); 1540 tes.Now());
1551 DispatchEventUsingWindowDispatcher(&press); 1541 DispatchEventUsingWindowDispatcher(&press);
1552 1542
1553 // Get rid of touch slop. 1543 // Get rid of touch slop.
1554 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(0, 5), 1544 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(0.f, 5.f), kTouchId,
1555 kTouchId, tes.Now()); 1545 tes.Now());
1556 DispatchEventUsingWindowDispatcher(&move); 1546 DispatchEventUsingWindowDispatcher(&move);
1557 delegate->Reset(); 1547 delegate->Reset();
1558 1548
1559 // Move the touch-point vertically enough that it is considered a 1549 // Move the touch-point vertically enough that it is considered a
1560 // vertical scroll. 1550 // vertical scroll.
1561 tes.SendScrollEvent(event_processor(), 0, 25, kTouchId, delegate.get()); 1551 tes.SendScrollEvent(event_processor(), 0, 25, kTouchId, delegate.get());
1562 EXPECT_EQ(0, delegate->scroll_x()); 1552 EXPECT_EQ(0, delegate->scroll_x());
1563 EXPECT_EQ(20, delegate->scroll_y()); 1553 EXPECT_EQ(20, delegate->scroll_y());
1564 1554
1565 tes.SendScrollEvent(event_processor(), 6, 30, kTouchId, delegate.get()); 1555 tes.SendScrollEvent(event_processor(), 6, 30, kTouchId, delegate.get());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 new GestureEventConsumeDelegate()); 1593 new GestureEventConsumeDelegate());
1604 TimedEvents tes; 1594 TimedEvents tes;
1605 const int kWindowWidth = 123; 1595 const int kWindowWidth = 123;
1606 const int kWindowHeight = 45; 1596 const int kWindowHeight = 45;
1607 const int kTouchId = 3; 1597 const int kTouchId = 3;
1608 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 1598 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
1609 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1599 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1610 delegate.get(), -1234, bounds, root_window())); 1600 delegate.get(), -1234, bounds, root_window()));
1611 1601
1612 delegate->Reset(); 1602 delegate->Reset();
1613 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 1603 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
1614 kTouchId, tes.Now()); 1604 kTouchId, tes.Now());
1615 DispatchEventUsingWindowDispatcher(&press); 1605 DispatchEventUsingWindowDispatcher(&press);
1616 EXPECT_FALSE(delegate->tap()); 1606 EXPECT_FALSE(delegate->tap());
1617 EXPECT_TRUE(delegate->tap_down()); 1607 EXPECT_TRUE(delegate->tap_down());
1618 EXPECT_FALSE(delegate->tap_cancel()); 1608 EXPECT_FALSE(delegate->tap_cancel());
1619 EXPECT_FALSE(delegate->scroll_begin()); 1609 EXPECT_FALSE(delegate->scroll_begin());
1620 EXPECT_FALSE(delegate->scroll_update()); 1610 EXPECT_FALSE(delegate->scroll_update());
1621 EXPECT_FALSE(delegate->scroll_end()); 1611 EXPECT_FALSE(delegate->scroll_end());
1622 1612
1623 // Make sure there is enough delay before the touch is released so that it is 1613 // Make sure there is enough delay before the touch is released so that it is
1624 // recognized as a tap. 1614 // recognized as a tap.
1625 delegate->Reset(); 1615 delegate->Reset();
1626 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 1616 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
1627 kTouchId, tes.LeapForward(50)); 1617 kTouchId, tes.LeapForward(50));
1628 DispatchEventUsingWindowDispatcher(&release); 1618 DispatchEventUsingWindowDispatcher(&release);
1629 EXPECT_TRUE(delegate->tap()); 1619 EXPECT_TRUE(delegate->tap());
1630 EXPECT_FALSE(delegate->tap_down()); 1620 EXPECT_FALSE(delegate->tap_down());
1631 EXPECT_FALSE(delegate->tap_cancel()); 1621 EXPECT_FALSE(delegate->tap_cancel());
1632 EXPECT_FALSE(delegate->scroll_begin()); 1622 EXPECT_FALSE(delegate->scroll_begin());
1633 EXPECT_FALSE(delegate->scroll_update()); 1623 EXPECT_FALSE(delegate->scroll_update());
1634 EXPECT_FALSE(delegate->scroll_end()); 1624 EXPECT_FALSE(delegate->scroll_end());
1635 1625
1636 // Now, do a scroll gesture. Delay it sufficiently so that it doesn't trigger 1626 // Now, do a scroll gesture. Delay it sufficiently so that it doesn't trigger
1637 // a double-tap. 1627 // a double-tap.
1638 delegate->Reset(); 1628 delegate->Reset();
1639 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 1629 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
1640 kTouchId, tes.LeapForward(1000)); 1630 kTouchId, tes.LeapForward(1000));
1641 DispatchEventUsingWindowDispatcher(&press1); 1631 DispatchEventUsingWindowDispatcher(&press1);
1642 EXPECT_FALSE(delegate->tap()); 1632 EXPECT_FALSE(delegate->tap());
1643 EXPECT_TRUE(delegate->tap_down()); 1633 EXPECT_TRUE(delegate->tap_down());
1644 EXPECT_FALSE(delegate->tap_cancel()); 1634 EXPECT_FALSE(delegate->tap_cancel());
1645 EXPECT_FALSE(delegate->scroll_begin()); 1635 EXPECT_FALSE(delegate->scroll_begin());
1646 EXPECT_FALSE(delegate->scroll_update()); 1636 EXPECT_FALSE(delegate->scroll_update());
1647 EXPECT_FALSE(delegate->scroll_end()); 1637 EXPECT_FALSE(delegate->scroll_end());
1648 1638
1649 // Get rid of touch slop. 1639 // Get rid of touch slop.
1650 ui::TouchEvent move_remove_slop(ui::ET_TOUCH_MOVED, gfx::Point(116, 216), 1640 ui::TouchEvent move_remove_slop(ui::ET_TOUCH_MOVED, gfx::PointF(116.f, 216.f),
1651 kTouchId, tes.Now()); 1641 kTouchId, tes.Now());
1652 DispatchEventUsingWindowDispatcher(&move_remove_slop); 1642 DispatchEventUsingWindowDispatcher(&move_remove_slop);
1653 EXPECT_TRUE(delegate->tap_cancel()); 1643 EXPECT_TRUE(delegate->tap_cancel());
1654 EXPECT_TRUE(delegate->scroll_begin()); 1644 EXPECT_TRUE(delegate->scroll_begin());
1655 EXPECT_TRUE(delegate->scroll_update()); 1645 EXPECT_TRUE(delegate->scroll_update());
1656 EXPECT_EQ(15, delegate->scroll_x_hint()); 1646 EXPECT_EQ(15, delegate->scroll_x_hint());
1657 EXPECT_EQ(15, delegate->scroll_y_hint()); 1647 EXPECT_EQ(15, delegate->scroll_y_hint());
1658 1648
1659 delegate->Reset(); 1649 delegate->Reset();
1660 1650
1661 // Move the touch-point enough so that it is considered as a scroll. This 1651 // Move the touch-point enough so that it is considered as a scroll. This
1662 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. 1652 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures.
1663 // The first movement is diagonal, to ensure that we have a free scroll, 1653 // The first movement is diagonal, to ensure that we have a free scroll,
1664 // and not a rail scroll. 1654 // and not a rail scroll.
1665 delegate->Reset(); 1655 delegate->Reset();
1666 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(135, 235), 1656 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(135.f, 235.f), kTouchId,
1667 kTouchId, tes.Now()); 1657 tes.Now());
1668 DispatchEventUsingWindowDispatcher(&move); 1658 DispatchEventUsingWindowDispatcher(&move);
1669 EXPECT_FALSE(delegate->tap()); 1659 EXPECT_FALSE(delegate->tap());
1670 EXPECT_FALSE(delegate->tap_down()); 1660 EXPECT_FALSE(delegate->tap_down());
1671 EXPECT_FALSE(delegate->tap_cancel()); 1661 EXPECT_FALSE(delegate->tap_cancel());
1672 EXPECT_FALSE(delegate->scroll_begin()); 1662 EXPECT_FALSE(delegate->scroll_begin());
1673 EXPECT_TRUE(delegate->scroll_update()); 1663 EXPECT_TRUE(delegate->scroll_update());
1674 EXPECT_FALSE(delegate->scroll_end()); 1664 EXPECT_FALSE(delegate->scroll_end());
1675 EXPECT_EQ(19, delegate->scroll_x()); 1665 EXPECT_EQ(19, delegate->scroll_x());
1676 EXPECT_EQ(19, delegate->scroll_y()); 1666 EXPECT_EQ(19, delegate->scroll_y());
1677 1667
1678 // Move some more to generate a few more scroll updates. 1668 // Move some more to generate a few more scroll updates.
1679 delegate->Reset(); 1669 delegate->Reset();
1680 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(115, 216), 1670 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::PointF(115.f, 216.f), kTouchId,
1681 kTouchId, tes.Now()); 1671 tes.Now());
1682 DispatchEventUsingWindowDispatcher(&move1); 1672 DispatchEventUsingWindowDispatcher(&move1);
1683 EXPECT_FALSE(delegate->tap()); 1673 EXPECT_FALSE(delegate->tap());
1684 EXPECT_FALSE(delegate->tap_down()); 1674 EXPECT_FALSE(delegate->tap_down());
1685 EXPECT_FALSE(delegate->tap_cancel()); 1675 EXPECT_FALSE(delegate->tap_cancel());
1686 EXPECT_FALSE(delegate->scroll_begin()); 1676 EXPECT_FALSE(delegate->scroll_begin());
1687 EXPECT_TRUE(delegate->scroll_update()); 1677 EXPECT_TRUE(delegate->scroll_update());
1688 EXPECT_FALSE(delegate->scroll_end()); 1678 EXPECT_FALSE(delegate->scroll_end());
1689 EXPECT_EQ(-20, delegate->scroll_x()); 1679 EXPECT_EQ(-20, delegate->scroll_x());
1690 EXPECT_EQ(-19, delegate->scroll_y()); 1680 EXPECT_EQ(-19, delegate->scroll_y());
1691 EXPECT_EQ(0, delegate->scroll_x_hint()); 1681 EXPECT_EQ(0, delegate->scroll_x_hint());
1692 EXPECT_EQ(0, delegate->scroll_y_hint()); 1682 EXPECT_EQ(0, delegate->scroll_y_hint());
1693 1683
1694 delegate->Reset(); 1684 delegate->Reset();
1695 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(145, 220), 1685 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::PointF(145.f, 220.f), kTouchId,
1696 kTouchId, tes.Now()); 1686 tes.Now());
1697 DispatchEventUsingWindowDispatcher(&move2); 1687 DispatchEventUsingWindowDispatcher(&move2);
1698 EXPECT_FALSE(delegate->tap()); 1688 EXPECT_FALSE(delegate->tap());
1699 EXPECT_FALSE(delegate->tap_down()); 1689 EXPECT_FALSE(delegate->tap_down());
1700 EXPECT_FALSE(delegate->tap_cancel()); 1690 EXPECT_FALSE(delegate->tap_cancel());
1701 EXPECT_FALSE(delegate->scroll_begin()); 1691 EXPECT_FALSE(delegate->scroll_begin());
1702 EXPECT_TRUE(delegate->scroll_update()); 1692 EXPECT_TRUE(delegate->scroll_update());
1703 EXPECT_FALSE(delegate->scroll_end()); 1693 EXPECT_FALSE(delegate->scroll_end());
1704 EXPECT_EQ(30, delegate->scroll_x()); 1694 EXPECT_EQ(30, delegate->scroll_x());
1705 EXPECT_EQ(4, delegate->scroll_y()); 1695 EXPECT_EQ(4, delegate->scroll_y());
1706 1696
1707 // Release the touch. This should end the scroll. 1697 // Release the touch. This should end the scroll.
1708 delegate->Reset(); 1698 delegate->Reset();
1709 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 1699 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
1710 kTouchId, tes.Now()); 1700 kTouchId, tes.Now());
1711 DispatchEventUsingWindowDispatcher(&release1); 1701 DispatchEventUsingWindowDispatcher(&release1);
1712 EXPECT_FALSE(delegate->tap()); 1702 EXPECT_FALSE(delegate->tap());
1713 EXPECT_FALSE(delegate->tap_down()); 1703 EXPECT_FALSE(delegate->tap_down());
1714 EXPECT_FALSE(delegate->tap_cancel()); 1704 EXPECT_FALSE(delegate->tap_cancel());
1715 EXPECT_FALSE(delegate->scroll_begin()); 1705 EXPECT_FALSE(delegate->scroll_begin());
1716 EXPECT_FALSE(delegate->scroll_update()); 1706 EXPECT_FALSE(delegate->scroll_update());
1717 EXPECT_FALSE(delegate->scroll_end()); 1707 EXPECT_FALSE(delegate->scroll_end());
1718 EXPECT_TRUE(delegate->fling()); 1708 EXPECT_TRUE(delegate->fling());
1719 } 1709 }
1720 1710
1721 TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) { 1711 TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
1722 scoped_ptr<QueueTouchEventDelegate> queued_delegate( 1712 scoped_ptr<QueueTouchEventDelegate> queued_delegate(
1723 new QueueTouchEventDelegate(host()->dispatcher())); 1713 new QueueTouchEventDelegate(host()->dispatcher()));
1724 TimedEvents tes; 1714 TimedEvents tes;
1725 const int kWindowWidth = 123; 1715 const int kWindowWidth = 123;
1726 const int kWindowHeight = 45; 1716 const int kWindowHeight = 45;
1727 const int kTouchId1 = 6; 1717 const int kTouchId1 = 6;
1728 const int kTouchId2 = 4; 1718 const int kTouchId2 = 4;
1729 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 1719 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
1730 scoped_ptr<aura::Window> queue(CreateTestWindowWithDelegate( 1720 scoped_ptr<aura::Window> queue(CreateTestWindowWithDelegate(
1731 queued_delegate.get(), -1234, bounds, root_window())); 1721 queued_delegate.get(), -1234, bounds, root_window()));
1732 1722
1733 queued_delegate->set_window(queue.get()); 1723 queued_delegate->set_window(queue.get());
1734 1724
1735 // Touch down on the window. This should not generate any gesture event. 1725 // Touch down on the window. This should not generate any gesture event.
1736 queued_delegate->Reset(); 1726 queued_delegate->Reset();
1737 ui::TouchEvent press( 1727 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
1738 ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId1, tes.Now()); 1728 kTouchId1, tes.Now());
1739 DispatchEventUsingWindowDispatcher(&press); 1729 DispatchEventUsingWindowDispatcher(&press);
1740 EXPECT_FALSE(queued_delegate->tap()); 1730 EXPECT_FALSE(queued_delegate->tap());
1741 EXPECT_FALSE(queued_delegate->tap_down()); 1731 EXPECT_FALSE(queued_delegate->tap_down());
1742 EXPECT_FALSE(queued_delegate->tap_cancel()); 1732 EXPECT_FALSE(queued_delegate->tap_cancel());
1743 EXPECT_FALSE(queued_delegate->begin()); 1733 EXPECT_FALSE(queued_delegate->begin());
1744 EXPECT_FALSE(queued_delegate->scroll_begin()); 1734 EXPECT_FALSE(queued_delegate->scroll_begin());
1745 EXPECT_FALSE(queued_delegate->scroll_update()); 1735 EXPECT_FALSE(queued_delegate->scroll_update());
1746 EXPECT_FALSE(queued_delegate->scroll_end()); 1736 EXPECT_FALSE(queued_delegate->scroll_end());
1747 1737
1748 // Introduce some delay before the touch is released so that it is recognized 1738 // Introduce some delay before the touch is released so that it is recognized
1749 // as a tap. However, this still should not create any gesture events. 1739 // as a tap. However, this still should not create any gesture events.
1750 queued_delegate->Reset(); 1740 queued_delegate->Reset();
1751 ui::TouchEvent release( 1741 ui::TouchEvent release(
1752 ui::ET_TOUCH_RELEASED, 1742 ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f), kTouchId1,
1753 gfx::Point(101, 201),
1754 kTouchId1,
1755 press.time_stamp() + base::TimeDelta::FromMilliseconds(50)); 1743 press.time_stamp() + base::TimeDelta::FromMilliseconds(50));
1756 DispatchEventUsingWindowDispatcher(&release); 1744 DispatchEventUsingWindowDispatcher(&release);
1757 EXPECT_FALSE(queued_delegate->tap()); 1745 EXPECT_FALSE(queued_delegate->tap());
1758 EXPECT_FALSE(queued_delegate->tap_down()); 1746 EXPECT_FALSE(queued_delegate->tap_down());
1759 EXPECT_FALSE(queued_delegate->tap_cancel()); 1747 EXPECT_FALSE(queued_delegate->tap_cancel());
1760 EXPECT_FALSE(queued_delegate->begin()); 1748 EXPECT_FALSE(queued_delegate->begin());
1761 EXPECT_FALSE(queued_delegate->end()); 1749 EXPECT_FALSE(queued_delegate->end());
1762 EXPECT_FALSE(queued_delegate->scroll_begin()); 1750 EXPECT_FALSE(queued_delegate->scroll_begin());
1763 EXPECT_FALSE(queued_delegate->scroll_update()); 1751 EXPECT_FALSE(queued_delegate->scroll_update());
1764 EXPECT_FALSE(queued_delegate->scroll_end()); 1752 EXPECT_FALSE(queued_delegate->scroll_end());
1765 1753
1766 // Create another window, and place a touch-down on it. This should create a 1754 // Create another window, and place a touch-down on it. This should create a
1767 // tap-down gesture. 1755 // tap-down gesture.
1768 scoped_ptr<GestureEventConsumeDelegate> delegate( 1756 scoped_ptr<GestureEventConsumeDelegate> delegate(
1769 new GestureEventConsumeDelegate()); 1757 new GestureEventConsumeDelegate());
1770 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1758 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1771 delegate.get(), -2345, gfx::Rect(0, 0, 50, 50), root_window())); 1759 delegate.get(), -2345, gfx::Rect(0, 0, 50, 50), root_window()));
1772 delegate->Reset(); 1760 delegate->Reset();
1773 ui::TouchEvent press2( 1761 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(10.f, 20.f),
1774 ui::ET_TOUCH_PRESSED, gfx::Point(10, 20), kTouchId2, tes.Now()); 1762 kTouchId2, tes.Now());
1775 DispatchEventUsingWindowDispatcher(&press2); 1763 DispatchEventUsingWindowDispatcher(&press2);
1776 EXPECT_FALSE(delegate->tap()); 1764 EXPECT_FALSE(delegate->tap());
1777 EXPECT_TRUE(delegate->tap_down()); 1765 EXPECT_TRUE(delegate->tap_down());
1778 EXPECT_FALSE(delegate->tap_cancel()); 1766 EXPECT_FALSE(delegate->tap_cancel());
1779 EXPECT_FALSE(queued_delegate->begin()); 1767 EXPECT_FALSE(queued_delegate->begin());
1780 EXPECT_FALSE(queued_delegate->end()); 1768 EXPECT_FALSE(queued_delegate->end());
1781 EXPECT_FALSE(delegate->scroll_begin()); 1769 EXPECT_FALSE(delegate->scroll_begin());
1782 EXPECT_FALSE(delegate->scroll_update()); 1770 EXPECT_FALSE(delegate->scroll_update());
1783 EXPECT_FALSE(delegate->scroll_end()); 1771 EXPECT_FALSE(delegate->scroll_end());
1784 1772
1785 ui::TouchEvent release2( 1773 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::PointF(10.f, 20.f),
1786 ui::ET_TOUCH_RELEASED, gfx::Point(10, 20), kTouchId2, tes.Now()); 1774 kTouchId2, tes.Now());
1787 DispatchEventUsingWindowDispatcher(&release2); 1775 DispatchEventUsingWindowDispatcher(&release2);
1788 1776
1789 // Process the first queued event. 1777 // Process the first queued event.
1790 queued_delegate->Reset(); 1778 queued_delegate->Reset();
1791 queued_delegate->ReceivedAck(); 1779 queued_delegate->ReceivedAck();
1792 EXPECT_FALSE(queued_delegate->tap()); 1780 EXPECT_FALSE(queued_delegate->tap());
1793 EXPECT_TRUE(queued_delegate->tap_down()); 1781 EXPECT_TRUE(queued_delegate->tap_down());
1794 EXPECT_TRUE(queued_delegate->begin()); 1782 EXPECT_TRUE(queued_delegate->begin());
1795 EXPECT_FALSE(queued_delegate->tap_cancel()); 1783 EXPECT_FALSE(queued_delegate->tap_cancel());
1796 EXPECT_FALSE(queued_delegate->end()); 1784 EXPECT_FALSE(queued_delegate->end());
1797 EXPECT_FALSE(queued_delegate->scroll_begin()); 1785 EXPECT_FALSE(queued_delegate->scroll_begin());
1798 EXPECT_FALSE(queued_delegate->scroll_update()); 1786 EXPECT_FALSE(queued_delegate->scroll_update());
1799 EXPECT_FALSE(queued_delegate->scroll_end()); 1787 EXPECT_FALSE(queued_delegate->scroll_end());
1800 1788
1801 // Now, process the second queued event. 1789 // Now, process the second queued event.
1802 queued_delegate->Reset(); 1790 queued_delegate->Reset();
1803 queued_delegate->ReceivedAck(); 1791 queued_delegate->ReceivedAck();
1804 EXPECT_TRUE(queued_delegate->tap()); 1792 EXPECT_TRUE(queued_delegate->tap());
1805 EXPECT_FALSE(queued_delegate->tap_down()); 1793 EXPECT_FALSE(queued_delegate->tap_down());
1806 EXPECT_FALSE(queued_delegate->tap_cancel()); 1794 EXPECT_FALSE(queued_delegate->tap_cancel());
1807 EXPECT_FALSE(queued_delegate->begin()); 1795 EXPECT_FALSE(queued_delegate->begin());
1808 EXPECT_TRUE(queued_delegate->end()); 1796 EXPECT_TRUE(queued_delegate->end());
1809 EXPECT_FALSE(queued_delegate->scroll_begin()); 1797 EXPECT_FALSE(queued_delegate->scroll_begin());
1810 EXPECT_FALSE(queued_delegate->scroll_update()); 1798 EXPECT_FALSE(queued_delegate->scroll_update());
1811 EXPECT_FALSE(queued_delegate->scroll_end()); 1799 EXPECT_FALSE(queued_delegate->scroll_end());
1812 1800
1813 // Start all over. Press on the first window, then press again on the second 1801 // Start all over. Press on the first window, then press again on the second
1814 // window. The second press should still go to the first window. 1802 // window. The second press should still go to the first window.
1815 queued_delegate->Reset(); 1803 queued_delegate->Reset();
1816 ui::TouchEvent press3( 1804 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
1817 ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId1, tes.Now()); 1805 kTouchId1, tes.Now());
1818 DispatchEventUsingWindowDispatcher(&press3); 1806 DispatchEventUsingWindowDispatcher(&press3);
1819 EXPECT_FALSE(queued_delegate->tap()); 1807 EXPECT_FALSE(queued_delegate->tap());
1820 EXPECT_FALSE(queued_delegate->tap_down()); 1808 EXPECT_FALSE(queued_delegate->tap_down());
1821 EXPECT_FALSE(queued_delegate->tap_cancel()); 1809 EXPECT_FALSE(queued_delegate->tap_cancel());
1822 EXPECT_FALSE(queued_delegate->begin()); 1810 EXPECT_FALSE(queued_delegate->begin());
1823 EXPECT_FALSE(queued_delegate->end()); 1811 EXPECT_FALSE(queued_delegate->end());
1824 EXPECT_FALSE(queued_delegate->begin()); 1812 EXPECT_FALSE(queued_delegate->begin());
1825 EXPECT_FALSE(queued_delegate->end()); 1813 EXPECT_FALSE(queued_delegate->end());
1826 EXPECT_FALSE(queued_delegate->scroll_begin()); 1814 EXPECT_FALSE(queued_delegate->scroll_begin());
1827 EXPECT_FALSE(queued_delegate->scroll_update()); 1815 EXPECT_FALSE(queued_delegate->scroll_update());
1828 EXPECT_FALSE(queued_delegate->scroll_end()); 1816 EXPECT_FALSE(queued_delegate->scroll_end());
1829 1817
1830 queued_delegate->Reset(); 1818 queued_delegate->Reset();
1831 delegate->Reset(); 1819 delegate->Reset();
1832 ui::TouchEvent press4( 1820 ui::TouchEvent press4(ui::ET_TOUCH_PRESSED, gfx::PointF(103.f, 203.f),
1833 ui::ET_TOUCH_PRESSED, gfx::Point(103, 203), kTouchId2, tes.Now()); 1821 kTouchId2, tes.Now());
1834 DispatchEventUsingWindowDispatcher(&press4); 1822 DispatchEventUsingWindowDispatcher(&press4);
1835 EXPECT_FALSE(delegate->tap()); 1823 EXPECT_FALSE(delegate->tap());
1836 EXPECT_FALSE(delegate->tap_down()); 1824 EXPECT_FALSE(delegate->tap_down());
1837 EXPECT_FALSE(delegate->tap_cancel()); 1825 EXPECT_FALSE(delegate->tap_cancel());
1838 EXPECT_FALSE(delegate->begin()); 1826 EXPECT_FALSE(delegate->begin());
1839 EXPECT_FALSE(delegate->end()); 1827 EXPECT_FALSE(delegate->end());
1840 EXPECT_FALSE(delegate->scroll_begin()); 1828 EXPECT_FALSE(delegate->scroll_begin());
1841 EXPECT_FALSE(delegate->scroll_update()); 1829 EXPECT_FALSE(delegate->scroll_update());
1842 EXPECT_FALSE(delegate->scroll_end()); 1830 EXPECT_FALSE(delegate->scroll_end());
1843 EXPECT_FALSE(queued_delegate->tap()); 1831 EXPECT_FALSE(queued_delegate->tap());
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1925 TimedEvents tes; 1913 TimedEvents tes;
1926 const int kWindowWidth = 300; 1914 const int kWindowWidth = 300;
1927 const int kWindowHeight = 400; 1915 const int kWindowHeight = 400;
1928 const int kTouchId1 = 5; 1916 const int kTouchId1 = 5;
1929 const int kTouchId2 = 3; 1917 const int kTouchId2 = 3;
1930 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); 1918 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight);
1931 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1919 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1932 delegate.get(), -1234, bounds, root_window())); 1920 delegate.get(), -1234, bounds, root_window()));
1933 1921
1934 delegate->Reset(); 1922 delegate->Reset();
1935 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 1923 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
1936 kTouchId1, tes.Now()); 1924 kTouchId1, tes.Now());
1937 DispatchEventUsingWindowDispatcher(&press); 1925 DispatchEventUsingWindowDispatcher(&press);
1938 EXPECT_2_EVENTS(delegate->events(), 1926 EXPECT_2_EVENTS(delegate->events(),
1939 ui::ET_GESTURE_BEGIN, 1927 ui::ET_GESTURE_BEGIN,
1940 ui::ET_GESTURE_TAP_DOWN); 1928 ui::ET_GESTURE_TAP_DOWN);
1941 1929
1942 // Move the touch-point enough so that it is considered as a scroll. This 1930 // Move the touch-point enough so that it is considered as a scroll. This
1943 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. 1931 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures.
1944 delegate->Reset(); 1932 delegate->Reset();
1945 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(130, 301), 1933 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(130.f, 301.f), kTouchId1,
1946 kTouchId1, tes.Now()); 1934 tes.Now());
1947 DispatchEventUsingWindowDispatcher(&move); 1935 DispatchEventUsingWindowDispatcher(&move);
1948 EXPECT_3_EVENTS(delegate->events(), 1936 EXPECT_3_EVENTS(delegate->events(),
1949 ui::ET_GESTURE_TAP_CANCEL, 1937 ui::ET_GESTURE_TAP_CANCEL,
1950 ui::ET_GESTURE_SCROLL_BEGIN, 1938 ui::ET_GESTURE_SCROLL_BEGIN,
1951 ui::ET_GESTURE_SCROLL_UPDATE); 1939 ui::ET_GESTURE_SCROLL_UPDATE);
1952 1940
1953 // Press the second finger. It should cause pinch-begin. Note that we will not 1941 // Press the second finger. It should cause pinch-begin. Note that we will not
1954 // transition to two finger tap here because the touch points are far enough. 1942 // transition to two finger tap here because the touch points are far enough.
1955 delegate->Reset(); 1943 delegate->Reset();
1956 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1944 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(10.f, 10.f),
1957 kTouchId2, tes.Now()); 1945 kTouchId2, tes.Now());
1958 DispatchEventUsingWindowDispatcher(&press2); 1946 DispatchEventUsingWindowDispatcher(&press2);
1959 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_BEGIN); 1947 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_BEGIN);
1960 EXPECT_EQ(gfx::Rect(10, 10, 120, 291).ToString(), 1948 EXPECT_EQ(gfx::Rect(10, 10, 120, 291).ToString(),
1961 delegate->bounding_box().ToString()); 1949 delegate->bounding_box().ToString());
1962 1950
1963 // Move the first finger. 1951 // Move the first finger.
1964 delegate->Reset(); 1952 delegate->Reset();
1965 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(95, 201), 1953 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::PointF(95.f, 201.f), kTouchId1,
1966 kTouchId1, tes.Now()); 1954 tes.Now());
1967 DispatchEventUsingWindowDispatcher(&move3); 1955 DispatchEventUsingWindowDispatcher(&move3);
1968 EXPECT_2_EVENTS(delegate->events(), 1956 EXPECT_2_EVENTS(delegate->events(),
1969 ui::ET_GESTURE_SCROLL_UPDATE, 1957 ui::ET_GESTURE_SCROLL_UPDATE,
1970 ui::ET_GESTURE_PINCH_BEGIN); 1958 ui::ET_GESTURE_PINCH_BEGIN);
1971 EXPECT_EQ(gfx::Rect(10, 10, 85, 191).ToString(), 1959 EXPECT_EQ(gfx::Rect(10, 10, 85, 191).ToString(),
1972 delegate->bounding_box().ToString()); 1960 delegate->bounding_box().ToString());
1973 1961
1974 // Now move the second finger. 1962 // Now move the second finger.
1975 delegate->Reset(); 1963 delegate->Reset();
1976 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(55, 15), 1964 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::PointF(55.f, 15.f), kTouchId2,
1977 kTouchId2, tes.Now()); 1965 tes.Now());
1978 DispatchEventUsingWindowDispatcher(&move4); 1966 DispatchEventUsingWindowDispatcher(&move4);
1979 EXPECT_2_EVENTS(delegate->events(), 1967 EXPECT_2_EVENTS(delegate->events(),
1980 ui::ET_GESTURE_SCROLL_UPDATE, 1968 ui::ET_GESTURE_SCROLL_UPDATE,
1981 ui::ET_GESTURE_PINCH_UPDATE); 1969 ui::ET_GESTURE_PINCH_UPDATE);
1982 EXPECT_EQ(gfx::Rect(55, 15, 40, 186).ToString(), 1970 EXPECT_EQ(gfx::Rect(55, 15, 40, 186).ToString(),
1983 delegate->bounding_box().ToString()); 1971 delegate->bounding_box().ToString());
1984 1972
1985 // Release the first finger. This should end pinch. 1973 // Release the first finger. This should end pinch.
1986 delegate->Reset(); 1974 delegate->Reset();
1987 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 1975 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
1988 kTouchId1, tes.Now()); 1976 kTouchId1, tes.Now());
1989 DispatchEventUsingWindowDispatcher(&release); 1977 DispatchEventUsingWindowDispatcher(&release);
1990 EXPECT_2_EVENTS(delegate->events(), 1978 EXPECT_2_EVENTS(delegate->events(),
1991 ui::ET_GESTURE_PINCH_END, 1979 ui::ET_GESTURE_PINCH_END,
1992 ui::ET_GESTURE_END); 1980 ui::ET_GESTURE_END);
1993 EXPECT_EQ(gfx::Rect(55, 15, 46, 186).ToString(), 1981 EXPECT_EQ(gfx::Rect(55, 15, 46, 186).ToString(),
1994 delegate->bounding_box().ToString()); 1982 delegate->bounding_box().ToString());
1995 1983
1996 // Move the second finger. This should still generate a scroll. 1984 // Move the second finger. This should still generate a scroll.
1997 delegate->Reset(); 1985 delegate->Reset();
1998 ui::TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), 1986 ui::TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::PointF(25.f, 10.f), kTouchId2,
1999 kTouchId2, tes.Now()); 1987 tes.Now());
2000 DispatchEventUsingWindowDispatcher(&move5); 1988 DispatchEventUsingWindowDispatcher(&move5);
2001 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); 1989 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE);
2002 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); 1990 EXPECT_TRUE(delegate->bounding_box().IsEmpty());
2003 } 1991 }
2004 1992
2005 TEST_F(GestureRecognizerTest, GestureEventPinchFromScrollFromPinch) { 1993 TEST_F(GestureRecognizerTest, GestureEventPinchFromScrollFromPinch) {
2006 scoped_ptr<GestureEventConsumeDelegate> delegate( 1994 scoped_ptr<GestureEventConsumeDelegate> delegate(
2007 new GestureEventConsumeDelegate()); 1995 new GestureEventConsumeDelegate());
2008 TimedEvents tes; 1996 TimedEvents tes;
2009 const int kWindowWidth = 300; 1997 const int kWindowWidth = 300;
2010 const int kWindowHeight = 400; 1998 const int kWindowHeight = 400;
2011 const int kTouchId1 = 5; 1999 const int kTouchId1 = 5;
2012 const int kTouchId2 = 3; 2000 const int kTouchId2 = 3;
2013 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); 2001 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight);
2014 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2002 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2015 delegate.get(), -1234, bounds, root_window())); 2003 delegate.get(), -1234, bounds, root_window()));
2016 2004
2017 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), 2005 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 301.f),
2018 kTouchId1, tes.Now()); 2006 kTouchId1, tes.Now());
2019 DispatchEventUsingWindowDispatcher(&press); 2007 DispatchEventUsingWindowDispatcher(&press);
2020 delegate->Reset(); 2008 delegate->Reset();
2021 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 2009 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(10.f, 10.f),
2022 kTouchId2, tes.Now()); 2010 kTouchId2, tes.Now());
2023 DispatchEventUsingWindowDispatcher(&press2); 2011 DispatchEventUsingWindowDispatcher(&press2);
2024 EXPECT_FALSE(delegate->pinch_begin()); 2012 EXPECT_FALSE(delegate->pinch_begin());
2025 2013
2026 // Touch move triggers pinch begin. 2014 // Touch move triggers pinch begin.
2027 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId1, delegate.get()); 2015 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId1, delegate.get());
2028 EXPECT_TRUE(delegate->pinch_begin()); 2016 EXPECT_TRUE(delegate->pinch_begin());
2029 EXPECT_FALSE(delegate->pinch_update()); 2017 EXPECT_FALSE(delegate->pinch_update());
2030 2018
2031 // Touch move triggers pinch update. 2019 // Touch move triggers pinch update.
2032 tes.SendScrollEvent(event_processor(), 160, 200, kTouchId1, delegate.get()); 2020 tes.SendScrollEvent(event_processor(), 160, 200, kTouchId1, delegate.get());
2033 EXPECT_FALSE(delegate->pinch_begin()); 2021 EXPECT_FALSE(delegate->pinch_begin());
2034 EXPECT_TRUE(delegate->pinch_update()); 2022 EXPECT_TRUE(delegate->pinch_update());
2035 2023
2036 // Pinch has started, now release the second finger 2024 // Pinch has started, now release the second finger
2037 delegate->Reset(); 2025 delegate->Reset();
2038 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 2026 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
2039 kTouchId1, tes.Now()); 2027 kTouchId1, tes.Now());
2040 DispatchEventUsingWindowDispatcher(&release); 2028 DispatchEventUsingWindowDispatcher(&release);
2041 EXPECT_TRUE(delegate->pinch_end()); 2029 EXPECT_TRUE(delegate->pinch_end());
2042 2030
2043 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId2, delegate.get()); 2031 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId2, delegate.get());
2044 EXPECT_TRUE(delegate->scroll_update()); 2032 EXPECT_TRUE(delegate->scroll_update());
2045 2033
2046 // Pinch again 2034 // Pinch again
2047 delegate->Reset(); 2035 delegate->Reset();
2048 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 2036 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::PointF(10.f, 10.f),
2049 kTouchId1, tes.Now()); 2037 kTouchId1, tes.Now());
2050 DispatchEventUsingWindowDispatcher(&press3); 2038 DispatchEventUsingWindowDispatcher(&press3);
2051 // Now the touch points are close. So we will go into two finger tap. 2039 // Now the touch points are close. So we will go into two finger tap.
2052 // Move the touch-point enough to break two-finger-tap and enter pinch. 2040 // Move the touch-point enough to break two-finger-tap and enter pinch.
2053 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(101, 50), 2041 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::PointF(101.f, 50.f), kTouchId1,
2054 kTouchId1, tes.Now()); 2042 tes.Now());
2055 DispatchEventUsingWindowDispatcher(&move2); 2043 DispatchEventUsingWindowDispatcher(&move2);
2056 EXPECT_TRUE(delegate->pinch_begin()); 2044 EXPECT_TRUE(delegate->pinch_begin());
2057 2045
2058 tes.SendScrollEvent(event_processor(), 350, 350, kTouchId1, delegate.get()); 2046 tes.SendScrollEvent(event_processor(), 350, 350, kTouchId1, delegate.get());
2059 EXPECT_TRUE(delegate->pinch_update()); 2047 EXPECT_TRUE(delegate->pinch_update());
2060 } 2048 }
2061 2049
2062 TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) { 2050 TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) {
2063 scoped_ptr<GestureEventConsumeDelegate> delegate( 2051 scoped_ptr<GestureEventConsumeDelegate> delegate(
2064 new GestureEventConsumeDelegate()); 2052 new GestureEventConsumeDelegate());
2065 TimedEvents tes; 2053 TimedEvents tes;
2066 const int kWindowWidth = 300; 2054 const int kWindowWidth = 300;
2067 const int kWindowHeight = 400; 2055 const int kWindowHeight = 400;
2068 const int kTouchId1 = 3; 2056 const int kTouchId1 = 3;
2069 const int kTouchId2 = 5; 2057 const int kTouchId2 = 5;
2070 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); 2058 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight);
2071 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2059 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2072 delegate.get(), -1234, bounds, root_window())); 2060 delegate.get(), -1234, bounds, root_window()));
2073 2061
2074 delegate->Reset(); 2062 delegate->Reset();
2075 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), 2063 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 301.f),
2076 kTouchId1, tes.Now()); 2064 kTouchId1, tes.Now());
2077 DispatchEventUsingWindowDispatcher(&press); 2065 DispatchEventUsingWindowDispatcher(&press);
2078 EXPECT_2_EVENTS(delegate->events(), 2066 EXPECT_2_EVENTS(delegate->events(),
2079 ui::ET_GESTURE_BEGIN, 2067 ui::ET_GESTURE_BEGIN,
2080 ui::ET_GESTURE_TAP_DOWN); 2068 ui::ET_GESTURE_TAP_DOWN);
2081 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); 2069 EXPECT_TRUE(delegate->bounding_box().IsEmpty());
2082 2070
2083 // Press the second finger far enough to break two finger tap. 2071 // Press the second finger far enough to break two finger tap.
2084 delegate->Reset(); 2072 delegate->Reset();
2085 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 2073 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(10.f, 10.f),
2086 kTouchId2, tes.Now()); 2074 kTouchId2, tes.Now());
2087 DispatchEventUsingWindowDispatcher(&press2); 2075 DispatchEventUsingWindowDispatcher(&press2);
2088 EXPECT_2_EVENTS(delegate->events(), 2076 EXPECT_2_EVENTS(delegate->events(),
2089 ui::ET_GESTURE_TAP_CANCEL, 2077 ui::ET_GESTURE_TAP_CANCEL,
2090 ui::ET_GESTURE_BEGIN); 2078 ui::ET_GESTURE_BEGIN);
2091 EXPECT_EQ(gfx::Rect(10, 10, 91, 291).ToString(), 2079 EXPECT_EQ(gfx::Rect(10, 10, 91, 291).ToString(),
2092 delegate->bounding_box().ToString()); 2080 delegate->bounding_box().ToString());
2093 2081
2094 // Move the first finger. 2082 // Move the first finger.
2095 delegate->Reset(); 2083 delegate->Reset();
2096 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(65, 201), 2084 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::PointF(65.f, 201.f), kTouchId1,
2097 kTouchId1, tes.Now()); 2085 tes.Now());
2098 DispatchEventUsingWindowDispatcher(&move3); 2086 DispatchEventUsingWindowDispatcher(&move3);
2099 EXPECT_3_EVENTS(delegate->events(), 2087 EXPECT_3_EVENTS(delegate->events(),
2100 ui::ET_GESTURE_SCROLL_BEGIN, 2088 ui::ET_GESTURE_SCROLL_BEGIN,
2101 ui::ET_GESTURE_SCROLL_UPDATE, 2089 ui::ET_GESTURE_SCROLL_UPDATE,
2102 ui::ET_GESTURE_PINCH_BEGIN); 2090 ui::ET_GESTURE_PINCH_BEGIN);
2103 EXPECT_EQ(gfx::Rect(10, 10, 55, 191).ToString(), 2091 EXPECT_EQ(gfx::Rect(10, 10, 55, 191).ToString(),
2104 delegate->bounding_box().ToString()); 2092 delegate->bounding_box().ToString());
2105 2093
2106 // Now move the second finger. 2094 // Now move the second finger.
2107 delegate->Reset(); 2095 delegate->Reset();
2108 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(55, 15), 2096 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::PointF(55.f, 15.f), kTouchId2,
2109 kTouchId2, tes.Now()); 2097 tes.Now());
2110 DispatchEventUsingWindowDispatcher(&move4); 2098 DispatchEventUsingWindowDispatcher(&move4);
2111 EXPECT_2_EVENTS(delegate->events(), 2099 EXPECT_2_EVENTS(delegate->events(),
2112 ui::ET_GESTURE_SCROLL_UPDATE, 2100 ui::ET_GESTURE_SCROLL_UPDATE,
2113 ui::ET_GESTURE_PINCH_UPDATE); 2101 ui::ET_GESTURE_PINCH_UPDATE);
2114 EXPECT_EQ(gfx::Rect(55, 15, 10, 186).ToString(), 2102 EXPECT_EQ(gfx::Rect(55, 15, 10, 186).ToString(),
2115 delegate->bounding_box().ToString()); 2103 delegate->bounding_box().ToString());
2116 2104
2117 // Release the first finger. This should end pinch. 2105 // Release the first finger. This should end pinch.
2118 delegate->Reset(); 2106 delegate->Reset();
2119 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 2107 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
2120 kTouchId1, tes.LeapForward(10)); 2108 kTouchId1, tes.LeapForward(10));
2121 DispatchEventUsingWindowDispatcher(&release); 2109 DispatchEventUsingWindowDispatcher(&release);
2122 EXPECT_2_EVENTS(delegate->events(), 2110 EXPECT_2_EVENTS(delegate->events(),
2123 ui::ET_GESTURE_PINCH_END, 2111 ui::ET_GESTURE_PINCH_END,
2124 ui::ET_GESTURE_END); 2112 ui::ET_GESTURE_END);
2125 EXPECT_EQ(gfx::Rect(55, 15, 46, 186).ToString(), 2113 EXPECT_EQ(gfx::Rect(55, 15, 46, 186).ToString(),
2126 delegate->bounding_box().ToString()); 2114 delegate->bounding_box().ToString());
2127 2115
2128 // Move the second finger. This should still generate a scroll. 2116 // Move the second finger. This should still generate a scroll.
2129 delegate->Reset(); 2117 delegate->Reset();
2130 ui::TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), 2118 ui::TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::PointF(25.f, 10.f), kTouchId2,
2131 kTouchId2, tes.Now()); 2119 tes.Now());
2132 DispatchEventUsingWindowDispatcher(&move5); 2120 DispatchEventUsingWindowDispatcher(&move5);
2133 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); 2121 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE);
2134 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); 2122 EXPECT_TRUE(delegate->bounding_box().IsEmpty());
2135 } 2123 }
2136 2124
2137 TEST_F(GestureRecognizerTest, GestureEventIgnoresDisconnectedEvents) { 2125 TEST_F(GestureRecognizerTest, GestureEventIgnoresDisconnectedEvents) {
2138 scoped_ptr<GestureEventConsumeDelegate> delegate( 2126 scoped_ptr<GestureEventConsumeDelegate> delegate(
2139 new GestureEventConsumeDelegate()); 2127 new GestureEventConsumeDelegate());
2140 TimedEvents tes; 2128 TimedEvents tes;
2141 2129
2142 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 2130 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f), 6,
2143 6, tes.Now()); 2131 tes.Now());
2144 DispatchEventUsingWindowDispatcher(&release1); 2132 DispatchEventUsingWindowDispatcher(&release1);
2145 EXPECT_FALSE(delegate->tap()); 2133 EXPECT_FALSE(delegate->tap());
2146 EXPECT_FALSE(delegate->tap_down()); 2134 EXPECT_FALSE(delegate->tap_down());
2147 } 2135 }
2148 2136
2149 // Check that a touch is locked to the window of the closest current touch 2137 // Check that a touch is locked to the window of the closest current touch
2150 // within max_separation_for_gesture_touches_in_pixels 2138 // within max_separation_for_gesture_touches_in_pixels
2151 TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) { 2139 TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) {
2152 ui::GestureRecognizer* gesture_recognizer = new ui::GestureRecognizerImpl(); 2140 ui::GestureRecognizer* gesture_recognizer = new ui::GestureRecognizerImpl();
2153 TimedEvents tes; 2141 TimedEvents tes;
(...skipping 16 matching lines...) Expand all
2170 2158
2171 scoped_ptr<aura::Window*[]> windows(new aura::Window*[kNumWindows]); 2159 scoped_ptr<aura::Window*[]> windows(new aura::Window*[kNumWindows]);
2172 2160
2173 // Instantiate windows with |window_bounds| and touch each window at 2161 // Instantiate windows with |window_bounds| and touch each window at
2174 // its origin. 2162 // its origin.
2175 for (int i = 0; i < kNumWindows; ++i) { 2163 for (int i = 0; i < kNumWindows; ++i) {
2176 delegates[i] = new GestureEventConsumeDelegate(); 2164 delegates[i] = new GestureEventConsumeDelegate();
2177 windows[i] = CreateTestWindowWithDelegate( 2165 windows[i] = CreateTestWindowWithDelegate(
2178 delegates[i], i, window_bounds[i], root_window()); 2166 delegates[i], i, window_bounds[i], root_window());
2179 windows[i]->set_id(i); 2167 windows[i]->set_id(i);
2180 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, window_bounds[i].origin(), 2168 ui::TouchEvent press(ui::ET_TOUCH_PRESSED,
2181 i, tes.Now()); 2169 gfx::PointF(window_bounds[i].origin()), i, tes.Now());
2182 DispatchEventUsingWindowDispatcher(&press); 2170 DispatchEventUsingWindowDispatcher(&press);
2183 } 2171 }
2184 2172
2185 // Touches should now be associated with the closest touch within 2173 // Touches should now be associated with the closest touch within
2186 // ui::GestureConfiguration::max_separation_for_gesture_touches_in_pixels 2174 // ui::GestureConfiguration::max_separation_for_gesture_touches_in_pixels
2187 target = gesture_recognizer->GetTargetForLocation(gfx::Point(11, 11), -1); 2175 target =
2176 gesture_recognizer->GetTargetForLocation(gfx::PointF(11.f, 11.f), -1);
2188 EXPECT_EQ("0", WindowIDAsString(target)); 2177 EXPECT_EQ("0", WindowIDAsString(target));
2189 target = gesture_recognizer->GetTargetForLocation(gfx::Point(511, 11), -1); 2178 target =
2179 gesture_recognizer->GetTargetForLocation(gfx::PointF(511.f, 11.f), -1);
2190 EXPECT_EQ("1", WindowIDAsString(target)); 2180 EXPECT_EQ("1", WindowIDAsString(target));
2191 target = gesture_recognizer->GetTargetForLocation(gfx::Point(11, 511), -1); 2181 target =
2182 gesture_recognizer->GetTargetForLocation(gfx::PointF(11.f, 511.f), -1);
2192 EXPECT_EQ("2", WindowIDAsString(target)); 2183 EXPECT_EQ("2", WindowIDAsString(target));
2193 target = gesture_recognizer->GetTargetForLocation(gfx::Point(511, 511), -1); 2184 target =
2185 gesture_recognizer->GetTargetForLocation(gfx::PointF(511.f, 511.f), -1);
2194 EXPECT_EQ("3", WindowIDAsString(target)); 2186 EXPECT_EQ("3", WindowIDAsString(target));
2195 2187
2196 // Add a touch in the middle associated with windows[2] 2188 // Add a touch in the middle associated with windows[2]
2197 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 500), 2189 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(0.f, 500.f),
2198 kNumWindows, tes.Now()); 2190 kNumWindows, tes.Now());
2199 DispatchEventUsingWindowDispatcher(&press); 2191 DispatchEventUsingWindowDispatcher(&press);
2200 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(250, 250), 2192 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(250.f, 250.f),
2201 kNumWindows, tes.Now()); 2193 kNumWindows, tes.Now());
2202 DispatchEventUsingWindowDispatcher(&move); 2194 DispatchEventUsingWindowDispatcher(&move);
2203 2195
2204 target = gesture_recognizer->GetTargetForLocation(gfx::Point(250, 250), -1); 2196 target =
2197 gesture_recognizer->GetTargetForLocation(gfx::PointF(250.f, 250.f), -1);
2205 EXPECT_EQ("2", WindowIDAsString(target)); 2198 EXPECT_EQ("2", WindowIDAsString(target));
2206 2199
2207 // Make sure that ties are broken by distance to a current touch 2200 // Make sure that ties are broken by distance to a current touch
2208 // Closer to the point in the bottom right. 2201 // Closer to the point in the bottom right.
2209 target = gesture_recognizer->GetTargetForLocation(gfx::Point(380, 380), -1); 2202 target =
2203 gesture_recognizer->GetTargetForLocation(gfx::PointF(380.f, 380.f), -1);
2210 EXPECT_EQ("3", WindowIDAsString(target)); 2204 EXPECT_EQ("3", WindowIDAsString(target));
2211 2205
2212 // This touch is closer to the point in the middle 2206 // This touch is closer to the point in the middle
2213 target = gesture_recognizer->GetTargetForLocation(gfx::Point(300, 300), -1); 2207 target =
2208 gesture_recognizer->GetTargetForLocation(gfx::PointF(300.f, 300.f), -1);
2214 EXPECT_EQ("2", WindowIDAsString(target)); 2209 EXPECT_EQ("2", WindowIDAsString(target));
2215 2210
2216 // A touch too far from other touches won't be locked to anything 2211 // A touch too far from other touches won't be locked to anything
2217 target = gesture_recognizer->GetTargetForLocation(gfx::Point(1000, 1000), -1); 2212 target =
2213 gesture_recognizer->GetTargetForLocation(gfx::PointF(1000.f, 1000.f), -1);
2218 EXPECT_TRUE(target == NULL); 2214 EXPECT_TRUE(target == NULL);
2219 2215
2220 // Move a touch associated with windows[2] to 1000, 1000 2216 // Move a touch associated with windows[2] to 1000, 1000
2221 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(1000, 1000), 2217 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::PointF(1000.f, 1000.f),
2222 kNumWindows, tes.Now()); 2218 kNumWindows, tes.Now());
2223 DispatchEventUsingWindowDispatcher(&move2); 2219 DispatchEventUsingWindowDispatcher(&move2);
2224 2220
2225 target = gesture_recognizer->GetTargetForLocation(gfx::Point(1000, 1000), -1); 2221 target =
2222 gesture_recognizer->GetTargetForLocation(gfx::PointF(1000.f, 1000.f), -1);
2226 EXPECT_EQ("2", WindowIDAsString(target)); 2223 EXPECT_EQ("2", WindowIDAsString(target));
2227 2224
2228 for (int i = 0; i < kNumWindows; ++i) { 2225 for (int i = 0; i < kNumWindows; ++i) {
2229 // Delete windows before deleting delegates. 2226 // Delete windows before deleting delegates.
2230 delete windows[i]; 2227 delete windows[i];
2231 delete delegates[i]; 2228 delete delegates[i];
2232 } 2229 }
2233 } 2230 }
2234 2231
2235 // Check that a touch's target will not be effected by a touch on a different 2232 // Check that a touch's target will not be effected by a touch on a different
2236 // screen. 2233 // screen.
2237 TEST_F(GestureRecognizerTest, GestureEventTouchLockIgnoresOtherScreens) { 2234 TEST_F(GestureRecognizerTest, GestureEventTouchLockIgnoresOtherScreens) {
2238 scoped_ptr<GestureEventConsumeDelegate> delegate( 2235 scoped_ptr<GestureEventConsumeDelegate> delegate(
2239 new GestureEventConsumeDelegate()); 2236 new GestureEventConsumeDelegate());
2240 gfx::Rect bounds(0, 0, 10, 10); 2237 gfx::Rect bounds(0, 0, 10, 10);
2241 scoped_ptr<aura::Window> window( 2238 scoped_ptr<aura::Window> window(
2242 CreateTestWindowWithDelegate(delegate.get(), 0, bounds, root_window())); 2239 CreateTestWindowWithDelegate(delegate.get(), 0, bounds, root_window()));
2243 2240
2244 const int kTouchId1 = 8; 2241 const int kTouchId1 = 8;
2245 const int kTouchId2 = 2; 2242 const int kTouchId2 = 2;
2246 TimedEvents tes; 2243 TimedEvents tes;
2247 2244
2248 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(5, 5), 2245 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(5.f, 5.f), kTouchId1,
2249 kTouchId1, tes.Now()); 2246 tes.Now());
2250 ui::EventTestApi test_press1(&press1); 2247 ui::EventTestApi test_press1(&press1);
2251 test_press1.set_source_device_id(1); 2248 test_press1.set_source_device_id(1);
2252 DispatchEventUsingWindowDispatcher(&press1); 2249 DispatchEventUsingWindowDispatcher(&press1);
2253 2250
2254 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(20, 20), 2251 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(20.f, 20.f),
2255 kTouchId2, tes.Now()); 2252 kTouchId2, tes.Now());
2256 ui::EventTestApi test_press2(&press2); 2253 ui::EventTestApi test_press2(&press2);
2257 test_press2.set_source_device_id(2); 2254 test_press2.set_source_device_id(2);
2258 DispatchEventUsingWindowDispatcher(&press2); 2255 DispatchEventUsingWindowDispatcher(&press2);
2259 2256
2260 // The second press should not have been locked to the same target as the 2257 // The second press should not have been locked to the same target as the
2261 // first, as they occured on different displays. 2258 // first, as they occured on different displays.
2262 EXPECT_NE( 2259 EXPECT_NE(
2263 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press1), 2260 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press1),
2264 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press2)); 2261 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press2));
2265 } 2262 }
2266 2263
2267 // Check that touch events outside the root window are still handled 2264 // Check that touch events outside the root window are still handled
2268 // by the root window's gesture sequence. 2265 // by the root window's gesture sequence.
2269 TEST_F(GestureRecognizerTest, GestureEventOutsideRootWindowTap) { 2266 TEST_F(GestureRecognizerTest, GestureEventOutsideRootWindowTap) {
2270 TimedEvents tes; 2267 TimedEvents tes;
2271 scoped_ptr<aura::Window> window(CreateTestWindowWithBounds( 2268 scoped_ptr<aura::Window> window(CreateTestWindowWithBounds(
2272 gfx::Rect(-100, -100, 2000, 2000), root_window())); 2269 gfx::Rect(-100, -100, 2000, 2000), root_window()));
2273 2270
2274 gfx::Point pos1(-10, -10); 2271 gfx::PointF pos1(-10.f, -10.f);
2275 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, pos1, 0, tes.Now()); 2272 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, pos1, 0, tes.Now());
2276 DispatchEventUsingWindowDispatcher(&press1); 2273 DispatchEventUsingWindowDispatcher(&press1);
2277 2274
2278 gfx::Point pos2(1000, 1000); 2275 gfx::PointF pos2(1000.f, 1000.f);
2279 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, pos2, 1, tes.Now()); 2276 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, pos2, 1, tes.Now());
2280 DispatchEventUsingWindowDispatcher(&press2); 2277 DispatchEventUsingWindowDispatcher(&press2);
2281 2278
2282 // As these presses were outside the root window, they should be 2279 // As these presses were outside the root window, they should be
2283 // associated with the root window. 2280 // associated with the root window.
2284 EXPECT_EQ(root_window(), 2281 EXPECT_EQ(root_window(),
2285 static_cast<aura::Window*>( 2282 static_cast<aura::Window*>(
2286 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press1))); 2283 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press1)));
2287 EXPECT_EQ(root_window(), 2284 EXPECT_EQ(root_window(),
2288 static_cast<aura::Window*>( 2285 static_cast<aura::Window*>(
2289 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press2))); 2286 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press2)));
2290 } 2287 }
2291 2288
2292 TEST_F(GestureRecognizerTest, NoTapWithPreventDefaultedRelease) { 2289 TEST_F(GestureRecognizerTest, NoTapWithPreventDefaultedRelease) {
2293 scoped_ptr<QueueTouchEventDelegate> delegate( 2290 scoped_ptr<QueueTouchEventDelegate> delegate(
2294 new QueueTouchEventDelegate(host()->dispatcher())); 2291 new QueueTouchEventDelegate(host()->dispatcher()));
2295 TimedEvents tes; 2292 TimedEvents tes;
2296 const int kTouchId = 2; 2293 const int kTouchId = 2;
2297 gfx::Rect bounds(100, 200, 100, 100); 2294 gfx::Rect bounds(100, 200, 100, 100);
2298 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2295 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2299 delegate.get(), -1234, bounds, root_window())); 2296 delegate.get(), -1234, bounds, root_window()));
2300 delegate->set_window(window.get()); 2297 delegate->set_window(window.get());
2301 2298
2302 delegate->Reset(); 2299 delegate->Reset();
2303 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2300 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
2304 kTouchId, tes.Now()); 2301 kTouchId, tes.Now());
2305 DispatchEventUsingWindowDispatcher(&press); 2302 DispatchEventUsingWindowDispatcher(&press);
2306 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 2303 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
2307 kTouchId, tes.LeapForward(50)); 2304 kTouchId, tes.LeapForward(50));
2308 DispatchEventUsingWindowDispatcher(&release); 2305 DispatchEventUsingWindowDispatcher(&release);
2309 2306
2310 delegate->Reset(); 2307 delegate->Reset();
2311 delegate->ReceivedAck(); 2308 delegate->ReceivedAck();
2312 EXPECT_TRUE(delegate->tap_down()); 2309 EXPECT_TRUE(delegate->tap_down());
2313 delegate->Reset(); 2310 delegate->Reset();
2314 delegate->ReceivedAckPreventDefaulted(); 2311 delegate->ReceivedAckPreventDefaulted();
2315 EXPECT_FALSE(delegate->tap()); 2312 EXPECT_FALSE(delegate->tap());
2316 EXPECT_TRUE(delegate->tap_cancel()); 2313 EXPECT_TRUE(delegate->tap_cancel());
2317 } 2314 }
2318 2315
2319 TEST_F(GestureRecognizerTest, PinchScrollWithPreventDefaultedRelease) { 2316 TEST_F(GestureRecognizerTest, PinchScrollWithPreventDefaultedRelease) {
2320 scoped_ptr<QueueTouchEventDelegate> delegate( 2317 scoped_ptr<QueueTouchEventDelegate> delegate(
2321 new QueueTouchEventDelegate(host()->dispatcher())); 2318 new QueueTouchEventDelegate(host()->dispatcher()));
2322 TimedEvents tes; 2319 TimedEvents tes;
2323 const int kTouchId1 = 7; 2320 const int kTouchId1 = 7;
2324 const int kTouchId2 = 5; 2321 const int kTouchId2 = 5;
2325 gfx::Rect bounds(10, 20, 100, 100); 2322 gfx::Rect bounds(10, 20, 100, 100);
2326 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2323 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2327 delegate.get(), -1234, bounds, root_window())); 2324 delegate.get(), -1234, bounds, root_window()));
2328 delegate->set_window(window.get()); 2325 delegate->set_window(window.get());
2329 2326
2330 { 2327 {
2331 delegate->Reset(); 2328 delegate->Reset();
2332 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(15, 25), kTouchId1, 2329 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(15.f, 25.f),
2333 tes.Now()); 2330 kTouchId1, tes.Now());
2334 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(20, 95), kTouchId1, 2331 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(20.f, 95.f), kTouchId1,
2335 tes.LeapForward(200)); 2332 tes.LeapForward(200));
2336 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(15, 25), kTouchId1, 2333 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(15.f, 25.f),
2337 tes.LeapForward(50)); 2334 kTouchId1, tes.LeapForward(50));
2338 DispatchEventUsingWindowDispatcher(&press); 2335 DispatchEventUsingWindowDispatcher(&press);
2339 DispatchEventUsingWindowDispatcher(&move); 2336 DispatchEventUsingWindowDispatcher(&move);
2340 DispatchEventUsingWindowDispatcher(&release); 2337 DispatchEventUsingWindowDispatcher(&release);
2341 delegate->Reset(); 2338 delegate->Reset();
2342 2339
2343 // Ack the press event. 2340 // Ack the press event.
2344 delegate->ReceivedAck(); 2341 delegate->ReceivedAck();
2345 EXPECT_2_EVENTS( 2342 EXPECT_2_EVENTS(
2346 delegate->events(), ui::ET_GESTURE_BEGIN, ui::ET_GESTURE_TAP_DOWN); 2343 delegate->events(), ui::ET_GESTURE_BEGIN, ui::ET_GESTURE_TAP_DOWN);
2347 delegate->Reset(); 2344 delegate->Reset();
2348 2345
2349 // Ack the move event. 2346 // Ack the move event.
2350 delegate->ReceivedAck(); 2347 delegate->ReceivedAck();
2351 EXPECT_3_EVENTS(delegate->events(), 2348 EXPECT_3_EVENTS(delegate->events(),
2352 ui::ET_GESTURE_TAP_CANCEL, 2349 ui::ET_GESTURE_TAP_CANCEL,
2353 ui::ET_GESTURE_SCROLL_BEGIN, 2350 ui::ET_GESTURE_SCROLL_BEGIN,
2354 ui::ET_GESTURE_SCROLL_UPDATE); 2351 ui::ET_GESTURE_SCROLL_UPDATE);
2355 delegate->Reset(); 2352 delegate->Reset();
2356 2353
2357 // Ack the release event. Although the release event has been processed, it 2354 // Ack the release event. Although the release event has been processed, it
2358 // should still generate a scroll-end event. 2355 // should still generate a scroll-end event.
2359 delegate->ReceivedAckPreventDefaulted(); 2356 delegate->ReceivedAckPreventDefaulted();
2360 EXPECT_2_EVENTS( 2357 EXPECT_2_EVENTS(
2361 delegate->events(), ui::ET_GESTURE_SCROLL_END, ui::ET_GESTURE_END); 2358 delegate->events(), ui::ET_GESTURE_SCROLL_END, ui::ET_GESTURE_END);
2362 } 2359 }
2363 2360
2364 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(15, 25), kTouchId1, 2361 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(15.f, 25.f), kTouchId1,
2365 tes.Now()); 2362 tes.Now());
2366 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(20, 95), kTouchId1, 2363 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(20.f, 95.f), kTouchId1,
2367 tes.LeapForward(200)); 2364 tes.LeapForward(200));
2368 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(15, 25), kTouchId1, 2365 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(15.f, 25.f),
2369 tes.LeapForward(50)); 2366 kTouchId1, tes.LeapForward(50));
2370 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(55, 25), kTouchId2, 2367 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(55.f, 25.f),
2371 tes.Now()); 2368 kTouchId2, tes.Now());
2372 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(145, 85), kTouchId2, 2369 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::PointF(145.f, 85.f), kTouchId2,
2373 tes.LeapForward(1000)); 2370 tes.LeapForward(1000));
2374 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(145, 85), kTouchId2, 2371 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::PointF(145.f, 85.f),
2375 tes.LeapForward(14)); 2372 kTouchId2, tes.LeapForward(14));
2376 2373
2377 // Do a pinch. 2374 // Do a pinch.
2378 DispatchEventUsingWindowDispatcher(&press); 2375 DispatchEventUsingWindowDispatcher(&press);
2379 DispatchEventUsingWindowDispatcher(&move); 2376 DispatchEventUsingWindowDispatcher(&move);
2380 DispatchEventUsingWindowDispatcher(&press2); 2377 DispatchEventUsingWindowDispatcher(&press2);
2381 DispatchEventUsingWindowDispatcher(&move2); 2378 DispatchEventUsingWindowDispatcher(&move2);
2382 DispatchEventUsingWindowDispatcher(&release); 2379 DispatchEventUsingWindowDispatcher(&release);
2383 DispatchEventUsingWindowDispatcher(&release2); 2380 DispatchEventUsingWindowDispatcher(&release2);
2384 2381
2385 // Ack the press and move events. 2382 // Ack the press and move events.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
2469 2466
2470 // Create a window and set it as the capture window. 2467 // Create a window and set it as the capture window.
2471 scoped_ptr<aura::Window> window1(CreateTestWindowWithDelegate(delegate.get(), 2468 scoped_ptr<aura::Window> window1(CreateTestWindowWithDelegate(delegate.get(),
2472 -1234, gfx::Rect(10, 10, 300, 300), root_window())); 2469 -1234, gfx::Rect(10, 10, 300, 300), root_window()));
2473 window1->SetCapture(); 2470 window1->SetCapture();
2474 2471
2475 ui::test::EventGenerator generator(root_window()); 2472 ui::test::EventGenerator generator(root_window());
2476 TimedEvents tes; 2473 TimedEvents tes;
2477 2474
2478 // Generate two touch-press events on the window. 2475 // Generate two touch-press events on the window.
2479 scoped_ptr<ui::TouchEvent> touch0(new ui::TouchEvent(ui::ET_TOUCH_PRESSED, 2476 scoped_ptr<ui::TouchEvent> touch0(new ui::TouchEvent(
2480 gfx::Point(20, 20), 0, 2477 ui::ET_TOUCH_PRESSED, gfx::PointF(20.f, 20.f), 0, tes.Now()));
2481 tes.Now())); 2478 scoped_ptr<ui::TouchEvent> touch1(new ui::TouchEvent(
2482 scoped_ptr<ui::TouchEvent> touch1(new ui::TouchEvent(ui::ET_TOUCH_PRESSED, 2479 ui::ET_TOUCH_PRESSED, gfx::PointF(30.f, 30.f), 1, tes.Now()));
2483 gfx::Point(30, 30), 1,
2484 tes.Now()));
2485 generator.Dispatch(touch0.get()); 2480 generator.Dispatch(touch0.get());
2486 generator.Dispatch(touch1.get()); 2481 generator.Dispatch(touch1.get());
2487 RunAllPendingInMessageLoop(); 2482 RunAllPendingInMessageLoop();
2488 EXPECT_EQ(2, handler->touch_pressed_count()); 2483 EXPECT_EQ(2, handler->touch_pressed_count());
2489 2484
2490 // Advance time. 2485 // Advance time.
2491 tes.LeapForward(1000); 2486 tes.LeapForward(1000);
2492 2487
2493 // End the two touches, one by a touch-release and one by a touch-cancel; to 2488 // End the two touches, one by a touch-release and one by a touch-cancel; to
2494 // cover both cases. 2489 // cover both cases.
2495 touch0.reset(new ui::TouchEvent(ui::ET_TOUCH_RELEASED, gfx::Point(20, 20), 0, 2490 touch0.reset(new ui::TouchEvent(ui::ET_TOUCH_RELEASED,
2496 tes.Now())); 2491 gfx::PointF(20.f, 20.f), 0, tes.Now()));
2497 touch1.reset(new ui::TouchEvent(ui::ET_TOUCH_CANCELLED, gfx::Point(30, 30), 1, 2492 touch1.reset(new ui::TouchEvent(ui::ET_TOUCH_CANCELLED,
2498 tes.Now())); 2493 gfx::PointF(30.f, 30.f), 1, tes.Now()));
2499 generator.Dispatch(touch0.get()); 2494 generator.Dispatch(touch0.get());
2500 generator.Dispatch(touch1.get()); 2495 generator.Dispatch(touch1.get());
2501 RunAllPendingInMessageLoop(); 2496 RunAllPendingInMessageLoop();
2502 EXPECT_EQ(1, handler->touch_released_count()); 2497 EXPECT_EQ(1, handler->touch_released_count());
2503 EXPECT_EQ(1, handler->touch_cancelled_count()); 2498 EXPECT_EQ(1, handler->touch_cancelled_count());
2504 2499
2505 // Create a new window and set it as the new capture window. 2500 // Create a new window and set it as the new capture window.
2506 scoped_ptr<aura::Window> window2(CreateTestWindowWithBounds( 2501 scoped_ptr<aura::Window> window2(CreateTestWindowWithBounds(
2507 gfx::Rect(100, 100, 300, 300), root_window())); 2502 gfx::Rect(100, 100, 300, 300), root_window()));
2508 window2->SetCapture(); 2503 window2->SetCapture();
2509 RunAllPendingInMessageLoop(); 2504 RunAllPendingInMessageLoop();
2510 // Check that setting capture does not generate any synthetic touch-cancels 2505 // Check that setting capture does not generate any synthetic touch-cancels
2511 // for the two previously finished touch actions. 2506 // for the two previously finished touch actions.
2512 EXPECT_EQ(1, handler->touch_cancelled_count()); 2507 EXPECT_EQ(1, handler->touch_cancelled_count());
2513 2508
2514 root_window()->RemovePreTargetHandler(handler.get()); 2509 root_window()->RemovePreTargetHandler(handler.get());
2515 } 2510 }
2516 2511
2517 // Tests that a press with the same touch id as an existing touch is ignored. 2512 // Tests that a press with the same touch id as an existing touch is ignored.
2518 TEST_F(GestureRecognizerTest, PressDoesNotCrash) { 2513 TEST_F(GestureRecognizerTest, PressDoesNotCrash) {
2519 scoped_ptr<GestureEventConsumeDelegate> delegate( 2514 scoped_ptr<GestureEventConsumeDelegate> delegate(
2520 new GestureEventConsumeDelegate()); 2515 new GestureEventConsumeDelegate());
2521 TimedEvents tes; 2516 TimedEvents tes;
2522 2517
2523 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2518 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2524 delegate.get(), -1234, gfx::Rect(10, 10, 300, 300), root_window())); 2519 delegate.get(), -1234, gfx::Rect(10, 10, 300, 300), root_window()));
2525 2520
2526 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(45, 45), 7, tes.Now()); 2521 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(45.f, 45.f), 7,
2522 tes.Now());
2527 press.set_radius_x(40); 2523 press.set_radius_x(40);
2528 DispatchEventUsingWindowDispatcher(&press); 2524 DispatchEventUsingWindowDispatcher(&press);
2529 EXPECT_TRUE(delegate->tap_down()); 2525 EXPECT_TRUE(delegate->tap_down());
2530 EXPECT_EQ(gfx::Rect(5, 5, 80, 80).ToString(), 2526 EXPECT_EQ(gfx::Rect(5, 5, 80, 80).ToString(),
2531 delegate->bounding_box().ToString()); 2527 delegate->bounding_box().ToString());
2532 delegate->Reset(); 2528 delegate->Reset();
2533 2529
2534 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(55, 45), 7, tes.Now()); 2530 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(55.f, 45.f), 7,
2531 tes.Now());
2535 DispatchEventUsingWindowDispatcher(&press2); 2532 DispatchEventUsingWindowDispatcher(&press2);
2536 2533
2537 // FIXME(tdresser): this should not generate a tap down; however, 2534 // FIXME(tdresser): this should not generate a tap down; however,
2538 // there is at least one case where we need to allow a touch press 2535 // there is at least one case where we need to allow a touch press
2539 // from a currently used touch id. See crbug.com/373125 for details. 2536 // from a currently used touch id. See crbug.com/373125 for details.
2540 EXPECT_TRUE(delegate->begin()); 2537 EXPECT_TRUE(delegate->begin());
2541 EXPECT_TRUE(delegate->tap_down()); 2538 EXPECT_TRUE(delegate->tap_down());
2542 EXPECT_TRUE(delegate->tap_cancel()); 2539 EXPECT_TRUE(delegate->tap_cancel());
2543 EXPECT_FALSE(delegate->scroll_begin()); 2540 EXPECT_FALSE(delegate->scroll_begin());
2544 } 2541 }
2545 2542
2546 TEST_F(GestureRecognizerTest, TwoFingerTap) { 2543 TEST_F(GestureRecognizerTest, TwoFingerTap) {
2547 scoped_ptr<GestureEventConsumeDelegate> delegate( 2544 scoped_ptr<GestureEventConsumeDelegate> delegate(
2548 new GestureEventConsumeDelegate()); 2545 new GestureEventConsumeDelegate());
2549 const int kWindowWidth = 123; 2546 const int kWindowWidth = 123;
2550 const int kWindowHeight = 45; 2547 const int kWindowHeight = 45;
2551 const int kTouchId1 = 2; 2548 const int kTouchId1 = 2;
2552 const int kTouchId2 = 3; 2549 const int kTouchId2 = 3;
2553 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2550 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2554 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2551 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2555 delegate.get(), -1234, bounds, root_window())); 2552 delegate.get(), -1234, bounds, root_window()));
2556 TimedEvents tes; 2553 TimedEvents tes;
2557 2554
2558 delegate->Reset(); 2555 delegate->Reset();
2559 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2556 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
2560 kTouchId1, tes.Now()); 2557 kTouchId1, tes.Now());
2561 DispatchEventUsingWindowDispatcher(&press1); 2558 DispatchEventUsingWindowDispatcher(&press1);
2562 EXPECT_2_EVENTS( 2559 EXPECT_2_EVENTS(
2563 delegate->events(), ui::ET_GESTURE_BEGIN, ui::ET_GESTURE_TAP_DOWN); 2560 delegate->events(), ui::ET_GESTURE_BEGIN, ui::ET_GESTURE_TAP_DOWN);
2564 2561
2565 delegate->Reset(); 2562 delegate->Reset();
2566 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), 2563 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(130.f, 201.f),
2567 kTouchId2, tes.Now()); 2564 kTouchId2, tes.Now());
2568 DispatchEventUsingWindowDispatcher(&press2); 2565 DispatchEventUsingWindowDispatcher(&press2);
2569 EXPECT_2_EVENTS( 2566 EXPECT_2_EVENTS(
2570 delegate->events(), ui::ET_GESTURE_TAP_CANCEL, ui::ET_GESTURE_BEGIN); 2567 delegate->events(), ui::ET_GESTURE_TAP_CANCEL, ui::ET_GESTURE_BEGIN);
2571 2568
2572 // Little bit of touch move should not affect our state. 2569 // Little bit of touch move should not affect our state.
2573 delegate->Reset(); 2570 delegate->Reset();
2574 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(102, 202), 2571 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::PointF(102.f, 202.f), kTouchId1,
2575 kTouchId1, tes.Now()); 2572 tes.Now());
2576 DispatchEventUsingWindowDispatcher(&move1); 2573 DispatchEventUsingWindowDispatcher(&move1);
2577 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(131, 202), 2574 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::PointF(131.f, 202.f), kTouchId2,
2578 kTouchId2, tes.Now()); 2575 tes.Now());
2579 DispatchEventUsingWindowDispatcher(&move2); 2576 DispatchEventUsingWindowDispatcher(&move2);
2580 EXPECT_3_EVENTS(delegate->events(), ui::ET_GESTURE_SCROLL_BEGIN, 2577 EXPECT_3_EVENTS(delegate->events(), ui::ET_GESTURE_SCROLL_BEGIN,
2581 ui::ET_GESTURE_SCROLL_UPDATE, ui::ET_GESTURE_SCROLL_UPDATE); 2578 ui::ET_GESTURE_SCROLL_UPDATE, ui::ET_GESTURE_SCROLL_UPDATE);
2582 2579
2583 // Make sure there is enough delay before the touch is released so that it is 2580 // Make sure there is enough delay before the touch is released so that it is
2584 // recognized as a tap. 2581 // recognized as a tap.
2585 delegate->Reset(); 2582 delegate->Reset();
2586 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 2583 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
2587 kTouchId1, tes.LeapForward(50)); 2584 kTouchId1, tes.LeapForward(50));
2588 2585
2589 DispatchEventUsingWindowDispatcher(&release1); 2586 DispatchEventUsingWindowDispatcher(&release1);
2590 EXPECT_2_EVENTS( 2587 EXPECT_2_EVENTS(
2591 delegate->events(), ui::ET_GESTURE_TWO_FINGER_TAP, ui::ET_GESTURE_END); 2588 delegate->events(), ui::ET_GESTURE_TWO_FINGER_TAP, ui::ET_GESTURE_END);
2592 2589
2593 // Lift second finger. 2590 // Lift second finger.
2594 // Make sure there is enough delay before the touch is released so that it is 2591 // Make sure there is enough delay before the touch is released so that it is
2595 // recognized as a tap. 2592 // recognized as a tap.
2596 delegate->Reset(); 2593 delegate->Reset();
2597 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(130, 201), 2594 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::PointF(130.f, 201.f),
2598 kTouchId2, tes.LeapForward(50)); 2595 kTouchId2, tes.LeapForward(50));
2599 2596
2600 DispatchEventUsingWindowDispatcher(&release2); 2597 DispatchEventUsingWindowDispatcher(&release2);
2601 EXPECT_2_EVENTS( 2598 EXPECT_2_EVENTS(
2602 delegate->events(), ui::ET_GESTURE_SCROLL_END, ui::ET_GESTURE_END); 2599 delegate->events(), ui::ET_GESTURE_SCROLL_END, ui::ET_GESTURE_END);
2603 } 2600 }
2604 2601
2605 TEST_F(GestureRecognizerTest, TwoFingerTapExpired) { 2602 TEST_F(GestureRecognizerTest, TwoFingerTapExpired) {
2606 scoped_ptr<GestureEventConsumeDelegate> delegate( 2603 scoped_ptr<GestureEventConsumeDelegate> delegate(
2607 new GestureEventConsumeDelegate()); 2604 new GestureEventConsumeDelegate());
2608 const int kWindowWidth = 123; 2605 const int kWindowWidth = 123;
2609 const int kWindowHeight = 45; 2606 const int kWindowHeight = 45;
2610 const int kTouchId1 = 2; 2607 const int kTouchId1 = 2;
2611 const int kTouchId2 = 3; 2608 const int kTouchId2 = 3;
2612 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2609 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2613 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2610 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2614 delegate.get(), -1234, bounds, root_window())); 2611 delegate.get(), -1234, bounds, root_window()));
2615 TimedEvents tes; 2612 TimedEvents tes;
2616 2613
2617 delegate->Reset(); 2614 delegate->Reset();
2618 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2615 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
2619 kTouchId1, tes.Now()); 2616 kTouchId1, tes.Now());
2620 DispatchEventUsingWindowDispatcher(&press1); 2617 DispatchEventUsingWindowDispatcher(&press1);
2621 2618
2622 delegate->Reset(); 2619 delegate->Reset();
2623 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), 2620 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(130.f, 201.f),
2624 kTouchId2, tes.Now()); 2621 kTouchId2, tes.Now());
2625 DispatchEventUsingWindowDispatcher(&press2); 2622 DispatchEventUsingWindowDispatcher(&press2);
2626 2623
2627 // Send release event after sufficient delay so that two finger time expires. 2624 // Send release event after sufficient delay so that two finger time expires.
2628 delegate->Reset(); 2625 delegate->Reset();
2629 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 2626 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
2630 kTouchId1, tes.LeapForward(1000)); 2627 kTouchId1, tes.LeapForward(1000));
2631 2628
2632 DispatchEventUsingWindowDispatcher(&release1); 2629 DispatchEventUsingWindowDispatcher(&release1);
2633 EXPECT_FALSE(delegate->two_finger_tap()); 2630 EXPECT_FALSE(delegate->two_finger_tap());
2634 2631
2635 // Lift second finger. 2632 // Lift second finger.
2636 // Make sure there is enough delay before the touch is released so that it is 2633 // Make sure there is enough delay before the touch is released so that it is
2637 // recognized as a tap. 2634 // recognized as a tap.
2638 delegate->Reset(); 2635 delegate->Reset();
2639 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(130, 201), 2636 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::PointF(130.f, 201.f),
2640 kTouchId2, tes.LeapForward(50)); 2637 kTouchId2, tes.LeapForward(50));
2641 2638
2642 DispatchEventUsingWindowDispatcher(&release2); 2639 DispatchEventUsingWindowDispatcher(&release2);
2643 EXPECT_FALSE(delegate->two_finger_tap()); 2640 EXPECT_FALSE(delegate->two_finger_tap());
2644 } 2641 }
2645 2642
2646 TEST_F(GestureRecognizerTest, TwoFingerTapChangesToPinch) { 2643 TEST_F(GestureRecognizerTest, TwoFingerTapChangesToPinch) {
2647 scoped_ptr<GestureEventConsumeDelegate> delegate( 2644 scoped_ptr<GestureEventConsumeDelegate> delegate(
2648 new GestureEventConsumeDelegate()); 2645 new GestureEventConsumeDelegate());
2649 const int kWindowWidth = 123; 2646 const int kWindowWidth = 123;
2650 const int kWindowHeight = 45; 2647 const int kWindowHeight = 45;
2651 const int kTouchId1 = 2; 2648 const int kTouchId1 = 2;
2652 const int kTouchId2 = 3; 2649 const int kTouchId2 = 3;
2653 TimedEvents tes; 2650 TimedEvents tes;
2654 2651
2655 // Test moving first finger 2652 // Test moving first finger
2656 { 2653 {
2657 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2654 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2658 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2655 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2659 delegate.get(), -1234, bounds, root_window())); 2656 delegate.get(), -1234, bounds, root_window()));
2660 2657
2661 delegate->Reset(); 2658 delegate->Reset();
2662 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2659 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
2663 kTouchId1, tes.Now()); 2660 kTouchId1, tes.Now());
2664 DispatchEventUsingWindowDispatcher(&press1); 2661 DispatchEventUsingWindowDispatcher(&press1);
2665 2662
2666 delegate->Reset(); 2663 delegate->Reset();
2667 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), 2664 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(130.f, 201.f),
2668 kTouchId2, tes.Now()); 2665 kTouchId2, tes.Now());
2669 DispatchEventUsingWindowDispatcher(&press2); 2666 DispatchEventUsingWindowDispatcher(&press2);
2670 2667
2671 tes.SendScrollEvent(event_processor(), 230, 330, kTouchId1, delegate.get()); 2668 tes.SendScrollEvent(event_processor(), 230, 330, kTouchId1, delegate.get());
2672 EXPECT_FALSE(delegate->two_finger_tap()); 2669 EXPECT_FALSE(delegate->two_finger_tap());
2673 EXPECT_TRUE(delegate->pinch_begin()); 2670 EXPECT_TRUE(delegate->pinch_begin());
2674 2671
2675 // Make sure there is enough delay before the touch is released so that it 2672 // Make sure there is enough delay before the touch is released so that it
2676 // is recognized as a tap. 2673 // is recognized as a tap.
2677 delegate->Reset(); 2674 delegate->Reset();
2678 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 2675 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
2679 kTouchId2, tes.LeapForward(50)); 2676 kTouchId2, tes.LeapForward(50));
2680 2677
2681 DispatchEventUsingWindowDispatcher(&release); 2678 DispatchEventUsingWindowDispatcher(&release);
2682 EXPECT_FALSE(delegate->two_finger_tap()); 2679 EXPECT_FALSE(delegate->two_finger_tap());
2683 EXPECT_TRUE(delegate->pinch_end()); 2680 EXPECT_TRUE(delegate->pinch_end());
2684 } 2681 }
2685 2682
2686 // Test moving second finger 2683 // Test moving second finger
2687 { 2684 {
2688 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2685 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2689 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2686 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2690 delegate.get(), -1234, bounds, root_window())); 2687 delegate.get(), -1234, bounds, root_window()));
2691 2688
2692 delegate->Reset(); 2689 delegate->Reset();
2693 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2690 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
2694 kTouchId1, tes.Now()); 2691 kTouchId1, tes.Now());
2695 DispatchEventUsingWindowDispatcher(&press1); 2692 DispatchEventUsingWindowDispatcher(&press1);
2696 2693
2697 delegate->Reset(); 2694 delegate->Reset();
2698 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), 2695 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(130.f, 201.f),
2699 kTouchId2, tes.Now()); 2696 kTouchId2, tes.Now());
2700 DispatchEventUsingWindowDispatcher(&press2); 2697 DispatchEventUsingWindowDispatcher(&press2);
2701 2698
2702 tes.SendScrollEvent(event_processor(), 301, 230, kTouchId2, delegate.get()); 2699 tes.SendScrollEvent(event_processor(), 301, 230, kTouchId2, delegate.get());
2703 EXPECT_FALSE(delegate->two_finger_tap()); 2700 EXPECT_FALSE(delegate->two_finger_tap());
2704 EXPECT_TRUE(delegate->pinch_begin()); 2701 EXPECT_TRUE(delegate->pinch_begin());
2705 2702
2706 // Make sure there is enough delay before the touch is released so that it 2703 // Make sure there is enough delay before the touch is released so that it
2707 // is recognized as a tap. 2704 // is recognized as a tap.
2708 delegate->Reset(); 2705 delegate->Reset();
2709 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 2706 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
2710 kTouchId1, tes.LeapForward(50)); 2707 kTouchId1, tes.LeapForward(50));
2711 2708
2712 DispatchEventUsingWindowDispatcher(&release); 2709 DispatchEventUsingWindowDispatcher(&release);
2713 EXPECT_FALSE(delegate->two_finger_tap()); 2710 EXPECT_FALSE(delegate->two_finger_tap());
2714 EXPECT_TRUE(delegate->pinch_end()); 2711 EXPECT_TRUE(delegate->pinch_end());
2715 } 2712 }
2716 } 2713 }
2717 2714
2718 TEST_F(GestureRecognizerTest, NoTwoFingerTapWhenFirstFingerHasScrolled) { 2715 TEST_F(GestureRecognizerTest, NoTwoFingerTapWhenFirstFingerHasScrolled) {
2719 scoped_ptr<GestureEventConsumeDelegate> delegate( 2716 scoped_ptr<GestureEventConsumeDelegate> delegate(
2720 new GestureEventConsumeDelegate()); 2717 new GestureEventConsumeDelegate());
2721 const int kWindowWidth = 123; 2718 const int kWindowWidth = 123;
2722 const int kWindowHeight = 45; 2719 const int kWindowHeight = 45;
2723 const int kTouchId1 = 2; 2720 const int kTouchId1 = 2;
2724 const int kTouchId2 = 3; 2721 const int kTouchId2 = 3;
2725 TimedEvents tes; 2722 TimedEvents tes;
2726 2723
2727 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2724 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2728 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2725 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2729 delegate.get(), -1234, bounds, root_window())); 2726 delegate.get(), -1234, bounds, root_window()));
2730 2727
2731 delegate->Reset(); 2728 delegate->Reset();
2732 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2729 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
2733 kTouchId1, tes.Now()); 2730 kTouchId1, tes.Now());
2734 DispatchEventUsingWindowDispatcher(&press1); 2731 DispatchEventUsingWindowDispatcher(&press1);
2735 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId1, delegate.get()); 2732 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId1, delegate.get());
2736 2733
2737 delegate->Reset(); 2734 delegate->Reset();
2738 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), 2735 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(130.f, 201.f),
2739 kTouchId2, tes.Now()); 2736 kTouchId2, tes.Now());
2740 DispatchEventUsingWindowDispatcher(&press2); 2737 DispatchEventUsingWindowDispatcher(&press2);
2741 2738
2742 EXPECT_FALSE(delegate->pinch_begin()); 2739 EXPECT_FALSE(delegate->pinch_begin());
2743 2740
2744 // Make sure there is enough delay before the touch is released so that it 2741 // Make sure there is enough delay before the touch is released so that it
2745 // is recognized as a tap. 2742 // is recognized as a tap.
2746 delegate->Reset(); 2743 delegate->Reset();
2747 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 2744 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
2748 kTouchId2, tes.LeapForward(50)); 2745 kTouchId2, tes.LeapForward(50));
2749 2746
2750 DispatchEventUsingWindowDispatcher(&release); 2747 DispatchEventUsingWindowDispatcher(&release);
2751 EXPECT_FALSE(delegate->two_finger_tap()); 2748 EXPECT_FALSE(delegate->two_finger_tap());
2752 EXPECT_FALSE(delegate->pinch_end()); 2749 EXPECT_FALSE(delegate->pinch_end());
2753 } 2750 }
2754 2751
2755 TEST_F(GestureRecognizerTest, MultiFingerSwipe) { 2752 TEST_F(GestureRecognizerTest, MultiFingerSwipe) {
2756 scoped_ptr<GestureEventConsumeDelegate> delegate( 2753 scoped_ptr<GestureEventConsumeDelegate> delegate(
2757 new GestureEventConsumeDelegate()); 2754 new GestureEventConsumeDelegate());
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2823 const int kTouchId2 = 3; 2820 const int kTouchId2 = 3;
2824 TimedEvents tes; 2821 TimedEvents tes;
2825 2822
2826 // Test canceling first finger. 2823 // Test canceling first finger.
2827 { 2824 {
2828 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2825 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2829 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2826 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2830 delegate.get(), -1234, bounds, root_window())); 2827 delegate.get(), -1234, bounds, root_window()));
2831 2828
2832 delegate->Reset(); 2829 delegate->Reset();
2833 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2830 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
2834 kTouchId1, tes.Now()); 2831 kTouchId1, tes.Now());
2835 DispatchEventUsingWindowDispatcher(&press1); 2832 DispatchEventUsingWindowDispatcher(&press1);
2836 2833
2837 delegate->Reset(); 2834 delegate->Reset();
2838 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), 2835 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(130.f, 201.f),
2839 kTouchId2, tes.Now()); 2836 kTouchId2, tes.Now());
2840 DispatchEventUsingWindowDispatcher(&press2); 2837 DispatchEventUsingWindowDispatcher(&press2);
2841 2838
2842 delegate->Reset(); 2839 delegate->Reset();
2843 ui::TouchEvent cancel(ui::ET_TOUCH_CANCELLED, gfx::Point(130, 201), 2840 ui::TouchEvent cancel(ui::ET_TOUCH_CANCELLED, gfx::PointF(130.f, 201.f),
2844 kTouchId1, tes.Now()); 2841 kTouchId1, tes.Now());
2845 DispatchEventUsingWindowDispatcher(&cancel); 2842 DispatchEventUsingWindowDispatcher(&cancel);
2846 EXPECT_FALSE(delegate->two_finger_tap()); 2843 EXPECT_FALSE(delegate->two_finger_tap());
2847 2844
2848 // Make sure there is enough delay before the touch is released so that it 2845 // Make sure there is enough delay before the touch is released so that it
2849 // is recognized as a tap. 2846 // is recognized as a tap.
2850 delegate->Reset(); 2847 delegate->Reset();
2851 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 2848 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
2852 kTouchId2, tes.LeapForward(50)); 2849 kTouchId2, tes.LeapForward(50));
2853 2850
2854 DispatchEventUsingWindowDispatcher(&release); 2851 DispatchEventUsingWindowDispatcher(&release);
2855 EXPECT_FALSE(delegate->two_finger_tap()); 2852 EXPECT_FALSE(delegate->two_finger_tap());
2856 } 2853 }
2857 2854
2858 // Test canceling second finger 2855 // Test canceling second finger
2859 { 2856 {
2860 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2857 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2861 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2858 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2862 delegate.get(), -1234, bounds, root_window())); 2859 delegate.get(), -1234, bounds, root_window()));
2863 2860
2864 delegate->Reset(); 2861 delegate->Reset();
2865 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2862 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
2866 kTouchId1, tes.Now()); 2863 kTouchId1, tes.Now());
2867 DispatchEventUsingWindowDispatcher(&press1); 2864 DispatchEventUsingWindowDispatcher(&press1);
2868 2865
2869 delegate->Reset(); 2866 delegate->Reset();
2870 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), 2867 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(130.f, 201.f),
2871 kTouchId2, tes.Now()); 2868 kTouchId2, tes.Now());
2872 DispatchEventUsingWindowDispatcher(&press2); 2869 DispatchEventUsingWindowDispatcher(&press2);
2873 2870
2874 delegate->Reset(); 2871 delegate->Reset();
2875 ui::TouchEvent cancel(ui::ET_TOUCH_CANCELLED, gfx::Point(130, 201), 2872 ui::TouchEvent cancel(ui::ET_TOUCH_CANCELLED, gfx::PointF(130.f, 201.f),
2876 kTouchId2, tes.Now()); 2873 kTouchId2, tes.Now());
2877 DispatchEventUsingWindowDispatcher(&cancel); 2874 DispatchEventUsingWindowDispatcher(&cancel);
2878 EXPECT_FALSE(delegate->two_finger_tap()); 2875 EXPECT_FALSE(delegate->two_finger_tap());
2879 2876
2880 // Make sure there is enough delay before the touch is released so that it 2877 // Make sure there is enough delay before the touch is released so that it
2881 // is recognized as a tap. 2878 // is recognized as a tap.
2882 delegate->Reset(); 2879 delegate->Reset();
2883 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 2880 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
2884 kTouchId1, tes.LeapForward(50)); 2881 kTouchId1, tes.LeapForward(50));
2885 2882
2886 DispatchEventUsingWindowDispatcher(&release); 2883 DispatchEventUsingWindowDispatcher(&release);
2887 EXPECT_FALSE(delegate->two_finger_tap()); 2884 EXPECT_FALSE(delegate->two_finger_tap());
2888 } 2885 }
2889 } 2886 }
2890 2887
2891 TEST_F(GestureRecognizerTest, VeryWideTwoFingerTouchDownShouldBeAPinch) { 2888 TEST_F(GestureRecognizerTest, VeryWideTwoFingerTouchDownShouldBeAPinch) {
2892 scoped_ptr<GestureEventConsumeDelegate> delegate( 2889 scoped_ptr<GestureEventConsumeDelegate> delegate(
2893 new GestureEventConsumeDelegate()); 2890 new GestureEventConsumeDelegate());
2894 const int kWindowWidth = 523; 2891 const int kWindowWidth = 523;
2895 const int kWindowHeight = 45; 2892 const int kWindowHeight = 45;
2896 const int kTouchId1 = 2; 2893 const int kTouchId1 = 2;
2897 const int kTouchId2 = 3; 2894 const int kTouchId2 = 3;
2898 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2895 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2899 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2896 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2900 delegate.get(), -1234, bounds, root_window())); 2897 delegate.get(), -1234, bounds, root_window()));
2901 TimedEvents tes; 2898 TimedEvents tes;
2902 2899
2903 delegate->Reset(); 2900 delegate->Reset();
2904 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2901 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
2905 kTouchId1, tes.Now()); 2902 kTouchId1, tes.Now());
2906 DispatchEventUsingWindowDispatcher(&press1); 2903 DispatchEventUsingWindowDispatcher(&press1);
2907 EXPECT_FALSE(delegate->tap()); 2904 EXPECT_FALSE(delegate->tap());
2908 EXPECT_TRUE(delegate->tap_down()); 2905 EXPECT_TRUE(delegate->tap_down());
2909 EXPECT_FALSE(delegate->tap_cancel()); 2906 EXPECT_FALSE(delegate->tap_cancel());
2910 EXPECT_FALSE(delegate->scroll_begin()); 2907 EXPECT_FALSE(delegate->scroll_begin());
2911 EXPECT_FALSE(delegate->scroll_update()); 2908 EXPECT_FALSE(delegate->scroll_update());
2912 EXPECT_FALSE(delegate->scroll_end()); 2909 EXPECT_FALSE(delegate->scroll_end());
2913 EXPECT_FALSE(delegate->long_press()); 2910 EXPECT_FALSE(delegate->long_press());
2914 EXPECT_FALSE(delegate->two_finger_tap()); 2911 EXPECT_FALSE(delegate->two_finger_tap());
2915 2912
2916 delegate->Reset(); 2913 delegate->Reset();
2917 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(430, 201), 2914 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(430.f, 201.f),
2918 kTouchId2, tes.Now()); 2915 kTouchId2, tes.Now());
2919 DispatchEventUsingWindowDispatcher(&press2); 2916 DispatchEventUsingWindowDispatcher(&press2);
2920 EXPECT_FALSE(delegate->tap()); 2917 EXPECT_FALSE(delegate->tap());
2921 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap. 2918 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap.
2922 EXPECT_TRUE(delegate->tap_cancel()); 2919 EXPECT_TRUE(delegate->tap_cancel());
2923 EXPECT_FALSE(delegate->scroll_begin()); 2920 EXPECT_FALSE(delegate->scroll_begin());
2924 EXPECT_FALSE(delegate->scroll_update()); 2921 EXPECT_FALSE(delegate->scroll_update());
2925 EXPECT_FALSE(delegate->scroll_end()); 2922 EXPECT_FALSE(delegate->scroll_end());
2926 EXPECT_FALSE(delegate->long_press()); 2923 EXPECT_FALSE(delegate->long_press());
2927 EXPECT_FALSE(delegate->two_finger_tap()); 2924 EXPECT_FALSE(delegate->two_finger_tap());
2928 EXPECT_FALSE(delegate->pinch_begin()); 2925 EXPECT_FALSE(delegate->pinch_begin());
2929 2926
2930 delegate->Reset(); 2927 delegate->Reset();
2931 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(530, 301), 2928 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::PointF(530.f, 301.f), kTouchId2,
2932 kTouchId2, tes.Now()); 2929 tes.Now());
2933 DispatchEventUsingWindowDispatcher(&move2); 2930 DispatchEventUsingWindowDispatcher(&move2);
2934 EXPECT_FALSE(delegate->tap()); 2931 EXPECT_FALSE(delegate->tap());
2935 EXPECT_FALSE(delegate->tap_down()); 2932 EXPECT_FALSE(delegate->tap_down());
2936 EXPECT_FALSE(delegate->tap_cancel()); 2933 EXPECT_FALSE(delegate->tap_cancel());
2937 // Pinch & Scroll only when there is enough movement. 2934 // Pinch & Scroll only when there is enough movement.
2938 EXPECT_TRUE(delegate->scroll_begin()); 2935 EXPECT_TRUE(delegate->scroll_begin());
2939 EXPECT_TRUE(delegate->scroll_update()); 2936 EXPECT_TRUE(delegate->scroll_update());
2940 EXPECT_FALSE(delegate->scroll_end()); 2937 EXPECT_FALSE(delegate->scroll_end());
2941 EXPECT_FALSE(delegate->long_press()); 2938 EXPECT_FALSE(delegate->long_press());
2942 EXPECT_FALSE(delegate->two_finger_tap()); 2939 EXPECT_FALSE(delegate->two_finger_tap());
2943 EXPECT_TRUE(delegate->pinch_begin()); 2940 EXPECT_TRUE(delegate->pinch_begin());
2944 } 2941 }
2945 2942
2946 // Verifies if a window is the target of multiple touch-ids and we hide the 2943 // Verifies if a window is the target of multiple touch-ids and we hide the
2947 // window everything is cleaned up correctly. 2944 // window everything is cleaned up correctly.
2948 TEST_F(GestureRecognizerTest, FlushAllOnHide) { 2945 TEST_F(GestureRecognizerTest, FlushAllOnHide) {
2949 scoped_ptr<GestureEventConsumeDelegate> delegate( 2946 scoped_ptr<GestureEventConsumeDelegate> delegate(
2950 new GestureEventConsumeDelegate()); 2947 new GestureEventConsumeDelegate());
2951 gfx::Rect bounds(0, 0, 200, 200); 2948 gfx::Rect bounds(0, 0, 200, 200);
2952 scoped_ptr<aura::Window> window( 2949 scoped_ptr<aura::Window> window(
2953 CreateTestWindowWithDelegate(delegate.get(), 0, bounds, root_window())); 2950 CreateTestWindowWithDelegate(delegate.get(), 0, bounds, root_window()));
2954 const int kTouchId1 = 8; 2951 const int kTouchId1 = 8;
2955 const int kTouchId2 = 2; 2952 const int kTouchId2 = 2;
2956 TimedEvents tes; 2953 TimedEvents tes;
2957 2954
2958 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 2955 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(10.f, 10.f),
2959 kTouchId1, tes.Now()); 2956 kTouchId1, tes.Now());
2960 DispatchEventUsingWindowDispatcher(&press1); 2957 DispatchEventUsingWindowDispatcher(&press1);
2961 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(20, 20), 2958 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(20.f, 20.f),
2962 kTouchId2, tes.Now()); 2959 kTouchId2, tes.Now());
2963 DispatchEventUsingWindowDispatcher(&press2); 2960 DispatchEventUsingWindowDispatcher(&press2);
2964 window->Hide(); 2961 window->Hide();
2965 EXPECT_EQ(NULL, 2962 EXPECT_EQ(NULL,
2966 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press1)); 2963 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press1));
2967 EXPECT_EQ(NULL, 2964 EXPECT_EQ(NULL,
2968 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press2)); 2965 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press2));
2969 } 2966 }
2970 2967
2971 TEST_F(GestureRecognizerTest, LongPressTimerStopsOnPreventDefaultedTouchMoves) { 2968 TEST_F(GestureRecognizerTest, LongPressTimerStopsOnPreventDefaultedTouchMoves) {
2972 scoped_ptr<QueueTouchEventDelegate> delegate( 2969 scoped_ptr<QueueTouchEventDelegate> delegate(
2973 new QueueTouchEventDelegate(host()->dispatcher())); 2970 new QueueTouchEventDelegate(host()->dispatcher()));
2974 const int kTouchId = 2; 2971 const int kTouchId = 2;
2975 gfx::Rect bounds(100, 200, 100, 100); 2972 gfx::Rect bounds(100, 200, 100, 100);
2976 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2973 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2977 delegate.get(), -1234, bounds, root_window())); 2974 delegate.get(), -1234, bounds, root_window()));
2978 delegate->set_window(window.get()); 2975 delegate->set_window(window.get());
2979 TimedEvents tes; 2976 TimedEvents tes;
2980 2977
2981 delegate->Reset(); 2978 delegate->Reset();
2982 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2979 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
2983 kTouchId, tes.Now()); 2980 kTouchId, tes.Now());
2984 DispatchEventUsingWindowDispatcher(&press); 2981 DispatchEventUsingWindowDispatcher(&press);
2985 // Scroll around, to cancel the long press 2982 // Scroll around, to cancel the long press
2986 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId, delegate.get()); 2983 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId, delegate.get());
2987 2984
2988 delegate->Reset(); 2985 delegate->Reset();
2989 delegate->ReceivedAck(); 2986 delegate->ReceivedAck();
2990 EXPECT_TRUE(delegate->tap_down()); 2987 EXPECT_TRUE(delegate->tap_down());
2991 2988
2992 // Wait long enough that long press would have fired if the touchmove hadn't 2989 // Wait long enough that long press would have fired if the touchmove hadn't
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3026 new ConsumesTouchMovesDelegate()); 3023 new ConsumesTouchMovesDelegate());
3027 const int kWindowWidth = 123; 3024 const int kWindowWidth = 123;
3028 const int kWindowHeight = 45; 3025 const int kWindowHeight = 45;
3029 const int kTouchId = 5; 3026 const int kTouchId = 5;
3030 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3027 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
3031 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3028 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3032 delegate.get(), -1234, bounds, root_window())); 3029 delegate.get(), -1234, bounds, root_window()));
3033 TimedEvents tes; 3030 TimedEvents tes;
3034 3031
3035 delegate->Reset(); 3032 delegate->Reset();
3036 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 3033 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
3037 kTouchId, tes.Now()); 3034 kTouchId, tes.Now());
3038 DispatchEventUsingWindowDispatcher(&press); 3035 DispatchEventUsingWindowDispatcher(&press);
3039 EXPECT_FALSE(delegate->tap()); 3036 EXPECT_FALSE(delegate->tap());
3040 EXPECT_TRUE(delegate->tap_down()); 3037 EXPECT_TRUE(delegate->tap_down());
3041 EXPECT_FALSE(delegate->tap_cancel()); 3038 EXPECT_FALSE(delegate->tap_cancel());
3042 EXPECT_TRUE(delegate->begin()); 3039 EXPECT_TRUE(delegate->begin());
3043 EXPECT_FALSE(delegate->scroll_begin()); 3040 EXPECT_FALSE(delegate->scroll_begin());
3044 EXPECT_FALSE(delegate->scroll_update()); 3041 EXPECT_FALSE(delegate->scroll_update());
3045 EXPECT_FALSE(delegate->scroll_end()); 3042 EXPECT_FALSE(delegate->scroll_end());
3046 3043
3047 // Move the touch-point enough so that it would normally be considered a 3044 // Move the touch-point enough so that it would normally be considered a
3048 // scroll. But since the touch-moves will be consumed, the scroll should not 3045 // scroll. But since the touch-moves will be consumed, the scroll should not
3049 // start. 3046 // start.
3050 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId, delegate.get()); 3047 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId, delegate.get());
3051 EXPECT_FALSE(delegate->tap()); 3048 EXPECT_FALSE(delegate->tap());
3052 EXPECT_FALSE(delegate->tap_down()); 3049 EXPECT_FALSE(delegate->tap_down());
3053 EXPECT_TRUE(delegate->tap_cancel()); 3050 EXPECT_TRUE(delegate->tap_cancel());
3054 EXPECT_FALSE(delegate->begin()); 3051 EXPECT_FALSE(delegate->begin());
3055 EXPECT_FALSE(delegate->scroll_update()); 3052 EXPECT_FALSE(delegate->scroll_update());
3056 EXPECT_FALSE(delegate->scroll_end()); 3053 EXPECT_FALSE(delegate->scroll_end());
3057 3054
3058 EXPECT_TRUE(delegate->scroll_begin()); 3055 EXPECT_TRUE(delegate->scroll_begin());
3059 3056
3060 // Release the touch back at the start point. This should end without causing 3057 // Release the touch back at the start point. This should end without causing
3061 // a tap. 3058 // a tap.
3062 delegate->Reset(); 3059 delegate->Reset();
3063 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(130, 230), 3060 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(130.f, 230.f),
3064 kTouchId, tes.LeapForward(50)); 3061 kTouchId, tes.LeapForward(50));
3065 DispatchEventUsingWindowDispatcher(&release); 3062 DispatchEventUsingWindowDispatcher(&release);
3066 EXPECT_FALSE(delegate->tap()); 3063 EXPECT_FALSE(delegate->tap());
3067 EXPECT_FALSE(delegate->tap_down()); 3064 EXPECT_FALSE(delegate->tap_down());
3068 EXPECT_FALSE(delegate->tap_cancel()); 3065 EXPECT_FALSE(delegate->tap_cancel());
3069 EXPECT_FALSE(delegate->begin()); 3066 EXPECT_FALSE(delegate->begin());
3070 EXPECT_TRUE(delegate->end()); 3067 EXPECT_TRUE(delegate->end());
3071 EXPECT_FALSE(delegate->scroll_begin()); 3068 EXPECT_FALSE(delegate->scroll_begin());
3072 EXPECT_FALSE(delegate->scroll_update()); 3069 EXPECT_FALSE(delegate->scroll_update());
3073 3070
3074 EXPECT_TRUE(delegate->scroll_end()); 3071 EXPECT_TRUE(delegate->scroll_end());
3075 } 3072 }
3076 3073
3077 // Tests the behavior of 2F scroll when some of the touch-move events are 3074 // Tests the behavior of 2F scroll when some of the touch-move events are
3078 // consumed. 3075 // consumed.
3079 TEST_F(GestureRecognizerTest, GestureEventScrollTwoFingerTouchMoveConsumed) { 3076 TEST_F(GestureRecognizerTest, GestureEventScrollTwoFingerTouchMoveConsumed) {
3080 scoped_ptr<ConsumesTouchMovesDelegate> delegate( 3077 scoped_ptr<ConsumesTouchMovesDelegate> delegate(
3081 new ConsumesTouchMovesDelegate()); 3078 new ConsumesTouchMovesDelegate());
3082 const int kWindowWidth = 123; 3079 const int kWindowWidth = 123;
3083 const int kWindowHeight = 100; 3080 const int kWindowHeight = 100;
3084 const int kTouchId1 = 2; 3081 const int kTouchId1 = 2;
3085 const int kTouchId2 = 3; 3082 const int kTouchId2 = 3;
3086 TimedEvents tes; 3083 TimedEvents tes;
3087 3084
3088 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3085 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
3089 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3086 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3090 delegate.get(), -1234, bounds, root_window())); 3087 delegate.get(), -1234, bounds, root_window()));
3091 3088
3092 delegate->Reset(); 3089 delegate->Reset();
3093 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 3090 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
3094 kTouchId1, tes.Now()); 3091 kTouchId1, tes.Now());
3095 DispatchEventUsingWindowDispatcher(&press1); 3092 DispatchEventUsingWindowDispatcher(&press1);
3096 tes.SendScrollEvent(event_processor(), 131, 231, kTouchId1, delegate.get()); 3093 tes.SendScrollEvent(event_processor(), 131, 231, kTouchId1, delegate.get());
3097 3094
3098 EXPECT_2_EVENTS(delegate->events(), 3095 EXPECT_2_EVENTS(delegate->events(),
3099 ui::ET_GESTURE_TAP_CANCEL, 3096 ui::ET_GESTURE_TAP_CANCEL,
3100 ui::ET_GESTURE_SCROLL_BEGIN); 3097 ui::ET_GESTURE_SCROLL_BEGIN);
3101 3098
3102 delegate->Reset(); 3099 delegate->Reset();
3103 // Second finger touches down and moves. 3100 // Second finger touches down and moves.
3104 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), 3101 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(130.f, 201.f),
3105 kTouchId2, tes.LeapForward(50)); 3102 kTouchId2, tes.LeapForward(50));
3106 DispatchEventUsingWindowDispatcher(&press2); 3103 DispatchEventUsingWindowDispatcher(&press2);
3107 tes.SendScrollEvent(event_processor(), 161, 231, kTouchId2, delegate.get()); 3104 tes.SendScrollEvent(event_processor(), 161, 231, kTouchId2, delegate.get());
3108 EXPECT_0_EVENTS(delegate->events()); 3105 EXPECT_0_EVENTS(delegate->events());
3109 3106
3110 delegate->Reset(); 3107 delegate->Reset();
3111 // Move first finger again, no PinchUpdate & ScrollUpdate. 3108 // Move first finger again, no PinchUpdate & ScrollUpdate.
3112 tes.SendScrollEvent(event_processor(), 161, 261, kTouchId1, delegate.get()); 3109 tes.SendScrollEvent(event_processor(), 161, 261, kTouchId1, delegate.get());
3113 EXPECT_0_EVENTS(delegate->events()); 3110 EXPECT_0_EVENTS(delegate->events());
3114 3111
3115 // Stops consuming touch-move. 3112 // Stops consuming touch-move.
3116 delegate->set_consume_touch_move(false); 3113 delegate->set_consume_touch_move(false);
3117 3114
3118 delegate->Reset(); 3115 delegate->Reset();
3119 // Making a pinch gesture. 3116 // Making a pinch gesture.
3120 tes.SendScrollEvent(event_processor(), 161, 260, kTouchId1, delegate.get()); 3117 tes.SendScrollEvent(event_processor(), 161, 260, kTouchId1, delegate.get());
3121 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); 3118 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE);
3122 3119
3123 delegate->Reset(); 3120 delegate->Reset();
3124 tes.SendScrollEvent(event_processor(), 161, 261, kTouchId2, delegate.get()); 3121 tes.SendScrollEvent(event_processor(), 161, 261, kTouchId2, delegate.get());
3125 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); 3122 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE);
3126 3123
3127 delegate->Reset(); 3124 delegate->Reset();
3128 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 3125 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
3129 kTouchId1, tes.Now()); 3126 kTouchId1, tes.Now());
3130 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(130, 201), 3127 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::PointF(130.f, 201.f),
3131 kTouchId2, tes.Now()); 3128 kTouchId2, tes.Now());
3132 DispatchEventUsingWindowDispatcher(&release1); 3129 DispatchEventUsingWindowDispatcher(&release1);
3133 DispatchEventUsingWindowDispatcher(&release2); 3130 DispatchEventUsingWindowDispatcher(&release2);
3134 3131
3135 EXPECT_3_EVENTS(delegate->events(), 3132 EXPECT_3_EVENTS(delegate->events(),
3136 ui::ET_GESTURE_END, 3133 ui::ET_GESTURE_END,
3137 ui::ET_SCROLL_FLING_START, 3134 ui::ET_SCROLL_FLING_START,
3138 ui::ET_GESTURE_END); 3135 ui::ET_GESTURE_END);
3139 } 3136 }
3140 3137
3141 // Like as GestureEventTouchMoveConsumed but tests the different behavior 3138 // Like as GestureEventTouchMoveConsumed but tests the different behavior
3142 // depending on whether the events were consumed before or after the scroll 3139 // depending on whether the events were consumed before or after the scroll
3143 // started. 3140 // started.
3144 TEST_F(GestureRecognizerTest, GestureEventScrollTouchMovePartialConsumed) { 3141 TEST_F(GestureRecognizerTest, GestureEventScrollTouchMovePartialConsumed) {
3145 scoped_ptr<ConsumesTouchMovesDelegate> delegate( 3142 scoped_ptr<ConsumesTouchMovesDelegate> delegate(
3146 new ConsumesTouchMovesDelegate()); 3143 new ConsumesTouchMovesDelegate());
3147 const int kWindowWidth = 123; 3144 const int kWindowWidth = 123;
3148 const int kWindowHeight = 45; 3145 const int kWindowHeight = 45;
3149 const int kTouchId = 5; 3146 const int kTouchId = 5;
3150 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3147 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
3151 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3148 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3152 delegate.get(), -1234, bounds, root_window())); 3149 delegate.get(), -1234, bounds, root_window()));
3153 TimedEvents tes; 3150 TimedEvents tes;
3154 3151
3155 delegate->Reset(); 3152 delegate->Reset();
3156 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 3153 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
3157 kTouchId, tes.Now()); 3154 kTouchId, tes.Now());
3158 DispatchEventUsingWindowDispatcher(&press); 3155 DispatchEventUsingWindowDispatcher(&press);
3159 EXPECT_FALSE(delegate->tap()); 3156 EXPECT_FALSE(delegate->tap());
3160 EXPECT_TRUE(delegate->tap_down()); 3157 EXPECT_TRUE(delegate->tap_down());
3161 EXPECT_FALSE(delegate->tap_cancel()); 3158 EXPECT_FALSE(delegate->tap_cancel());
3162 EXPECT_TRUE(delegate->begin()); 3159 EXPECT_TRUE(delegate->begin());
3163 EXPECT_FALSE(delegate->scroll_begin()); 3160 EXPECT_FALSE(delegate->scroll_begin());
3164 EXPECT_FALSE(delegate->scroll_update()); 3161 EXPECT_FALSE(delegate->scroll_update());
3165 EXPECT_FALSE(delegate->scroll_end()); 3162 EXPECT_FALSE(delegate->scroll_end());
3166 3163
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
3216 EXPECT_FALSE(delegate->tap_cancel()); 3213 EXPECT_FALSE(delegate->tap_cancel());
3217 EXPECT_FALSE(delegate->begin()); 3214 EXPECT_FALSE(delegate->begin());
3218 EXPECT_FALSE(delegate->scroll_begin()); 3215 EXPECT_FALSE(delegate->scroll_begin());
3219 EXPECT_FALSE(delegate->scroll_update()); 3216 EXPECT_FALSE(delegate->scroll_update());
3220 EXPECT_FALSE(delegate->scroll_end()); 3217 EXPECT_FALSE(delegate->scroll_end());
3221 EXPECT_EQ(0, delegate->scroll_x()); 3218 EXPECT_EQ(0, delegate->scroll_x());
3222 EXPECT_EQ(0, delegate->scroll_y()); 3219 EXPECT_EQ(0, delegate->scroll_y());
3223 3220
3224 // Release the touch. 3221 // Release the touch.
3225 delegate->Reset(); 3222 delegate->Reset();
3226 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 3223 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
3227 kTouchId, tes.LeapForward(50)); 3224 kTouchId, tes.LeapForward(50));
3228 DispatchEventUsingWindowDispatcher(&release); 3225 DispatchEventUsingWindowDispatcher(&release);
3229 EXPECT_FALSE(delegate->tap()); 3226 EXPECT_FALSE(delegate->tap());
3230 EXPECT_FALSE(delegate->tap_down()); 3227 EXPECT_FALSE(delegate->tap_down());
3231 EXPECT_FALSE(delegate->tap_cancel()); 3228 EXPECT_FALSE(delegate->tap_cancel());
3232 EXPECT_FALSE(delegate->begin()); 3229 EXPECT_FALSE(delegate->begin());
3233 EXPECT_TRUE(delegate->end()); 3230 EXPECT_TRUE(delegate->end());
3234 EXPECT_FALSE(delegate->scroll_begin()); 3231 EXPECT_FALSE(delegate->scroll_begin());
3235 EXPECT_FALSE(delegate->scroll_update()); 3232 EXPECT_FALSE(delegate->scroll_update());
3236 EXPECT_FALSE(delegate->fling()); 3233 EXPECT_FALSE(delegate->fling());
3237 3234
3238 EXPECT_TRUE(delegate->scroll_end()); 3235 EXPECT_TRUE(delegate->scroll_end());
3239 } 3236 }
3240 3237
3241 // Check that appropriate touch events generate double tap gesture events. 3238 // Check that appropriate touch events generate double tap gesture events.
3242 TEST_F(GestureRecognizerTest, GestureEventDoubleTap) { 3239 TEST_F(GestureRecognizerTest, GestureEventDoubleTap) {
3243 scoped_ptr<GestureEventConsumeDelegate> delegate( 3240 scoped_ptr<GestureEventConsumeDelegate> delegate(
3244 new GestureEventConsumeDelegate()); 3241 new GestureEventConsumeDelegate());
3245 const int kWindowWidth = 123; 3242 const int kWindowWidth = 123;
3246 const int kWindowHeight = 45; 3243 const int kWindowHeight = 45;
3247 const int kTouchId = 2; 3244 const int kTouchId = 2;
3248 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3245 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
3249 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3246 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3250 delegate.get(), -1234, bounds, root_window())); 3247 delegate.get(), -1234, bounds, root_window()));
3251 TimedEvents tes; 3248 TimedEvents tes;
3252 3249
3253 // First tap (tested in GestureEventTap) 3250 // First tap (tested in GestureEventTap)
3254 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(104, 201), 3251 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(104.f, 201.f),
3255 kTouchId, tes.Now()); 3252 kTouchId, tes.Now());
3256 DispatchEventUsingWindowDispatcher(&press1); 3253 DispatchEventUsingWindowDispatcher(&press1);
3257 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(104, 201), 3254 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::PointF(104.f, 201.f),
3258 kTouchId, tes.LeapForward(50)); 3255 kTouchId, tes.LeapForward(50));
3259 DispatchEventUsingWindowDispatcher(&release1); 3256 DispatchEventUsingWindowDispatcher(&release1);
3260 delegate->Reset(); 3257 delegate->Reset();
3261 3258
3262 // Second tap 3259 // Second tap
3263 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(101, 203), 3260 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 203.f),
3264 kTouchId, tes.LeapForward(200)); 3261 kTouchId, tes.LeapForward(200));
3265 DispatchEventUsingWindowDispatcher(&press2); 3262 DispatchEventUsingWindowDispatcher(&press2);
3266 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(102, 206), 3263 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::PointF(102.f, 206.f),
3267 kTouchId, tes.LeapForward(50)); 3264 kTouchId, tes.LeapForward(50));
3268 DispatchEventUsingWindowDispatcher(&release2); 3265 DispatchEventUsingWindowDispatcher(&release2);
3269 3266
3270 EXPECT_TRUE(delegate->tap()); 3267 EXPECT_TRUE(delegate->tap());
3271 EXPECT_TRUE(delegate->tap_down()); 3268 EXPECT_TRUE(delegate->tap_down());
3272 EXPECT_FALSE(delegate->tap_cancel()); 3269 EXPECT_FALSE(delegate->tap_cancel());
3273 EXPECT_TRUE(delegate->begin()); 3270 EXPECT_TRUE(delegate->begin());
3274 EXPECT_TRUE(delegate->end()); 3271 EXPECT_TRUE(delegate->end());
3275 EXPECT_FALSE(delegate->scroll_begin()); 3272 EXPECT_FALSE(delegate->scroll_begin());
3276 EXPECT_FALSE(delegate->scroll_update()); 3273 EXPECT_FALSE(delegate->scroll_update());
3277 EXPECT_FALSE(delegate->scroll_end()); 3274 EXPECT_FALSE(delegate->scroll_end());
3278 3275
3279 EXPECT_EQ(2, delegate->tap_count()); 3276 EXPECT_EQ(2, delegate->tap_count());
3280 } 3277 }
3281 3278
3282 // Check that appropriate touch events generate triple tap gesture events. 3279 // Check that appropriate touch events generate triple tap gesture events.
3283 TEST_F(GestureRecognizerTest, GestureEventTripleTap) { 3280 TEST_F(GestureRecognizerTest, GestureEventTripleTap) {
3284 scoped_ptr<GestureEventConsumeDelegate> delegate( 3281 scoped_ptr<GestureEventConsumeDelegate> delegate(
3285 new GestureEventConsumeDelegate()); 3282 new GestureEventConsumeDelegate());
3286 const int kWindowWidth = 123; 3283 const int kWindowWidth = 123;
3287 const int kWindowHeight = 45; 3284 const int kWindowHeight = 45;
3288 const int kTouchId = 2; 3285 const int kTouchId = 2;
3289 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3286 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
3290 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3287 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3291 delegate.get(), -1234, bounds, root_window())); 3288 delegate.get(), -1234, bounds, root_window()));
3292 TimedEvents tes; 3289 TimedEvents tes;
3293 3290
3294 // First tap (tested in GestureEventTap) 3291 // First tap (tested in GestureEventTap)
3295 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(104, 201), 3292 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(104.f, 201.f),
3296 kTouchId, tes.Now()); 3293 kTouchId, tes.Now());
3297 DispatchEventUsingWindowDispatcher(&press1); 3294 DispatchEventUsingWindowDispatcher(&press1);
3298 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(104, 201), 3295 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::PointF(104.f, 201.f),
3299 kTouchId, tes.LeapForward(50)); 3296 kTouchId, tes.LeapForward(50));
3300 DispatchEventUsingWindowDispatcher(&release1); 3297 DispatchEventUsingWindowDispatcher(&release1);
3301 3298
3302 EXPECT_EQ(1, delegate->tap_count()); 3299 EXPECT_EQ(1, delegate->tap_count());
3303 delegate->Reset(); 3300 delegate->Reset();
3304 3301
3305 // Second tap (tested in GestureEventDoubleTap) 3302 // Second tap (tested in GestureEventDoubleTap)
3306 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(101, 203), 3303 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 203.f),
3307 kTouchId, tes.LeapForward(200)); 3304 kTouchId, tes.LeapForward(200));
3308 DispatchEventUsingWindowDispatcher(&press2); 3305 DispatchEventUsingWindowDispatcher(&press2);
3309 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(102, 206), 3306 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::PointF(102.f, 206.f),
3310 kTouchId, tes.LeapForward(50)); 3307 kTouchId, tes.LeapForward(50));
3311 DispatchEventUsingWindowDispatcher(&release2); 3308 DispatchEventUsingWindowDispatcher(&release2);
3312 3309
3313 EXPECT_EQ(2, delegate->tap_count()); 3310 EXPECT_EQ(2, delegate->tap_count());
3314 delegate->Reset(); 3311 delegate->Reset();
3315 3312
3316 // Third tap 3313 // Third tap
3317 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(102, 206), 3314 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::PointF(102.f, 206.f),
3318 kTouchId, tes.LeapForward(200)); 3315 kTouchId, tes.LeapForward(200));
3319 DispatchEventUsingWindowDispatcher(&press3); 3316 DispatchEventUsingWindowDispatcher(&press3);
3320 ui::TouchEvent release3(ui::ET_TOUCH_RELEASED, gfx::Point(102, 206), 3317 ui::TouchEvent release3(ui::ET_TOUCH_RELEASED, gfx::PointF(102.f, 206.f),
3321 kTouchId, tes.LeapForward(50)); 3318 kTouchId, tes.LeapForward(50));
3322 DispatchEventUsingWindowDispatcher(&release3); 3319 DispatchEventUsingWindowDispatcher(&release3);
3323 3320
3324 // Third, Fourth and Fifth Taps. Taps after the third should have their 3321 // Third, Fourth and Fifth Taps. Taps after the third should have their
3325 // |tap_count| wrap around back to 1. 3322 // |tap_count| wrap around back to 1.
3326 for (int i = 3; i < 5; ++i) { 3323 for (int i = 3; i < 5; ++i) {
3327 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, 3324 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::PointF(102.f, 206.f),
3328 gfx::Point(102, 206), 3325 kTouchId, tes.LeapForward(200));
3329 kTouchId,
3330 tes.LeapForward(200));
3331 DispatchEventUsingWindowDispatcher(&press3); 3326 DispatchEventUsingWindowDispatcher(&press3);
3332 ui::TouchEvent release3(ui::ET_TOUCH_RELEASED, 3327 ui::TouchEvent release3(ui::ET_TOUCH_RELEASED, gfx::PointF(102.f, 206.f),
3333 gfx::Point(102, 206), 3328 kTouchId, tes.LeapForward(50));
3334 kTouchId,
3335 tes.LeapForward(50));
3336 DispatchEventUsingWindowDispatcher(&release3); 3329 DispatchEventUsingWindowDispatcher(&release3);
3337 3330
3338 EXPECT_TRUE(delegate->tap()); 3331 EXPECT_TRUE(delegate->tap());
3339 EXPECT_TRUE(delegate->tap_down()); 3332 EXPECT_TRUE(delegate->tap_down());
3340 EXPECT_FALSE(delegate->tap_cancel()); 3333 EXPECT_FALSE(delegate->tap_cancel());
3341 EXPECT_TRUE(delegate->begin()); 3334 EXPECT_TRUE(delegate->begin());
3342 EXPECT_TRUE(delegate->end()); 3335 EXPECT_TRUE(delegate->end());
3343 EXPECT_FALSE(delegate->scroll_begin()); 3336 EXPECT_FALSE(delegate->scroll_begin());
3344 EXPECT_FALSE(delegate->scroll_update()); 3337 EXPECT_FALSE(delegate->scroll_update());
3345 EXPECT_FALSE(delegate->scroll_end()); 3338 EXPECT_FALSE(delegate->scroll_end());
3346 EXPECT_EQ(1 + (i % 3), delegate->tap_count()); 3339 EXPECT_EQ(1 + (i % 3), delegate->tap_count());
3347 } 3340 }
3348 } 3341 }
3349 3342
3350 // Check that we don't get a double tap when the two taps are far apart. 3343 // Check that we don't get a double tap when the two taps are far apart.
3351 TEST_F(GestureRecognizerTest, TwoTapsFarApart) { 3344 TEST_F(GestureRecognizerTest, TwoTapsFarApart) {
3352 scoped_ptr<GestureEventConsumeDelegate> delegate( 3345 scoped_ptr<GestureEventConsumeDelegate> delegate(
3353 new GestureEventConsumeDelegate()); 3346 new GestureEventConsumeDelegate());
3354 const int kWindowWidth = 123; 3347 const int kWindowWidth = 123;
3355 const int kWindowHeight = 45; 3348 const int kWindowHeight = 45;
3356 const int kTouchId = 2; 3349 const int kTouchId = 2;
3357 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3350 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
3358 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3351 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3359 delegate.get(), -1234, bounds, root_window())); 3352 delegate.get(), -1234, bounds, root_window()));
3360 TimedEvents tes; 3353 TimedEvents tes;
3361 3354
3362 // First tap (tested in GestureEventTap) 3355 // First tap (tested in GestureEventTap)
3363 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 3356 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
3364 kTouchId, tes.Now()); 3357 kTouchId, tes.Now());
3365 DispatchEventUsingWindowDispatcher(&press1); 3358 DispatchEventUsingWindowDispatcher(&press1);
3366 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 3359 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
3367 kTouchId, tes.LeapForward(50)); 3360 kTouchId, tes.LeapForward(50));
3368 DispatchEventUsingWindowDispatcher(&release1); 3361 DispatchEventUsingWindowDispatcher(&release1);
3369 delegate->Reset(); 3362 delegate->Reset();
3370 3363
3371 // Second tap, close in time but far in distance 3364 // Second tap, close in time but far in distance
3372 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(201, 201), 3365 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(201.f, 201.f),
3373 kTouchId, tes.LeapForward(200)); 3366 kTouchId, tes.LeapForward(200));
3374 DispatchEventUsingWindowDispatcher(&press2); 3367 DispatchEventUsingWindowDispatcher(&press2);
3375 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(201, 201), 3368 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::PointF(201.f, 201.f),
3376 kTouchId, tes.LeapForward(50)); 3369 kTouchId, tes.LeapForward(50));
3377 DispatchEventUsingWindowDispatcher(&release2); 3370 DispatchEventUsingWindowDispatcher(&release2);
3378 3371
3379 EXPECT_TRUE(delegate->tap()); 3372 EXPECT_TRUE(delegate->tap());
3380 EXPECT_TRUE(delegate->tap_down()); 3373 EXPECT_TRUE(delegate->tap_down());
3381 EXPECT_FALSE(delegate->tap_cancel()); 3374 EXPECT_FALSE(delegate->tap_cancel());
3382 EXPECT_TRUE(delegate->begin()); 3375 EXPECT_TRUE(delegate->begin());
3383 EXPECT_TRUE(delegate->end()); 3376 EXPECT_TRUE(delegate->end());
3384 EXPECT_FALSE(delegate->scroll_begin()); 3377 EXPECT_FALSE(delegate->scroll_begin());
3385 EXPECT_FALSE(delegate->scroll_update()); 3378 EXPECT_FALSE(delegate->scroll_update());
3386 EXPECT_FALSE(delegate->scroll_end()); 3379 EXPECT_FALSE(delegate->scroll_end());
3387 3380
3388 EXPECT_EQ(1, delegate->tap_count()); 3381 EXPECT_EQ(1, delegate->tap_count());
3389 } 3382 }
3390 3383
3391 // Check that we don't get a double tap when the two taps have a long enough 3384 // Check that we don't get a double tap when the two taps have a long enough
3392 // delay in between. 3385 // delay in between.
3393 TEST_F(GestureRecognizerTest, TwoTapsWithDelayBetween) { 3386 TEST_F(GestureRecognizerTest, TwoTapsWithDelayBetween) {
3394 scoped_ptr<GestureEventConsumeDelegate> delegate( 3387 scoped_ptr<GestureEventConsumeDelegate> delegate(
3395 new GestureEventConsumeDelegate()); 3388 new GestureEventConsumeDelegate());
3396 const int kWindowWidth = 123; 3389 const int kWindowWidth = 123;
3397 const int kWindowHeight = 45; 3390 const int kWindowHeight = 45;
3398 const int kTouchId = 2; 3391 const int kTouchId = 2;
3399 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3392 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
3400 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3393 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3401 delegate.get(), -1234, bounds, root_window())); 3394 delegate.get(), -1234, bounds, root_window()));
3402 TimedEvents tes; 3395 TimedEvents tes;
3403 3396
3404 // First tap (tested in GestureEventTap) 3397 // First tap (tested in GestureEventTap)
3405 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 3398 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
3406 kTouchId, tes.Now()); 3399 kTouchId, tes.Now());
3407 DispatchEventUsingWindowDispatcher(&press1); 3400 DispatchEventUsingWindowDispatcher(&press1);
3408 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 3401 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
3409 kTouchId, tes.LeapForward(50)); 3402 kTouchId, tes.LeapForward(50));
3410 DispatchEventUsingWindowDispatcher(&release1); 3403 DispatchEventUsingWindowDispatcher(&release1);
3411 delegate->Reset(); 3404 delegate->Reset();
3412 3405
3413 // Second tap, close in distance but after some delay 3406 // Second tap, close in distance but after some delay
3414 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 3407 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
3415 kTouchId, tes.LeapForward(2000)); 3408 kTouchId, tes.LeapForward(2000));
3416 DispatchEventUsingWindowDispatcher(&press2); 3409 DispatchEventUsingWindowDispatcher(&press2);
3417 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 3410 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
3418 kTouchId, tes.LeapForward(50)); 3411 kTouchId, tes.LeapForward(50));
3419 DispatchEventUsingWindowDispatcher(&release2); 3412 DispatchEventUsingWindowDispatcher(&release2);
3420 3413
3421 EXPECT_TRUE(delegate->tap()); 3414 EXPECT_TRUE(delegate->tap());
3422 EXPECT_TRUE(delegate->tap_down()); 3415 EXPECT_TRUE(delegate->tap_down());
3423 EXPECT_FALSE(delegate->tap_cancel()); 3416 EXPECT_FALSE(delegate->tap_cancel());
3424 EXPECT_TRUE(delegate->begin()); 3417 EXPECT_TRUE(delegate->begin());
3425 EXPECT_TRUE(delegate->end()); 3418 EXPECT_TRUE(delegate->end());
3426 EXPECT_FALSE(delegate->scroll_begin()); 3419 EXPECT_FALSE(delegate->scroll_begin());
3427 EXPECT_FALSE(delegate->scroll_update()); 3420 EXPECT_FALSE(delegate->scroll_update());
3428 EXPECT_FALSE(delegate->scroll_end()); 3421 EXPECT_FALSE(delegate->scroll_end());
3429 3422
3430 EXPECT_EQ(1, delegate->tap_count()); 3423 EXPECT_EQ(1, delegate->tap_count());
3431 } 3424 }
3432 3425
3433 // Checks that if the bounding-box of a gesture changes because of change in 3426 // Checks that if the bounding-box of a gesture changes because of change in
3434 // radius of a touch-point, and not because of change in position, then there 3427 // radius of a touch-point, and not because of change in position, then there
3435 // are not gesture events from that. 3428 // are not gesture events from that.
3436 TEST_F(GestureRecognizerTest, BoundingBoxRadiusChange) { 3429 TEST_F(GestureRecognizerTest, BoundingBoxRadiusChange) {
3437 scoped_ptr<GestureEventConsumeDelegate> delegate( 3430 scoped_ptr<GestureEventConsumeDelegate> delegate(
3438 new GestureEventConsumeDelegate()); 3431 new GestureEventConsumeDelegate());
3439 const int kWindowWidth = 234; 3432 const int kWindowWidth = 234;
3440 const int kWindowHeight = 345; 3433 const int kWindowHeight = 345;
3441 const int kTouchId = 5, kTouchId2 = 7; 3434 const int kTouchId = 5, kTouchId2 = 7;
3442 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3435 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
3443 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3436 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3444 delegate.get(), -1234, bounds, root_window())); 3437 delegate.get(), -1234, bounds, root_window()));
3445 TimedEvents tes; 3438 TimedEvents tes;
3446 3439
3447 ui::TouchEvent press1( 3440 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
3448 ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId, tes.Now()); 3441 kTouchId, tes.Now());
3449 DispatchEventUsingWindowDispatcher(&press1); 3442 DispatchEventUsingWindowDispatcher(&press1);
3450 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); 3443 EXPECT_TRUE(delegate->bounding_box().IsEmpty());
3451 3444
3452 delegate->Reset(); 3445 delegate->Reset();
3453 3446
3454 ui::TouchEvent press2( 3447 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(201.f, 201.f),
3455 ui::ET_TOUCH_PRESSED, gfx::Point(201, 201), kTouchId2, 3448 kTouchId2, tes.LeapForward(400));
3456 tes.LeapForward(400));
3457 press2.set_radius_x(5); 3449 press2.set_radius_x(5);
3458 DispatchEventUsingWindowDispatcher(&press2); 3450 DispatchEventUsingWindowDispatcher(&press2);
3459 EXPECT_FALSE(delegate->pinch_begin()); 3451 EXPECT_FALSE(delegate->pinch_begin());
3460 EXPECT_EQ(gfx::Rect(101, 196, 105, 10).ToString(), 3452 EXPECT_EQ(gfx::Rect(101, 196, 105, 10).ToString(),
3461 delegate->bounding_box().ToString()); 3453 delegate->bounding_box().ToString());
3462 3454
3463 delegate->Reset(); 3455 delegate->Reset();
3464 3456
3465 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(50, 50), kTouchId, 3457 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::PointF(50.f, 50.f), kTouchId,
3466 tes.LeapForward(40)); 3458 tes.LeapForward(40));
3467 DispatchEventUsingWindowDispatcher(&move1); 3459 DispatchEventUsingWindowDispatcher(&move1);
3468 EXPECT_TRUE(delegate->pinch_begin()); 3460 EXPECT_TRUE(delegate->pinch_begin());
3469 EXPECT_EQ(gfx::Rect(50, 50, 156, 156).ToString(), 3461 EXPECT_EQ(gfx::Rect(50, 50, 156, 156).ToString(),
3470 delegate->bounding_box().ToString()); 3462 delegate->bounding_box().ToString());
3471 3463
3472 delegate->Reset(); 3464 delegate->Reset();
3473 3465
3474 // The position doesn't move, but the radius changes. 3466 // The position doesn't move, but the radius changes.
3475 ui::TouchEvent move2( 3467 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::PointF(50.f, 50.f), kTouchId,
3476 ui::ET_TOUCH_MOVED, gfx::Point(50, 50), kTouchId, tes.LeapForward(40)); 3468 tes.LeapForward(40));
3477 move2.set_radius_x(50); 3469 move2.set_radius_x(50);
3478 move2.set_radius_y(60); 3470 move2.set_radius_y(60);
3479 DispatchEventUsingWindowDispatcher(&move2); 3471 DispatchEventUsingWindowDispatcher(&move2);
3480 EXPECT_FALSE(delegate->tap()); 3472 EXPECT_FALSE(delegate->tap());
3481 EXPECT_FALSE(delegate->tap_cancel()); 3473 EXPECT_FALSE(delegate->tap_cancel());
3482 EXPECT_FALSE(delegate->scroll_update()); 3474 EXPECT_FALSE(delegate->scroll_update());
3483 EXPECT_FALSE(delegate->pinch_update()); 3475 EXPECT_FALSE(delegate->pinch_update());
3484 3476
3485 delegate->Reset(); 3477 delegate->Reset();
3486 } 3478 }
3487 3479
3488 // Checks that slow scrolls deliver the correct deltas. 3480 // Checks that slow scrolls deliver the correct deltas.
3489 // In particular, fix for http;//crbug.com/150573. 3481 // In particular, fix for http;//crbug.com/150573.
3490 TEST_F(GestureRecognizerTest, NoDriftInScroll) { 3482 TEST_F(GestureRecognizerTest, NoDriftInScroll) {
3491 ui::GestureConfiguration::GetInstance() 3483 ui::GestureConfiguration::GetInstance()
3492 ->set_max_touch_move_in_pixels_for_click(3); 3484 ->set_max_touch_move_in_pixels_for_click(3);
3493 scoped_ptr<GestureEventConsumeDelegate> delegate( 3485 scoped_ptr<GestureEventConsumeDelegate> delegate(
3494 new GestureEventConsumeDelegate()); 3486 new GestureEventConsumeDelegate());
3495 const int kWindowWidth = 234; 3487 const int kWindowWidth = 234;
3496 const int kWindowHeight = 345; 3488 const int kWindowHeight = 345;
3497 const int kTouchId = 5; 3489 const int kTouchId = 5;
3498 TimedEvents tes; 3490 TimedEvents tes;
3499 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3491 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
3500 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3492 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3501 delegate.get(), -1234, bounds, root_window())); 3493 delegate.get(), -1234, bounds, root_window()));
3502 3494
3503 ui::TouchEvent press1( 3495 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 208.f),
3504 ui::ET_TOUCH_PRESSED, gfx::Point(101, 208), kTouchId, tes.Now()); 3496 kTouchId, tes.Now());
3505 DispatchEventUsingWindowDispatcher(&press1); 3497 DispatchEventUsingWindowDispatcher(&press1);
3506 EXPECT_TRUE(delegate->begin()); 3498 EXPECT_TRUE(delegate->begin());
3507 3499
3508 delegate->Reset(); 3500 delegate->Reset();
3509 3501
3510 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(101, 206), kTouchId, 3502 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::PointF(101.f, 206.f), kTouchId,
3511 tes.LeapForward(40)); 3503 tes.LeapForward(40));
3512 DispatchEventUsingWindowDispatcher(&move1); 3504 DispatchEventUsingWindowDispatcher(&move1);
3513 EXPECT_FALSE(delegate->scroll_begin()); 3505 EXPECT_FALSE(delegate->scroll_begin());
3514 3506
3515 delegate->Reset(); 3507 delegate->Reset();
3516 3508
3517 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(101, 204), kTouchId, 3509 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::PointF(101.f, 204.f), kTouchId,
3518 tes.LeapForward(40)); 3510 tes.LeapForward(40));
3519 DispatchEventUsingWindowDispatcher(&move2); 3511 DispatchEventUsingWindowDispatcher(&move2);
3520 EXPECT_TRUE(delegate->tap_cancel()); 3512 EXPECT_TRUE(delegate->tap_cancel());
3521 EXPECT_TRUE(delegate->scroll_begin()); 3513 EXPECT_TRUE(delegate->scroll_begin());
3522 EXPECT_TRUE(delegate->scroll_update()); 3514 EXPECT_TRUE(delegate->scroll_update());
3523 // 3 px consumed by touch slop region. 3515 // 3 px consumed by touch slop region.
3524 EXPECT_EQ(-1, delegate->scroll_y()); 3516 EXPECT_EQ(-1, delegate->scroll_y());
3525 EXPECT_EQ(-4, delegate->scroll_y_hint()); 3517 EXPECT_EQ(-4, delegate->scroll_y_hint());
3526 3518
3527 delegate->Reset(); 3519 delegate->Reset();
3528 3520
3529 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(101, 204), kTouchId, 3521 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::PointF(101.f, 204.f), kTouchId,
3530 tes.LeapForward(40)); 3522 tes.LeapForward(40));
3531 DispatchEventUsingWindowDispatcher(&move3); 3523 DispatchEventUsingWindowDispatcher(&move3);
3532 EXPECT_FALSE(delegate->scroll_update()); 3524 EXPECT_FALSE(delegate->scroll_update());
3533 3525
3534 delegate->Reset(); 3526 delegate->Reset();
3535 3527
3536 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(101, 203), kTouchId, 3528 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::PointF(101.f, 203.f), kTouchId,
3537 tes.LeapForward(40)); 3529 tes.LeapForward(40));
3538 DispatchEventUsingWindowDispatcher(&move4); 3530 DispatchEventUsingWindowDispatcher(&move4);
3539 EXPECT_TRUE(delegate->scroll_update()); 3531 EXPECT_TRUE(delegate->scroll_update());
3540 EXPECT_EQ(-1, delegate->scroll_y()); 3532 EXPECT_EQ(-1, delegate->scroll_y());
3541 3533
3542 delegate->Reset(); 3534 delegate->Reset();
3543 } 3535 }
3544 3536
3545 // Ensure that move events which are preventDefaulted will cause a tap 3537 // Ensure that move events which are preventDefaulted will cause a tap
3546 // cancel gesture event to be fired if the move would normally cause a 3538 // cancel gesture event to be fired if the move would normally cause a
3547 // scroll. See bug http://crbug.com/146397. 3539 // scroll. See bug http://crbug.com/146397.
3548 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveCanFireTapCancel) { 3540 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveCanFireTapCancel) {
3549 scoped_ptr<ConsumesTouchMovesDelegate> delegate( 3541 scoped_ptr<ConsumesTouchMovesDelegate> delegate(
3550 new ConsumesTouchMovesDelegate()); 3542 new ConsumesTouchMovesDelegate());
3551 const int kTouchId = 5; 3543 const int kTouchId = 5;
3552 gfx::Rect bounds(100, 200, 123, 45); 3544 gfx::Rect bounds(100, 200, 123, 45);
3553 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3545 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3554 delegate.get(), -1234, bounds, root_window())); 3546 delegate.get(), -1234, bounds, root_window()));
3555 TimedEvents tes; 3547 TimedEvents tes;
3556 3548
3557 delegate->Reset(); 3549 delegate->Reset();
3558 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 3550 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
3559 kTouchId, tes.Now()); 3551 kTouchId, tes.Now());
3560 3552
3561 delegate->set_consume_touch_move(false); 3553 delegate->set_consume_touch_move(false);
3562 DispatchEventUsingWindowDispatcher(&press); 3554 DispatchEventUsingWindowDispatcher(&press);
3563 delegate->set_consume_touch_move(true); 3555 delegate->set_consume_touch_move(true);
3564 delegate->Reset(); 3556 delegate->Reset();
3565 // Move the touch-point enough so that it would normally be considered a 3557 // Move the touch-point enough so that it would normally be considered a
3566 // scroll. But since the touch-moves will be consumed, no scrolling should 3558 // scroll. But since the touch-moves will be consumed, no scrolling should
3567 // occur. 3559 // occur.
3568 // With the unified gesture detector, we will receive a scroll begin gesture, 3560 // With the unified gesture detector, we will receive a scroll begin gesture,
(...skipping 17 matching lines...) Expand all
3586 const int kTouchId2 = 2; 3578 const int kTouchId2 = 2;
3587 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); 3579 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight);
3588 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3580 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3589 delegate.get(), -1234, bounds, root_window())); 3581 delegate.get(), -1234, bounds, root_window()));
3590 scoped_ptr<TestEventHandler> handler(new TestEventHandler()); 3582 scoped_ptr<TestEventHandler> handler(new TestEventHandler());
3591 window->AddPreTargetHandler(handler.get()); 3583 window->AddPreTargetHandler(handler.get());
3592 3584
3593 // Start a gesture sequence on |window|. Then cancel all touches. 3585 // Start a gesture sequence on |window|. Then cancel all touches.
3594 // Make sure |window| receives a touch-cancel event. 3586 // Make sure |window| receives a touch-cancel event.
3595 delegate->Reset(); 3587 delegate->Reset();
3596 ui::TouchEvent press( 3588 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
3597 ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId1, tes.Now()); 3589 kTouchId1, tes.Now());
3598 DispatchEventUsingWindowDispatcher(&press); 3590 DispatchEventUsingWindowDispatcher(&press);
3599 EXPECT_2_EVENTS( 3591 EXPECT_2_EVENTS(
3600 delegate->events(), ui::ET_GESTURE_BEGIN, ui::ET_GESTURE_TAP_DOWN); 3592 delegate->events(), ui::ET_GESTURE_BEGIN, ui::ET_GESTURE_TAP_DOWN);
3601 delegate->Reset(); 3593 delegate->Reset();
3602 ui::TouchEvent p2( 3594 ui::TouchEvent p2(ui::ET_TOUCH_PRESSED, gfx::PointF(50.f, 50.f), kTouchId2,
3603 ui::ET_TOUCH_PRESSED, gfx::Point(50, 50), kTouchId2, tes.Now()); 3595 tes.Now());
3604 DispatchEventUsingWindowDispatcher(&p2); 3596 DispatchEventUsingWindowDispatcher(&p2);
3605 EXPECT_2_EVENTS( 3597 EXPECT_2_EVENTS(
3606 delegate->events(), ui::ET_GESTURE_TAP_CANCEL, ui::ET_GESTURE_BEGIN); 3598 delegate->events(), ui::ET_GESTURE_TAP_CANCEL, ui::ET_GESTURE_BEGIN);
3607 delegate->Reset(); 3599 delegate->Reset();
3608 ui::TouchEvent move( 3600 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(350.f, 300.f), kTouchId2,
3609 ui::ET_TOUCH_MOVED, gfx::Point(350, 300), kTouchId2, tes.Now()); 3601 tes.Now());
3610 DispatchEventUsingWindowDispatcher(&move); 3602 DispatchEventUsingWindowDispatcher(&move);
3611 EXPECT_3_EVENTS(delegate->events(), 3603 EXPECT_3_EVENTS(delegate->events(),
3612 ui::ET_GESTURE_SCROLL_BEGIN, 3604 ui::ET_GESTURE_SCROLL_BEGIN,
3613 ui::ET_GESTURE_SCROLL_UPDATE, 3605 ui::ET_GESTURE_SCROLL_UPDATE,
3614 ui::ET_GESTURE_PINCH_BEGIN); 3606 ui::ET_GESTURE_PINCH_BEGIN);
3615 EXPECT_EQ(2, handler->touch_pressed_count()); 3607 EXPECT_EQ(2, handler->touch_pressed_count());
3616 delegate->Reset(); 3608 delegate->Reset();
3617 handler->Reset(); 3609 handler->Reset();
3618 3610
3619 ui::GestureRecognizer* gesture_recognizer = ui::GestureRecognizer::Get(); 3611 ui::GestureRecognizer* gesture_recognizer = ui::GestureRecognizer::Get();
3620 EXPECT_EQ(window.get(), 3612 EXPECT_EQ(window.get(),
3621 gesture_recognizer->GetTouchLockedTarget(press)); 3613 gesture_recognizer->GetTouchLockedTarget(press));
3622 3614
3623 ui::GestureRecognizer::Get()->CancelActiveTouchesExcept(nullptr); 3615 ui::GestureRecognizer::Get()->CancelActiveTouchesExcept(nullptr);
3624 3616
3625 EXPECT_EQ(NULL, gesture_recognizer->GetTouchLockedTarget(press)); 3617 EXPECT_EQ(NULL, gesture_recognizer->GetTouchLockedTarget(press));
3626 EXPECT_4_EVENTS(delegate->events(), 3618 EXPECT_4_EVENTS(delegate->events(),
3627 ui::ET_GESTURE_PINCH_END, 3619 ui::ET_GESTURE_PINCH_END,
3628 ui::ET_GESTURE_SCROLL_END, 3620 ui::ET_GESTURE_SCROLL_END,
3629 ui::ET_GESTURE_END, 3621 ui::ET_GESTURE_END,
3630 ui::ET_GESTURE_END); 3622 ui::ET_GESTURE_END);
3631 const std::vector<gfx::PointF>& points = handler->cancelled_touch_points(); 3623 const std::vector<gfx::PointF>& points = handler->cancelled_touch_points();
3632 EXPECT_EQ(2U, points.size()); 3624 EXPECT_EQ(2U, points.size());
3633 EXPECT_EQ(gfx::Point(101, 201), points[0]); 3625 EXPECT_EQ(gfx::PointF(101.f, 201.f), points[0]);
3634 EXPECT_EQ(gfx::Point(350, 300), points[1]); 3626 EXPECT_EQ(gfx::PointF(350.f, 300.f), points[1]);
3635 } 3627 }
3636 3628
3637 // Check that appropriate touch events generate show press events 3629 // Check that appropriate touch events generate show press events
3638 TEST_F(GestureRecognizerTest, GestureEventShowPress) { 3630 TEST_F(GestureRecognizerTest, GestureEventShowPress) {
3639 scoped_ptr<GestureEventConsumeDelegate> delegate( 3631 scoped_ptr<GestureEventConsumeDelegate> delegate(
3640 new GestureEventConsumeDelegate()); 3632 new GestureEventConsumeDelegate());
3641 TimedEvents tes; 3633 TimedEvents tes;
3642 const int kWindowWidth = 123; 3634 const int kWindowWidth = 123;
3643 const int kWindowHeight = 45; 3635 const int kWindowHeight = 45;
3644 const int kTouchId = 2; 3636 const int kTouchId = 2;
3645 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3637 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
3646 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3638 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3647 delegate.get(), -1234, bounds, root_window())); 3639 delegate.get(), -1234, bounds, root_window()));
3648 3640
3649 delegate->Reset(); 3641 delegate->Reset();
3650 3642
3651 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 3643 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
3652 kTouchId, tes.Now()); 3644 kTouchId, tes.Now());
3653 DispatchEventUsingWindowDispatcher(&press1); 3645 DispatchEventUsingWindowDispatcher(&press1);
3654 EXPECT_TRUE(delegate->tap_down()); 3646 EXPECT_TRUE(delegate->tap_down());
3655 EXPECT_TRUE(delegate->begin()); 3647 EXPECT_TRUE(delegate->begin());
3656 EXPECT_FALSE(delegate->tap_cancel()); 3648 EXPECT_FALSE(delegate->tap_cancel());
3657 3649
3658 // We haven't pressed long enough for a show press to occur 3650 // We haven't pressed long enough for a show press to occur
3659 EXPECT_FALSE(delegate->show_press()); 3651 EXPECT_FALSE(delegate->show_press());
3660 3652
3661 // Wait until the timer runs out 3653 // Wait until the timer runs out
3662 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_SHOW_PRESS); 3654 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_SHOW_PRESS);
3663 EXPECT_TRUE(delegate->show_press()); 3655 EXPECT_TRUE(delegate->show_press());
3664 EXPECT_FALSE(delegate->tap_cancel()); 3656 EXPECT_FALSE(delegate->tap_cancel());
3665 3657
3666 delegate->Reset(); 3658 delegate->Reset();
3667 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 3659 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
3668 kTouchId, tes.Now()); 3660 kTouchId, tes.Now());
3669 DispatchEventUsingWindowDispatcher(&release1); 3661 DispatchEventUsingWindowDispatcher(&release1);
3670 EXPECT_FALSE(delegate->long_press()); 3662 EXPECT_FALSE(delegate->long_press());
3671 3663
3672 // Note the tap isn't dispatched until the release 3664 // Note the tap isn't dispatched until the release
3673 EXPECT_FALSE(delegate->tap_cancel()); 3665 EXPECT_FALSE(delegate->tap_cancel());
3674 EXPECT_TRUE(delegate->tap()); 3666 EXPECT_TRUE(delegate->tap());
3675 } 3667 }
3676 3668
3677 // Check that scrolling cancels a show press 3669 // Check that scrolling cancels a show press
3678 TEST_F(GestureRecognizerTest, GestureEventShowPressCancelledByScroll) { 3670 TEST_F(GestureRecognizerTest, GestureEventShowPressCancelledByScroll) {
3679 scoped_ptr<GestureEventConsumeDelegate> delegate( 3671 scoped_ptr<GestureEventConsumeDelegate> delegate(
3680 new GestureEventConsumeDelegate()); 3672 new GestureEventConsumeDelegate());
3681 TimedEvents tes; 3673 TimedEvents tes;
3682 const int kWindowWidth = 123; 3674 const int kWindowWidth = 123;
3683 const int kWindowHeight = 45; 3675 const int kWindowHeight = 45;
3684 const int kTouchId = 6; 3676 const int kTouchId = 6;
3685 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3677 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
3686 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3678 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3687 delegate.get(), -1234, bounds, root_window())); 3679 delegate.get(), -1234, bounds, root_window()));
3688 3680
3689 delegate->Reset(); 3681 delegate->Reset();
3690 3682
3691 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 3683 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
3692 kTouchId, tes.Now()); 3684 kTouchId, tes.Now());
3693 DispatchEventUsingWindowDispatcher(&press1); 3685 DispatchEventUsingWindowDispatcher(&press1);
3694 EXPECT_TRUE(delegate->tap_down()); 3686 EXPECT_TRUE(delegate->tap_down());
3695 3687
3696 // We haven't pressed long enough for a show press to occur 3688 // We haven't pressed long enough for a show press to occur
3697 EXPECT_FALSE(delegate->show_press()); 3689 EXPECT_FALSE(delegate->show_press());
3698 EXPECT_FALSE(delegate->tap_cancel()); 3690 EXPECT_FALSE(delegate->tap_cancel());
3699 3691
3700 // Scroll around, to cancel the show press 3692 // Scroll around, to cancel the show press
3701 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId, delegate.get()); 3693 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId, delegate.get());
3702 // Wait until the timer runs out 3694 // Wait until the timer runs out
3703 DelayByShowPressTimeout(); 3695 DelayByShowPressTimeout();
3704 EXPECT_FALSE(delegate->show_press()); 3696 EXPECT_FALSE(delegate->show_press());
3705 EXPECT_TRUE(delegate->tap_cancel()); 3697 EXPECT_TRUE(delegate->tap_cancel());
3706 3698
3707 delegate->Reset(); 3699 delegate->Reset();
3708 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 3700 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
3709 kTouchId, tes.LeapForward(10)); 3701 kTouchId, tes.LeapForward(10));
3710 DispatchEventUsingWindowDispatcher(&release1); 3702 DispatchEventUsingWindowDispatcher(&release1);
3711 EXPECT_FALSE(delegate->show_press()); 3703 EXPECT_FALSE(delegate->show_press());
3712 EXPECT_FALSE(delegate->tap_cancel()); 3704 EXPECT_FALSE(delegate->tap_cancel());
3713 } 3705 }
3714 3706
3715 // Test that show press events are sent immediately on tap 3707 // Test that show press events are sent immediately on tap
3716 TEST_F(GestureRecognizerTest, GestureEventShowPressSentOnTap) { 3708 TEST_F(GestureRecognizerTest, GestureEventShowPressSentOnTap) {
3717 scoped_ptr<GestureEventConsumeDelegate> delegate( 3709 scoped_ptr<GestureEventConsumeDelegate> delegate(
3718 new GestureEventConsumeDelegate()); 3710 new GestureEventConsumeDelegate());
3719 TimedEvents tes; 3711 TimedEvents tes;
3720 const int kWindowWidth = 123; 3712 const int kWindowWidth = 123;
3721 const int kWindowHeight = 45; 3713 const int kWindowHeight = 45;
3722 const int kTouchId = 6; 3714 const int kTouchId = 6;
3723 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3715 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
3724 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3716 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3725 delegate.get(), -1234, bounds, root_window())); 3717 delegate.get(), -1234, bounds, root_window()));
3726 3718
3727 delegate->Reset(); 3719 delegate->Reset();
3728 3720
3729 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 3721 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
3730 kTouchId, tes.Now()); 3722 kTouchId, tes.Now());
3731 DispatchEventUsingWindowDispatcher(&press1); 3723 DispatchEventUsingWindowDispatcher(&press1);
3732 EXPECT_TRUE(delegate->tap_down()); 3724 EXPECT_TRUE(delegate->tap_down());
3733 3725
3734 // We haven't pressed long enough for a show press to occur 3726 // We haven't pressed long enough for a show press to occur
3735 EXPECT_FALSE(delegate->show_press()); 3727 EXPECT_FALSE(delegate->show_press());
3736 EXPECT_FALSE(delegate->tap_cancel()); 3728 EXPECT_FALSE(delegate->tap_cancel());
3737 3729
3738 delegate->Reset(); 3730 delegate->Reset();
3739 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 3731 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
3740 kTouchId, tes.LeapForward(50)); 3732 kTouchId, tes.LeapForward(50));
3741 DispatchEventUsingWindowDispatcher(&release1); 3733 DispatchEventUsingWindowDispatcher(&release1);
3742 EXPECT_TRUE(delegate->show_press()); 3734 EXPECT_TRUE(delegate->show_press());
3743 EXPECT_FALSE(delegate->tap_cancel()); 3735 EXPECT_FALSE(delegate->tap_cancel());
3744 EXPECT_TRUE(delegate->tap()); 3736 EXPECT_TRUE(delegate->tap());
3745 } 3737 }
3746 3738
3747 // Test that consuming the first move touch event prevents a scroll. 3739 // Test that consuming the first move touch event prevents a scroll.
3748 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveScrollTest) { 3740 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveScrollTest) {
3749 scoped_ptr<QueueTouchEventDelegate> delegate( 3741 scoped_ptr<QueueTouchEventDelegate> delegate(
3750 new QueueTouchEventDelegate(host()->dispatcher())); 3742 new QueueTouchEventDelegate(host()->dispatcher()));
3751 TimedEvents tes; 3743 TimedEvents tes;
3752 const int kTouchId = 7; 3744 const int kTouchId = 7;
3753 gfx::Rect bounds(0, 0, 1000, 1000); 3745 gfx::Rect bounds(0, 0, 1000, 1000);
3754 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3746 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3755 delegate.get(), -1234, bounds, root_window())); 3747 delegate.get(), -1234, bounds, root_window()));
3756 delegate->set_window(window.get()); 3748 delegate->set_window(window.get());
3757 3749
3758 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 3750 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(0.f, 0.f), kTouchId,
3759 kTouchId, tes.Now()); 3751 tes.Now());
3760 DispatchEventUsingWindowDispatcher(&press); 3752 DispatchEventUsingWindowDispatcher(&press);
3761 delegate->ReceivedAck(); 3753 delegate->ReceivedAck();
3762 3754
3763 // A touch move within the slop region is never consumed in web contents. The 3755 // A touch move within the slop region is never consumed in web contents. The
3764 // unified GR won't prevent scroll if a touch move within the slop region is 3756 // unified GR won't prevent scroll if a touch move within the slop region is
3765 // consumed, so make sure this touch move exceeds the slop region. 3757 // consumed, so make sure this touch move exceeds the slop region.
3766 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(10, 10), 3758 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::PointF(10.f, 10.f), kTouchId,
3767 kTouchId, tes.Now()); 3759 tes.Now());
3768 DispatchEventUsingWindowDispatcher(&move1); 3760 DispatchEventUsingWindowDispatcher(&move1);
3769 delegate->ReceivedAckPreventDefaulted(); 3761 delegate->ReceivedAckPreventDefaulted();
3770 3762
3771 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 3763 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::PointF(20.f, 20.f), kTouchId,
3772 kTouchId, tes.Now()); 3764 tes.Now());
3773 DispatchEventUsingWindowDispatcher(&move2); 3765 DispatchEventUsingWindowDispatcher(&move2);
3774 delegate->ReceivedAck(); 3766 delegate->ReceivedAck();
3775 3767
3776 // With the unified gesture detector, consuming the first touch move event 3768 // With the unified gesture detector, consuming the first touch move event
3777 // won't prevent all future scrolling. 3769 // won't prevent all future scrolling.
3778 EXPECT_TRUE(delegate->scroll_begin()); 3770 EXPECT_TRUE(delegate->scroll_begin());
3779 EXPECT_TRUE(delegate->scroll_update()); 3771 EXPECT_TRUE(delegate->scroll_update());
3780 } 3772 }
3781 3773
3782 // Test that consuming the first move touch doesn't prevent a tap. 3774 // Test that consuming the first move touch doesn't prevent a tap.
3783 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveTapTest) { 3775 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveTapTest) {
3784 scoped_ptr<QueueTouchEventDelegate> delegate( 3776 scoped_ptr<QueueTouchEventDelegate> delegate(
3785 new QueueTouchEventDelegate(host()->dispatcher())); 3777 new QueueTouchEventDelegate(host()->dispatcher()));
3786 TimedEvents tes; 3778 TimedEvents tes;
3787 const int kTouchId = 7; 3779 const int kTouchId = 7;
3788 gfx::Rect bounds(0, 0, 1000, 1000); 3780 gfx::Rect bounds(0, 0, 1000, 1000);
3789 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3781 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3790 delegate.get(), -1234, bounds, root_window())); 3782 delegate.get(), -1234, bounds, root_window()));
3791 delegate->set_window(window.get()); 3783 delegate->set_window(window.get());
3792 3784
3793 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 3785 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(0.f, 0.f), kTouchId,
3794 kTouchId, tes.Now()); 3786 tes.Now());
3795 DispatchEventUsingWindowDispatcher(&press); 3787 DispatchEventUsingWindowDispatcher(&press);
3796 delegate->ReceivedAck(); 3788 delegate->ReceivedAck();
3797 3789
3798 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(2, 2), 3790 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(2.f, 2.f), kTouchId,
3799 kTouchId, tes.Now()); 3791 tes.Now());
3800 DispatchEventUsingWindowDispatcher(&move); 3792 DispatchEventUsingWindowDispatcher(&move);
3801 delegate->ReceivedAckPreventDefaulted(); 3793 delegate->ReceivedAckPreventDefaulted();
3802 3794
3803 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(2, 2), 3795 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(2.f, 2.f), kTouchId,
3804 kTouchId, tes.LeapForward(50)); 3796 tes.LeapForward(50));
3805 DispatchEventUsingWindowDispatcher(&release); 3797 DispatchEventUsingWindowDispatcher(&release);
3806 delegate->ReceivedAck(); 3798 delegate->ReceivedAck();
3807 3799
3808 EXPECT_TRUE(delegate->tap()); 3800 EXPECT_TRUE(delegate->tap());
3809 } 3801 }
3810 3802
3811 // Test that consuming the first move touch doesn't prevent a long press. 3803 // Test that consuming the first move touch doesn't prevent a long press.
3812 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveLongPressTest) { 3804 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveLongPressTest) {
3813 scoped_ptr<QueueTouchEventDelegate> delegate( 3805 scoped_ptr<QueueTouchEventDelegate> delegate(
3814 new QueueTouchEventDelegate(host()->dispatcher())); 3806 new QueueTouchEventDelegate(host()->dispatcher()));
3815 TimedEvents tes; 3807 TimedEvents tes;
3816 const int kWindowWidth = 123; 3808 const int kWindowWidth = 123;
3817 const int kWindowHeight = 45; 3809 const int kWindowHeight = 45;
3818 const int kTouchId = 2; 3810 const int kTouchId = 2;
3819 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3811 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
3820 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3812 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3821 delegate.get(), -1234, bounds, root_window())); 3813 delegate.get(), -1234, bounds, root_window()));
3822 delegate->set_window(window.get()); 3814 delegate->set_window(window.get());
3823 3815
3824 delegate->Reset(); 3816 delegate->Reset();
3825 3817
3826 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 3818 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
3827 kTouchId, tes.Now()); 3819 kTouchId, tes.Now());
3828 DispatchEventUsingWindowDispatcher(&press1); 3820 DispatchEventUsingWindowDispatcher(&press1);
3829 delegate->ReceivedAck(); 3821 delegate->ReceivedAck();
3830 3822
3831 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(103, 203), 3823 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(103.f, 203.f), kTouchId,
3832 kTouchId, tes.Now()); 3824 tes.Now());
3833 DispatchEventUsingWindowDispatcher(&move); 3825 DispatchEventUsingWindowDispatcher(&move);
3834 delegate->ReceivedAckPreventDefaulted(); 3826 delegate->ReceivedAckPreventDefaulted();
3835 3827
3836 // Wait until the timer runs out 3828 // Wait until the timer runs out
3837 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS); 3829 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS);
3838 EXPECT_TRUE(delegate->long_press()); 3830 EXPECT_TRUE(delegate->long_press());
3839 } 3831 }
3840 3832
3841 // Tests that the deltas are correct when leaving the slop region very slowly. 3833 // Tests that the deltas are correct when leaving the slop region very slowly.
3842 TEST_F(GestureRecognizerTest, TestExceedingSlopSlowly) { 3834 TEST_F(GestureRecognizerTest, TestExceedingSlopSlowly) {
3843 ui::GestureConfiguration::GetInstance() 3835 ui::GestureConfiguration::GetInstance()
3844 ->set_max_touch_move_in_pixels_for_click(3); 3836 ->set_max_touch_move_in_pixels_for_click(3);
3845 scoped_ptr<GestureEventConsumeDelegate> delegate( 3837 scoped_ptr<GestureEventConsumeDelegate> delegate(
3846 new GestureEventConsumeDelegate()); 3838 new GestureEventConsumeDelegate());
3847 const int kWindowWidth = 234; 3839 const int kWindowWidth = 234;
3848 const int kWindowHeight = 345; 3840 const int kWindowHeight = 345;
3849 const int kTouchId = 5; 3841 const int kTouchId = 5;
3850 TimedEvents tes; 3842 TimedEvents tes;
3851 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); 3843 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight);
3852 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3844 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3853 delegate.get(), -1234, bounds, root_window())); 3845 delegate.get(), -1234, bounds, root_window()));
3854 3846
3855 ui::TouchEvent press( 3847 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(10.f, 10.f), kTouchId,
3856 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), kTouchId, tes.Now()); 3848 tes.Now());
3857 DispatchEventUsingWindowDispatcher(&press); 3849 DispatchEventUsingWindowDispatcher(&press);
3858 EXPECT_FALSE(delegate->scroll_begin()); 3850 EXPECT_FALSE(delegate->scroll_begin());
3859 EXPECT_FALSE(delegate->scroll_update()); 3851 EXPECT_FALSE(delegate->scroll_update());
3860 delegate->Reset(); 3852 delegate->Reset();
3861 3853
3862 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(11, 10), kTouchId, 3854 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::PointF(11.f, 10.f), kTouchId,
3863 tes.LeapForward(40)); 3855 tes.LeapForward(40));
3864 DispatchEventUsingWindowDispatcher(&move1); 3856 DispatchEventUsingWindowDispatcher(&move1);
3865 EXPECT_FALSE(delegate->scroll_begin()); 3857 EXPECT_FALSE(delegate->scroll_begin());
3866 EXPECT_FALSE(delegate->scroll_update()); 3858 EXPECT_FALSE(delegate->scroll_update());
3867 EXPECT_EQ(0, delegate->scroll_x()); 3859 EXPECT_EQ(0, delegate->scroll_x());
3868 EXPECT_EQ(0, delegate->scroll_x_hint()); 3860 EXPECT_EQ(0, delegate->scroll_x_hint());
3869 delegate->Reset(); 3861 delegate->Reset();
3870 3862
3871 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(12, 10), kTouchId, 3863 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::PointF(12.f, 10.f), kTouchId,
3872 tes.LeapForward(40)); 3864 tes.LeapForward(40));
3873 DispatchEventUsingWindowDispatcher(&move2); 3865 DispatchEventUsingWindowDispatcher(&move2);
3874 EXPECT_FALSE(delegate->scroll_begin()); 3866 EXPECT_FALSE(delegate->scroll_begin());
3875 EXPECT_FALSE(delegate->scroll_update()); 3867 EXPECT_FALSE(delegate->scroll_update());
3876 EXPECT_EQ(0, delegate->scroll_x()); 3868 EXPECT_EQ(0, delegate->scroll_x());
3877 EXPECT_EQ(0, delegate->scroll_x_hint()); 3869 EXPECT_EQ(0, delegate->scroll_x_hint());
3878 delegate->Reset(); 3870 delegate->Reset();
3879 3871
3880 3872
3881 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::PointF(13.1f, 10.f), kTouchId, 3873 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::PointF(13.1f, 10.f), kTouchId,
3882 tes.LeapForward(40)); 3874 tes.LeapForward(40));
3883 DispatchEventUsingWindowDispatcher(&move3); 3875 DispatchEventUsingWindowDispatcher(&move3);
3884 EXPECT_TRUE(delegate->scroll_begin()); 3876 EXPECT_TRUE(delegate->scroll_begin());
3885 EXPECT_TRUE(delegate->scroll_update()); 3877 EXPECT_TRUE(delegate->scroll_update());
3886 EXPECT_NEAR(0.1, delegate->scroll_x(), 0.0001); 3878 EXPECT_NEAR(0.1, delegate->scroll_x(), 0.0001);
3887 EXPECT_FLOAT_EQ(3.1f, delegate->scroll_x_hint()); 3879 EXPECT_FLOAT_EQ(3.1f, delegate->scroll_x_hint());
3888 delegate->Reset(); 3880 delegate->Reset();
3889 3881
3890 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(14, 10), kTouchId, 3882 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::PointF(14.f, 10.f), kTouchId,
3891 tes.LeapForward(40)); 3883 tes.LeapForward(40));
3892 DispatchEventUsingWindowDispatcher(&move4); 3884 DispatchEventUsingWindowDispatcher(&move4);
3893 EXPECT_FALSE(delegate->scroll_begin()); 3885 EXPECT_FALSE(delegate->scroll_begin());
3894 EXPECT_TRUE(delegate->scroll_update()); 3886 EXPECT_TRUE(delegate->scroll_update());
3895 EXPECT_NEAR(0.9, delegate->scroll_x(), 0.0001); 3887 EXPECT_NEAR(0.9, delegate->scroll_x(), 0.0001);
3896 EXPECT_EQ(0.f, delegate->scroll_x_hint()); 3888 EXPECT_EQ(0.f, delegate->scroll_x_hint());
3897 delegate->Reset(); 3889 delegate->Reset();
3898 } 3890 }
3899 3891
3900 TEST_F(GestureRecognizerTest, ScrollAlternatelyConsumedTest) { 3892 TEST_F(GestureRecognizerTest, ScrollAlternatelyConsumedTest) {
3901 scoped_ptr<QueueTouchEventDelegate> delegate( 3893 scoped_ptr<QueueTouchEventDelegate> delegate(
3902 new QueueTouchEventDelegate(host()->dispatcher())); 3894 new QueueTouchEventDelegate(host()->dispatcher()));
3903 TimedEvents tes; 3895 TimedEvents tes;
3904 const int kWindowWidth = 3000; 3896 const int kWindowWidth = 3000;
3905 const int kWindowHeight = 3000; 3897 const int kWindowHeight = 3000;
3906 const int kTouchId = 2; 3898 const int kTouchId = 2;
3907 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); 3899 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight);
3908 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3900 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3909 delegate.get(), -1234, bounds, root_window())); 3901 delegate.get(), -1234, bounds, root_window()));
3910 delegate->set_window(window.get()); 3902 delegate->set_window(window.get());
3911 3903
3912 delegate->Reset(); 3904 delegate->Reset();
3913 3905
3914 int x = 0; 3906 int x = 0;
3915 int y = 0; 3907 int y = 0;
3916 3908
3917 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(x, y), 3909 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(x, y), kTouchId,
3918 kTouchId, tes.Now()); 3910 tes.Now());
3919 DispatchEventUsingWindowDispatcher(&press1); 3911 DispatchEventUsingWindowDispatcher(&press1);
3920 delegate->ReceivedAck(); 3912 delegate->ReceivedAck();
3921 EXPECT_FALSE(delegate->scroll_begin()); 3913 EXPECT_FALSE(delegate->scroll_begin());
3922 EXPECT_FALSE(delegate->scroll_update()); 3914 EXPECT_FALSE(delegate->scroll_update());
3923 delegate->Reset(); 3915 delegate->Reset();
3924 3916
3925 x += 100; 3917 x += 100;
3926 y += 100; 3918 y += 100;
3927 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(x, y), 3919 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::PointF(x, y), kTouchId,
3928 kTouchId, tes.Now()); 3920 tes.Now());
3929 DispatchEventUsingWindowDispatcher(&move1); 3921 DispatchEventUsingWindowDispatcher(&move1);
3930 delegate->ReceivedAck(); 3922 delegate->ReceivedAck();
3931 EXPECT_TRUE(delegate->scroll_begin()); 3923 EXPECT_TRUE(delegate->scroll_begin());
3932 EXPECT_TRUE(delegate->scroll_update()); 3924 EXPECT_TRUE(delegate->scroll_update());
3933 delegate->Reset(); 3925 delegate->Reset();
3934 3926
3935 for (int i = 0; i < 3; ++i) { 3927 for (int i = 0; i < 3; ++i) {
3936 x += 10; 3928 x += 10;
3937 y += 10; 3929 y += 10;
3938 ui::TouchEvent move2( 3930 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::PointF(x, y), kTouchId,
3939 ui::ET_TOUCH_MOVED, gfx::Point(x, y), kTouchId, tes.Now()); 3931 tes.Now());
3940 DispatchEventUsingWindowDispatcher(&move2); 3932 DispatchEventUsingWindowDispatcher(&move2);
3941 delegate->ReceivedAck(); 3933 delegate->ReceivedAck();
3942 EXPECT_FALSE(delegate->scroll_begin()); 3934 EXPECT_FALSE(delegate->scroll_begin());
3943 EXPECT_TRUE(delegate->scroll_update()); 3935 EXPECT_TRUE(delegate->scroll_update());
3944 EXPECT_EQ(10, delegate->scroll_x()); 3936 EXPECT_EQ(10, delegate->scroll_x());
3945 EXPECT_EQ(10, delegate->scroll_y()); 3937 EXPECT_EQ(10, delegate->scroll_y());
3946 delegate->Reset(); 3938 delegate->Reset();
3947 3939
3948 x += 20; 3940 x += 20;
3949 y += 20; 3941 y += 20;
3950 ui::TouchEvent move3( 3942 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::PointF(x, y), kTouchId,
3951 ui::ET_TOUCH_MOVED, gfx::Point(x, y), kTouchId, tes.Now()); 3943 tes.Now());
3952 DispatchEventUsingWindowDispatcher(&move3); 3944 DispatchEventUsingWindowDispatcher(&move3);
3953 delegate->ReceivedAckPreventDefaulted(); 3945 delegate->ReceivedAckPreventDefaulted();
3954 EXPECT_FALSE(delegate->scroll_begin()); 3946 EXPECT_FALSE(delegate->scroll_begin());
3955 EXPECT_FALSE(delegate->scroll_update()); 3947 EXPECT_FALSE(delegate->scroll_update());
3956 delegate->Reset(); 3948 delegate->Reset();
3957 } 3949 }
3958 } 3950 }
3959 3951
3960 TEST_F(GestureRecognizerTest, PinchAlternatelyConsumedTest) { 3952 TEST_F(GestureRecognizerTest, PinchAlternatelyConsumedTest) {
3961 scoped_ptr<QueueTouchEventDelegate> delegate( 3953 scoped_ptr<QueueTouchEventDelegate> delegate(
3962 new QueueTouchEventDelegate(host()->dispatcher())); 3954 new QueueTouchEventDelegate(host()->dispatcher()));
3963 TimedEvents tes; 3955 TimedEvents tes;
3964 const int kWindowWidth = 3000; 3956 const int kWindowWidth = 3000;
3965 const int kWindowHeight = 3000; 3957 const int kWindowHeight = 3000;
3966 const int kTouchId1 = 5; 3958 const int kTouchId1 = 5;
3967 const int kTouchId2 = 7; 3959 const int kTouchId2 = 7;
3968 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); 3960 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight);
3969 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3961 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3970 delegate.get(), -1234, bounds, root_window())); 3962 delegate.get(), -1234, bounds, root_window()));
3971 delegate->set_window(window.get()); 3963 delegate->set_window(window.get());
3972 delegate->Reset(); 3964 delegate->Reset();
3973 3965
3974 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 3966 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(0.f, 0.f), kTouchId1,
3975 kTouchId1, tes.Now()); 3967 tes.Now());
3976 DispatchEventUsingWindowDispatcher(&press1); 3968 DispatchEventUsingWindowDispatcher(&press1);
3977 delegate->ReceivedAck(); 3969 delegate->ReceivedAck();
3978 EXPECT_FALSE(delegate->scroll_begin()); 3970 EXPECT_FALSE(delegate->scroll_begin());
3979 EXPECT_FALSE(delegate->scroll_update()); 3971 EXPECT_FALSE(delegate->scroll_update());
3980 delegate->Reset(); 3972 delegate->Reset();
3981 3973
3982 int x = 0; 3974 int x = 0;
3983 int y = 0; 3975 int y = 0;
3984 3976
3985 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(x, y), 3977 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(x, y), kTouchId2,
3986 kTouchId2, tes.Now()); 3978 tes.Now());
3987 DispatchEventUsingWindowDispatcher(&press2); 3979 DispatchEventUsingWindowDispatcher(&press2);
3988 delegate->ReceivedAck(); 3980 delegate->ReceivedAck();
3989 EXPECT_FALSE(delegate->scroll_begin()); 3981 EXPECT_FALSE(delegate->scroll_begin());
3990 EXPECT_FALSE(delegate->scroll_update()); 3982 EXPECT_FALSE(delegate->scroll_update());
3991 EXPECT_FALSE(delegate->pinch_begin()); 3983 EXPECT_FALSE(delegate->pinch_begin());
3992 EXPECT_FALSE(delegate->pinch_update()); 3984 EXPECT_FALSE(delegate->pinch_update());
3993 3985
3994 delegate->Reset(); 3986 delegate->Reset();
3995 3987
3996 x += 100; 3988 x += 100;
3997 y += 100; 3989 y += 100;
3998 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(x, y), 3990 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::PointF(x, y), kTouchId2,
3999 kTouchId2, tes.Now()); 3991 tes.Now());
4000 DispatchEventUsingWindowDispatcher(&move1); 3992 DispatchEventUsingWindowDispatcher(&move1);
4001 delegate->ReceivedAck(); 3993 delegate->ReceivedAck();
4002 EXPECT_TRUE(delegate->scroll_begin()); 3994 EXPECT_TRUE(delegate->scroll_begin());
4003 EXPECT_TRUE(delegate->scroll_update()); 3995 EXPECT_TRUE(delegate->scroll_update());
4004 EXPECT_TRUE(delegate->pinch_begin()); 3996 EXPECT_TRUE(delegate->pinch_begin());
4005 EXPECT_FALSE(delegate->pinch_update()); 3997 EXPECT_FALSE(delegate->pinch_update());
4006 delegate->Reset(); 3998 delegate->Reset();
4007 3999
4008 const float expected_scales[] = {1.5f, 1.2f, 1.125f}; 4000 const float expected_scales[] = {1.5f, 1.2f, 1.125f};
4009 4001
4010 for (int i = 0; i < 3; ++i) { 4002 for (int i = 0; i < 3; ++i) {
4011 x += 50; 4003 x += 50;
4012 y += 50; 4004 y += 50;
4013 ui::TouchEvent move2( 4005 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::PointF(x, y), kTouchId2,
4014 ui::ET_TOUCH_MOVED, gfx::Point(x, y), kTouchId2, tes.Now()); 4006 tes.Now());
4015 DispatchEventUsingWindowDispatcher(&move2); 4007 DispatchEventUsingWindowDispatcher(&move2);
4016 delegate->ReceivedAck(); 4008 delegate->ReceivedAck();
4017 EXPECT_FALSE(delegate->scroll_begin()); 4009 EXPECT_FALSE(delegate->scroll_begin());
4018 EXPECT_TRUE(delegate->scroll_update()); 4010 EXPECT_TRUE(delegate->scroll_update());
4019 EXPECT_FALSE(delegate->scroll_end()); 4011 EXPECT_FALSE(delegate->scroll_end());
4020 EXPECT_FALSE(delegate->pinch_begin()); 4012 EXPECT_FALSE(delegate->pinch_begin());
4021 EXPECT_TRUE(delegate->pinch_update()); 4013 EXPECT_TRUE(delegate->pinch_update());
4022 EXPECT_FALSE(delegate->pinch_end()); 4014 EXPECT_FALSE(delegate->pinch_end());
4023 EXPECT_EQ(25, delegate->scroll_x()); 4015 EXPECT_EQ(25, delegate->scroll_x());
4024 EXPECT_EQ(25, delegate->scroll_y()); 4016 EXPECT_EQ(25, delegate->scroll_y());
4025 EXPECT_FLOAT_EQ(expected_scales[i], delegate->scale()); 4017 EXPECT_FLOAT_EQ(expected_scales[i], delegate->scale());
4026 delegate->Reset(); 4018 delegate->Reset();
4027 4019
4028 x += 100; 4020 x += 100;
4029 y += 100; 4021 y += 100;
4030 ui::TouchEvent move3( 4022 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::PointF(x, y), kTouchId2,
4031 ui::ET_TOUCH_MOVED, gfx::Point(x, y), kTouchId2, tes.Now()); 4023 tes.Now());
4032 DispatchEventUsingWindowDispatcher(&move3); 4024 DispatchEventUsingWindowDispatcher(&move3);
4033 delegate->ReceivedAckPreventDefaulted(); 4025 delegate->ReceivedAckPreventDefaulted();
4034 EXPECT_FALSE(delegate->scroll_begin()); 4026 EXPECT_FALSE(delegate->scroll_begin());
4035 EXPECT_FALSE(delegate->scroll_update()); 4027 EXPECT_FALSE(delegate->scroll_update());
4036 EXPECT_FALSE(delegate->scroll_end()); 4028 EXPECT_FALSE(delegate->scroll_end());
4037 EXPECT_FALSE(delegate->pinch_begin()); 4029 EXPECT_FALSE(delegate->pinch_begin());
4038 EXPECT_FALSE(delegate->pinch_update()); 4030 EXPECT_FALSE(delegate->pinch_update());
4039 EXPECT_FALSE(delegate->pinch_end()); 4031 EXPECT_FALSE(delegate->pinch_end());
4040 delegate->Reset(); 4032 delegate->Reset();
4041 } 4033 }
4042 } 4034 }
4043 4035
4044 // Test that touch event flags are passed through to the gesture event. 4036 // Test that touch event flags are passed through to the gesture event.
4045 TEST_F(GestureRecognizerTest, GestureEventFlagsPassedFromTouchEvent) { 4037 TEST_F(GestureRecognizerTest, GestureEventFlagsPassedFromTouchEvent) {
4046 scoped_ptr<GestureEventConsumeDelegate> delegate( 4038 scoped_ptr<GestureEventConsumeDelegate> delegate(
4047 new GestureEventConsumeDelegate()); 4039 new GestureEventConsumeDelegate());
4048 TimedEvents tes; 4040 TimedEvents tes;
4049 const int kWindowWidth = 123; 4041 const int kWindowWidth = 123;
4050 const int kWindowHeight = 45; 4042 const int kWindowHeight = 45;
4051 const int kTouchId = 6; 4043 const int kTouchId = 6;
4052 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 4044 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
4053 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 4045 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
4054 delegate.get(), -1234, bounds, root_window())); 4046 delegate.get(), -1234, bounds, root_window()));
4055 4047
4056 delegate->Reset(); 4048 delegate->Reset();
4057 4049
4058 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 4050 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
4059 kTouchId, tes.Now()); 4051 kTouchId, tes.Now());
4060 DispatchEventUsingWindowDispatcher(&press1); 4052 DispatchEventUsingWindowDispatcher(&press1);
4061 EXPECT_TRUE(delegate->tap_down()); 4053 EXPECT_TRUE(delegate->tap_down());
4062 4054
4063 int default_flags = delegate->flags(); 4055 int default_flags = delegate->flags();
4064 4056
4065 ui::TouchEvent move1( 4057 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::PointF(397.f, 149.f), kTouchId,
4066 ui::ET_TOUCH_MOVED, gfx::Point(397, 149), kTouchId, tes.LeapForward(50)); 4058 tes.LeapForward(50));
4067 move1.set_flags(992); 4059 move1.set_flags(992);
4068 4060
4069 DispatchEventUsingWindowDispatcher(&move1); 4061 DispatchEventUsingWindowDispatcher(&move1);
4070 EXPECT_NE(default_flags, delegate->flags()); 4062 EXPECT_NE(default_flags, delegate->flags());
4071 } 4063 }
4072 4064
4073 // A delegate that deletes a window on long press. 4065 // A delegate that deletes a window on long press.
4074 class GestureEventDeleteWindowOnLongPress : public GestureEventConsumeDelegate { 4066 class GestureEventDeleteWindowOnLongPress : public GestureEventConsumeDelegate {
4075 public: 4067 public:
4076 GestureEventDeleteWindowOnLongPress() 4068 GestureEventDeleteWindowOnLongPress()
(...skipping 20 matching lines...) Expand all
4097 TEST_F(GestureRecognizerTest, GestureEventLongPressDeletingWindow) { 4089 TEST_F(GestureRecognizerTest, GestureEventLongPressDeletingWindow) {
4098 GestureEventDeleteWindowOnLongPress delegate; 4090 GestureEventDeleteWindowOnLongPress delegate;
4099 const int kWindowWidth = 123; 4091 const int kWindowWidth = 123;
4100 const int kWindowHeight = 45; 4092 const int kWindowHeight = 45;
4101 const int kTouchId = 2; 4093 const int kTouchId = 2;
4102 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 4094 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
4103 aura::Window* window(CreateTestWindowWithDelegate( 4095 aura::Window* window(CreateTestWindowWithDelegate(
4104 &delegate, -1234, bounds, root_window())); 4096 &delegate, -1234, bounds, root_window()));
4105 delegate.set_window(&window); 4097 delegate.set_window(&window);
4106 4098
4107 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, 4099 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
4108 gfx::Point(101, 201), 4100 kTouchId, ui::EventTimeForNow());
4109 kTouchId,
4110 ui::EventTimeForNow());
4111 DispatchEventUsingWindowDispatcher(&press1); 4101 DispatchEventUsingWindowDispatcher(&press1);
4112 EXPECT_TRUE(window != NULL); 4102 EXPECT_TRUE(window != NULL);
4113 4103
4114 // Wait until the timer runs out. 4104 // Wait until the timer runs out.
4115 delegate.WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS); 4105 delegate.WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS);
4116 EXPECT_EQ(NULL, window); 4106 EXPECT_EQ(NULL, window);
4117 } 4107 }
4118 4108
4119 TEST_F(GestureRecognizerWithSwitchTest, GestureEventSmallPinchDisabled) { 4109 TEST_F(GestureRecognizerWithSwitchTest, GestureEventSmallPinchDisabled) {
4120 scoped_ptr<GestureEventConsumeDelegate> delegate( 4110 scoped_ptr<GestureEventConsumeDelegate> delegate(
4121 new GestureEventConsumeDelegate()); 4111 new GestureEventConsumeDelegate());
4122 TimedEvents tes; 4112 TimedEvents tes;
4123 const int kWindowWidth = 300; 4113 const int kWindowWidth = 300;
4124 const int kWindowHeight = 400; 4114 const int kWindowHeight = 400;
4125 const int kTouchId1 = 3; 4115 const int kTouchId1 = 3;
4126 const int kTouchId2 = 5; 4116 const int kTouchId2 = 5;
4127 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); 4117 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight);
4128 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 4118 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
4129 delegate.get(), -1234, bounds, root_window())); 4119 delegate.get(), -1234, bounds, root_window()));
4130 4120
4131 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), 4121 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 301.f),
4132 kTouchId1, tes.Now()); 4122 kTouchId1, tes.Now());
4133 DispatchEventUsingWindowDispatcher(&press1); 4123 DispatchEventUsingWindowDispatcher(&press1);
4134 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 4124 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(10.f, 10.f),
4135 kTouchId2, tes.Now()); 4125 kTouchId2, tes.Now());
4136 DispatchEventUsingWindowDispatcher(&press2); 4126 DispatchEventUsingWindowDispatcher(&press2);
4137 4127
4138 // Move the first finger. 4128 // Move the first finger.
4139 delegate->Reset(); 4129 delegate->Reset();
4140 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(65, 201), 4130 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::PointF(65.f, 201.f), kTouchId1,
4141 kTouchId1, tes.Now()); 4131 tes.Now());
4142 DispatchEventUsingWindowDispatcher(&move1); 4132 DispatchEventUsingWindowDispatcher(&move1);
4143 4133
4144 EXPECT_3_EVENTS(delegate->events(), 4134 EXPECT_3_EVENTS(delegate->events(),
4145 ui::ET_GESTURE_SCROLL_BEGIN, 4135 ui::ET_GESTURE_SCROLL_BEGIN,
4146 ui::ET_GESTURE_SCROLL_UPDATE, 4136 ui::ET_GESTURE_SCROLL_UPDATE,
4147 ui::ET_GESTURE_PINCH_BEGIN); 4137 ui::ET_GESTURE_PINCH_BEGIN);
4148 4138
4149 // No pinch update occurs, as kCompensateForUnstablePinchZoom is on and 4139 // No pinch update occurs, as kCompensateForUnstablePinchZoom is on and
4150 // |min_pinch_update_span_delta| was nonzero, and this is a very small pinch. 4140 // |min_pinch_update_span_delta| was nonzero, and this is a very small pinch.
4151 delegate->Reset(); 4141 delegate->Reset();
4152 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(65, 202), 4142 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::PointF(65.f, 202.f), kTouchId1,
4153 kTouchId1, tes.Now()); 4143 tes.Now());
4154 DispatchEventUsingWindowDispatcher(&move2); 4144 DispatchEventUsingWindowDispatcher(&move2);
4155 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); 4145 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE);
4156 } 4146 }
4157 4147
4158 TEST_F(GestureRecognizerTest, GestureEventSmallPinchEnabled) { 4148 TEST_F(GestureRecognizerTest, GestureEventSmallPinchEnabled) {
4159 scoped_ptr<GestureEventConsumeDelegate> delegate( 4149 scoped_ptr<GestureEventConsumeDelegate> delegate(
4160 new GestureEventConsumeDelegate()); 4150 new GestureEventConsumeDelegate());
4161 TimedEvents tes; 4151 TimedEvents tes;
4162 const int kWindowWidth = 300; 4152 const int kWindowWidth = 300;
4163 const int kWindowHeight = 400; 4153 const int kWindowHeight = 400;
4164 const int kTouchId1 = 3; 4154 const int kTouchId1 = 3;
4165 const int kTouchId2 = 5; 4155 const int kTouchId2 = 5;
4166 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); 4156 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight);
4167 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 4157 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
4168 delegate.get(), -1234, bounds, root_window())); 4158 delegate.get(), -1234, bounds, root_window()));
4169 4159
4170 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), 4160 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 301.f),
4171 kTouchId1, tes.Now()); 4161 kTouchId1, tes.Now());
4172 DispatchEventUsingWindowDispatcher(&press1); 4162 DispatchEventUsingWindowDispatcher(&press1);
4173 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 4163 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(10.f, 10.f),
4174 kTouchId2, tes.Now()); 4164 kTouchId2, tes.Now());
4175 DispatchEventUsingWindowDispatcher(&press2); 4165 DispatchEventUsingWindowDispatcher(&press2);
4176 4166
4177 // Move the first finger. 4167 // Move the first finger.
4178 delegate->Reset(); 4168 delegate->Reset();
4179 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(65, 201), 4169 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::PointF(65.f, 201.f), kTouchId1,
4180 kTouchId1, tes.Now()); 4170 tes.Now());
4181 DispatchEventUsingWindowDispatcher(&move1); 4171 DispatchEventUsingWindowDispatcher(&move1);
4182 4172
4183 EXPECT_3_EVENTS(delegate->events(), 4173 EXPECT_3_EVENTS(delegate->events(),
4184 ui::ET_GESTURE_SCROLL_BEGIN, 4174 ui::ET_GESTURE_SCROLL_BEGIN,
4185 ui::ET_GESTURE_SCROLL_UPDATE, 4175 ui::ET_GESTURE_SCROLL_UPDATE,
4186 ui::ET_GESTURE_PINCH_BEGIN); 4176 ui::ET_GESTURE_PINCH_BEGIN);
4187 4177
4188 delegate->Reset(); 4178 delegate->Reset();
4189 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(65, 202), 4179 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::PointF(65.f, 202.f), kTouchId1,
4190 kTouchId1, tes.Now()); 4180 tes.Now());
4191 DispatchEventUsingWindowDispatcher(&move2); 4181 DispatchEventUsingWindowDispatcher(&move2);
4192 EXPECT_2_EVENTS(delegate->events(), 4182 EXPECT_2_EVENTS(delegate->events(),
4193 ui::ET_GESTURE_SCROLL_UPDATE, 4183 ui::ET_GESTURE_SCROLL_UPDATE,
4194 ui::ET_GESTURE_PINCH_UPDATE); 4184 ui::ET_GESTURE_PINCH_UPDATE);
4195 } 4185 }
4196 4186
4197 // Tests that delaying the ack of a touch release doesn't trigger a long press 4187 // Tests that delaying the ack of a touch release doesn't trigger a long press
4198 // gesture. 4188 // gesture.
4199 TEST_F(GestureRecognizerTest, EagerGestureDetection) { 4189 TEST_F(GestureRecognizerTest, EagerGestureDetection) {
4200 scoped_ptr<QueueTouchEventDelegate> delegate( 4190 scoped_ptr<QueueTouchEventDelegate> delegate(
4201 new QueueTouchEventDelegate(host()->dispatcher())); 4191 new QueueTouchEventDelegate(host()->dispatcher()));
4202 TimedEvents tes; 4192 TimedEvents tes;
4203 const int kTouchId = 2; 4193 const int kTouchId = 2;
4204 gfx::Rect bounds(100, 200, 100, 100); 4194 gfx::Rect bounds(100, 200, 100, 100);
4205 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 4195 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
4206 delegate.get(), -1234, bounds, root_window())); 4196 delegate.get(), -1234, bounds, root_window()));
4207 delegate->set_window(window.get()); 4197 delegate->set_window(window.get());
4208 4198
4209 delegate->Reset(); 4199 delegate->Reset();
4210 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 4200 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 201.f),
4211 kTouchId, tes.Now()); 4201 kTouchId, tes.Now());
4212 DispatchEventUsingWindowDispatcher(&press); 4202 DispatchEventUsingWindowDispatcher(&press);
4213 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 4203 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(101.f, 201.f),
4214 kTouchId, tes.LeapForward(50)); 4204 kTouchId, tes.LeapForward(50));
4215 DispatchEventUsingWindowDispatcher(&release); 4205 DispatchEventUsingWindowDispatcher(&release);
4216 4206
4217 delegate->Reset(); 4207 delegate->Reset();
4218 // Ack the touch press. 4208 // Ack the touch press.
4219 delegate->ReceivedAck(); 4209 delegate->ReceivedAck();
4220 EXPECT_TRUE(delegate->tap_down()); 4210 EXPECT_TRUE(delegate->tap_down());
4221 4211
4222 delegate->Reset(); 4212 delegate->Reset();
4223 // Wait until the long press event would fire (if we weren't eager). 4213 // Wait until the long press event would fire (if we weren't eager).
(...skipping 12 matching lines...) Expand all
4236 new QueueTouchEventDelegate(host()->dispatcher())); 4226 new QueueTouchEventDelegate(host()->dispatcher()));
4237 TimedEvents tes; 4227 TimedEvents tes;
4238 const int kWindowWidth = 300; 4228 const int kWindowWidth = 300;
4239 const int kWindowHeight = 400; 4229 const int kWindowHeight = 400;
4240 const int kTouchId1 = 3; 4230 const int kTouchId1 = 3;
4241 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); 4231 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight);
4242 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 4232 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
4243 delegate.get(), -1234, bounds, root_window())); 4233 delegate.get(), -1234, bounds, root_window()));
4244 delegate->set_window(window.get()); 4234 delegate->set_window(window.get());
4245 4235
4246 ui::TouchEvent press1( 4236 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(101.f, 301.f),
4247 ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), kTouchId1, tes.Now()); 4237 kTouchId1, tes.Now());
4248 DispatchEventUsingWindowDispatcher(&press1); 4238 DispatchEventUsingWindowDispatcher(&press1);
4249 delegate->ReceivedAck(); 4239 delegate->ReceivedAck();
4250 4240
4251 EXPECT_2_EVENTS( 4241 EXPECT_2_EVENTS(
4252 delegate->events(), ui::ET_GESTURE_BEGIN, ui::ET_GESTURE_TAP_DOWN); 4242 delegate->events(), ui::ET_GESTURE_BEGIN, ui::ET_GESTURE_TAP_DOWN);
4253 4243
4254 // Move the first finger. 4244 // Move the first finger.
4255 delegate->Reset(); 4245 delegate->Reset();
4256 ui::TouchEvent move1( 4246 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::PointF(65.f, 201.f), kTouchId1,
4257 ui::ET_TOUCH_MOVED, gfx::Point(65, 201), kTouchId1, tes.Now()); 4247 tes.Now());
4258 DispatchEventUsingWindowDispatcher(&move1); 4248 DispatchEventUsingWindowDispatcher(&move1);
4259 delegate->ReceivedAck(); 4249 delegate->ReceivedAck();
4260 4250
4261 EXPECT_3_EVENTS(delegate->events(), 4251 EXPECT_3_EVENTS(delegate->events(),
4262 ui::ET_GESTURE_TAP_CANCEL, 4252 ui::ET_GESTURE_TAP_CANCEL,
4263 ui::ET_GESTURE_SCROLL_BEGIN, 4253 ui::ET_GESTURE_SCROLL_BEGIN,
4264 ui::ET_GESTURE_SCROLL_UPDATE); 4254 ui::ET_GESTURE_SCROLL_UPDATE);
4265 4255
4266 delegate->Reset(); 4256 delegate->Reset();
4267 4257
4268 // Send a valid event, but don't ack it. 4258 // Send a valid event, but don't ack it.
4269 ui::TouchEvent move2( 4259 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::PointF(65.f, 202.f), kTouchId1,
4270 ui::ET_TOUCH_MOVED, gfx::Point(65, 202), kTouchId1, tes.Now()); 4260 tes.Now());
4271 DispatchEventUsingWindowDispatcher(&move2); 4261 DispatchEventUsingWindowDispatcher(&move2);
4272 EXPECT_0_EVENTS(delegate->events()); 4262 EXPECT_0_EVENTS(delegate->events());
4273 4263
4274 // Send a touchmove event at the same location as the previous touchmove 4264 // Send a touchmove event at the same location as the previous touchmove
4275 // event. This shouldn't do anything. 4265 // event. This shouldn't do anything.
4276 ui::TouchEvent move3( 4266 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::PointF(65.f, 202.f), kTouchId1,
4277 ui::ET_TOUCH_MOVED, gfx::Point(65, 202), kTouchId1, tes.Now()); 4267 tes.Now());
4278 DispatchEventUsingWindowDispatcher(&move3); 4268 DispatchEventUsingWindowDispatcher(&move3);
4279 4269
4280 // Ack the previous valid event. The intermediary invalid event shouldn't 4270 // Ack the previous valid event. The intermediary invalid event shouldn't
4281 // interfere. 4271 // interfere.
4282 delegate->ReceivedAck(); 4272 delegate->ReceivedAck();
4283 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); 4273 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE);
4284 } 4274 }
4285 4275
4286 // Tests that an event stream can have a mix of sync and async acks. 4276 // Tests that an event stream can have a mix of sync and async acks.
4287 TEST_F(GestureRecognizerTest, 4277 TEST_F(GestureRecognizerTest,
4288 MixedSyncAndAsyncAcksDontCauseOutOfOrderDispatch) { 4278 MixedSyncAndAsyncAcksDontCauseOutOfOrderDispatch) {
4289 scoped_ptr<QueueTouchEventDelegate> delegate( 4279 scoped_ptr<QueueTouchEventDelegate> delegate(
4290 new QueueTouchEventDelegate(host()->dispatcher())); 4280 new QueueTouchEventDelegate(host()->dispatcher()));
4291 TimedEvents tes; 4281 TimedEvents tes;
4292 const int kWindowWidth = 300; 4282 const int kWindowWidth = 300;
4293 const int kWindowHeight = 400; 4283 const int kWindowHeight = 400;
4294 const int kTouchId1 = 3; 4284 const int kTouchId1 = 3;
4295 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); 4285 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight);
4296 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 4286 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
4297 delegate.get(), -1234, bounds, root_window())); 4287 delegate.get(), -1234, bounds, root_window()));
4298 delegate->set_window(window.get()); 4288 delegate->set_window(window.get());
4299 4289
4300 // Start a scroll gesture. 4290 // Start a scroll gesture.
4301 ui::TouchEvent press1( 4291 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(0.f, 0.f), kTouchId1,
4302 ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), kTouchId1, tes.Now()); 4292 tes.Now());
4303 DispatchEventUsingWindowDispatcher(&press1); 4293 DispatchEventUsingWindowDispatcher(&press1);
4304 delegate->ReceivedAck(); 4294 delegate->ReceivedAck();
4305 4295
4306 ui::TouchEvent move1( 4296 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::PointF(100.f, 100.f), kTouchId1,
4307 ui::ET_TOUCH_MOVED, gfx::Point(100, 100), kTouchId1, tes.Now()); 4297 tes.Now());
4308 DispatchEventUsingWindowDispatcher(&move1); 4298 DispatchEventUsingWindowDispatcher(&move1);
4309 delegate->ReceivedAck(); 4299 delegate->ReceivedAck();
4310 4300
4311 delegate->Reset(); 4301 delegate->Reset();
4312 // Dispatch a synchronously consumed touch move, which should be ignored. 4302 // Dispatch a synchronously consumed touch move, which should be ignored.
4313 delegate->set_synchronous_ack_for_next_event(true); 4303 delegate->set_synchronous_ack_for_next_event(true);
4314 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(200, 200), kTouchId1, 4304 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::PointF(200.f, 200.f), kTouchId1,
4315 tes.Now()); 4305 tes.Now());
4316 DispatchEventUsingWindowDispatcher(&move2); 4306 DispatchEventUsingWindowDispatcher(&move2);
4317 EXPECT_0_EVENTS(delegate->events()); 4307 EXPECT_0_EVENTS(delegate->events());
4318 4308
4319 // Dispatch a touch move, but don't ack it. 4309 // Dispatch a touch move, but don't ack it.
4320 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(300, 300), kTouchId1, 4310 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::PointF(300.f, 300.f), kTouchId1,
4321 tes.Now()); 4311 tes.Now());
4322 DispatchEventUsingWindowDispatcher(&move3); 4312 DispatchEventUsingWindowDispatcher(&move3);
4323 4313
4324 // Dispatch two synchronously consumed touch moves, which should be ignored. 4314 // Dispatch two synchronously consumed touch moves, which should be ignored.
4325 delegate->set_synchronous_ack_for_next_event(true); 4315 delegate->set_synchronous_ack_for_next_event(true);
4326 ui::TouchEvent move4( 4316 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::PointF(400.f, 400.f), kTouchId1,
4327 ui::ET_TOUCH_MOVED, gfx::Point(400, 400), kTouchId1, tes.Now()); 4317 tes.Now());
4328 DispatchEventUsingWindowDispatcher(&move4); 4318 DispatchEventUsingWindowDispatcher(&move4);
4329 4319
4330 delegate->set_synchronous_ack_for_next_event(true); 4320 delegate->set_synchronous_ack_for_next_event(true);
4331 ui::TouchEvent move5( 4321 ui::TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::PointF(500.f, 500.f), kTouchId1,
4332 ui::ET_TOUCH_MOVED, gfx::Point(500, 500), kTouchId1, tes.Now()); 4322 tes.Now());
4333 DispatchEventUsingWindowDispatcher(&move5); 4323 DispatchEventUsingWindowDispatcher(&move5);
4334 4324
4335 EXPECT_0_EVENTS(delegate->events()); 4325 EXPECT_0_EVENTS(delegate->events());
4336 EXPECT_EQ(100, delegate->bounding_box().x()); 4326 EXPECT_EQ(100, delegate->bounding_box().x());
4337 // Ack the pending touch move, and ensure the most recent gesture event 4327 // Ack the pending touch move, and ensure the most recent gesture event
4338 // used its co-ordinates. 4328 // used its co-ordinates.
4339 delegate->ReceivedAck(); 4329 delegate->ReceivedAck();
4340 EXPECT_EQ(300, delegate->bounding_box().x()); 4330 EXPECT_EQ(300, delegate->bounding_box().x());
4341 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); 4331 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE);
4342 4332
4343 // Dispatch a touch move, but don't ack it. 4333 // Dispatch a touch move, but don't ack it.
4344 delegate->Reset(); 4334 delegate->Reset();
4345 ui::TouchEvent move6(ui::ET_TOUCH_MOVED, gfx::Point(600, 600), kTouchId1, 4335 ui::TouchEvent move6(ui::ET_TOUCH_MOVED, gfx::PointF(600.f, 600.f), kTouchId1,
4346 tes.Now()); 4336 tes.Now());
4347 DispatchEventUsingWindowDispatcher(&move6); 4337 DispatchEventUsingWindowDispatcher(&move6);
4348 4338
4349 // Dispatch a synchronously unconsumed touch move. 4339 // Dispatch a synchronously unconsumed touch move.
4350 delegate->set_synchronous_ack_for_next_event(false); 4340 delegate->set_synchronous_ack_for_next_event(false);
4351 ui::TouchEvent move7( 4341 ui::TouchEvent move7(ui::ET_TOUCH_MOVED, gfx::PointF(700.f, 700.f), kTouchId1,
4352 ui::ET_TOUCH_MOVED, gfx::Point(700, 700), kTouchId1, tes.Now()); 4342 tes.Now());
4353 DispatchEventUsingWindowDispatcher(&move7); 4343 DispatchEventUsingWindowDispatcher(&move7);
4354 4344
4355 // The synchronous ack is stuck behind the pending touch move. 4345 // The synchronous ack is stuck behind the pending touch move.
4356 EXPECT_0_EVENTS(delegate->events()); 4346 EXPECT_0_EVENTS(delegate->events());
4357 4347
4358 delegate->ReceivedAck(); 4348 delegate->ReceivedAck();
4359 EXPECT_2_EVENTS(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE, 4349 EXPECT_2_EVENTS(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE,
4360 ui::ET_GESTURE_SCROLL_UPDATE); 4350 ui::ET_GESTURE_SCROLL_UPDATE);
4361 } 4351 }
4362 4352
4363 } // namespace test 4353 } // namespace test
4364 } // namespace aura 4354 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698