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

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

Issue 126513004: Rename RootWindowHost to WindowTreeHost (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura/env.h ('k') | ui/aura/remote_root_window_host_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/memory/scoped_vector.h" 6 #include "base/memory/scoped_vector.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/timer/timer.h" 9 #include "base/timer/timer.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 GestureEventConsumeDelegate* delegate) { 582 GestureEventConsumeDelegate* delegate) {
583 int x = x_start; 583 int x = x_start;
584 int y = y_start; 584 int y = y_start;
585 585
586 for (int i = 0; i < num_steps; i++) { 586 for (int i = 0; i < num_steps; i++) {
587 x += dx; 587 x += dx;
588 y += dy; 588 y += dy;
589 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(x, y), 589 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(x, y),
590 touch_id, 590 touch_id,
591 base::TimeDelta::FromMilliseconds(simulated_now_)); 591 base::TimeDelta::FromMilliseconds(simulated_now_));
592 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&move); 592 root_window->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move);
593 simulated_now_ += time_step; 593 simulated_now_ += time_step;
594 } 594 }
595 } 595 }
596 596
597 void SendScrollEvent(RootWindow* root_window, 597 void SendScrollEvent(RootWindow* root_window,
598 int x, 598 int x,
599 int y, 599 int y,
600 int touch_id, 600 int touch_id,
601 GestureEventConsumeDelegate* delegate) { 601 GestureEventConsumeDelegate* delegate) {
602 delegate->Reset(); 602 delegate->Reset();
603 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(x, y), 603 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(x, y),
604 touch_id, 604 touch_id,
605 base::TimeDelta::FromMilliseconds(simulated_now_)); 605 base::TimeDelta::FromMilliseconds(simulated_now_));
606 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&move); 606 root_window->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move);
607 simulated_now_++; 607 simulated_now_++;
608 } 608 }
609 }; 609 };
610 610
611 // An event handler to keep track of events. 611 // An event handler to keep track of events.
612 class TestEventHandler : public ui::EventHandler { 612 class TestEventHandler : public ui::EventHandler {
613 public: 613 public:
614 TestEventHandler() : touch_released_count_(0), touch_pressed_count_(0), 614 TestEventHandler() : touch_released_count_(0), touch_pressed_count_(0),
615 touch_moved_count_(0), touch_stationary_count_(0), 615 touch_moved_count_(0), touch_stationary_count_(0),
616 touch_cancelled_count_(0) { 616 touch_cancelled_count_(0) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 const int kWindowWidth = 123; 710 const int kWindowWidth = 123;
711 const int kWindowHeight = 45; 711 const int kWindowHeight = 45;
712 const int kTouchId = 2; 712 const int kTouchId = 2;
713 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 713 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
714 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 714 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
715 delegate.get(), -1234, bounds, root_window())); 715 delegate.get(), -1234, bounds, root_window()));
716 716
717 delegate->Reset(); 717 delegate->Reset();
718 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 718 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
719 kTouchId, tes.Now()); 719 kTouchId, tes.Now());
720 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 720 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
721 EXPECT_FALSE(delegate->tap()); 721 EXPECT_FALSE(delegate->tap());
722 EXPECT_FALSE(delegate->show_press()); 722 EXPECT_FALSE(delegate->show_press());
723 EXPECT_TRUE(delegate->tap_down()); 723 EXPECT_TRUE(delegate->tap_down());
724 EXPECT_FALSE(delegate->tap_cancel()); 724 EXPECT_FALSE(delegate->tap_cancel());
725 EXPECT_TRUE(delegate->begin()); 725 EXPECT_TRUE(delegate->begin());
726 EXPECT_FALSE(delegate->scroll_begin()); 726 EXPECT_FALSE(delegate->scroll_begin());
727 EXPECT_FALSE(delegate->scroll_update()); 727 EXPECT_FALSE(delegate->scroll_update());
728 EXPECT_FALSE(delegate->scroll_end()); 728 EXPECT_FALSE(delegate->scroll_end());
729 EXPECT_FALSE(delegate->long_press()); 729 EXPECT_FALSE(delegate->long_press());
730 730
731 delegate->Reset(); 731 delegate->Reset();
732 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_SHOW_PRESS); 732 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_SHOW_PRESS);
733 EXPECT_TRUE(delegate->show_press()); 733 EXPECT_TRUE(delegate->show_press());
734 EXPECT_FALSE(delegate->tap_down()); 734 EXPECT_FALSE(delegate->tap_down());
735 735
736 // Make sure there is enough delay before the touch is released so that it is 736 // Make sure there is enough delay before the touch is released so that it is
737 // recognized as a tap. 737 // recognized as a tap.
738 delegate->Reset(); 738 delegate->Reset();
739 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 739 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
740 kTouchId, tes.LeapForward(50)); 740 kTouchId, tes.LeapForward(50));
741 741
742 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 742 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
743 EXPECT_TRUE(delegate->tap()); 743 EXPECT_TRUE(delegate->tap());
744 EXPECT_FALSE(delegate->tap_down()); 744 EXPECT_FALSE(delegate->tap_down());
745 EXPECT_FALSE(delegate->tap_cancel()); 745 EXPECT_FALSE(delegate->tap_cancel());
746 EXPECT_FALSE(delegate->begin()); 746 EXPECT_FALSE(delegate->begin());
747 EXPECT_TRUE(delegate->end()); 747 EXPECT_TRUE(delegate->end());
748 EXPECT_FALSE(delegate->scroll_begin()); 748 EXPECT_FALSE(delegate->scroll_begin());
749 EXPECT_FALSE(delegate->scroll_update()); 749 EXPECT_FALSE(delegate->scroll_update());
750 EXPECT_FALSE(delegate->scroll_end()); 750 EXPECT_FALSE(delegate->scroll_end());
751 751
752 EXPECT_EQ(1, delegate->tap_count()); 752 EXPECT_EQ(1, delegate->tap_count());
(...skipping 12 matching lines...) Expand all
765 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 765 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
766 delegate.get(), -1234, bounds, root_window())); 766 delegate.get(), -1234, bounds, root_window()));
767 767
768 // Test with no ET_TOUCH_MOVED events. 768 // Test with no ET_TOUCH_MOVED events.
769 { 769 {
770 delegate->Reset(); 770 delegate->Reset();
771 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 771 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
772 kTouchId, tes.Now()); 772 kTouchId, tes.Now());
773 press.set_radius_x(5); 773 press.set_radius_x(5);
774 press.set_radius_y(12); 774 press.set_radius_y(12);
775 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 775 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
776 EXPECT_FALSE(delegate->tap()); 776 EXPECT_FALSE(delegate->tap());
777 EXPECT_TRUE(delegate->tap_down()); 777 EXPECT_TRUE(delegate->tap_down());
778 EXPECT_FALSE(delegate->tap_cancel()); 778 EXPECT_FALSE(delegate->tap_cancel());
779 EXPECT_TRUE(delegate->begin()); 779 EXPECT_TRUE(delegate->begin());
780 EXPECT_FALSE(delegate->scroll_begin()); 780 EXPECT_FALSE(delegate->scroll_begin());
781 EXPECT_FALSE(delegate->scroll_update()); 781 EXPECT_FALSE(delegate->scroll_update());
782 EXPECT_FALSE(delegate->scroll_end()); 782 EXPECT_FALSE(delegate->scroll_end());
783 EXPECT_FALSE(delegate->long_press()); 783 EXPECT_FALSE(delegate->long_press());
784 784
785 // Make sure there is enough delay before the touch is released so that it 785 // Make sure there is enough delay before the touch is released so that it
786 // is recognized as a tap. 786 // is recognized as a tap.
787 delegate->Reset(); 787 delegate->Reset();
788 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 788 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
789 kTouchId, tes.LeapForward(50)); 789 kTouchId, tes.LeapForward(50));
790 release.set_radius_x(5); 790 release.set_radius_x(5);
791 release.set_radius_y(12); 791 release.set_radius_y(12);
792 792
793 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 793 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
794 EXPECT_TRUE(delegate->tap()); 794 EXPECT_TRUE(delegate->tap());
795 EXPECT_FALSE(delegate->tap_down()); 795 EXPECT_FALSE(delegate->tap_down());
796 EXPECT_FALSE(delegate->tap_cancel()); 796 EXPECT_FALSE(delegate->tap_cancel());
797 EXPECT_FALSE(delegate->begin()); 797 EXPECT_FALSE(delegate->begin());
798 EXPECT_TRUE(delegate->end()); 798 EXPECT_TRUE(delegate->end());
799 EXPECT_FALSE(delegate->scroll_begin()); 799 EXPECT_FALSE(delegate->scroll_begin());
800 EXPECT_FALSE(delegate->scroll_update()); 800 EXPECT_FALSE(delegate->scroll_update());
801 EXPECT_FALSE(delegate->scroll_end()); 801 EXPECT_FALSE(delegate->scroll_end());
802 802
803 EXPECT_EQ(1, delegate->tap_count()); 803 EXPECT_EQ(1, delegate->tap_count());
804 gfx::Point actual_point(delegate->tap_location()); 804 gfx::Point actual_point(delegate->tap_location());
805 EXPECT_EQ(24, delegate->bounding_box().width()); 805 EXPECT_EQ(24, delegate->bounding_box().width());
806 EXPECT_EQ(24, delegate->bounding_box().height()); 806 EXPECT_EQ(24, delegate->bounding_box().height());
807 EXPECT_EQ(101, actual_point.x()); 807 EXPECT_EQ(101, actual_point.x());
808 EXPECT_EQ(201, actual_point.y()); 808 EXPECT_EQ(201, actual_point.y());
809 } 809 }
810 810
811 // Test with no ET_TOUCH_MOVED events but different touch points and radii. 811 // Test with no ET_TOUCH_MOVED events but different touch points and radii.
812 { 812 {
813 delegate->Reset(); 813 delegate->Reset();
814 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(365, 290), 814 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(365, 290),
815 kTouchId, tes.Now()); 815 kTouchId, tes.Now());
816 press.set_radius_x(8); 816 press.set_radius_x(8);
817 press.set_radius_y(14); 817 press.set_radius_y(14);
818 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 818 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
819 EXPECT_FALSE(delegate->tap()); 819 EXPECT_FALSE(delegate->tap());
820 EXPECT_TRUE(delegate->tap_down()); 820 EXPECT_TRUE(delegate->tap_down());
821 EXPECT_FALSE(delegate->tap_cancel()); 821 EXPECT_FALSE(delegate->tap_cancel());
822 EXPECT_TRUE(delegate->begin()); 822 EXPECT_TRUE(delegate->begin());
823 EXPECT_FALSE(delegate->scroll_begin()); 823 EXPECT_FALSE(delegate->scroll_begin());
824 EXPECT_FALSE(delegate->scroll_update()); 824 EXPECT_FALSE(delegate->scroll_update());
825 EXPECT_FALSE(delegate->scroll_end()); 825 EXPECT_FALSE(delegate->scroll_end());
826 EXPECT_FALSE(delegate->long_press()); 826 EXPECT_FALSE(delegate->long_press());
827 827
828 delegate->Reset(); 828 delegate->Reset();
829 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(367, 291), 829 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(367, 291),
830 kTouchId, tes.LeapForward(50)); 830 kTouchId, tes.LeapForward(50));
831 release.set_radius_x(20); 831 release.set_radius_x(20);
832 release.set_radius_y(13); 832 release.set_radius_y(13);
833 833
834 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 834 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
835 EXPECT_TRUE(delegate->tap()); 835 EXPECT_TRUE(delegate->tap());
836 EXPECT_FALSE(delegate->tap_down()); 836 EXPECT_FALSE(delegate->tap_down());
837 EXPECT_FALSE(delegate->tap_cancel()); 837 EXPECT_FALSE(delegate->tap_cancel());
838 EXPECT_FALSE(delegate->begin()); 838 EXPECT_FALSE(delegate->begin());
839 EXPECT_TRUE(delegate->end()); 839 EXPECT_TRUE(delegate->end());
840 EXPECT_FALSE(delegate->scroll_begin()); 840 EXPECT_FALSE(delegate->scroll_begin());
841 EXPECT_FALSE(delegate->scroll_update()); 841 EXPECT_FALSE(delegate->scroll_update());
842 EXPECT_FALSE(delegate->scroll_end()); 842 EXPECT_FALSE(delegate->scroll_end());
843 843
844 EXPECT_EQ(1, delegate->tap_count()); 844 EXPECT_EQ(1, delegate->tap_count());
845 gfx::Point actual_point(delegate->tap_location()); 845 gfx::Point actual_point(delegate->tap_location());
846 EXPECT_EQ(40, delegate->bounding_box().width()); 846 EXPECT_EQ(40, delegate->bounding_box().width());
847 EXPECT_EQ(40, delegate->bounding_box().height()); 847 EXPECT_EQ(40, delegate->bounding_box().height());
848 EXPECT_EQ(367, actual_point.x()); 848 EXPECT_EQ(367, actual_point.x());
849 EXPECT_EQ(291, actual_point.y()); 849 EXPECT_EQ(291, actual_point.y());
850 } 850 }
851 851
852 // Test with a single ET_TOUCH_MOVED event. 852 // Test with a single ET_TOUCH_MOVED event.
853 { 853 {
854 delegate->Reset(); 854 delegate->Reset();
855 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(46, 205), 855 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(46, 205),
856 kTouchId, tes.Now()); 856 kTouchId, tes.Now());
857 press.set_radius_x(6); 857 press.set_radius_x(6);
858 press.set_radius_y(10); 858 press.set_radius_y(10);
859 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 859 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
860 EXPECT_FALSE(delegate->tap()); 860 EXPECT_FALSE(delegate->tap());
861 EXPECT_TRUE(delegate->tap_down()); 861 EXPECT_TRUE(delegate->tap_down());
862 EXPECT_FALSE(delegate->tap_cancel()); 862 EXPECT_FALSE(delegate->tap_cancel());
863 EXPECT_TRUE(delegate->begin()); 863 EXPECT_TRUE(delegate->begin());
864 EXPECT_FALSE(delegate->tap_cancel()); 864 EXPECT_FALSE(delegate->tap_cancel());
865 EXPECT_FALSE(delegate->scroll_begin()); 865 EXPECT_FALSE(delegate->scroll_begin());
866 EXPECT_FALSE(delegate->scroll_update()); 866 EXPECT_FALSE(delegate->scroll_update());
867 EXPECT_FALSE(delegate->scroll_end()); 867 EXPECT_FALSE(delegate->scroll_end());
868 EXPECT_FALSE(delegate->long_press()); 868 EXPECT_FALSE(delegate->long_press());
869 869
870 delegate->Reset(); 870 delegate->Reset();
871 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(49, 204), 871 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(49, 204),
872 kTouchId, tes.LeapForward(50)); 872 kTouchId, tes.LeapForward(50));
873 move.set_radius_x(8); 873 move.set_radius_x(8);
874 move.set_radius_y(12); 874 move.set_radius_y(12);
875 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move); 875 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move);
876 EXPECT_FALSE(delegate->tap()); 876 EXPECT_FALSE(delegate->tap());
877 EXPECT_FALSE(delegate->tap_down()); 877 EXPECT_FALSE(delegate->tap_down());
878 EXPECT_FALSE(delegate->tap_cancel()); 878 EXPECT_FALSE(delegate->tap_cancel());
879 EXPECT_FALSE(delegate->begin()); 879 EXPECT_FALSE(delegate->begin());
880 EXPECT_FALSE(delegate->scroll_begin()); 880 EXPECT_FALSE(delegate->scroll_begin());
881 EXPECT_FALSE(delegate->scroll_update()); 881 EXPECT_FALSE(delegate->scroll_update());
882 EXPECT_FALSE(delegate->scroll_end()); 882 EXPECT_FALSE(delegate->scroll_end());
883 EXPECT_FALSE(delegate->long_press()); 883 EXPECT_FALSE(delegate->long_press());
884 884
885 delegate->Reset(); 885 delegate->Reset();
886 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(49, 204), 886 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(49, 204),
887 kTouchId, tes.LeapForward(50)); 887 kTouchId, tes.LeapForward(50));
888 release.set_radius_x(4); 888 release.set_radius_x(4);
889 release.set_radius_y(8); 889 release.set_radius_y(8);
890 890
891 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 891 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
892 EXPECT_TRUE(delegate->tap()); 892 EXPECT_TRUE(delegate->tap());
893 EXPECT_FALSE(delegate->tap_down()); 893 EXPECT_FALSE(delegate->tap_down());
894 EXPECT_FALSE(delegate->tap_cancel()); 894 EXPECT_FALSE(delegate->tap_cancel());
895 EXPECT_FALSE(delegate->begin()); 895 EXPECT_FALSE(delegate->begin());
896 EXPECT_TRUE(delegate->end()); 896 EXPECT_TRUE(delegate->end());
897 EXPECT_FALSE(delegate->scroll_begin()); 897 EXPECT_FALSE(delegate->scroll_begin());
898 EXPECT_FALSE(delegate->scroll_update()); 898 EXPECT_FALSE(delegate->scroll_update());
899 EXPECT_FALSE(delegate->scroll_end()); 899 EXPECT_FALSE(delegate->scroll_end());
900 900
901 EXPECT_EQ(1, delegate->tap_count()); 901 EXPECT_EQ(1, delegate->tap_count());
902 gfx::Point actual_point(delegate->tap_location()); 902 gfx::Point actual_point(delegate->tap_location());
903 EXPECT_EQ(25, delegate->bounding_box().width()); 903 EXPECT_EQ(25, delegate->bounding_box().width());
904 EXPECT_EQ(24, delegate->bounding_box().height()); 904 EXPECT_EQ(24, delegate->bounding_box().height());
905 EXPECT_EQ(48, actual_point.x()); 905 EXPECT_EQ(48, actual_point.x());
906 EXPECT_EQ(204, actual_point.y()); 906 EXPECT_EQ(204, actual_point.y());
907 } 907 }
908 908
909 // Test with a few ET_TOUCH_MOVED events. 909 // Test with a few ET_TOUCH_MOVED events.
910 { 910 {
911 delegate->Reset(); 911 delegate->Reset();
912 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(400, 150), 912 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(400, 150),
913 kTouchId, tes.Now()); 913 kTouchId, tes.Now());
914 press.set_radius_x(7); 914 press.set_radius_x(7);
915 press.set_radius_y(10); 915 press.set_radius_y(10);
916 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 916 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
917 EXPECT_FALSE(delegate->tap()); 917 EXPECT_FALSE(delegate->tap());
918 EXPECT_TRUE(delegate->tap_down()); 918 EXPECT_TRUE(delegate->tap_down());
919 EXPECT_FALSE(delegate->tap_cancel()); 919 EXPECT_FALSE(delegate->tap_cancel());
920 EXPECT_TRUE(delegate->begin()); 920 EXPECT_TRUE(delegate->begin());
921 EXPECT_FALSE(delegate->scroll_begin()); 921 EXPECT_FALSE(delegate->scroll_begin());
922 EXPECT_FALSE(delegate->scroll_update()); 922 EXPECT_FALSE(delegate->scroll_update());
923 EXPECT_FALSE(delegate->scroll_end()); 923 EXPECT_FALSE(delegate->scroll_end());
924 EXPECT_FALSE(delegate->long_press()); 924 EXPECT_FALSE(delegate->long_press());
925 925
926 delegate->Reset(); 926 delegate->Reset();
927 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(397, 151), 927 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(397, 151),
928 kTouchId, tes.LeapForward(50)); 928 kTouchId, tes.LeapForward(50));
929 move.set_radius_x(13); 929 move.set_radius_x(13);
930 move.set_radius_y(12); 930 move.set_radius_y(12);
931 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move); 931 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move);
932 EXPECT_FALSE(delegate->tap()); 932 EXPECT_FALSE(delegate->tap());
933 EXPECT_FALSE(delegate->tap_down()); 933 EXPECT_FALSE(delegate->tap_down());
934 EXPECT_FALSE(delegate->tap_cancel()); 934 EXPECT_FALSE(delegate->tap_cancel());
935 EXPECT_FALSE(delegate->begin()); 935 EXPECT_FALSE(delegate->begin());
936 EXPECT_FALSE(delegate->scroll_begin()); 936 EXPECT_FALSE(delegate->scroll_begin());
937 EXPECT_FALSE(delegate->scroll_update()); 937 EXPECT_FALSE(delegate->scroll_update());
938 EXPECT_FALSE(delegate->scroll_end()); 938 EXPECT_FALSE(delegate->scroll_end());
939 EXPECT_FALSE(delegate->long_press()); 939 EXPECT_FALSE(delegate->long_press());
940 940
941 delegate->Reset(); 941 delegate->Reset();
942 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(397, 149), 942 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(397, 149),
943 kTouchId, tes.LeapForward(50)); 943 kTouchId, tes.LeapForward(50));
944 move1.set_radius_x(16); 944 move1.set_radius_x(16);
945 move1.set_radius_y(16); 945 move1.set_radius_y(16);
946 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move1); 946 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move1);
947 EXPECT_FALSE(delegate->tap()); 947 EXPECT_FALSE(delegate->tap());
948 EXPECT_FALSE(delegate->tap_down()); 948 EXPECT_FALSE(delegate->tap_down());
949 EXPECT_FALSE(delegate->tap_cancel()); 949 EXPECT_FALSE(delegate->tap_cancel());
950 EXPECT_FALSE(delegate->begin()); 950 EXPECT_FALSE(delegate->begin());
951 EXPECT_FALSE(delegate->scroll_begin()); 951 EXPECT_FALSE(delegate->scroll_begin());
952 EXPECT_FALSE(delegate->scroll_update()); 952 EXPECT_FALSE(delegate->scroll_update());
953 EXPECT_FALSE(delegate->scroll_end()); 953 EXPECT_FALSE(delegate->scroll_end());
954 EXPECT_FALSE(delegate->long_press()); 954 EXPECT_FALSE(delegate->long_press());
955 955
956 delegate->Reset(); 956 delegate->Reset();
957 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(400, 150), 957 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(400, 150),
958 kTouchId, tes.LeapForward(50)); 958 kTouchId, tes.LeapForward(50));
959 move2.set_radius_x(14); 959 move2.set_radius_x(14);
960 move2.set_radius_y(10); 960 move2.set_radius_y(10);
961 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2); 961 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move2);
962 EXPECT_FALSE(delegate->tap()); 962 EXPECT_FALSE(delegate->tap());
963 EXPECT_FALSE(delegate->tap_down()); 963 EXPECT_FALSE(delegate->tap_down());
964 EXPECT_FALSE(delegate->tap_cancel()); 964 EXPECT_FALSE(delegate->tap_cancel());
965 EXPECT_FALSE(delegate->begin()); 965 EXPECT_FALSE(delegate->begin());
966 EXPECT_FALSE(delegate->scroll_begin()); 966 EXPECT_FALSE(delegate->scroll_begin());
967 EXPECT_FALSE(delegate->scroll_update()); 967 EXPECT_FALSE(delegate->scroll_update());
968 EXPECT_FALSE(delegate->scroll_end()); 968 EXPECT_FALSE(delegate->scroll_end());
969 EXPECT_FALSE(delegate->long_press()); 969 EXPECT_FALSE(delegate->long_press());
970 970
971 delegate->Reset(); 971 delegate->Reset();
972 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(401, 149), 972 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(401, 149),
973 kTouchId, tes.LeapForward(50)); 973 kTouchId, tes.LeapForward(50));
974 release.set_radius_x(8); 974 release.set_radius_x(8);
975 release.set_radius_y(9); 975 release.set_radius_y(9);
976 976
977 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 977 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
978 EXPECT_TRUE(delegate->tap()); 978 EXPECT_TRUE(delegate->tap());
979 EXPECT_FALSE(delegate->tap_down()); 979 EXPECT_FALSE(delegate->tap_down());
980 EXPECT_FALSE(delegate->tap_cancel()); 980 EXPECT_FALSE(delegate->tap_cancel());
981 EXPECT_FALSE(delegate->begin()); 981 EXPECT_FALSE(delegate->begin());
982 EXPECT_TRUE(delegate->end()); 982 EXPECT_TRUE(delegate->end());
983 EXPECT_FALSE(delegate->scroll_begin()); 983 EXPECT_FALSE(delegate->scroll_begin());
984 EXPECT_FALSE(delegate->scroll_update()); 984 EXPECT_FALSE(delegate->scroll_update());
985 EXPECT_FALSE(delegate->scroll_end()); 985 EXPECT_FALSE(delegate->scroll_end());
986 986
987 EXPECT_EQ(1, delegate->tap_count()); 987 EXPECT_EQ(1, delegate->tap_count());
(...skipping 13 matching lines...) Expand all
1001 const int kWindowWidth = 123; 1001 const int kWindowWidth = 123;
1002 const int kWindowHeight = 45; 1002 const int kWindowHeight = 45;
1003 const int kTouchId = 5; 1003 const int kTouchId = 5;
1004 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 1004 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
1005 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1005 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1006 delegate.get(), -1234, bounds, root_window())); 1006 delegate.get(), -1234, bounds, root_window()));
1007 1007
1008 delegate->Reset(); 1008 delegate->Reset();
1009 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 1009 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
1010 kTouchId, tes.Now()); 1010 kTouchId, tes.Now());
1011 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 1011 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
1012 EXPECT_2_EVENTS(delegate->events(), 1012 EXPECT_2_EVENTS(delegate->events(),
1013 ui::ET_GESTURE_BEGIN, 1013 ui::ET_GESTURE_BEGIN,
1014 ui::ET_GESTURE_TAP_DOWN); 1014 ui::ET_GESTURE_TAP_DOWN);
1015 1015
1016 // Move the touch-point enough so that it is considered as a scroll. This 1016 // Move the touch-point enough so that it is considered as a scroll. This
1017 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. 1017 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures.
1018 // The first movement is diagonal, to ensure that we have a free scroll, 1018 // The first movement is diagonal, to ensure that we have a free scroll,
1019 // and not a rail scroll. 1019 // and not a rail scroll.
1020 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get()); 1020 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get());
1021 EXPECT_3_EVENTS(delegate->events(), 1021 EXPECT_3_EVENTS(delegate->events(),
(...skipping 20 matching lines...) Expand all
1042 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); 1042 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE);
1043 EXPECT_EQ(30, delegate->scroll_x()); 1043 EXPECT_EQ(30, delegate->scroll_x());
1044 EXPECT_EQ(4, delegate->scroll_y()); 1044 EXPECT_EQ(4, delegate->scroll_y());
1045 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); 1045 EXPECT_TRUE(delegate->bounding_box().IsEmpty());
1046 1046
1047 // Release the touch. This should end the scroll. 1047 // Release the touch. This should end the scroll.
1048 delegate->Reset(); 1048 delegate->Reset();
1049 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 1049 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
1050 kTouchId, 1050 kTouchId,
1051 tes.LeapForward(50)); 1051 tes.LeapForward(50));
1052 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 1052 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
1053 EXPECT_2_EVENTS(delegate->events(), 1053 EXPECT_2_EVENTS(delegate->events(),
1054 ui::ET_SCROLL_FLING_START, 1054 ui::ET_SCROLL_FLING_START,
1055 ui::ET_GESTURE_END); 1055 ui::ET_GESTURE_END);
1056 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); 1056 EXPECT_TRUE(delegate->bounding_box().IsEmpty());
1057 } 1057 }
1058 1058
1059 // Check that predicted scroll update positions are correct. 1059 // Check that predicted scroll update positions are correct.
1060 TEST_F(GestureRecognizerTest, GestureEventScrollPrediction) { 1060 TEST_F(GestureRecognizerTest, GestureEventScrollPrediction) {
1061 const double prediction_interval = 0.03; 1061 const double prediction_interval = 0.03;
1062 ui::GestureConfiguration::set_scroll_prediction_seconds(prediction_interval); 1062 ui::GestureConfiguration::set_scroll_prediction_seconds(prediction_interval);
1063 scoped_ptr<GestureEventConsumeDelegate> delegate( 1063 scoped_ptr<GestureEventConsumeDelegate> delegate(
1064 new GestureEventConsumeDelegate()); 1064 new GestureEventConsumeDelegate());
1065 TimedEvents tes; 1065 TimedEvents tes;
1066 const int kWindowWidth = 123; 1066 const int kWindowWidth = 123;
1067 const int kWindowHeight = 45; 1067 const int kWindowHeight = 45;
1068 const int kTouchId = 5; 1068 const int kTouchId = 5;
1069 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 1069 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
1070 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1070 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1071 delegate.get(), -1234, bounds, root_window())); 1071 delegate.get(), -1234, bounds, root_window()));
1072 1072
1073 delegate->Reset(); 1073 delegate->Reset();
1074 // Tracks the total scroll since we want to verify that the correct position 1074 // Tracks the total scroll since we want to verify that the correct position
1075 // will be scrolled to throughout the prediction. 1075 // will be scrolled to throughout the prediction.
1076 gfx::Vector2dF total_scroll; 1076 gfx::Vector2dF total_scroll;
1077 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 1077 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
1078 kTouchId, tes.Now()); 1078 kTouchId, tes.Now());
1079 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 1079 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
1080 EXPECT_2_EVENTS(delegate->events(), 1080 EXPECT_2_EVENTS(delegate->events(),
1081 ui::ET_GESTURE_BEGIN, 1081 ui::ET_GESTURE_BEGIN,
1082 ui::ET_GESTURE_TAP_DOWN); 1082 ui::ET_GESTURE_TAP_DOWN);
1083 1083
1084 // Move the touch-point enough so that it is considered as a scroll. This 1084 // Move the touch-point enough so that it is considered as a scroll. This
1085 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. 1085 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures.
1086 // The first movement is diagonal, to ensure that we have a free scroll, 1086 // The first movement is diagonal, to ensure that we have a free scroll,
1087 // and not a rail scroll. 1087 // and not a rail scroll.
1088 tes.LeapForward(30); 1088 tes.LeapForward(30);
1089 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get()); 1089 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get());
(...skipping 29 matching lines...) Expand all
1119 EXPECT_EQ((int)(39 + delegate->scroll_velocity_x() * prediction_interval), 1119 EXPECT_EQ((int)(39 + delegate->scroll_velocity_x() * prediction_interval),
1120 (int)(total_scroll.x())); 1120 (int)(total_scroll.x()));
1121 EXPECT_EQ((int)(14 + delegate->scroll_velocity_y() * prediction_interval), 1121 EXPECT_EQ((int)(14 + delegate->scroll_velocity_y() * prediction_interval),
1122 (int)(total_scroll.y())); 1122 (int)(total_scroll.y()));
1123 1123
1124 // Release the touch. This should end the scroll. 1124 // Release the touch. This should end the scroll.
1125 delegate->Reset(); 1125 delegate->Reset();
1126 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 1126 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
1127 kTouchId, 1127 kTouchId,
1128 tes.LeapForward(50)); 1128 tes.LeapForward(50));
1129 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 1129 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
1130 } 1130 }
1131 1131
1132 // Check that the bounding box during a scroll event is correct. 1132 // Check that the bounding box during a scroll event is correct.
1133 TEST_F(GestureRecognizerTest, GestureEventScrollBoundingBox) { 1133 TEST_F(GestureRecognizerTest, GestureEventScrollBoundingBox) {
1134 TimedEvents tes; 1134 TimedEvents tes;
1135 for (int radius = 1; radius <= 10; ++radius) { 1135 for (int radius = 1; radius <= 10; ++radius) {
1136 ui::GestureConfiguration::set_default_radius(radius); 1136 ui::GestureConfiguration::set_default_radius(radius);
1137 scoped_ptr<GestureEventConsumeDelegate> delegate( 1137 scoped_ptr<GestureEventConsumeDelegate> delegate(
1138 new GestureEventConsumeDelegate()); 1138 new GestureEventConsumeDelegate());
1139 const int kWindowWidth = 123; 1139 const int kWindowWidth = 123;
1140 const int kWindowHeight = 45; 1140 const int kWindowHeight = 45;
1141 const int kTouchId = 5; 1141 const int kTouchId = 5;
1142 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 1142 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
1143 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1143 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1144 delegate.get(), -1234, bounds, root_window())); 1144 delegate.get(), -1234, bounds, root_window()));
1145 1145
1146 const int kPositionX = 101; 1146 const int kPositionX = 101;
1147 const int kPositionY = 201; 1147 const int kPositionY = 201;
1148 delegate->Reset(); 1148 delegate->Reset();
1149 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, 1149 ui::TouchEvent press(ui::ET_TOUCH_PRESSED,
1150 gfx::Point(kPositionX, kPositionY), 1150 gfx::Point(kPositionX, kPositionY),
1151 kTouchId, 1151 kTouchId,
1152 tes.Now()); 1152 tes.Now());
1153 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 1153 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
1154 EXPECT_EQ(gfx::Rect(kPositionX - radius, 1154 EXPECT_EQ(gfx::Rect(kPositionX - radius,
1155 kPositionY - radius, 1155 kPositionY - radius,
1156 radius * 2, 1156 radius * 2,
1157 radius * 2).ToString(), 1157 radius * 2).ToString(),
1158 delegate->bounding_box().ToString()); 1158 delegate->bounding_box().ToString());
1159 1159
1160 const int kScrollAmount = 50; 1160 const int kScrollAmount = 50;
1161 tes.SendScrollEvents(dispatcher(), kPositionX, kPositionY, 1161 tes.SendScrollEvents(dispatcher(), kPositionX, kPositionY,
1162 1, 1, kTouchId, 1, kScrollAmount, delegate.get()); 1162 1, 1, kTouchId, 1, kScrollAmount, delegate.get());
1163 EXPECT_EQ(gfx::Point(1, 1).ToString(), 1163 EXPECT_EQ(gfx::Point(1, 1).ToString(),
1164 delegate->scroll_begin_position().ToString()); 1164 delegate->scroll_begin_position().ToString());
1165 EXPECT_EQ(gfx::Rect(kPositionX + kScrollAmount - radius, 1165 EXPECT_EQ(gfx::Rect(kPositionX + kScrollAmount - radius,
1166 kPositionY + kScrollAmount - radius, 1166 kPositionY + kScrollAmount - radius,
1167 radius * 2, 1167 radius * 2,
1168 radius * 2).ToString(), 1168 radius * 2).ToString(),
1169 delegate->bounding_box().ToString()); 1169 delegate->bounding_box().ToString());
1170 1170
1171 // Release the touch. This should end the scroll. 1171 // Release the touch. This should end the scroll.
1172 delegate->Reset(); 1172 delegate->Reset();
1173 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, 1173 ui::TouchEvent release(ui::ET_TOUCH_RELEASED,
1174 gfx::Point(kPositionX + kScrollAmount, 1174 gfx::Point(kPositionX + kScrollAmount,
1175 kPositionY + kScrollAmount), 1175 kPositionY + kScrollAmount),
1176 kTouchId, press.time_stamp() + 1176 kTouchId, press.time_stamp() +
1177 base::TimeDelta::FromMilliseconds(50)); 1177 base::TimeDelta::FromMilliseconds(50));
1178 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 1178 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
1179 EXPECT_EQ(gfx::Rect(kPositionX + kScrollAmount - radius, 1179 EXPECT_EQ(gfx::Rect(kPositionX + kScrollAmount - radius,
1180 kPositionY + kScrollAmount - radius, 1180 kPositionY + kScrollAmount - radius,
1181 radius * 2, 1181 radius * 2,
1182 radius * 2).ToString(), 1182 radius * 2).ToString(),
1183 delegate->bounding_box().ToString()); 1183 delegate->bounding_box().ToString());
1184 } 1184 }
1185 ui::GestureConfiguration::set_default_radius(0); 1185 ui::GestureConfiguration::set_default_radius(0);
1186 } 1186 }
1187 1187
1188 // Check Scroll End Events report correct velocities 1188 // Check Scroll End Events report correct velocities
1189 // if the user was on a horizontal rail 1189 // if the user was on a horizontal rail
1190 TEST_F(GestureRecognizerTest, GestureEventHorizontalRailFling) { 1190 TEST_F(GestureRecognizerTest, GestureEventHorizontalRailFling) {
1191 scoped_ptr<GestureEventConsumeDelegate> delegate( 1191 scoped_ptr<GestureEventConsumeDelegate> delegate(
1192 new GestureEventConsumeDelegate()); 1192 new GestureEventConsumeDelegate());
1193 TimedEvents tes; 1193 TimedEvents tes;
1194 const int kTouchId = 7; 1194 const int kTouchId = 7;
1195 gfx::Rect bounds(0, 0, 1000, 1000); 1195 gfx::Rect bounds(0, 0, 1000, 1000);
1196 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1196 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1197 delegate.get(), -1234, bounds, root_window())); 1197 delegate.get(), -1234, bounds, root_window()));
1198 1198
1199 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 1199 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0),
1200 kTouchId, tes.Now()); 1200 kTouchId, tes.Now());
1201 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 1201 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
1202 1202
1203 // Move the touch-point horizontally enough that it is considered a 1203 // Move the touch-point horizontally enough that it is considered a
1204 // horizontal scroll. 1204 // horizontal scroll.
1205 tes.SendScrollEvent(dispatcher(), 20, 1, kTouchId, delegate.get()); 1205 tes.SendScrollEvent(dispatcher(), 20, 1, kTouchId, delegate.get());
1206 EXPECT_EQ(0, delegate->scroll_y()); 1206 EXPECT_EQ(0, delegate->scroll_y());
1207 EXPECT_EQ(1, delegate->scroll_y_ordinal()); 1207 EXPECT_EQ(1, delegate->scroll_y_ordinal());
1208 EXPECT_EQ(20, delegate->scroll_x()); 1208 EXPECT_EQ(20, delegate->scroll_x());
1209 EXPECT_EQ(20, delegate->scroll_x_ordinal()); 1209 EXPECT_EQ(20, delegate->scroll_x_ordinal());
1210 1210
1211 // Get a high x velocity, while still staying on the rail 1211 // Get a high x velocity, while still staying on the rail
1212 tes.SendScrollEvents(dispatcher(), 1, 1, 1212 tes.SendScrollEvents(dispatcher(), 1, 1,
1213 100, 10, kTouchId, 1, 1213 100, 10, kTouchId, 1,
1214 ui::GestureConfiguration::points_buffered_for_velocity(), 1214 ui::GestureConfiguration::points_buffered_for_velocity(),
1215 delegate.get()); 1215 delegate.get());
1216 // The y-velocity during the scroll should be 0 since this is in a horizontal 1216 // The y-velocity during the scroll should be 0 since this is in a horizontal
1217 // rail scroll. 1217 // rail scroll.
1218 EXPECT_GT(delegate->scroll_velocity_x(), 0); 1218 EXPECT_GT(delegate->scroll_velocity_x(), 0);
1219 EXPECT_EQ(0, delegate->scroll_velocity_y()); 1219 EXPECT_EQ(0, delegate->scroll_velocity_y());
1220 1220
1221 delegate->Reset(); 1221 delegate->Reset();
1222 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 1222 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
1223 kTouchId, tes.Now()); 1223 kTouchId, tes.Now());
1224 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 1224 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
1225 1225
1226 EXPECT_TRUE(delegate->fling()); 1226 EXPECT_TRUE(delegate->fling());
1227 EXPECT_FALSE(delegate->scroll_end()); 1227 EXPECT_FALSE(delegate->scroll_end());
1228 EXPECT_GT(delegate->velocity_x(), 0); 1228 EXPECT_GT(delegate->velocity_x(), 0);
1229 EXPECT_EQ(0, delegate->velocity_y()); 1229 EXPECT_EQ(0, delegate->velocity_y());
1230 } 1230 }
1231 1231
1232 // Check Scroll End Events report correct velocities 1232 // Check Scroll End Events report correct velocities
1233 // if the user was on a vertical rail 1233 // if the user was on a vertical rail
1234 TEST_F(GestureRecognizerTest, GestureEventVerticalRailFling) { 1234 TEST_F(GestureRecognizerTest, GestureEventVerticalRailFling) {
1235 scoped_ptr<GestureEventConsumeDelegate> delegate( 1235 scoped_ptr<GestureEventConsumeDelegate> delegate(
1236 new GestureEventConsumeDelegate()); 1236 new GestureEventConsumeDelegate());
1237 TimedEvents tes; 1237 TimedEvents tes;
1238 const int kTouchId = 7; 1238 const int kTouchId = 7;
1239 gfx::Rect bounds(0, 0, 1000, 1000); 1239 gfx::Rect bounds(0, 0, 1000, 1000);
1240 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1240 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1241 delegate.get(), -1234, bounds, root_window())); 1241 delegate.get(), -1234, bounds, root_window()));
1242 1242
1243 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 1243 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0),
1244 kTouchId, tes.Now()); 1244 kTouchId, tes.Now());
1245 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 1245 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
1246 1246
1247 // Move the touch-point vertically enough that it is considered a 1247 // Move the touch-point vertically enough that it is considered a
1248 // vertical scroll. 1248 // vertical scroll.
1249 tes.SendScrollEvent(dispatcher(), 1, 20, kTouchId, delegate.get()); 1249 tes.SendScrollEvent(dispatcher(), 1, 20, kTouchId, delegate.get());
1250 EXPECT_EQ(20, delegate->scroll_y()); 1250 EXPECT_EQ(20, delegate->scroll_y());
1251 EXPECT_EQ(20, delegate->scroll_y_ordinal()); 1251 EXPECT_EQ(20, delegate->scroll_y_ordinal());
1252 EXPECT_EQ(0, delegate->scroll_x()); 1252 EXPECT_EQ(0, delegate->scroll_x());
1253 EXPECT_EQ(1, delegate->scroll_x_ordinal()); 1253 EXPECT_EQ(1, delegate->scroll_x_ordinal());
1254 EXPECT_EQ(0, delegate->scroll_velocity_x()); 1254 EXPECT_EQ(0, delegate->scroll_velocity_x());
1255 EXPECT_GT(delegate->scroll_velocity_x_ordinal(), 0); 1255 EXPECT_GT(delegate->scroll_velocity_x_ordinal(), 0);
1256 1256
1257 // Get a high y velocity, while still staying on the rail 1257 // Get a high y velocity, while still staying on the rail
1258 tes.SendScrollEvents(dispatcher(), 1, 1, 1258 tes.SendScrollEvents(dispatcher(), 1, 1,
1259 10, 100, kTouchId, 1, 1259 10, 100, kTouchId, 1,
1260 ui::GestureConfiguration::points_buffered_for_velocity(), 1260 ui::GestureConfiguration::points_buffered_for_velocity(),
1261 delegate.get()); 1261 delegate.get());
1262 EXPECT_EQ(0, delegate->scroll_velocity_x()); 1262 EXPECT_EQ(0, delegate->scroll_velocity_x());
1263 EXPECT_GT(delegate->scroll_velocity_y(), 0); 1263 EXPECT_GT(delegate->scroll_velocity_y(), 0);
1264 1264
1265 delegate->Reset(); 1265 delegate->Reset();
1266 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 1266 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
1267 kTouchId, tes.Now()); 1267 kTouchId, tes.Now());
1268 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 1268 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
1269 1269
1270 EXPECT_TRUE(delegate->fling()); 1270 EXPECT_TRUE(delegate->fling());
1271 EXPECT_FALSE(delegate->scroll_end()); 1271 EXPECT_FALSE(delegate->scroll_end());
1272 EXPECT_EQ(0, delegate->velocity_x()); 1272 EXPECT_EQ(0, delegate->velocity_x());
1273 EXPECT_GT(delegate->velocity_y(), 0); 1273 EXPECT_GT(delegate->velocity_y(), 0);
1274 } 1274 }
1275 1275
1276 // Check Scroll End Events reports zero velocities 1276 // Check Scroll End Events reports zero velocities
1277 // if the user is not on a rail 1277 // if the user is not on a rail
1278 TEST_F(GestureRecognizerTest, GestureEventNonRailFling) { 1278 TEST_F(GestureRecognizerTest, GestureEventNonRailFling) {
1279 scoped_ptr<GestureEventConsumeDelegate> delegate( 1279 scoped_ptr<GestureEventConsumeDelegate> delegate(
1280 new GestureEventConsumeDelegate()); 1280 new GestureEventConsumeDelegate());
1281 TimedEvents tes; 1281 TimedEvents tes;
1282 const int kTouchId = 7; 1282 const int kTouchId = 7;
1283 gfx::Rect bounds(0, 0, 1000, 1000); 1283 gfx::Rect bounds(0, 0, 1000, 1000);
1284 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1284 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1285 delegate.get(), -1234, bounds, root_window())); 1285 delegate.get(), -1234, bounds, root_window()));
1286 1286
1287 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 1287 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0),
1288 kTouchId, tes.Now()); 1288 kTouchId, tes.Now());
1289 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 1289 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
1290 1290
1291 // Move the touch-point such that a non-rail scroll begins 1291 // Move the touch-point such that a non-rail scroll begins
1292 tes.SendScrollEvent(dispatcher(), 20, 20, kTouchId, delegate.get()); 1292 tes.SendScrollEvent(dispatcher(), 20, 20, kTouchId, delegate.get());
1293 EXPECT_EQ(20, delegate->scroll_y()); 1293 EXPECT_EQ(20, delegate->scroll_y());
1294 EXPECT_EQ(20, delegate->scroll_x()); 1294 EXPECT_EQ(20, delegate->scroll_x());
1295 1295
1296 tes.SendScrollEvents(dispatcher(), 1, 1, 1296 tes.SendScrollEvents(dispatcher(), 1, 1,
1297 10, 100, kTouchId, 1, 1297 10, 100, kTouchId, 1,
1298 ui::GestureConfiguration::points_buffered_for_velocity(), 1298 ui::GestureConfiguration::points_buffered_for_velocity(),
1299 delegate.get()); 1299 delegate.get());
1300 1300
1301 delegate->Reset(); 1301 delegate->Reset();
1302 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 1302 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
1303 kTouchId, tes.Now()); 1303 kTouchId, tes.Now());
1304 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 1304 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
1305 1305
1306 EXPECT_TRUE(delegate->fling()); 1306 EXPECT_TRUE(delegate->fling());
1307 EXPECT_FALSE(delegate->scroll_end()); 1307 EXPECT_FALSE(delegate->scroll_end());
1308 EXPECT_GT(delegate->velocity_x(), 0); 1308 EXPECT_GT(delegate->velocity_x(), 0);
1309 EXPECT_GT(delegate->velocity_y(), 0); 1309 EXPECT_GT(delegate->velocity_y(), 0);
1310 } 1310 }
1311 1311
1312 // Check that appropriate touch events generate long press events 1312 // Check that appropriate touch events generate long press events
1313 TEST_F(GestureRecognizerTest, GestureEventLongPress) { 1313 TEST_F(GestureRecognizerTest, GestureEventLongPress) {
1314 scoped_ptr<GestureEventConsumeDelegate> delegate( 1314 scoped_ptr<GestureEventConsumeDelegate> delegate(
1315 new GestureEventConsumeDelegate()); 1315 new GestureEventConsumeDelegate());
1316 TimedEvents tes; 1316 TimedEvents tes;
1317 const int kWindowWidth = 123; 1317 const int kWindowWidth = 123;
1318 const int kWindowHeight = 45; 1318 const int kWindowHeight = 45;
1319 const int kTouchId = 2; 1319 const int kTouchId = 2;
1320 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 1320 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
1321 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1321 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1322 delegate.get(), -1234, bounds, root_window())); 1322 delegate.get(), -1234, bounds, root_window()));
1323 1323
1324 delegate->Reset(); 1324 delegate->Reset();
1325 1325
1326 TimerTestGestureRecognizer* gesture_recognizer = 1326 TimerTestGestureRecognizer* gesture_recognizer =
1327 new TimerTestGestureRecognizer(); 1327 new TimerTestGestureRecognizer();
1328 1328
1329 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); 1329 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer);
1330 1330
1331 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 1331 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
1332 kTouchId, tes.Now()); 1332 kTouchId, tes.Now());
1333 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 1333 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1);
1334 EXPECT_TRUE(delegate->tap_down()); 1334 EXPECT_TRUE(delegate->tap_down());
1335 EXPECT_TRUE(delegate->begin()); 1335 EXPECT_TRUE(delegate->begin());
1336 EXPECT_FALSE(delegate->tap_cancel()); 1336 EXPECT_FALSE(delegate->tap_cancel());
1337 1337
1338 // We haven't pressed long enough for a long press to occur 1338 // We haven't pressed long enough for a long press to occur
1339 EXPECT_FALSE(delegate->long_press()); 1339 EXPECT_FALSE(delegate->long_press());
1340 1340
1341 // Wait until the timer runs out 1341 // Wait until the timer runs out
1342 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS); 1342 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS);
1343 EXPECT_TRUE(delegate->long_press()); 1343 EXPECT_TRUE(delegate->long_press());
1344 EXPECT_EQ(0, delegate->touch_id()); 1344 EXPECT_EQ(0, delegate->touch_id());
1345 EXPECT_FALSE(delegate->tap_cancel()); 1345 EXPECT_FALSE(delegate->tap_cancel());
1346 1346
1347 delegate->Reset(); 1347 delegate->Reset();
1348 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 1348 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
1349 kTouchId, tes.Now()); 1349 kTouchId, tes.Now());
1350 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); 1350 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1);
1351 EXPECT_FALSE(delegate->long_press()); 1351 EXPECT_FALSE(delegate->long_press());
1352 1352
1353 // Note the tap down isn't cancelled until the release 1353 // Note the tap down isn't cancelled until the release
1354 EXPECT_TRUE(delegate->tap_cancel()); 1354 EXPECT_TRUE(delegate->tap_cancel());
1355 } 1355 }
1356 1356
1357 // Check that scrolling cancels a long press 1357 // Check that scrolling cancels a long press
1358 TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByScroll) { 1358 TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByScroll) {
1359 scoped_ptr<GestureEventConsumeDelegate> delegate( 1359 scoped_ptr<GestureEventConsumeDelegate> delegate(
1360 new GestureEventConsumeDelegate()); 1360 new GestureEventConsumeDelegate());
(...skipping 11 matching lines...) Expand all
1372 TimerTestGestureRecognizer* gesture_recognizer = 1372 TimerTestGestureRecognizer* gesture_recognizer =
1373 new TimerTestGestureRecognizer(); 1373 new TimerTestGestureRecognizer();
1374 TimerTestGestureSequence* gesture_sequence = 1374 TimerTestGestureSequence* gesture_sequence =
1375 static_cast<TimerTestGestureSequence*>( 1375 static_cast<TimerTestGestureSequence*>(
1376 gesture_recognizer->GetGestureSequenceForTesting(window.get())); 1376 gesture_recognizer->GetGestureSequenceForTesting(window.get()));
1377 1377
1378 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); 1378 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer);
1379 1379
1380 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 1380 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
1381 kTouchId, tes.Now()); 1381 kTouchId, tes.Now());
1382 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 1382 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1);
1383 EXPECT_TRUE(delegate->tap_down()); 1383 EXPECT_TRUE(delegate->tap_down());
1384 1384
1385 // We haven't pressed long enough for a long press to occur 1385 // We haven't pressed long enough for a long press to occur
1386 EXPECT_FALSE(delegate->long_press()); 1386 EXPECT_FALSE(delegate->long_press());
1387 EXPECT_FALSE(delegate->tap_cancel()); 1387 EXPECT_FALSE(delegate->tap_cancel());
1388 1388
1389 // Scroll around, to cancel the long press 1389 // Scroll around, to cancel the long press
1390 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get()); 1390 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get());
1391 // Wait until the timer runs out 1391 // Wait until the timer runs out
1392 gesture_sequence->ForceTimeout(); 1392 gesture_sequence->ForceTimeout();
1393 EXPECT_FALSE(delegate->long_press()); 1393 EXPECT_FALSE(delegate->long_press());
1394 EXPECT_TRUE(delegate->tap_cancel()); 1394 EXPECT_TRUE(delegate->tap_cancel());
1395 1395
1396 delegate->Reset(); 1396 delegate->Reset();
1397 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 1397 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
1398 kTouchId, tes.LeapForward(10)); 1398 kTouchId, tes.LeapForward(10));
1399 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); 1399 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1);
1400 EXPECT_FALSE(delegate->long_press()); 1400 EXPECT_FALSE(delegate->long_press());
1401 EXPECT_FALSE(delegate->tap_cancel()); 1401 EXPECT_FALSE(delegate->tap_cancel());
1402 } 1402 }
1403 1403
1404 // Check that appropriate touch events generate long tap events 1404 // Check that appropriate touch events generate long tap events
1405 TEST_F(GestureRecognizerTest, GestureEventLongTap) { 1405 TEST_F(GestureRecognizerTest, GestureEventLongTap) {
1406 scoped_ptr<GestureEventConsumeDelegate> delegate( 1406 scoped_ptr<GestureEventConsumeDelegate> delegate(
1407 new GestureEventConsumeDelegate()); 1407 new GestureEventConsumeDelegate());
1408 TimedEvents tes; 1408 TimedEvents tes;
1409 const int kWindowWidth = 123; 1409 const int kWindowWidth = 123;
1410 const int kWindowHeight = 45; 1410 const int kWindowHeight = 45;
1411 const int kTouchId = 2; 1411 const int kTouchId = 2;
1412 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 1412 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
1413 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1413 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1414 delegate.get(), -1234, bounds, root_window())); 1414 delegate.get(), -1234, bounds, root_window()));
1415 1415
1416 delegate->Reset(); 1416 delegate->Reset();
1417 1417
1418 TimerTestGestureRecognizer* gesture_recognizer = 1418 TimerTestGestureRecognizer* gesture_recognizer =
1419 new TimerTestGestureRecognizer(); 1419 new TimerTestGestureRecognizer();
1420 1420
1421 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); 1421 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer);
1422 1422
1423 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 1423 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
1424 kTouchId, tes.Now()); 1424 kTouchId, tes.Now());
1425 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 1425 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1);
1426 EXPECT_TRUE(delegate->tap_down()); 1426 EXPECT_TRUE(delegate->tap_down());
1427 EXPECT_TRUE(delegate->begin()); 1427 EXPECT_TRUE(delegate->begin());
1428 EXPECT_FALSE(delegate->tap_cancel()); 1428 EXPECT_FALSE(delegate->tap_cancel());
1429 1429
1430 // We haven't pressed long enough for a long press to occur 1430 // We haven't pressed long enough for a long press to occur
1431 EXPECT_FALSE(delegate->long_press()); 1431 EXPECT_FALSE(delegate->long_press());
1432 1432
1433 // Wait until the timer runs out 1433 // Wait until the timer runs out
1434 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS); 1434 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS);
1435 EXPECT_TRUE(delegate->long_press()); 1435 EXPECT_TRUE(delegate->long_press());
1436 EXPECT_EQ(0, delegate->touch_id()); 1436 EXPECT_EQ(0, delegate->touch_id());
1437 EXPECT_FALSE(delegate->tap_cancel()); 1437 EXPECT_FALSE(delegate->tap_cancel());
1438 1438
1439 delegate->Reset(); 1439 delegate->Reset();
1440 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 1440 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
1441 kTouchId, tes.Now()); 1441 kTouchId, tes.Now());
1442 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); 1442 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1);
1443 EXPECT_FALSE(delegate->long_press()); 1443 EXPECT_FALSE(delegate->long_press());
1444 EXPECT_TRUE(delegate->long_tap()); 1444 EXPECT_TRUE(delegate->long_tap());
1445 1445
1446 // Note the tap down isn't cancelled until the release 1446 // Note the tap down isn't cancelled until the release
1447 EXPECT_TRUE(delegate->tap_cancel()); 1447 EXPECT_TRUE(delegate->tap_cancel());
1448 } 1448 }
1449 1449
1450 // Check that second tap cancels a long press 1450 // Check that second tap cancels a long press
1451 TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledBySecondTap) { 1451 TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledBySecondTap) {
1452 scoped_ptr<GestureEventConsumeDelegate> delegate( 1452 scoped_ptr<GestureEventConsumeDelegate> delegate(
(...skipping 12 matching lines...) Expand all
1465 new TimerTestGestureRecognizer(); 1465 new TimerTestGestureRecognizer();
1466 TimerTestGestureSequence* gesture_sequence = 1466 TimerTestGestureSequence* gesture_sequence =
1467 static_cast<TimerTestGestureSequence*>( 1467 static_cast<TimerTestGestureSequence*>(
1468 gesture_recognizer->GetGestureSequenceForTesting(window.get())); 1468 gesture_recognizer->GetGestureSequenceForTesting(window.get()));
1469 1469
1470 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); 1470 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer);
1471 1471
1472 delegate->Reset(); 1472 delegate->Reset();
1473 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 1473 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
1474 kTouchId1, tes.Now()); 1474 kTouchId1, tes.Now());
1475 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 1475 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
1476 EXPECT_TRUE(delegate->tap_down()); 1476 EXPECT_TRUE(delegate->tap_down());
1477 EXPECT_TRUE(delegate->begin()); 1477 EXPECT_TRUE(delegate->begin());
1478 1478
1479 // We haven't pressed long enough for a long press to occur 1479 // We haven't pressed long enough for a long press to occur
1480 EXPECT_FALSE(delegate->long_press()); 1480 EXPECT_FALSE(delegate->long_press());
1481 1481
1482 // Second tap, to cancel the long press 1482 // Second tap, to cancel the long press
1483 delegate->Reset(); 1483 delegate->Reset();
1484 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1484 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10),
1485 kTouchId2, tes.Now()); 1485 kTouchId2, tes.Now());
1486 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 1486 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2);
1487 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap. 1487 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap.
1488 EXPECT_TRUE(delegate->tap_cancel()); 1488 EXPECT_TRUE(delegate->tap_cancel());
1489 EXPECT_TRUE(delegate->begin()); 1489 EXPECT_TRUE(delegate->begin());
1490 1490
1491 // Wait until the timer runs out 1491 // Wait until the timer runs out
1492 gesture_sequence->ForceTimeout(); 1492 gesture_sequence->ForceTimeout();
1493 1493
1494 // No long press occurred 1494 // No long press occurred
1495 EXPECT_FALSE(delegate->long_press()); 1495 EXPECT_FALSE(delegate->long_press());
1496 1496
1497 delegate->Reset(); 1497 delegate->Reset();
1498 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 1498 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
1499 kTouchId1, tes.Now()); 1499 kTouchId1, tes.Now());
1500 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); 1500 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1);
1501 EXPECT_FALSE(delegate->long_press()); 1501 EXPECT_FALSE(delegate->long_press());
1502 EXPECT_TRUE(delegate->two_finger_tap()); 1502 EXPECT_TRUE(delegate->two_finger_tap());
1503 EXPECT_FALSE(delegate->tap_cancel()); 1503 EXPECT_FALSE(delegate->tap_cancel());
1504 } 1504 }
1505 1505
1506 // Check that horizontal scroll gestures cause scrolls on horizontal rails. 1506 // Check that horizontal scroll gestures cause scrolls on horizontal rails.
1507 // Also tests that horizontal rails can be broken. 1507 // Also tests that horizontal rails can be broken.
1508 TEST_F(GestureRecognizerTest, GestureEventHorizontalRailScroll) { 1508 TEST_F(GestureRecognizerTest, GestureEventHorizontalRailScroll) {
1509 scoped_ptr<GestureEventConsumeDelegate> delegate( 1509 scoped_ptr<GestureEventConsumeDelegate> delegate(
1510 new GestureEventConsumeDelegate()); 1510 new GestureEventConsumeDelegate());
1511 TimedEvents tes; 1511 TimedEvents tes;
1512 const int kTouchId = 7; 1512 const int kTouchId = 7;
1513 gfx::Rect bounds(0, 0, 1000, 1000); 1513 gfx::Rect bounds(0, 0, 1000, 1000);
1514 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1514 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1515 delegate.get(), -1234, bounds, root_window())); 1515 delegate.get(), -1234, bounds, root_window()));
1516 1516
1517 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 1517 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0),
1518 kTouchId, tes.Now()); 1518 kTouchId, tes.Now());
1519 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 1519 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
1520 1520
1521 // Move the touch-point horizontally enough that it is considered a 1521 // Move the touch-point horizontally enough that it is considered a
1522 // horizontal scroll. 1522 // horizontal scroll.
1523 tes.SendScrollEvent(dispatcher(), 20, 1, kTouchId, delegate.get()); 1523 tes.SendScrollEvent(dispatcher(), 20, 1, kTouchId, delegate.get());
1524 EXPECT_EQ(0, delegate->scroll_y()); 1524 EXPECT_EQ(0, delegate->scroll_y());
1525 EXPECT_EQ(20, delegate->scroll_x()); 1525 EXPECT_EQ(20, delegate->scroll_x());
1526 1526
1527 tes.SendScrollEvent(dispatcher(), 25, 6, kTouchId, delegate.get()); 1527 tes.SendScrollEvent(dispatcher(), 25, 6, kTouchId, delegate.get());
1528 EXPECT_TRUE(delegate->scroll_update()); 1528 EXPECT_TRUE(delegate->scroll_update());
1529 EXPECT_EQ(5, delegate->scroll_x()); 1529 EXPECT_EQ(5, delegate->scroll_x());
(...skipping 26 matching lines...) Expand all
1556 scoped_ptr<GestureEventConsumeDelegate> delegate( 1556 scoped_ptr<GestureEventConsumeDelegate> delegate(
1557 new GestureEventConsumeDelegate()); 1557 new GestureEventConsumeDelegate());
1558 TimedEvents tes; 1558 TimedEvents tes;
1559 const int kTouchId = 7; 1559 const int kTouchId = 7;
1560 gfx::Rect bounds(0, 0, 1000, 1000); 1560 gfx::Rect bounds(0, 0, 1000, 1000);
1561 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1561 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1562 delegate.get(), -1234, bounds, root_window())); 1562 delegate.get(), -1234, bounds, root_window()));
1563 1563
1564 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 1564 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0),
1565 kTouchId, tes.Now()); 1565 kTouchId, tes.Now());
1566 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 1566 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
1567 1567
1568 // Move the touch-point vertically enough that it is considered a 1568 // Move the touch-point vertically enough that it is considered a
1569 // vertical scroll. 1569 // vertical scroll.
1570 tes.SendScrollEvent(dispatcher(), 1, 20, kTouchId, delegate.get()); 1570 tes.SendScrollEvent(dispatcher(), 1, 20, kTouchId, delegate.get());
1571 EXPECT_EQ(0, delegate->scroll_x()); 1571 EXPECT_EQ(0, delegate->scroll_x());
1572 EXPECT_EQ(20, delegate->scroll_y()); 1572 EXPECT_EQ(20, delegate->scroll_y());
1573 1573
1574 tes.SendScrollEvent(dispatcher(), 6, 25, kTouchId, delegate.get()); 1574 tes.SendScrollEvent(dispatcher(), 6, 25, kTouchId, delegate.get());
1575 EXPECT_TRUE(delegate->scroll_update()); 1575 EXPECT_TRUE(delegate->scroll_update());
1576 EXPECT_EQ(5, delegate->scroll_y()); 1576 EXPECT_EQ(5, delegate->scroll_y());
(...skipping 27 matching lines...) Expand all
1604 const int kWindowWidth = 123; 1604 const int kWindowWidth = 123;
1605 const int kWindowHeight = 45; 1605 const int kWindowHeight = 45;
1606 const int kTouchId = 3; 1606 const int kTouchId = 3;
1607 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 1607 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
1608 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1608 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1609 delegate.get(), -1234, bounds, root_window())); 1609 delegate.get(), -1234, bounds, root_window()));
1610 1610
1611 delegate->Reset(); 1611 delegate->Reset();
1612 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 1612 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
1613 kTouchId, tes.Now()); 1613 kTouchId, tes.Now());
1614 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 1614 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
1615 EXPECT_FALSE(delegate->tap()); 1615 EXPECT_FALSE(delegate->tap());
1616 EXPECT_TRUE(delegate->tap_down()); 1616 EXPECT_TRUE(delegate->tap_down());
1617 EXPECT_FALSE(delegate->tap_cancel()); 1617 EXPECT_FALSE(delegate->tap_cancel());
1618 EXPECT_FALSE(delegate->scroll_begin()); 1618 EXPECT_FALSE(delegate->scroll_begin());
1619 EXPECT_FALSE(delegate->scroll_update()); 1619 EXPECT_FALSE(delegate->scroll_update());
1620 EXPECT_FALSE(delegate->scroll_end()); 1620 EXPECT_FALSE(delegate->scroll_end());
1621 1621
1622 // Make sure there is enough delay before the touch is released so that it is 1622 // Make sure there is enough delay before the touch is released so that it is
1623 // recognized as a tap. 1623 // recognized as a tap.
1624 delegate->Reset(); 1624 delegate->Reset();
1625 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 1625 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
1626 kTouchId, tes.LeapForward(50)); 1626 kTouchId, tes.LeapForward(50));
1627 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 1627 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
1628 EXPECT_TRUE(delegate->tap()); 1628 EXPECT_TRUE(delegate->tap());
1629 EXPECT_FALSE(delegate->tap_down()); 1629 EXPECT_FALSE(delegate->tap_down());
1630 EXPECT_FALSE(delegate->tap_cancel()); 1630 EXPECT_FALSE(delegate->tap_cancel());
1631 EXPECT_FALSE(delegate->scroll_begin()); 1631 EXPECT_FALSE(delegate->scroll_begin());
1632 EXPECT_FALSE(delegate->scroll_update()); 1632 EXPECT_FALSE(delegate->scroll_update());
1633 EXPECT_FALSE(delegate->scroll_end()); 1633 EXPECT_FALSE(delegate->scroll_end());
1634 1634
1635 // Now, do a scroll gesture. Delay it sufficiently so that it doesn't trigger 1635 // Now, do a scroll gesture. Delay it sufficiently so that it doesn't trigger
1636 // a double-tap. 1636 // a double-tap.
1637 delegate->Reset(); 1637 delegate->Reset();
1638 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 1638 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
1639 kTouchId, tes.LeapForward(1000)); 1639 kTouchId, tes.LeapForward(1000));
1640 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 1640 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1);
1641 EXPECT_FALSE(delegate->tap()); 1641 EXPECT_FALSE(delegate->tap());
1642 EXPECT_TRUE(delegate->tap_down()); 1642 EXPECT_TRUE(delegate->tap_down());
1643 EXPECT_FALSE(delegate->tap_cancel()); 1643 EXPECT_FALSE(delegate->tap_cancel());
1644 EXPECT_FALSE(delegate->scroll_begin()); 1644 EXPECT_FALSE(delegate->scroll_begin());
1645 EXPECT_FALSE(delegate->scroll_update()); 1645 EXPECT_FALSE(delegate->scroll_update());
1646 EXPECT_FALSE(delegate->scroll_end()); 1646 EXPECT_FALSE(delegate->scroll_end());
1647 1647
1648 // Move the touch-point enough so that it is considered as a scroll. This 1648 // Move the touch-point enough so that it is considered as a scroll. This
1649 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. 1649 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures.
1650 // The first movement is diagonal, to ensure that we have a free scroll, 1650 // The first movement is diagonal, to ensure that we have a free scroll,
1651 // and not a rail scroll. 1651 // and not a rail scroll.
1652 delegate->Reset(); 1652 delegate->Reset();
1653 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(130, 230), 1653 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(130, 230),
1654 kTouchId, tes.Now()); 1654 kTouchId, tes.Now());
1655 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move); 1655 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move);
1656 EXPECT_FALSE(delegate->tap()); 1656 EXPECT_FALSE(delegate->tap());
1657 EXPECT_FALSE(delegate->tap_down()); 1657 EXPECT_FALSE(delegate->tap_down());
1658 EXPECT_TRUE(delegate->tap_cancel()); 1658 EXPECT_TRUE(delegate->tap_cancel());
1659 EXPECT_TRUE(delegate->scroll_begin()); 1659 EXPECT_TRUE(delegate->scroll_begin());
1660 EXPECT_TRUE(delegate->scroll_update()); 1660 EXPECT_TRUE(delegate->scroll_update());
1661 EXPECT_FALSE(delegate->scroll_end()); 1661 EXPECT_FALSE(delegate->scroll_end());
1662 EXPECT_EQ(29, delegate->scroll_x()); 1662 EXPECT_EQ(29, delegate->scroll_x());
1663 EXPECT_EQ(29, delegate->scroll_y()); 1663 EXPECT_EQ(29, delegate->scroll_y());
1664 EXPECT_EQ(29, delegate->scroll_x_hint()); 1664 EXPECT_EQ(29, delegate->scroll_x_hint());
1665 EXPECT_EQ(29, delegate->scroll_y_hint()); 1665 EXPECT_EQ(29, delegate->scroll_y_hint());
1666 1666
1667 // Move some more to generate a few more scroll updates. 1667 // Move some more to generate a few more scroll updates.
1668 delegate->Reset(); 1668 delegate->Reset();
1669 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(110, 211), 1669 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(110, 211),
1670 kTouchId, tes.Now()); 1670 kTouchId, tes.Now());
1671 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move1); 1671 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move1);
1672 EXPECT_FALSE(delegate->tap()); 1672 EXPECT_FALSE(delegate->tap());
1673 EXPECT_FALSE(delegate->tap_down()); 1673 EXPECT_FALSE(delegate->tap_down());
1674 EXPECT_FALSE(delegate->tap_cancel()); 1674 EXPECT_FALSE(delegate->tap_cancel());
1675 EXPECT_FALSE(delegate->scroll_begin()); 1675 EXPECT_FALSE(delegate->scroll_begin());
1676 EXPECT_TRUE(delegate->scroll_update()); 1676 EXPECT_TRUE(delegate->scroll_update());
1677 EXPECT_FALSE(delegate->scroll_end()); 1677 EXPECT_FALSE(delegate->scroll_end());
1678 EXPECT_EQ(-20, delegate->scroll_x()); 1678 EXPECT_EQ(-20, delegate->scroll_x());
1679 EXPECT_EQ(-19, delegate->scroll_y()); 1679 EXPECT_EQ(-19, delegate->scroll_y());
1680 EXPECT_EQ(0, delegate->scroll_x_hint()); 1680 EXPECT_EQ(0, delegate->scroll_x_hint());
1681 EXPECT_EQ(0, delegate->scroll_y_hint()); 1681 EXPECT_EQ(0, delegate->scroll_y_hint());
1682 1682
1683 delegate->Reset(); 1683 delegate->Reset();
1684 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(140, 215), 1684 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(140, 215),
1685 kTouchId, tes.Now()); 1685 kTouchId, tes.Now());
1686 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2); 1686 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move2);
1687 EXPECT_FALSE(delegate->tap()); 1687 EXPECT_FALSE(delegate->tap());
1688 EXPECT_FALSE(delegate->tap_down()); 1688 EXPECT_FALSE(delegate->tap_down());
1689 EXPECT_FALSE(delegate->tap_cancel()); 1689 EXPECT_FALSE(delegate->tap_cancel());
1690 EXPECT_FALSE(delegate->scroll_begin()); 1690 EXPECT_FALSE(delegate->scroll_begin());
1691 EXPECT_TRUE(delegate->scroll_update()); 1691 EXPECT_TRUE(delegate->scroll_update());
1692 EXPECT_FALSE(delegate->scroll_end()); 1692 EXPECT_FALSE(delegate->scroll_end());
1693 EXPECT_EQ(30, delegate->scroll_x()); 1693 EXPECT_EQ(30, delegate->scroll_x());
1694 EXPECT_EQ(4, delegate->scroll_y()); 1694 EXPECT_EQ(4, delegate->scroll_y());
1695 1695
1696 // Release the touch. This should end the scroll. 1696 // Release the touch. This should end the scroll.
1697 delegate->Reset(); 1697 delegate->Reset();
1698 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 1698 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
1699 kTouchId, tes.Now()); 1699 kTouchId, tes.Now());
1700 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); 1700 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1);
1701 EXPECT_FALSE(delegate->tap()); 1701 EXPECT_FALSE(delegate->tap());
1702 EXPECT_FALSE(delegate->tap_down()); 1702 EXPECT_FALSE(delegate->tap_down());
1703 EXPECT_FALSE(delegate->tap_cancel()); 1703 EXPECT_FALSE(delegate->tap_cancel());
1704 EXPECT_FALSE(delegate->scroll_begin()); 1704 EXPECT_FALSE(delegate->scroll_begin());
1705 EXPECT_FALSE(delegate->scroll_update()); 1705 EXPECT_FALSE(delegate->scroll_update());
1706 EXPECT_FALSE(delegate->scroll_end()); 1706 EXPECT_FALSE(delegate->scroll_end());
1707 EXPECT_TRUE(delegate->fling()); 1707 EXPECT_TRUE(delegate->fling());
1708 } 1708 }
1709 1709
1710 TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) { 1710 TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
1711 scoped_ptr<QueueTouchEventDelegate> queued_delegate( 1711 scoped_ptr<QueueTouchEventDelegate> queued_delegate(
1712 new QueueTouchEventDelegate(dispatcher())); 1712 new QueueTouchEventDelegate(dispatcher()));
1713 const int kWindowWidth = 123; 1713 const int kWindowWidth = 123;
1714 const int kWindowHeight = 45; 1714 const int kWindowHeight = 45;
1715 const int kTouchId1 = 6; 1715 const int kTouchId1 = 6;
1716 const int kTouchId2 = 4; 1716 const int kTouchId2 = 4;
1717 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 1717 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
1718 scoped_ptr<aura::Window> queue(CreateTestWindowWithDelegate( 1718 scoped_ptr<aura::Window> queue(CreateTestWindowWithDelegate(
1719 queued_delegate.get(), -1234, bounds, root_window())); 1719 queued_delegate.get(), -1234, bounds, root_window()));
1720 1720
1721 queued_delegate->set_window(queue.get()); 1721 queued_delegate->set_window(queue.get());
1722 1722
1723 // Touch down on the window. This should not generate any gesture event. 1723 // Touch down on the window. This should not generate any gesture event.
1724 queued_delegate->Reset(); 1724 queued_delegate->Reset();
1725 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 1725 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
1726 kTouchId1, GetTime()); 1726 kTouchId1, GetTime());
1727 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 1727 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
1728 EXPECT_FALSE(queued_delegate->tap()); 1728 EXPECT_FALSE(queued_delegate->tap());
1729 EXPECT_FALSE(queued_delegate->tap_down()); 1729 EXPECT_FALSE(queued_delegate->tap_down());
1730 EXPECT_FALSE(queued_delegate->tap_cancel()); 1730 EXPECT_FALSE(queued_delegate->tap_cancel());
1731 EXPECT_FALSE(queued_delegate->begin()); 1731 EXPECT_FALSE(queued_delegate->begin());
1732 EXPECT_FALSE(queued_delegate->scroll_begin()); 1732 EXPECT_FALSE(queued_delegate->scroll_begin());
1733 EXPECT_FALSE(queued_delegate->scroll_update()); 1733 EXPECT_FALSE(queued_delegate->scroll_update());
1734 EXPECT_FALSE(queued_delegate->scroll_end()); 1734 EXPECT_FALSE(queued_delegate->scroll_end());
1735 1735
1736 // Introduce some delay before the touch is released so that it is recognized 1736 // Introduce some delay before the touch is released so that it is recognized
1737 // as a tap. However, this still should not create any gesture events. 1737 // as a tap. However, this still should not create any gesture events.
1738 queued_delegate->Reset(); 1738 queued_delegate->Reset();
1739 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 1739 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
1740 kTouchId1, press.time_stamp() + 1740 kTouchId1, press.time_stamp() +
1741 base::TimeDelta::FromMilliseconds(50)); 1741 base::TimeDelta::FromMilliseconds(50));
1742 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 1742 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
1743 EXPECT_FALSE(queued_delegate->tap()); 1743 EXPECT_FALSE(queued_delegate->tap());
1744 EXPECT_FALSE(queued_delegate->tap_down()); 1744 EXPECT_FALSE(queued_delegate->tap_down());
1745 EXPECT_FALSE(queued_delegate->tap_cancel()); 1745 EXPECT_FALSE(queued_delegate->tap_cancel());
1746 EXPECT_FALSE(queued_delegate->begin()); 1746 EXPECT_FALSE(queued_delegate->begin());
1747 EXPECT_FALSE(queued_delegate->end()); 1747 EXPECT_FALSE(queued_delegate->end());
1748 EXPECT_FALSE(queued_delegate->scroll_begin()); 1748 EXPECT_FALSE(queued_delegate->scroll_begin());
1749 EXPECT_FALSE(queued_delegate->scroll_update()); 1749 EXPECT_FALSE(queued_delegate->scroll_update());
1750 EXPECT_FALSE(queued_delegate->scroll_end()); 1750 EXPECT_FALSE(queued_delegate->scroll_end());
1751 1751
1752 // Create another window, and place a touch-down on it. This should create a 1752 // Create another window, and place a touch-down on it. This should create a
1753 // tap-down gesture. 1753 // tap-down gesture.
1754 scoped_ptr<GestureEventConsumeDelegate> delegate( 1754 scoped_ptr<GestureEventConsumeDelegate> delegate(
1755 new GestureEventConsumeDelegate()); 1755 new GestureEventConsumeDelegate());
1756 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1756 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1757 delegate.get(), -2345, gfx::Rect(0, 0, 50, 50), root_window())); 1757 delegate.get(), -2345, gfx::Rect(0, 0, 50, 50), root_window()));
1758 delegate->Reset(); 1758 delegate->Reset();
1759 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 20), 1759 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 20),
1760 kTouchId2, GetTime()); 1760 kTouchId2, GetTime());
1761 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 1761 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2);
1762 EXPECT_FALSE(delegate->tap()); 1762 EXPECT_FALSE(delegate->tap());
1763 EXPECT_TRUE(delegate->tap_down()); 1763 EXPECT_TRUE(delegate->tap_down());
1764 EXPECT_FALSE(delegate->tap_cancel()); 1764 EXPECT_FALSE(delegate->tap_cancel());
1765 EXPECT_FALSE(queued_delegate->begin()); 1765 EXPECT_FALSE(queued_delegate->begin());
1766 EXPECT_FALSE(queued_delegate->end()); 1766 EXPECT_FALSE(queued_delegate->end());
1767 EXPECT_FALSE(delegate->scroll_begin()); 1767 EXPECT_FALSE(delegate->scroll_begin());
1768 EXPECT_FALSE(delegate->scroll_update()); 1768 EXPECT_FALSE(delegate->scroll_update());
1769 EXPECT_FALSE(delegate->scroll_end()); 1769 EXPECT_FALSE(delegate->scroll_end());
1770 1770
1771 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(10, 20), 1771 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(10, 20),
1772 kTouchId2, GetTime()); 1772 kTouchId2, GetTime());
1773 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release2); 1773 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release2);
1774 1774
1775 // Process the first queued event. 1775 // Process the first queued event.
1776 queued_delegate->Reset(); 1776 queued_delegate->Reset();
1777 queued_delegate->ReceivedAck(); 1777 queued_delegate->ReceivedAck();
1778 EXPECT_FALSE(queued_delegate->tap()); 1778 EXPECT_FALSE(queued_delegate->tap());
1779 EXPECT_TRUE(queued_delegate->tap_down()); 1779 EXPECT_TRUE(queued_delegate->tap_down());
1780 EXPECT_TRUE(queued_delegate->begin()); 1780 EXPECT_TRUE(queued_delegate->begin());
1781 EXPECT_FALSE(queued_delegate->tap_cancel()); 1781 EXPECT_FALSE(queued_delegate->tap_cancel());
1782 EXPECT_FALSE(queued_delegate->end()); 1782 EXPECT_FALSE(queued_delegate->end());
1783 EXPECT_FALSE(queued_delegate->scroll_begin()); 1783 EXPECT_FALSE(queued_delegate->scroll_begin());
(...skipping 10 matching lines...) Expand all
1794 EXPECT_TRUE(queued_delegate->end()); 1794 EXPECT_TRUE(queued_delegate->end());
1795 EXPECT_FALSE(queued_delegate->scroll_begin()); 1795 EXPECT_FALSE(queued_delegate->scroll_begin());
1796 EXPECT_FALSE(queued_delegate->scroll_update()); 1796 EXPECT_FALSE(queued_delegate->scroll_update());
1797 EXPECT_FALSE(queued_delegate->scroll_end()); 1797 EXPECT_FALSE(queued_delegate->scroll_end());
1798 1798
1799 // Start all over. Press on the first window, then press again on the second 1799 // Start all over. Press on the first window, then press again on the second
1800 // window. The second press should still go to the first window. 1800 // window. The second press should still go to the first window.
1801 queued_delegate->Reset(); 1801 queued_delegate->Reset();
1802 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 1802 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
1803 kTouchId1, GetTime()); 1803 kTouchId1, GetTime());
1804 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press3); 1804 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press3);
1805 EXPECT_FALSE(queued_delegate->tap()); 1805 EXPECT_FALSE(queued_delegate->tap());
1806 EXPECT_FALSE(queued_delegate->tap_down()); 1806 EXPECT_FALSE(queued_delegate->tap_down());
1807 EXPECT_FALSE(queued_delegate->tap_cancel()); 1807 EXPECT_FALSE(queued_delegate->tap_cancel());
1808 EXPECT_FALSE(queued_delegate->begin()); 1808 EXPECT_FALSE(queued_delegate->begin());
1809 EXPECT_FALSE(queued_delegate->end()); 1809 EXPECT_FALSE(queued_delegate->end());
1810 EXPECT_FALSE(queued_delegate->begin()); 1810 EXPECT_FALSE(queued_delegate->begin());
1811 EXPECT_FALSE(queued_delegate->end()); 1811 EXPECT_FALSE(queued_delegate->end());
1812 EXPECT_FALSE(queued_delegate->scroll_begin()); 1812 EXPECT_FALSE(queued_delegate->scroll_begin());
1813 EXPECT_FALSE(queued_delegate->scroll_update()); 1813 EXPECT_FALSE(queued_delegate->scroll_update());
1814 EXPECT_FALSE(queued_delegate->scroll_end()); 1814 EXPECT_FALSE(queued_delegate->scroll_end());
1815 1815
1816 queued_delegate->Reset(); 1816 queued_delegate->Reset();
1817 delegate->Reset(); 1817 delegate->Reset();
1818 ui::TouchEvent press4(ui::ET_TOUCH_PRESSED, gfx::Point(103, 203), 1818 ui::TouchEvent press4(ui::ET_TOUCH_PRESSED, gfx::Point(103, 203),
1819 kTouchId2, GetTime()); 1819 kTouchId2, GetTime());
1820 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press4); 1820 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press4);
1821 EXPECT_FALSE(delegate->tap()); 1821 EXPECT_FALSE(delegate->tap());
1822 EXPECT_FALSE(delegate->tap_down()); 1822 EXPECT_FALSE(delegate->tap_down());
1823 EXPECT_FALSE(delegate->tap_cancel()); 1823 EXPECT_FALSE(delegate->tap_cancel());
1824 EXPECT_FALSE(delegate->begin()); 1824 EXPECT_FALSE(delegate->begin());
1825 EXPECT_FALSE(delegate->end()); 1825 EXPECT_FALSE(delegate->end());
1826 EXPECT_FALSE(delegate->scroll_begin()); 1826 EXPECT_FALSE(delegate->scroll_begin());
1827 EXPECT_FALSE(delegate->scroll_update()); 1827 EXPECT_FALSE(delegate->scroll_update());
1828 EXPECT_FALSE(delegate->scroll_end()); 1828 EXPECT_FALSE(delegate->scroll_end());
1829 EXPECT_FALSE(queued_delegate->tap()); 1829 EXPECT_FALSE(queued_delegate->tap());
1830 EXPECT_FALSE(queued_delegate->tap_down()); 1830 EXPECT_FALSE(queued_delegate->tap_down());
1831 EXPECT_FALSE(queued_delegate->tap_cancel()); 1831 EXPECT_FALSE(queued_delegate->tap_cancel());
1832 EXPECT_FALSE(queued_delegate->begin()); 1832 EXPECT_FALSE(queued_delegate->begin());
1833 EXPECT_FALSE(queued_delegate->end()); 1833 EXPECT_FALSE(queued_delegate->end());
1834 EXPECT_FALSE(queued_delegate->scroll_begin()); 1834 EXPECT_FALSE(queued_delegate->scroll_begin());
1835 EXPECT_FALSE(queued_delegate->scroll_update()); 1835 EXPECT_FALSE(queued_delegate->scroll_update());
1836 EXPECT_FALSE(queued_delegate->scroll_end()); 1836 EXPECT_FALSE(queued_delegate->scroll_end());
1837 1837
1838 // Move the second touch-point enough so that it is considered a pinch. This 1838 // Move the second touch-point enough so that it is considered a pinch. This
1839 // should generate both SCROLL_BEGIN and PINCH_BEGIN gestures. 1839 // should generate both SCROLL_BEGIN and PINCH_BEGIN gestures.
1840 queued_delegate->Reset(); 1840 queued_delegate->Reset();
1841 delegate->Reset(); 1841 delegate->Reset();
1842 int x_move = ui::GestureConfiguration::max_touch_move_in_pixels_for_click(); 1842 int x_move = ui::GestureConfiguration::max_touch_move_in_pixels_for_click();
1843 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(103 + x_move, 203), 1843 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(103 + x_move, 203),
1844 kTouchId2, GetTime()); 1844 kTouchId2, GetTime());
1845 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move); 1845 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move);
1846 EXPECT_FALSE(delegate->tap()); 1846 EXPECT_FALSE(delegate->tap());
1847 EXPECT_FALSE(delegate->tap_down()); 1847 EXPECT_FALSE(delegate->tap_down());
1848 EXPECT_FALSE(delegate->tap_cancel()); 1848 EXPECT_FALSE(delegate->tap_cancel());
1849 EXPECT_FALSE(delegate->begin()); 1849 EXPECT_FALSE(delegate->begin());
1850 EXPECT_FALSE(delegate->scroll_begin()); 1850 EXPECT_FALSE(delegate->scroll_begin());
1851 EXPECT_FALSE(delegate->scroll_update()); 1851 EXPECT_FALSE(delegate->scroll_update());
1852 EXPECT_FALSE(delegate->scroll_end()); 1852 EXPECT_FALSE(delegate->scroll_end());
1853 EXPECT_FALSE(queued_delegate->tap()); 1853 EXPECT_FALSE(queued_delegate->tap());
1854 EXPECT_FALSE(queued_delegate->tap_down()); 1854 EXPECT_FALSE(queued_delegate->tap_down());
1855 EXPECT_FALSE(queued_delegate->tap_cancel()); 1855 EXPECT_FALSE(queued_delegate->tap_cancel());
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1909 const int kTouchId2 = 3; 1909 const int kTouchId2 = 3;
1910 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); 1910 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight);
1911 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1911 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1912 delegate.get(), -1234, bounds, root_window())); 1912 delegate.get(), -1234, bounds, root_window()));
1913 1913
1914 aura::RootWindow* root = dispatcher(); 1914 aura::RootWindow* root = dispatcher();
1915 1915
1916 delegate->Reset(); 1916 delegate->Reset();
1917 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 1917 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
1918 kTouchId1, tes.Now()); 1918 kTouchId1, tes.Now());
1919 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 1919 root->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
1920 EXPECT_2_EVENTS(delegate->events(), 1920 EXPECT_2_EVENTS(delegate->events(),
1921 ui::ET_GESTURE_BEGIN, 1921 ui::ET_GESTURE_BEGIN,
1922 ui::ET_GESTURE_TAP_DOWN); 1922 ui::ET_GESTURE_TAP_DOWN);
1923 1923
1924 // Move the touch-point enough so that it is considered as a scroll. This 1924 // Move the touch-point enough so that it is considered as a scroll. This
1925 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. 1925 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures.
1926 delegate->Reset(); 1926 delegate->Reset();
1927 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(130, 301), 1927 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(130, 301),
1928 kTouchId1, tes.Now()); 1928 kTouchId1, tes.Now());
1929 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&move); 1929 root->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move);
1930 EXPECT_3_EVENTS(delegate->events(), 1930 EXPECT_3_EVENTS(delegate->events(),
1931 ui::ET_GESTURE_TAP_CANCEL, 1931 ui::ET_GESTURE_TAP_CANCEL,
1932 ui::ET_GESTURE_SCROLL_BEGIN, 1932 ui::ET_GESTURE_SCROLL_BEGIN,
1933 ui::ET_GESTURE_SCROLL_UPDATE); 1933 ui::ET_GESTURE_SCROLL_UPDATE);
1934 1934
1935 // Press the second finger. It should cause pinch-begin. Note that we will not 1935 // Press the second finger. It should cause pinch-begin. Note that we will not
1936 // transition to two finger tap here because the touch points are far enough. 1936 // transition to two finger tap here because the touch points are far enough.
1937 delegate->Reset(); 1937 delegate->Reset();
1938 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1938 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10),
1939 kTouchId2, tes.Now()); 1939 kTouchId2, tes.Now());
1940 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 1940 root->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2);
1941 EXPECT_2_EVENTS(delegate->events(), 1941 EXPECT_2_EVENTS(delegate->events(),
1942 ui::ET_GESTURE_BEGIN, 1942 ui::ET_GESTURE_BEGIN,
1943 ui::ET_GESTURE_PINCH_BEGIN); 1943 ui::ET_GESTURE_PINCH_BEGIN);
1944 EXPECT_EQ(gfx::Rect(10, 10, 120, 291).ToString(), 1944 EXPECT_EQ(gfx::Rect(10, 10, 120, 291).ToString(),
1945 delegate->bounding_box().ToString()); 1945 delegate->bounding_box().ToString());
1946 1946
1947 // Move the first finger. 1947 // Move the first finger.
1948 delegate->Reset(); 1948 delegate->Reset();
1949 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(95, 201), 1949 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(95, 201),
1950 kTouchId1, tes.Now()); 1950 kTouchId1, tes.Now());
1951 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&move3); 1951 root->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move3);
1952 EXPECT_2_EVENTS(delegate->events(), 1952 EXPECT_2_EVENTS(delegate->events(),
1953 ui::ET_GESTURE_PINCH_UPDATE, 1953 ui::ET_GESTURE_PINCH_UPDATE,
1954 ui::ET_GESTURE_SCROLL_UPDATE); 1954 ui::ET_GESTURE_SCROLL_UPDATE);
1955 EXPECT_EQ(gfx::Rect(10, 10, 85, 191).ToString(), 1955 EXPECT_EQ(gfx::Rect(10, 10, 85, 191).ToString(),
1956 delegate->bounding_box().ToString()); 1956 delegate->bounding_box().ToString());
1957 1957
1958 // Now move the second finger. 1958 // Now move the second finger.
1959 delegate->Reset(); 1959 delegate->Reset();
1960 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(55, 15), 1960 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(55, 15),
1961 kTouchId2, tes.Now()); 1961 kTouchId2, tes.Now());
1962 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&move4); 1962 root->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move4);
1963 EXPECT_2_EVENTS(delegate->events(), 1963 EXPECT_2_EVENTS(delegate->events(),
1964 ui::ET_GESTURE_PINCH_UPDATE, 1964 ui::ET_GESTURE_PINCH_UPDATE,
1965 ui::ET_GESTURE_SCROLL_UPDATE); 1965 ui::ET_GESTURE_SCROLL_UPDATE);
1966 EXPECT_EQ(gfx::Rect(55, 15, 40, 186).ToString(), 1966 EXPECT_EQ(gfx::Rect(55, 15, 40, 186).ToString(),
1967 delegate->bounding_box().ToString()); 1967 delegate->bounding_box().ToString());
1968 1968
1969 // Release the first finger. This should end pinch. 1969 // Release the first finger. This should end pinch.
1970 delegate->Reset(); 1970 delegate->Reset();
1971 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 1971 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
1972 kTouchId1, tes.Now()); 1972 kTouchId1, tes.Now());
1973 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 1973 root->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
1974 EXPECT_2_EVENTS(delegate->events(), 1974 EXPECT_2_EVENTS(delegate->events(),
1975 ui::ET_GESTURE_PINCH_END, 1975 ui::ET_GESTURE_PINCH_END,
1976 ui::ET_GESTURE_END); 1976 ui::ET_GESTURE_END);
1977 EXPECT_EQ(gfx::Rect(55, 15, 46, 186).ToString(), 1977 EXPECT_EQ(gfx::Rect(55, 15, 46, 186).ToString(),
1978 delegate->bounding_box().ToString()); 1978 delegate->bounding_box().ToString());
1979 1979
1980 // Move the second finger. This should still generate a scroll. 1980 // Move the second finger. This should still generate a scroll.
1981 delegate->Reset(); 1981 delegate->Reset();
1982 ui::TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), 1982 ui::TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10),
1983 kTouchId2, tes.Now()); 1983 kTouchId2, tes.Now());
1984 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&move5); 1984 root->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move5);
1985 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); 1985 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE);
1986 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); 1986 EXPECT_TRUE(delegate->bounding_box().IsEmpty());
1987 } 1987 }
1988 1988
1989 TEST_F(GestureRecognizerTest, GestureEventPinchFromScrollFromPinch) { 1989 TEST_F(GestureRecognizerTest, GestureEventPinchFromScrollFromPinch) {
1990 scoped_ptr<GestureEventConsumeDelegate> delegate( 1990 scoped_ptr<GestureEventConsumeDelegate> delegate(
1991 new GestureEventConsumeDelegate()); 1991 new GestureEventConsumeDelegate());
1992 TimedEvents tes; 1992 TimedEvents tes;
1993 const int kWindowWidth = 300; 1993 const int kWindowWidth = 300;
1994 const int kWindowHeight = 400; 1994 const int kWindowHeight = 400;
1995 const int kTouchId1 = 5; 1995 const int kTouchId1 = 5;
1996 const int kTouchId2 = 3; 1996 const int kTouchId2 = 3;
1997 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); 1997 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight);
1998 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1998 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1999 delegate.get(), -1234, bounds, root_window())); 1999 delegate.get(), -1234, bounds, root_window()));
2000 2000
2001 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), 2001 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 301),
2002 kTouchId1, tes.Now()); 2002 kTouchId1, tes.Now());
2003 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 2003 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
2004 delegate->Reset(); 2004 delegate->Reset();
2005 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 2005 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10),
2006 kTouchId2, tes.Now()); 2006 kTouchId2, tes.Now());
2007 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 2007 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2);
2008 EXPECT_FALSE(delegate->pinch_begin()); 2008 EXPECT_FALSE(delegate->pinch_begin());
2009 2009
2010 // Touch move triggers pinch begin. 2010 // Touch move triggers pinch begin.
2011 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId1, delegate.get()); 2011 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId1, delegate.get());
2012 EXPECT_TRUE(delegate->pinch_begin()); 2012 EXPECT_TRUE(delegate->pinch_begin());
2013 EXPECT_FALSE(delegate->pinch_update()); 2013 EXPECT_FALSE(delegate->pinch_update());
2014 2014
2015 // Touch move triggers pinch update. 2015 // Touch move triggers pinch update.
2016 tes.SendScrollEvent(dispatcher(), 160, 200, kTouchId1, delegate.get()); 2016 tes.SendScrollEvent(dispatcher(), 160, 200, kTouchId1, delegate.get());
2017 EXPECT_FALSE(delegate->pinch_begin()); 2017 EXPECT_FALSE(delegate->pinch_begin());
2018 EXPECT_TRUE(delegate->pinch_update()); 2018 EXPECT_TRUE(delegate->pinch_update());
2019 2019
2020 // Pinch has started, now release the second finger 2020 // Pinch has started, now release the second finger
2021 delegate->Reset(); 2021 delegate->Reset();
2022 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 2022 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
2023 kTouchId1, tes.Now()); 2023 kTouchId1, tes.Now());
2024 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 2024 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
2025 EXPECT_TRUE(delegate->pinch_end()); 2025 EXPECT_TRUE(delegate->pinch_end());
2026 2026
2027 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId2, delegate.get()); 2027 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId2, delegate.get());
2028 EXPECT_TRUE(delegate->scroll_update()); 2028 EXPECT_TRUE(delegate->scroll_update());
2029 2029
2030 // Pinch again 2030 // Pinch again
2031 delegate->Reset(); 2031 delegate->Reset();
2032 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 2032 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10),
2033 kTouchId1, tes.Now()); 2033 kTouchId1, tes.Now());
2034 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press3); 2034 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press3);
2035 // Now the touch points are close. So we will go into two finger tap. 2035 // Now the touch points are close. So we will go into two finger tap.
2036 // Move the touch-point enough to break two-finger-tap and enter pinch. 2036 // Move the touch-point enough to break two-finger-tap and enter pinch.
2037 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(101, 202), 2037 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(101, 202),
2038 kTouchId1, tes.Now()); 2038 kTouchId1, tes.Now());
2039 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2); 2039 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move2);
2040 EXPECT_TRUE(delegate->pinch_begin()); 2040 EXPECT_TRUE(delegate->pinch_begin());
2041 2041
2042 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId1, delegate.get()); 2042 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId1, delegate.get());
2043 EXPECT_TRUE(delegate->pinch_update()); 2043 EXPECT_TRUE(delegate->pinch_update());
2044 } 2044 }
2045 2045
2046 TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) { 2046 TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) {
2047 scoped_ptr<GestureEventConsumeDelegate> delegate( 2047 scoped_ptr<GestureEventConsumeDelegate> delegate(
2048 new GestureEventConsumeDelegate()); 2048 new GestureEventConsumeDelegate());
2049 TimedEvents tes; 2049 TimedEvents tes;
2050 const int kWindowWidth = 300; 2050 const int kWindowWidth = 300;
2051 const int kWindowHeight = 400; 2051 const int kWindowHeight = 400;
2052 const int kTouchId1 = 3; 2052 const int kTouchId1 = 3;
2053 const int kTouchId2 = 5; 2053 const int kTouchId2 = 5;
2054 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); 2054 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight);
2055 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2055 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2056 delegate.get(), -1234, bounds, root_window())); 2056 delegate.get(), -1234, bounds, root_window()));
2057 2057
2058 aura::RootWindow* root = dispatcher(); 2058 aura::RootWindow* root = dispatcher();
2059 2059
2060 delegate->Reset(); 2060 delegate->Reset();
2061 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), 2061 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 301),
2062 kTouchId1, tes.Now()); 2062 kTouchId1, tes.Now());
2063 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 2063 root->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
2064 EXPECT_2_EVENTS(delegate->events(), 2064 EXPECT_2_EVENTS(delegate->events(),
2065 ui::ET_GESTURE_BEGIN, 2065 ui::ET_GESTURE_BEGIN,
2066 ui::ET_GESTURE_TAP_DOWN); 2066 ui::ET_GESTURE_TAP_DOWN);
2067 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); 2067 EXPECT_TRUE(delegate->bounding_box().IsEmpty());
2068 2068
2069 // Press the second finger far enough to break two finger tap. 2069 // Press the second finger far enough to break two finger tap.
2070 delegate->Reset(); 2070 delegate->Reset();
2071 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 2071 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10),
2072 kTouchId2, tes.Now()); 2072 kTouchId2, tes.Now());
2073 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 2073 root->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2);
2074 EXPECT_2_EVENTS(delegate->events(), 2074 EXPECT_2_EVENTS(delegate->events(),
2075 ui::ET_GESTURE_TAP_CANCEL, 2075 ui::ET_GESTURE_TAP_CANCEL,
2076 ui::ET_GESTURE_BEGIN); 2076 ui::ET_GESTURE_BEGIN);
2077 EXPECT_EQ(gfx::Rect(10, 10, 91, 291).ToString(), 2077 EXPECT_EQ(gfx::Rect(10, 10, 91, 291).ToString(),
2078 delegate->bounding_box().ToString()); 2078 delegate->bounding_box().ToString());
2079 2079
2080 // Move the first finger. 2080 // Move the first finger.
2081 delegate->Reset(); 2081 delegate->Reset();
2082 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(65, 201), 2082 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(65, 201),
2083 kTouchId1, tes.Now()); 2083 kTouchId1, tes.Now());
2084 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&move3); 2084 root->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move3);
2085 EXPECT_2_EVENTS(delegate->events(), 2085 EXPECT_2_EVENTS(delegate->events(),
2086 ui::ET_GESTURE_PINCH_BEGIN, 2086 ui::ET_GESTURE_PINCH_BEGIN,
2087 ui::ET_GESTURE_SCROLL_BEGIN); 2087 ui::ET_GESTURE_SCROLL_BEGIN);
2088 EXPECT_EQ(gfx::Rect(10, 10, 55, 191).ToString(), 2088 EXPECT_EQ(gfx::Rect(10, 10, 55, 191).ToString(),
2089 delegate->bounding_box().ToString()); 2089 delegate->bounding_box().ToString());
2090 2090
2091 // Now move the second finger. 2091 // Now move the second finger.
2092 delegate->Reset(); 2092 delegate->Reset();
2093 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(55, 15), 2093 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(55, 15),
2094 kTouchId2, tes.Now()); 2094 kTouchId2, tes.Now());
2095 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&move4); 2095 root->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move4);
2096 EXPECT_2_EVENTS(delegate->events(), 2096 EXPECT_2_EVENTS(delegate->events(),
2097 ui::ET_GESTURE_PINCH_UPDATE, 2097 ui::ET_GESTURE_PINCH_UPDATE,
2098 ui::ET_GESTURE_SCROLL_UPDATE); 2098 ui::ET_GESTURE_SCROLL_UPDATE);
2099 EXPECT_EQ(gfx::Rect(55, 15, 10, 186).ToString(), 2099 EXPECT_EQ(gfx::Rect(55, 15, 10, 186).ToString(),
2100 delegate->bounding_box().ToString()); 2100 delegate->bounding_box().ToString());
2101 2101
2102 // Release the first finger. This should end pinch. 2102 // Release the first finger. This should end pinch.
2103 delegate->Reset(); 2103 delegate->Reset();
2104 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 2104 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
2105 kTouchId1, tes.LeapForward(10)); 2105 kTouchId1, tes.LeapForward(10));
2106 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 2106 root->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
2107 EXPECT_2_EVENTS(delegate->events(), 2107 EXPECT_2_EVENTS(delegate->events(),
2108 ui::ET_GESTURE_PINCH_END, 2108 ui::ET_GESTURE_PINCH_END,
2109 ui::ET_GESTURE_END); 2109 ui::ET_GESTURE_END);
2110 EXPECT_EQ(gfx::Rect(55, 15, 46, 186).ToString(), 2110 EXPECT_EQ(gfx::Rect(55, 15, 46, 186).ToString(),
2111 delegate->bounding_box().ToString()); 2111 delegate->bounding_box().ToString());
2112 2112
2113 // Move the second finger. This should still generate a scroll. 2113 // Move the second finger. This should still generate a scroll.
2114 delegate->Reset(); 2114 delegate->Reset();
2115 ui::TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), 2115 ui::TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10),
2116 kTouchId2, tes.Now()); 2116 kTouchId2, tes.Now());
2117 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&move5); 2117 root->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move5);
2118 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); 2118 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE);
2119 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); 2119 EXPECT_TRUE(delegate->bounding_box().IsEmpty());
2120 } 2120 }
2121 2121
2122 TEST_F(GestureRecognizerTest, GestureEventIgnoresDisconnectedEvents) { 2122 TEST_F(GestureRecognizerTest, GestureEventIgnoresDisconnectedEvents) {
2123 scoped_ptr<GestureEventConsumeDelegate> delegate( 2123 scoped_ptr<GestureEventConsumeDelegate> delegate(
2124 new GestureEventConsumeDelegate()); 2124 new GestureEventConsumeDelegate());
2125 TimedEvents tes; 2125 TimedEvents tes;
2126 2126
2127 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 2127 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
2128 6, tes.Now()); 2128 6, tes.Now());
2129 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); 2129 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1);
2130 EXPECT_FALSE(delegate->tap()); 2130 EXPECT_FALSE(delegate->tap());
2131 EXPECT_FALSE(delegate->tap_down()); 2131 EXPECT_FALSE(delegate->tap_down());
2132 } 2132 }
2133 2133
2134 // Check that a touch is locked to the window of the closest current touch 2134 // Check that a touch is locked to the window of the closest current touch
2135 // within max_separation_for_gesture_touches_in_pixels 2135 // within max_separation_for_gesture_touches_in_pixels
2136 TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) { 2136 TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) {
2137 ui::GestureRecognizer* gesture_recognizer = new ui::GestureRecognizerImpl(); 2137 ui::GestureRecognizer* gesture_recognizer = new ui::GestureRecognizerImpl();
2138 TimedEvents tes; 2138 TimedEvents tes;
2139 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); 2139 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer);
(...skipping 17 matching lines...) Expand all
2157 2157
2158 // Instantiate windows with |window_bounds| and touch each window at 2158 // Instantiate windows with |window_bounds| and touch each window at
2159 // its origin. 2159 // its origin.
2160 for (int i = 0; i < kNumWindows; ++i) { 2160 for (int i = 0; i < kNumWindows; ++i) {
2161 delegates[i] = new GestureEventConsumeDelegate(); 2161 delegates[i] = new GestureEventConsumeDelegate();
2162 windows[i] = CreateTestWindowWithDelegate( 2162 windows[i] = CreateTestWindowWithDelegate(
2163 delegates[i], i, window_bounds[i], root_window()); 2163 delegates[i], i, window_bounds[i], root_window());
2164 windows[i]->set_id(i); 2164 windows[i]->set_id(i);
2165 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, window_bounds[i].origin(), 2165 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, window_bounds[i].origin(),
2166 i, tes.Now()); 2166 i, tes.Now());
2167 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 2167 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
2168 } 2168 }
2169 2169
2170 // Touches should now be associated with the closest touch within 2170 // Touches should now be associated with the closest touch within
2171 // ui::GestureConfiguration::max_separation_for_gesture_touches_in_pixels 2171 // ui::GestureConfiguration::max_separation_for_gesture_touches_in_pixels
2172 target = gesture_recognizer->GetTargetForLocation(gfx::Point(11, 11)); 2172 target = gesture_recognizer->GetTargetForLocation(gfx::Point(11, 11));
2173 EXPECT_EQ("0", WindowIDAsString(target)); 2173 EXPECT_EQ("0", WindowIDAsString(target));
2174 target = gesture_recognizer->GetTargetForLocation(gfx::Point(511, 11)); 2174 target = gesture_recognizer->GetTargetForLocation(gfx::Point(511, 11));
2175 EXPECT_EQ("1", WindowIDAsString(target)); 2175 EXPECT_EQ("1", WindowIDAsString(target));
2176 target = gesture_recognizer->GetTargetForLocation(gfx::Point(11, 511)); 2176 target = gesture_recognizer->GetTargetForLocation(gfx::Point(11, 511));
2177 EXPECT_EQ("2", WindowIDAsString(target)); 2177 EXPECT_EQ("2", WindowIDAsString(target));
2178 target = gesture_recognizer->GetTargetForLocation(gfx::Point(511, 511)); 2178 target = gesture_recognizer->GetTargetForLocation(gfx::Point(511, 511));
2179 EXPECT_EQ("3", WindowIDAsString(target)); 2179 EXPECT_EQ("3", WindowIDAsString(target));
2180 2180
2181 // Add a touch in the middle associated with windows[2] 2181 // Add a touch in the middle associated with windows[2]
2182 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 500), 2182 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 500),
2183 kNumWindows, tes.Now()); 2183 kNumWindows, tes.Now());
2184 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 2184 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
2185 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(250, 250), 2185 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(250, 250),
2186 kNumWindows, tes.Now()); 2186 kNumWindows, tes.Now());
2187 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move); 2187 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move);
2188 2188
2189 target = gesture_recognizer->GetTargetForLocation(gfx::Point(250, 250)); 2189 target = gesture_recognizer->GetTargetForLocation(gfx::Point(250, 250));
2190 EXPECT_EQ("2", WindowIDAsString(target)); 2190 EXPECT_EQ("2", WindowIDAsString(target));
2191 2191
2192 // Make sure that ties are broken by distance to a current touch 2192 // Make sure that ties are broken by distance to a current touch
2193 // Closer to the point in the bottom right. 2193 // Closer to the point in the bottom right.
2194 target = gesture_recognizer->GetTargetForLocation(gfx::Point(380, 380)); 2194 target = gesture_recognizer->GetTargetForLocation(gfx::Point(380, 380));
2195 EXPECT_EQ("3", WindowIDAsString(target)); 2195 EXPECT_EQ("3", WindowIDAsString(target));
2196 2196
2197 // This touch is closer to the point in the middle 2197 // This touch is closer to the point in the middle
2198 target = gesture_recognizer->GetTargetForLocation(gfx::Point(300, 300)); 2198 target = gesture_recognizer->GetTargetForLocation(gfx::Point(300, 300));
2199 EXPECT_EQ("2", WindowIDAsString(target)); 2199 EXPECT_EQ("2", WindowIDAsString(target));
2200 2200
2201 // A touch too far from other touches won't be locked to anything 2201 // A touch too far from other touches won't be locked to anything
2202 target = gesture_recognizer->GetTargetForLocation(gfx::Point(1000, 1000)); 2202 target = gesture_recognizer->GetTargetForLocation(gfx::Point(1000, 1000));
2203 EXPECT_TRUE(target == NULL); 2203 EXPECT_TRUE(target == NULL);
2204 2204
2205 // Move a touch associated with windows[2] to 1000, 1000 2205 // Move a touch associated with windows[2] to 1000, 1000
2206 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(1000, 1000), 2206 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(1000, 1000),
2207 kNumWindows, tes.Now()); 2207 kNumWindows, tes.Now());
2208 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2); 2208 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move2);
2209 2209
2210 target = gesture_recognizer->GetTargetForLocation(gfx::Point(1000, 1000)); 2210 target = gesture_recognizer->GetTargetForLocation(gfx::Point(1000, 1000));
2211 EXPECT_EQ("2", WindowIDAsString(target)); 2211 EXPECT_EQ("2", WindowIDAsString(target));
2212 2212
2213 for (int i = 0; i < kNumWindows; ++i) { 2213 for (int i = 0; i < kNumWindows; ++i) {
2214 // Delete windows before deleting delegates. 2214 // Delete windows before deleting delegates.
2215 delete windows[i]; 2215 delete windows[i];
2216 delete delegates[i]; 2216 delete delegates[i];
2217 } 2217 }
2218 } 2218 }
(...skipping 10 matching lines...) Expand all
2229 gfx::Rect(-100, -100, 2000, 2000), root_window())); 2229 gfx::Rect(-100, -100, 2000, 2000), root_window()));
2230 2230
2231 ui::GestureSequence* window_gesture_sequence = 2231 ui::GestureSequence* window_gesture_sequence =
2232 gesture_recognizer->GetGestureSequenceForTesting(window.get()); 2232 gesture_recognizer->GetGestureSequenceForTesting(window.get());
2233 2233
2234 ui::GestureSequence* root_window_gesture_sequence = 2234 ui::GestureSequence* root_window_gesture_sequence =
2235 gesture_recognizer->GetGestureSequenceForTesting(root_window()); 2235 gesture_recognizer->GetGestureSequenceForTesting(root_window());
2236 2236
2237 gfx::Point pos1(-10, -10); 2237 gfx::Point pos1(-10, -10);
2238 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, pos1, 0, tes.Now()); 2238 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, pos1, 0, tes.Now());
2239 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 2239 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1);
2240 2240
2241 gfx::Point pos2(1000, 1000); 2241 gfx::Point pos2(1000, 1000);
2242 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, pos2, 1, tes.Now()); 2242 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, pos2, 1, tes.Now());
2243 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 2243 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2);
2244 2244
2245 // As these presses were outside the root window, they should be 2245 // As these presses were outside the root window, they should be
2246 // associated with the root window. 2246 // associated with the root window.
2247 EXPECT_EQ(0, window_gesture_sequence->point_count()); 2247 EXPECT_EQ(0, window_gesture_sequence->point_count());
2248 EXPECT_EQ(2, root_window_gesture_sequence->point_count()); 2248 EXPECT_EQ(2, root_window_gesture_sequence->point_count());
2249 } 2249 }
2250 2250
2251 TEST_F(GestureRecognizerTest, NoTapWithPreventDefaultedRelease) { 2251 TEST_F(GestureRecognizerTest, NoTapWithPreventDefaultedRelease) {
2252 scoped_ptr<QueueTouchEventDelegate> delegate( 2252 scoped_ptr<QueueTouchEventDelegate> delegate(
2253 new QueueTouchEventDelegate(dispatcher())); 2253 new QueueTouchEventDelegate(dispatcher()));
2254 TimedEvents tes; 2254 TimedEvents tes;
2255 const int kTouchId = 2; 2255 const int kTouchId = 2;
2256 gfx::Rect bounds(100, 200, 100, 100); 2256 gfx::Rect bounds(100, 200, 100, 100);
2257 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2257 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2258 delegate.get(), -1234, bounds, root_window())); 2258 delegate.get(), -1234, bounds, root_window()));
2259 delegate->set_window(window.get()); 2259 delegate->set_window(window.get());
2260 2260
2261 delegate->Reset(); 2261 delegate->Reset();
2262 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2262 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
2263 kTouchId, tes.Now()); 2263 kTouchId, tes.Now());
2264 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 2264 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
2265 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 2265 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
2266 kTouchId, tes.LeapForward(50)); 2266 kTouchId, tes.LeapForward(50));
2267 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 2267 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
2268 2268
2269 delegate->Reset(); 2269 delegate->Reset();
2270 delegate->ReceivedAck(); 2270 delegate->ReceivedAck();
2271 EXPECT_TRUE(delegate->tap_down()); 2271 EXPECT_TRUE(delegate->tap_down());
2272 delegate->Reset(); 2272 delegate->Reset();
2273 delegate->ReceivedAckPreventDefaulted(); 2273 delegate->ReceivedAckPreventDefaulted();
2274 EXPECT_FALSE(delegate->tap()); 2274 EXPECT_FALSE(delegate->tap());
2275 EXPECT_TRUE(delegate->tap_cancel()); 2275 EXPECT_TRUE(delegate->tap_cancel());
2276 } 2276 }
2277 2277
2278 TEST_F(GestureRecognizerTest, PinchScrollWithPreventDefaultedRelease) { 2278 TEST_F(GestureRecognizerTest, PinchScrollWithPreventDefaultedRelease) {
2279 scoped_ptr<QueueTouchEventDelegate> delegate( 2279 scoped_ptr<QueueTouchEventDelegate> delegate(
2280 new QueueTouchEventDelegate(dispatcher())); 2280 new QueueTouchEventDelegate(dispatcher()));
2281 TimedEvents tes; 2281 TimedEvents tes;
2282 const int kTouchId1 = 7; 2282 const int kTouchId1 = 7;
2283 const int kTouchId2 = 5; 2283 const int kTouchId2 = 5;
2284 gfx::Rect bounds(10, 20, 100, 100); 2284 gfx::Rect bounds(10, 20, 100, 100);
2285 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2285 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2286 delegate.get(), -1234, bounds, root_window())); 2286 delegate.get(), -1234, bounds, root_window()));
2287 delegate->set_window(window.get()); 2287 delegate->set_window(window.get());
2288 2288
2289 { 2289 {
2290 delegate->Reset(); 2290 delegate->Reset();
2291 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(15, 25), kTouchId1, 2291 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(15, 25), kTouchId1,
2292 tes.Now()); 2292 tes.Now());
2293 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(20, 95), kTouchId1, 2293 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(20, 95), kTouchId1,
2294 tes.LeapForward(200)); 2294 tes.LeapForward(200));
2295 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(15, 25), kTouchId1, 2295 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(15, 25), kTouchId1,
2296 tes.LeapForward(50)); 2296 tes.LeapForward(50));
2297 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 2297 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
2298 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move); 2298 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move);
2299 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 2299 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
2300 delegate->Reset(); 2300 delegate->Reset();
2301 2301
2302 // Ack the press event. 2302 // Ack the press event.
2303 delegate->ReceivedAck(); 2303 delegate->ReceivedAck();
2304 EXPECT_TRUE(delegate->tap_down()); 2304 EXPECT_TRUE(delegate->tap_down());
2305 delegate->Reset(); 2305 delegate->Reset();
2306 2306
2307 // Ack the move event. 2307 // Ack the move event.
2308 delegate->ReceivedAck(); 2308 delegate->ReceivedAck();
2309 EXPECT_TRUE(delegate->tap_cancel()); 2309 EXPECT_TRUE(delegate->tap_cancel());
(...skipping 13 matching lines...) Expand all
2323 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(15, 25), kTouchId1, 2323 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(15, 25), kTouchId1,
2324 tes.LeapForward(50)); 2324 tes.LeapForward(50));
2325 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(55, 25), kTouchId2, 2325 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(55, 25), kTouchId2,
2326 tes.Now()); 2326 tes.Now());
2327 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(45, 85), kTouchId2, 2327 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(45, 85), kTouchId2,
2328 tes.LeapForward(1000)); 2328 tes.LeapForward(1000));
2329 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(45, 85), kTouchId2, 2329 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(45, 85), kTouchId2,
2330 tes.LeapForward(14)); 2330 tes.LeapForward(14));
2331 2331
2332 // Do a pinch. 2332 // Do a pinch.
2333 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 2333 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
2334 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move); 2334 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move);
2335 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 2335 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2);
2336 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2); 2336 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move2);
2337 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 2337 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
2338 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release2); 2338 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release2);
2339 2339
2340 // Ack the press and move events. 2340 // Ack the press and move events.
2341 delegate->Reset(); 2341 delegate->Reset();
2342 delegate->ReceivedAck(); 2342 delegate->ReceivedAck();
2343 EXPECT_TRUE(delegate->begin()); 2343 EXPECT_TRUE(delegate->begin());
2344 EXPECT_TRUE(delegate->tap_down()); 2344 EXPECT_TRUE(delegate->tap_down());
2345 2345
2346 delegate->Reset(); 2346 delegate->Reset();
2347 delegate->ReceivedAck(); 2347 delegate->ReceivedAck();
2348 EXPECT_TRUE(delegate->scroll_begin()); 2348 EXPECT_TRUE(delegate->scroll_begin());
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
2457 TestGestureRecognizer* gesture_recognizer = 2457 TestGestureRecognizer* gesture_recognizer =
2458 new TestGestureRecognizer(); 2458 new TestGestureRecognizer();
2459 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); 2459 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer);
2460 TimedEvents tes; 2460 TimedEvents tes;
2461 2461
2462 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2462 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2463 delegate.get(), -1234, gfx::Rect(10, 10, 300, 300), root_window())); 2463 delegate.get(), -1234, gfx::Rect(10, 10, 300, 300), root_window()));
2464 2464
2465 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(45, 45), 7, tes.Now()); 2465 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(45, 45), 7, tes.Now());
2466 press.set_radius_x(40); 2466 press.set_radius_x(40);
2467 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 2467 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
2468 EXPECT_TRUE(delegate->tap_down()); 2468 EXPECT_TRUE(delegate->tap_down());
2469 EXPECT_EQ(gfx::Rect(5, 5, 80, 80).ToString(), 2469 EXPECT_EQ(gfx::Rect(5, 5, 80, 80).ToString(),
2470 delegate->bounding_box().ToString()); 2470 delegate->bounding_box().ToString());
2471 delegate->Reset(); 2471 delegate->Reset();
2472 2472
2473 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(55, 45), 7, tes.Now()); 2473 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(55, 45), 7, tes.Now());
2474 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 2474 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2);
2475 2475
2476 // This new press should not generate a tap-down. 2476 // This new press should not generate a tap-down.
2477 EXPECT_FALSE(delegate->begin()); 2477 EXPECT_FALSE(delegate->begin());
2478 EXPECT_FALSE(delegate->tap_down()); 2478 EXPECT_FALSE(delegate->tap_down());
2479 EXPECT_FALSE(delegate->tap_cancel()); 2479 EXPECT_FALSE(delegate->tap_cancel());
2480 EXPECT_FALSE(delegate->scroll_begin()); 2480 EXPECT_FALSE(delegate->scroll_begin());
2481 } 2481 }
2482 2482
2483 TEST_F(GestureRecognizerTest, TwoFingerTap) { 2483 TEST_F(GestureRecognizerTest, TwoFingerTap) {
2484 scoped_ptr<GestureEventConsumeDelegate> delegate( 2484 scoped_ptr<GestureEventConsumeDelegate> delegate(
2485 new GestureEventConsumeDelegate()); 2485 new GestureEventConsumeDelegate());
2486 const int kWindowWidth = 123; 2486 const int kWindowWidth = 123;
2487 const int kWindowHeight = 45; 2487 const int kWindowHeight = 45;
2488 const int kTouchId1 = 2; 2488 const int kTouchId1 = 2;
2489 const int kTouchId2 = 3; 2489 const int kTouchId2 = 3;
2490 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2490 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2491 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2491 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2492 delegate.get(), -1234, bounds, root_window())); 2492 delegate.get(), -1234, bounds, root_window()));
2493 TimedEvents tes; 2493 TimedEvents tes;
2494 2494
2495 delegate->Reset(); 2495 delegate->Reset();
2496 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2496 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
2497 kTouchId1, tes.Now()); 2497 kTouchId1, tes.Now());
2498 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 2498 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1);
2499 EXPECT_FALSE(delegate->tap()); 2499 EXPECT_FALSE(delegate->tap());
2500 EXPECT_TRUE(delegate->tap_down()); 2500 EXPECT_TRUE(delegate->tap_down());
2501 EXPECT_FALSE(delegate->tap_cancel()); 2501 EXPECT_FALSE(delegate->tap_cancel());
2502 EXPECT_FALSE(delegate->scroll_begin()); 2502 EXPECT_FALSE(delegate->scroll_begin());
2503 EXPECT_FALSE(delegate->scroll_update()); 2503 EXPECT_FALSE(delegate->scroll_update());
2504 EXPECT_FALSE(delegate->scroll_end()); 2504 EXPECT_FALSE(delegate->scroll_end());
2505 EXPECT_FALSE(delegate->long_press()); 2505 EXPECT_FALSE(delegate->long_press());
2506 EXPECT_FALSE(delegate->two_finger_tap()); 2506 EXPECT_FALSE(delegate->two_finger_tap());
2507 2507
2508 delegate->Reset(); 2508 delegate->Reset();
2509 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), 2509 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201),
2510 kTouchId2, tes.Now()); 2510 kTouchId2, tes.Now());
2511 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 2511 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2);
2512 EXPECT_FALSE(delegate->tap()); 2512 EXPECT_FALSE(delegate->tap());
2513 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap. 2513 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap.
2514 EXPECT_TRUE(delegate->tap_cancel()); 2514 EXPECT_TRUE(delegate->tap_cancel());
2515 EXPECT_FALSE(delegate->scroll_begin()); 2515 EXPECT_FALSE(delegate->scroll_begin());
2516 EXPECT_FALSE(delegate->scroll_update()); 2516 EXPECT_FALSE(delegate->scroll_update());
2517 EXPECT_FALSE(delegate->scroll_end()); 2517 EXPECT_FALSE(delegate->scroll_end());
2518 EXPECT_FALSE(delegate->long_press()); 2518 EXPECT_FALSE(delegate->long_press());
2519 EXPECT_FALSE(delegate->two_finger_tap()); 2519 EXPECT_FALSE(delegate->two_finger_tap());
2520 2520
2521 // Little bit of touch move should not affect our state. 2521 // Little bit of touch move should not affect our state.
2522 delegate->Reset(); 2522 delegate->Reset();
2523 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(102, 202), 2523 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(102, 202),
2524 kTouchId1, tes.Now()); 2524 kTouchId1, tes.Now());
2525 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move1); 2525 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move1);
2526 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(131, 202), 2526 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(131, 202),
2527 kTouchId2, tes.Now()); 2527 kTouchId2, tes.Now());
2528 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2); 2528 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move2);
2529 EXPECT_FALSE(delegate->tap()); 2529 EXPECT_FALSE(delegate->tap());
2530 EXPECT_FALSE(delegate->tap_down()); 2530 EXPECT_FALSE(delegate->tap_down());
2531 EXPECT_FALSE(delegate->tap_cancel()); 2531 EXPECT_FALSE(delegate->tap_cancel());
2532 EXPECT_FALSE(delegate->scroll_begin()); 2532 EXPECT_FALSE(delegate->scroll_begin());
2533 EXPECT_FALSE(delegate->scroll_update()); 2533 EXPECT_FALSE(delegate->scroll_update());
2534 EXPECT_FALSE(delegate->scroll_end()); 2534 EXPECT_FALSE(delegate->scroll_end());
2535 EXPECT_FALSE(delegate->long_press()); 2535 EXPECT_FALSE(delegate->long_press());
2536 EXPECT_FALSE(delegate->two_finger_tap()); 2536 EXPECT_FALSE(delegate->two_finger_tap());
2537 2537
2538 // Make sure there is enough delay before the touch is released so that it is 2538 // Make sure there is enough delay before the touch is released so that it is
2539 // recognized as a tap. 2539 // recognized as a tap.
2540 delegate->Reset(); 2540 delegate->Reset();
2541 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 2541 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
2542 kTouchId1, tes.LeapForward(50)); 2542 kTouchId1, tes.LeapForward(50));
2543 2543
2544 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); 2544 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1);
2545 EXPECT_FALSE(delegate->tap()); 2545 EXPECT_FALSE(delegate->tap());
2546 EXPECT_FALSE(delegate->tap_down()); 2546 EXPECT_FALSE(delegate->tap_down());
2547 EXPECT_FALSE(delegate->tap_cancel()); 2547 EXPECT_FALSE(delegate->tap_cancel());
2548 EXPECT_FALSE(delegate->scroll_begin()); 2548 EXPECT_FALSE(delegate->scroll_begin());
2549 EXPECT_FALSE(delegate->scroll_update()); 2549 EXPECT_FALSE(delegate->scroll_update());
2550 EXPECT_FALSE(delegate->scroll_end()); 2550 EXPECT_FALSE(delegate->scroll_end());
2551 EXPECT_TRUE(delegate->two_finger_tap()); 2551 EXPECT_TRUE(delegate->two_finger_tap());
2552 2552
2553 // Lift second finger. 2553 // Lift second finger.
2554 // Make sure there is enough delay before the touch is released so that it is 2554 // Make sure there is enough delay before the touch is released so that it is
2555 // recognized as a tap. 2555 // recognized as a tap.
2556 delegate->Reset(); 2556 delegate->Reset();
2557 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(130, 201), 2557 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(130, 201),
2558 kTouchId2, tes.LeapForward(50)); 2558 kTouchId2, tes.LeapForward(50));
2559 2559
2560 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release2); 2560 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release2);
2561 EXPECT_FALSE(delegate->tap()); 2561 EXPECT_FALSE(delegate->tap());
2562 EXPECT_FALSE(delegate->tap_down()); 2562 EXPECT_FALSE(delegate->tap_down());
2563 EXPECT_FALSE(delegate->tap_cancel()); 2563 EXPECT_FALSE(delegate->tap_cancel());
2564 EXPECT_FALSE(delegate->scroll_begin()); 2564 EXPECT_FALSE(delegate->scroll_begin());
2565 EXPECT_FALSE(delegate->scroll_update()); 2565 EXPECT_FALSE(delegate->scroll_update());
2566 EXPECT_FALSE(delegate->scroll_end()); 2566 EXPECT_FALSE(delegate->scroll_end());
2567 EXPECT_TRUE(delegate->fling()); 2567 EXPECT_TRUE(delegate->fling());
2568 EXPECT_FALSE(delegate->two_finger_tap()); 2568 EXPECT_FALSE(delegate->two_finger_tap());
2569 } 2569 }
2570 2570
2571 TEST_F(GestureRecognizerTest, TwoFingerTapExpired) { 2571 TEST_F(GestureRecognizerTest, TwoFingerTapExpired) {
2572 scoped_ptr<GestureEventConsumeDelegate> delegate( 2572 scoped_ptr<GestureEventConsumeDelegate> delegate(
2573 new GestureEventConsumeDelegate()); 2573 new GestureEventConsumeDelegate());
2574 const int kWindowWidth = 123; 2574 const int kWindowWidth = 123;
2575 const int kWindowHeight = 45; 2575 const int kWindowHeight = 45;
2576 const int kTouchId1 = 2; 2576 const int kTouchId1 = 2;
2577 const int kTouchId2 = 3; 2577 const int kTouchId2 = 3;
2578 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2578 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2579 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2579 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2580 delegate.get(), -1234, bounds, root_window())); 2580 delegate.get(), -1234, bounds, root_window()));
2581 TimedEvents tes; 2581 TimedEvents tes;
2582 2582
2583 delegate->Reset(); 2583 delegate->Reset();
2584 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2584 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
2585 kTouchId1, tes.Now()); 2585 kTouchId1, tes.Now());
2586 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 2586 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1);
2587 2587
2588 delegate->Reset(); 2588 delegate->Reset();
2589 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), 2589 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201),
2590 kTouchId2, tes.Now()); 2590 kTouchId2, tes.Now());
2591 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 2591 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2);
2592 2592
2593 // Send release event after sufficient delay so that two finger time expires. 2593 // Send release event after sufficient delay so that two finger time expires.
2594 delegate->Reset(); 2594 delegate->Reset();
2595 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 2595 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
2596 kTouchId1, tes.LeapForward(1000)); 2596 kTouchId1, tes.LeapForward(1000));
2597 2597
2598 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); 2598 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1);
2599 EXPECT_FALSE(delegate->two_finger_tap()); 2599 EXPECT_FALSE(delegate->two_finger_tap());
2600 2600
2601 // Lift second finger. 2601 // Lift second finger.
2602 // Make sure there is enough delay before the touch is released so that it is 2602 // Make sure there is enough delay before the touch is released so that it is
2603 // recognized as a tap. 2603 // recognized as a tap.
2604 delegate->Reset(); 2604 delegate->Reset();
2605 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(130, 201), 2605 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(130, 201),
2606 kTouchId2, tes.LeapForward(50)); 2606 kTouchId2, tes.LeapForward(50));
2607 2607
2608 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release2); 2608 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release2);
2609 EXPECT_FALSE(delegate->two_finger_tap()); 2609 EXPECT_FALSE(delegate->two_finger_tap());
2610 } 2610 }
2611 2611
2612 TEST_F(GestureRecognizerTest, TwoFingerTapChangesToPinch) { 2612 TEST_F(GestureRecognizerTest, TwoFingerTapChangesToPinch) {
2613 scoped_ptr<GestureEventConsumeDelegate> delegate( 2613 scoped_ptr<GestureEventConsumeDelegate> delegate(
2614 new GestureEventConsumeDelegate()); 2614 new GestureEventConsumeDelegate());
2615 const int kWindowWidth = 123; 2615 const int kWindowWidth = 123;
2616 const int kWindowHeight = 45; 2616 const int kWindowHeight = 45;
2617 const int kTouchId1 = 2; 2617 const int kTouchId1 = 2;
2618 const int kTouchId2 = 3; 2618 const int kTouchId2 = 3;
2619 TimedEvents tes; 2619 TimedEvents tes;
2620 2620
2621 // Test moving first finger 2621 // Test moving first finger
2622 { 2622 {
2623 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2623 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2624 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2624 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2625 delegate.get(), -1234, bounds, root_window())); 2625 delegate.get(), -1234, bounds, root_window()));
2626 2626
2627 delegate->Reset(); 2627 delegate->Reset();
2628 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2628 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
2629 kTouchId1, tes.Now()); 2629 kTouchId1, tes.Now());
2630 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 2630 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1);
2631 2631
2632 delegate->Reset(); 2632 delegate->Reset();
2633 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), 2633 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201),
2634 kTouchId2, tes.Now()); 2634 kTouchId2, tes.Now());
2635 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 2635 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2);
2636 2636
2637 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId1, delegate.get()); 2637 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId1, delegate.get());
2638 EXPECT_FALSE(delegate->two_finger_tap()); 2638 EXPECT_FALSE(delegate->two_finger_tap());
2639 EXPECT_TRUE(delegate->pinch_begin()); 2639 EXPECT_TRUE(delegate->pinch_begin());
2640 2640
2641 // Make sure there is enough delay before the touch is released so that it 2641 // Make sure there is enough delay before the touch is released so that it
2642 // is recognized as a tap. 2642 // is recognized as a tap.
2643 delegate->Reset(); 2643 delegate->Reset();
2644 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 2644 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
2645 kTouchId2, tes.LeapForward(50)); 2645 kTouchId2, tes.LeapForward(50));
2646 2646
2647 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 2647 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
2648 EXPECT_FALSE(delegate->two_finger_tap()); 2648 EXPECT_FALSE(delegate->two_finger_tap());
2649 EXPECT_TRUE(delegate->pinch_end()); 2649 EXPECT_TRUE(delegate->pinch_end());
2650 } 2650 }
2651 2651
2652 // Test moving second finger 2652 // Test moving second finger
2653 { 2653 {
2654 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2654 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2655 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2655 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2656 delegate.get(), -1234, bounds, root_window())); 2656 delegate.get(), -1234, bounds, root_window()));
2657 2657
2658 delegate->Reset(); 2658 delegate->Reset();
2659 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2659 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
2660 kTouchId1, tes.Now()); 2660 kTouchId1, tes.Now());
2661 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 2661 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1);
2662 2662
2663 delegate->Reset(); 2663 delegate->Reset();
2664 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), 2664 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201),
2665 kTouchId2, tes.Now()); 2665 kTouchId2, tes.Now());
2666 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 2666 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2);
2667 2667
2668 tes.SendScrollEvent(dispatcher(), 101, 230, kTouchId2, delegate.get()); 2668 tes.SendScrollEvent(dispatcher(), 101, 230, kTouchId2, delegate.get());
2669 EXPECT_FALSE(delegate->two_finger_tap()); 2669 EXPECT_FALSE(delegate->two_finger_tap());
2670 EXPECT_TRUE(delegate->pinch_begin()); 2670 EXPECT_TRUE(delegate->pinch_begin());
2671 2671
2672 // 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
2673 // is recognized as a tap. 2673 // is recognized as a tap.
2674 delegate->Reset(); 2674 delegate->Reset();
2675 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 2675 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
2676 kTouchId1, tes.LeapForward(50)); 2676 kTouchId1, tes.LeapForward(50));
2677 2677
2678 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 2678 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
2679 EXPECT_FALSE(delegate->two_finger_tap()); 2679 EXPECT_FALSE(delegate->two_finger_tap());
2680 EXPECT_TRUE(delegate->pinch_end()); 2680 EXPECT_TRUE(delegate->pinch_end());
2681 } 2681 }
2682 } 2682 }
2683 2683
2684 TEST_F(GestureRecognizerTest, NoTwoFingerTapWhenFirstFingerHasScrolled) { 2684 TEST_F(GestureRecognizerTest, NoTwoFingerTapWhenFirstFingerHasScrolled) {
2685 scoped_ptr<GestureEventConsumeDelegate> delegate( 2685 scoped_ptr<GestureEventConsumeDelegate> delegate(
2686 new GestureEventConsumeDelegate()); 2686 new GestureEventConsumeDelegate());
2687 const int kWindowWidth = 123; 2687 const int kWindowWidth = 123;
2688 const int kWindowHeight = 45; 2688 const int kWindowHeight = 45;
2689 const int kTouchId1 = 2; 2689 const int kTouchId1 = 2;
2690 const int kTouchId2 = 3; 2690 const int kTouchId2 = 3;
2691 TimedEvents tes; 2691 TimedEvents tes;
2692 2692
2693 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2693 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2694 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2694 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2695 delegate.get(), -1234, bounds, root_window())); 2695 delegate.get(), -1234, bounds, root_window()));
2696 2696
2697 delegate->Reset(); 2697 delegate->Reset();
2698 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2698 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
2699 kTouchId1, tes.Now()); 2699 kTouchId1, tes.Now());
2700 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 2700 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1);
2701 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId1, delegate.get()); 2701 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId1, delegate.get());
2702 2702
2703 delegate->Reset(); 2703 delegate->Reset();
2704 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), 2704 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201),
2705 kTouchId2, tes.Now()); 2705 kTouchId2, tes.Now());
2706 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 2706 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2);
2707 2707
2708 EXPECT_TRUE(delegate->pinch_begin()); 2708 EXPECT_TRUE(delegate->pinch_begin());
2709 2709
2710 // Make sure there is enough delay before the touch is released so that it 2710 // Make sure there is enough delay before the touch is released so that it
2711 // is recognized as a tap. 2711 // is recognized as a tap.
2712 delegate->Reset(); 2712 delegate->Reset();
2713 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 2713 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
2714 kTouchId2, tes.LeapForward(50)); 2714 kTouchId2, tes.LeapForward(50));
2715 2715
2716 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 2716 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
2717 EXPECT_FALSE(delegate->two_finger_tap()); 2717 EXPECT_FALSE(delegate->two_finger_tap());
2718 EXPECT_TRUE(delegate->pinch_end()); 2718 EXPECT_TRUE(delegate->pinch_end());
2719 } 2719 }
2720 2720
2721 TEST_F(GestureRecognizerTest, MultiFingerSwipe) { 2721 TEST_F(GestureRecognizerTest, MultiFingerSwipe) {
2722 scoped_ptr<GestureEventConsumeDelegate> delegate( 2722 scoped_ptr<GestureEventConsumeDelegate> delegate(
2723 new GestureEventConsumeDelegate()); 2723 new GestureEventConsumeDelegate());
2724 const int kWindowWidth = 123; 2724 const int kWindowWidth = 123;
2725 const int kWindowHeight = 45; 2725 const int kWindowHeight = 45;
2726 2726
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2769 2769
2770 // Test canceling first finger. 2770 // Test canceling first finger.
2771 { 2771 {
2772 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2772 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2773 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2773 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2774 delegate.get(), -1234, bounds, root_window())); 2774 delegate.get(), -1234, bounds, root_window()));
2775 2775
2776 delegate->Reset(); 2776 delegate->Reset();
2777 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2777 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
2778 kTouchId1, tes.Now()); 2778 kTouchId1, tes.Now());
2779 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 2779 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1);
2780 2780
2781 delegate->Reset(); 2781 delegate->Reset();
2782 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), 2782 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201),
2783 kTouchId2, tes.Now()); 2783 kTouchId2, tes.Now());
2784 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 2784 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2);
2785 2785
2786 delegate->Reset(); 2786 delegate->Reset();
2787 ui::TouchEvent cancel(ui::ET_TOUCH_CANCELLED, gfx::Point(130, 201), 2787 ui::TouchEvent cancel(ui::ET_TOUCH_CANCELLED, gfx::Point(130, 201),
2788 kTouchId1, tes.Now()); 2788 kTouchId1, tes.Now());
2789 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&cancel); 2789 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&cancel);
2790 EXPECT_FALSE(delegate->two_finger_tap()); 2790 EXPECT_FALSE(delegate->two_finger_tap());
2791 2791
2792 // Make sure there is enough delay before the touch is released so that it 2792 // Make sure there is enough delay before the touch is released so that it
2793 // is recognized as a tap. 2793 // is recognized as a tap.
2794 delegate->Reset(); 2794 delegate->Reset();
2795 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 2795 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
2796 kTouchId2, tes.LeapForward(50)); 2796 kTouchId2, tes.LeapForward(50));
2797 2797
2798 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 2798 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
2799 EXPECT_FALSE(delegate->two_finger_tap()); 2799 EXPECT_FALSE(delegate->two_finger_tap());
2800 } 2800 }
2801 2801
2802 // Test canceling second finger 2802 // Test canceling second finger
2803 { 2803 {
2804 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2804 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2805 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2805 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2806 delegate.get(), -1234, bounds, root_window())); 2806 delegate.get(), -1234, bounds, root_window()));
2807 2807
2808 delegate->Reset(); 2808 delegate->Reset();
2809 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2809 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
2810 kTouchId1, tes.Now()); 2810 kTouchId1, tes.Now());
2811 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 2811 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1);
2812 2812
2813 delegate->Reset(); 2813 delegate->Reset();
2814 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), 2814 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201),
2815 kTouchId2, tes.Now()); 2815 kTouchId2, tes.Now());
2816 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 2816 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2);
2817 2817
2818 delegate->Reset(); 2818 delegate->Reset();
2819 ui::TouchEvent cancel(ui::ET_TOUCH_CANCELLED, gfx::Point(130, 201), 2819 ui::TouchEvent cancel(ui::ET_TOUCH_CANCELLED, gfx::Point(130, 201),
2820 kTouchId2, tes.Now()); 2820 kTouchId2, tes.Now());
2821 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&cancel); 2821 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&cancel);
2822 EXPECT_FALSE(delegate->two_finger_tap()); 2822 EXPECT_FALSE(delegate->two_finger_tap());
2823 2823
2824 // Make sure there is enough delay before the touch is released so that it 2824 // Make sure there is enough delay before the touch is released so that it
2825 // is recognized as a tap. 2825 // is recognized as a tap.
2826 delegate->Reset(); 2826 delegate->Reset();
2827 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 2827 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
2828 kTouchId1, tes.LeapForward(50)); 2828 kTouchId1, tes.LeapForward(50));
2829 2829
2830 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 2830 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
2831 EXPECT_FALSE(delegate->two_finger_tap()); 2831 EXPECT_FALSE(delegate->two_finger_tap());
2832 } 2832 }
2833 } 2833 }
2834 2834
2835 TEST_F(GestureRecognizerTest, VeryWideTwoFingerTouchDownShouldBeAPinch) { 2835 TEST_F(GestureRecognizerTest, VeryWideTwoFingerTouchDownShouldBeAPinch) {
2836 scoped_ptr<GestureEventConsumeDelegate> delegate( 2836 scoped_ptr<GestureEventConsumeDelegate> delegate(
2837 new GestureEventConsumeDelegate()); 2837 new GestureEventConsumeDelegate());
2838 const int kWindowWidth = 523; 2838 const int kWindowWidth = 523;
2839 const int kWindowHeight = 45; 2839 const int kWindowHeight = 45;
2840 const int kTouchId1 = 2; 2840 const int kTouchId1 = 2;
2841 const int kTouchId2 = 3; 2841 const int kTouchId2 = 3;
2842 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2842 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2843 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2843 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2844 delegate.get(), -1234, bounds, root_window())); 2844 delegate.get(), -1234, bounds, root_window()));
2845 TimedEvents tes; 2845 TimedEvents tes;
2846 2846
2847 delegate->Reset(); 2847 delegate->Reset();
2848 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2848 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
2849 kTouchId1, tes.Now()); 2849 kTouchId1, tes.Now());
2850 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 2850 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1);
2851 EXPECT_FALSE(delegate->tap()); 2851 EXPECT_FALSE(delegate->tap());
2852 EXPECT_TRUE(delegate->tap_down()); 2852 EXPECT_TRUE(delegate->tap_down());
2853 EXPECT_FALSE(delegate->tap_cancel()); 2853 EXPECT_FALSE(delegate->tap_cancel());
2854 EXPECT_FALSE(delegate->scroll_begin()); 2854 EXPECT_FALSE(delegate->scroll_begin());
2855 EXPECT_FALSE(delegate->scroll_update()); 2855 EXPECT_FALSE(delegate->scroll_update());
2856 EXPECT_FALSE(delegate->scroll_end()); 2856 EXPECT_FALSE(delegate->scroll_end());
2857 EXPECT_FALSE(delegate->long_press()); 2857 EXPECT_FALSE(delegate->long_press());
2858 EXPECT_FALSE(delegate->two_finger_tap()); 2858 EXPECT_FALSE(delegate->two_finger_tap());
2859 2859
2860 delegate->Reset(); 2860 delegate->Reset();
2861 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(430, 201), 2861 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(430, 201),
2862 kTouchId2, tes.Now()); 2862 kTouchId2, tes.Now());
2863 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 2863 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2);
2864 EXPECT_FALSE(delegate->tap()); 2864 EXPECT_FALSE(delegate->tap());
2865 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap. 2865 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap.
2866 EXPECT_TRUE(delegate->tap_cancel()); 2866 EXPECT_TRUE(delegate->tap_cancel());
2867 EXPECT_FALSE(delegate->scroll_begin()); 2867 EXPECT_FALSE(delegate->scroll_begin());
2868 EXPECT_FALSE(delegate->scroll_update()); 2868 EXPECT_FALSE(delegate->scroll_update());
2869 EXPECT_FALSE(delegate->scroll_end()); 2869 EXPECT_FALSE(delegate->scroll_end());
2870 EXPECT_FALSE(delegate->long_press()); 2870 EXPECT_FALSE(delegate->long_press());
2871 EXPECT_FALSE(delegate->two_finger_tap()); 2871 EXPECT_FALSE(delegate->two_finger_tap());
2872 EXPECT_FALSE(delegate->pinch_begin()); 2872 EXPECT_FALSE(delegate->pinch_begin());
2873 2873
2874 delegate->Reset(); 2874 delegate->Reset();
2875 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(530, 301), 2875 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(530, 301),
2876 kTouchId2, tes.Now()); 2876 kTouchId2, tes.Now());
2877 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2); 2877 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move2);
2878 EXPECT_FALSE(delegate->tap()); 2878 EXPECT_FALSE(delegate->tap());
2879 EXPECT_FALSE(delegate->tap_down()); 2879 EXPECT_FALSE(delegate->tap_down());
2880 EXPECT_FALSE(delegate->tap_cancel()); 2880 EXPECT_FALSE(delegate->tap_cancel());
2881 // Pinch & Scroll only when there is enough movement. 2881 // Pinch & Scroll only when there is enough movement.
2882 EXPECT_TRUE(delegate->scroll_begin()); 2882 EXPECT_TRUE(delegate->scroll_begin());
2883 EXPECT_FALSE(delegate->scroll_update()); 2883 EXPECT_FALSE(delegate->scroll_update());
2884 EXPECT_FALSE(delegate->scroll_end()); 2884 EXPECT_FALSE(delegate->scroll_end());
2885 EXPECT_FALSE(delegate->long_press()); 2885 EXPECT_FALSE(delegate->long_press());
2886 EXPECT_FALSE(delegate->two_finger_tap()); 2886 EXPECT_FALSE(delegate->two_finger_tap());
2887 EXPECT_TRUE(delegate->pinch_begin()); 2887 EXPECT_TRUE(delegate->pinch_begin());
2888 } 2888 }
2889 2889
2890 // Verifies if a window is the target of multiple touch-ids and we hide the 2890 // Verifies if a window is the target of multiple touch-ids and we hide the
2891 // window everything is cleaned up correctly. 2891 // window everything is cleaned up correctly.
2892 TEST_F(GestureRecognizerTest, FlushAllOnHide) { 2892 TEST_F(GestureRecognizerTest, FlushAllOnHide) {
2893 scoped_ptr<GestureEventConsumeDelegate> delegate( 2893 scoped_ptr<GestureEventConsumeDelegate> delegate(
2894 new GestureEventConsumeDelegate()); 2894 new GestureEventConsumeDelegate());
2895 gfx::Rect bounds(0, 0, 200, 200); 2895 gfx::Rect bounds(0, 0, 200, 200);
2896 scoped_ptr<aura::Window> window( 2896 scoped_ptr<aura::Window> window(
2897 CreateTestWindowWithDelegate(delegate.get(), 0, bounds, root_window())); 2897 CreateTestWindowWithDelegate(delegate.get(), 0, bounds, root_window()));
2898 const int kTouchId1 = 8; 2898 const int kTouchId1 = 8;
2899 const int kTouchId2 = 2; 2899 const int kTouchId2 = 2;
2900 TimedEvents tes; 2900 TimedEvents tes;
2901 2901
2902 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 2902 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10),
2903 kTouchId1, tes.Now()); 2903 kTouchId1, tes.Now());
2904 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 2904 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1);
2905 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(20, 20), 2905 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(20, 20),
2906 kTouchId2, tes.Now()); 2906 kTouchId2, tes.Now());
2907 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 2907 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2);
2908 window->Hide(); 2908 window->Hide();
2909 EXPECT_EQ(NULL, 2909 EXPECT_EQ(NULL,
2910 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press1)); 2910 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press1));
2911 EXPECT_EQ(NULL, 2911 EXPECT_EQ(NULL,
2912 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press2)); 2912 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press2));
2913 } 2913 }
2914 2914
2915 TEST_F(GestureRecognizerTest, LongPressTimerStopsOnPreventDefaultedTouchMoves) { 2915 TEST_F(GestureRecognizerTest, LongPressTimerStopsOnPreventDefaultedTouchMoves) {
2916 scoped_ptr<QueueTouchEventDelegate> delegate( 2916 scoped_ptr<QueueTouchEventDelegate> delegate(
2917 new QueueTouchEventDelegate(dispatcher())); 2917 new QueueTouchEventDelegate(dispatcher()));
2918 const int kTouchId = 2; 2918 const int kTouchId = 2;
2919 gfx::Rect bounds(100, 200, 100, 100); 2919 gfx::Rect bounds(100, 200, 100, 100);
2920 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2920 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2921 delegate.get(), -1234, bounds, root_window())); 2921 delegate.get(), -1234, bounds, root_window()));
2922 delegate->set_window(window.get()); 2922 delegate->set_window(window.get());
2923 TimedEvents tes; 2923 TimedEvents tes;
2924 2924
2925 TimerTestGestureRecognizer* gesture_recognizer = 2925 TimerTestGestureRecognizer* gesture_recognizer =
2926 new TimerTestGestureRecognizer(); 2926 new TimerTestGestureRecognizer();
2927 TimerTestGestureSequence* gesture_sequence = 2927 TimerTestGestureSequence* gesture_sequence =
2928 static_cast<TimerTestGestureSequence*>( 2928 static_cast<TimerTestGestureSequence*>(
2929 gesture_recognizer->GetGestureSequenceForTesting(window.get())); 2929 gesture_recognizer->GetGestureSequenceForTesting(window.get()));
2930 2930
2931 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); 2931 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer);
2932 2932
2933 delegate->Reset(); 2933 delegate->Reset();
2934 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2934 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
2935 kTouchId, tes.Now()); 2935 kTouchId, tes.Now());
2936 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 2936 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
2937 // Scroll around, to cancel the long press 2937 // Scroll around, to cancel the long press
2938 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get()); 2938 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get());
2939 2939
2940 delegate->Reset(); 2940 delegate->Reset();
2941 delegate->ReceivedAck(); 2941 delegate->ReceivedAck();
2942 EXPECT_TRUE(delegate->tap_down()); 2942 EXPECT_TRUE(delegate->tap_down());
2943 EXPECT_TRUE(gesture_sequence->IsTimerRunning()); 2943 EXPECT_TRUE(gesture_sequence->IsTimerRunning());
2944 2944
2945 delegate->Reset(); 2945 delegate->Reset();
2946 delegate->ReceivedAckPreventDefaulted(); 2946 delegate->ReceivedAckPreventDefaulted();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2979 const int kWindowHeight = 45; 2979 const int kWindowHeight = 45;
2980 const int kTouchId = 5; 2980 const int kTouchId = 5;
2981 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2981 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2982 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2982 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2983 delegate.get(), -1234, bounds, root_window())); 2983 delegate.get(), -1234, bounds, root_window()));
2984 TimedEvents tes; 2984 TimedEvents tes;
2985 2985
2986 delegate->Reset(); 2986 delegate->Reset();
2987 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2987 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
2988 kTouchId, tes.Now()); 2988 kTouchId, tes.Now());
2989 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 2989 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
2990 EXPECT_FALSE(delegate->tap()); 2990 EXPECT_FALSE(delegate->tap());
2991 EXPECT_TRUE(delegate->tap_down()); 2991 EXPECT_TRUE(delegate->tap_down());
2992 EXPECT_FALSE(delegate->tap_cancel()); 2992 EXPECT_FALSE(delegate->tap_cancel());
2993 EXPECT_TRUE(delegate->begin()); 2993 EXPECT_TRUE(delegate->begin());
2994 EXPECT_FALSE(delegate->scroll_begin()); 2994 EXPECT_FALSE(delegate->scroll_begin());
2995 EXPECT_FALSE(delegate->scroll_update()); 2995 EXPECT_FALSE(delegate->scroll_update());
2996 EXPECT_FALSE(delegate->scroll_end()); 2996 EXPECT_FALSE(delegate->scroll_end());
2997 2997
2998 // Move the touch-point enough so that it would normally be considered a 2998 // Move the touch-point enough so that it would normally be considered a
2999 // scroll. But since the touch-moves will be consumed, the scroll should not 2999 // scroll. But since the touch-moves will be consumed, the scroll should not
3000 // start. 3000 // start.
3001 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get()); 3001 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get());
3002 EXPECT_FALSE(delegate->tap()); 3002 EXPECT_FALSE(delegate->tap());
3003 EXPECT_FALSE(delegate->tap_down()); 3003 EXPECT_FALSE(delegate->tap_down());
3004 EXPECT_TRUE(delegate->tap_cancel()); 3004 EXPECT_TRUE(delegate->tap_cancel());
3005 EXPECT_FALSE(delegate->begin()); 3005 EXPECT_FALSE(delegate->begin());
3006 EXPECT_FALSE(delegate->scroll_begin()); 3006 EXPECT_FALSE(delegate->scroll_begin());
3007 EXPECT_FALSE(delegate->scroll_update()); 3007 EXPECT_FALSE(delegate->scroll_update());
3008 EXPECT_FALSE(delegate->scroll_end()); 3008 EXPECT_FALSE(delegate->scroll_end());
3009 3009
3010 // Release the touch back at the start point. This should end without causing 3010 // Release the touch back at the start point. This should end without causing
3011 // a tap. 3011 // a tap.
3012 delegate->Reset(); 3012 delegate->Reset();
3013 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(130, 230), 3013 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(130, 230),
3014 kTouchId, tes.LeapForward(50)); 3014 kTouchId, tes.LeapForward(50));
3015 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 3015 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
3016 EXPECT_FALSE(delegate->tap()); 3016 EXPECT_FALSE(delegate->tap());
3017 EXPECT_FALSE(delegate->tap_down()); 3017 EXPECT_FALSE(delegate->tap_down());
3018 EXPECT_FALSE(delegate->tap_cancel()); 3018 EXPECT_FALSE(delegate->tap_cancel());
3019 EXPECT_FALSE(delegate->begin()); 3019 EXPECT_FALSE(delegate->begin());
3020 EXPECT_TRUE(delegate->end()); 3020 EXPECT_TRUE(delegate->end());
3021 EXPECT_FALSE(delegate->scroll_begin()); 3021 EXPECT_FALSE(delegate->scroll_begin());
3022 EXPECT_FALSE(delegate->scroll_update()); 3022 EXPECT_FALSE(delegate->scroll_update());
3023 EXPECT_FALSE(delegate->scroll_end()); 3023 EXPECT_FALSE(delegate->scroll_end());
3024 } 3024 }
3025 3025
3026 // Tests the behavior of 2F scroll when all the touch-move events are consumed. 3026 // Tests the behavior of 2F scroll when all the touch-move events are consumed.
3027 TEST_F(GestureRecognizerTest, GestureEventScrollTwoFingerTouchMoveConsumed) { 3027 TEST_F(GestureRecognizerTest, GestureEventScrollTwoFingerTouchMoveConsumed) {
3028 scoped_ptr<ConsumesTouchMovesDelegate> delegate( 3028 scoped_ptr<ConsumesTouchMovesDelegate> delegate(
3029 new ConsumesTouchMovesDelegate()); 3029 new ConsumesTouchMovesDelegate());
3030 const int kWindowWidth = 123; 3030 const int kWindowWidth = 123;
3031 const int kWindowHeight = 100; 3031 const int kWindowHeight = 100;
3032 const int kTouchId1 = 2; 3032 const int kTouchId1 = 2;
3033 const int kTouchId2 = 3; 3033 const int kTouchId2 = 3;
3034 TimedEvents tes; 3034 TimedEvents tes;
3035 3035
3036 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3036 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
3037 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3037 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3038 delegate.get(), -1234, bounds, root_window())); 3038 delegate.get(), -1234, bounds, root_window()));
3039 3039
3040 delegate->Reset(); 3040 delegate->Reset();
3041 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 3041 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
3042 kTouchId1, tes.Now()); 3042 kTouchId1, tes.Now());
3043 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 3043 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1);
3044 tes.SendScrollEvent(dispatcher(), 131, 231, kTouchId1, delegate.get()); 3044 tes.SendScrollEvent(dispatcher(), 131, 231, kTouchId1, delegate.get());
3045 3045
3046 // First finger touches down and moves. 3046 // First finger touches down and moves.
3047 EXPECT_FALSE(delegate->tap()); 3047 EXPECT_FALSE(delegate->tap());
3048 EXPECT_FALSE(delegate->scroll_begin()); 3048 EXPECT_FALSE(delegate->scroll_begin());
3049 EXPECT_FALSE(delegate->scroll_update()); 3049 EXPECT_FALSE(delegate->scroll_update());
3050 EXPECT_FALSE(delegate->scroll_end()); 3050 EXPECT_FALSE(delegate->scroll_end());
3051 3051
3052 delegate->Reset(); 3052 delegate->Reset();
3053 // Second finger touches down and moves. 3053 // Second finger touches down and moves.
3054 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), 3054 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201),
3055 kTouchId2, tes.LeapForward(50)); 3055 kTouchId2, tes.LeapForward(50));
3056 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 3056 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2);
3057 tes.SendScrollEvent(dispatcher(), 161, 231, kTouchId2, delegate.get()); 3057 tes.SendScrollEvent(dispatcher(), 161, 231, kTouchId2, delegate.get());
3058 3058
3059 // PinchBegin & ScrollBegin were not sent if the touch-move events were 3059 // PinchBegin & ScrollBegin were not sent if the touch-move events were
3060 // consumed. 3060 // consumed.
3061 EXPECT_FALSE(delegate->pinch_begin()); 3061 EXPECT_FALSE(delegate->pinch_begin());
3062 EXPECT_FALSE(delegate->scroll_begin()); 3062 EXPECT_FALSE(delegate->scroll_begin());
3063 3063
3064 EXPECT_FALSE(delegate->tap()); 3064 EXPECT_FALSE(delegate->tap());
3065 EXPECT_FALSE(delegate->two_finger_tap()); 3065 EXPECT_FALSE(delegate->two_finger_tap());
3066 3066
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3103 3103
3104 EXPECT_FALSE(delegate->pinch_begin()); 3104 EXPECT_FALSE(delegate->pinch_begin());
3105 EXPECT_FALSE(delegate->pinch_update()); 3105 EXPECT_FALSE(delegate->pinch_update());
3106 EXPECT_FALSE(delegate->pinch_end()); 3106 EXPECT_FALSE(delegate->pinch_end());
3107 3107
3108 delegate->Reset(); 3108 delegate->Reset();
3109 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 3109 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
3110 kTouchId1, tes.Now()); 3110 kTouchId1, tes.Now());
3111 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(130, 201), 3111 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(130, 201),
3112 kTouchId2, tes.Now()); 3112 kTouchId2, tes.Now());
3113 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); 3113 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1);
3114 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release2); 3114 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release2);
3115 3115
3116 EXPECT_FALSE(delegate->tap()); 3116 EXPECT_FALSE(delegate->tap());
3117 // Touch release is not consumed, so we still see two finger tap. 3117 // Touch release is not consumed, so we still see two finger tap.
3118 EXPECT_TRUE(delegate->two_finger_tap()); 3118 EXPECT_TRUE(delegate->two_finger_tap());
3119 3119
3120 // Should not see PinchEnd & ScrollEnd. 3120 // Should not see PinchEnd & ScrollEnd.
3121 EXPECT_FALSE(delegate->scroll_begin()); 3121 EXPECT_FALSE(delegate->scroll_begin());
3122 EXPECT_FALSE(delegate->scroll_update()); 3122 EXPECT_FALSE(delegate->scroll_update());
3123 EXPECT_FALSE(delegate->scroll_end()); 3123 EXPECT_FALSE(delegate->scroll_end());
3124 3124
(...skipping 12 matching lines...) Expand all
3137 const int kWindowHeight = 45; 3137 const int kWindowHeight = 45;
3138 const int kTouchId = 5; 3138 const int kTouchId = 5;
3139 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3139 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
3140 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3140 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3141 delegate.get(), -1234, bounds, root_window())); 3141 delegate.get(), -1234, bounds, root_window()));
3142 TimedEvents tes; 3142 TimedEvents tes;
3143 3143
3144 delegate->Reset(); 3144 delegate->Reset();
3145 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 3145 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
3146 kTouchId, tes.Now()); 3146 kTouchId, tes.Now());
3147 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 3147 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
3148 EXPECT_FALSE(delegate->tap()); 3148 EXPECT_FALSE(delegate->tap());
3149 EXPECT_TRUE(delegate->tap_down()); 3149 EXPECT_TRUE(delegate->tap_down());
3150 EXPECT_FALSE(delegate->tap_cancel()); 3150 EXPECT_FALSE(delegate->tap_cancel());
3151 EXPECT_TRUE(delegate->begin()); 3151 EXPECT_TRUE(delegate->begin());
3152 EXPECT_FALSE(delegate->scroll_begin()); 3152 EXPECT_FALSE(delegate->scroll_begin());
3153 EXPECT_FALSE(delegate->scroll_update()); 3153 EXPECT_FALSE(delegate->scroll_update());
3154 EXPECT_FALSE(delegate->scroll_end()); 3154 EXPECT_FALSE(delegate->scroll_end());
3155 3155
3156 // Move the touch-point enough so that it would normally be considered a 3156 // Move the touch-point enough so that it would normally be considered a
3157 // scroll. But since the touch-moves will be consumed, the scroll should not 3157 // scroll. But since the touch-moves will be consumed, the scroll should not
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
3204 EXPECT_FALSE(delegate->scroll_begin()); 3204 EXPECT_FALSE(delegate->scroll_begin());
3205 EXPECT_FALSE(delegate->scroll_update()); 3205 EXPECT_FALSE(delegate->scroll_update());
3206 EXPECT_FALSE(delegate->scroll_end()); 3206 EXPECT_FALSE(delegate->scroll_end());
3207 EXPECT_EQ(0, delegate->scroll_x()); 3207 EXPECT_EQ(0, delegate->scroll_x());
3208 EXPECT_EQ(0, delegate->scroll_y()); 3208 EXPECT_EQ(0, delegate->scroll_y());
3209 3209
3210 // Release the touch. 3210 // Release the touch.
3211 delegate->Reset(); 3211 delegate->Reset();
3212 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 3212 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
3213 kTouchId, tes.LeapForward(50)); 3213 kTouchId, tes.LeapForward(50));
3214 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 3214 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
3215 EXPECT_FALSE(delegate->tap()); 3215 EXPECT_FALSE(delegate->tap());
3216 EXPECT_FALSE(delegate->tap_down()); 3216 EXPECT_FALSE(delegate->tap_down());
3217 EXPECT_FALSE(delegate->tap_cancel()); 3217 EXPECT_FALSE(delegate->tap_cancel());
3218 EXPECT_FALSE(delegate->begin()); 3218 EXPECT_FALSE(delegate->begin());
3219 EXPECT_TRUE(delegate->end()); 3219 EXPECT_TRUE(delegate->end());
3220 EXPECT_FALSE(delegate->scroll_begin()); 3220 EXPECT_FALSE(delegate->scroll_begin());
3221 EXPECT_FALSE(delegate->scroll_update()); 3221 EXPECT_FALSE(delegate->scroll_update());
3222 EXPECT_FALSE(delegate->scroll_end()); 3222 EXPECT_FALSE(delegate->scroll_end());
3223 EXPECT_FALSE(delegate->fling()); 3223 EXPECT_FALSE(delegate->fling());
3224 } 3224 }
3225 3225
3226 // Check that appropriate touch events generate double tap gesture events. 3226 // Check that appropriate touch events generate double tap gesture events.
3227 TEST_F(GestureRecognizerTest, GestureEventDoubleTap) { 3227 TEST_F(GestureRecognizerTest, GestureEventDoubleTap) {
3228 scoped_ptr<GestureEventConsumeDelegate> delegate( 3228 scoped_ptr<GestureEventConsumeDelegate> delegate(
3229 new GestureEventConsumeDelegate()); 3229 new GestureEventConsumeDelegate());
3230 const int kWindowWidth = 123; 3230 const int kWindowWidth = 123;
3231 const int kWindowHeight = 45; 3231 const int kWindowHeight = 45;
3232 const int kTouchId = 2; 3232 const int kTouchId = 2;
3233 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3233 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
3234 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3234 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3235 delegate.get(), -1234, bounds, root_window())); 3235 delegate.get(), -1234, bounds, root_window()));
3236 TimedEvents tes; 3236 TimedEvents tes;
3237 3237
3238 // First tap (tested in GestureEventTap) 3238 // First tap (tested in GestureEventTap)
3239 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(104, 201), 3239 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(104, 201),
3240 kTouchId, tes.Now()); 3240 kTouchId, tes.Now());
3241 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 3241 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1);
3242 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(104, 201), 3242 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(104, 201),
3243 kTouchId, tes.LeapForward(50)); 3243 kTouchId, tes.LeapForward(50));
3244 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); 3244 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1);
3245 delegate->Reset(); 3245 delegate->Reset();
3246 3246
3247 // Second tap 3247 // Second tap
3248 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(101, 203), 3248 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(101, 203),
3249 kTouchId, tes.LeapForward(200)); 3249 kTouchId, tes.LeapForward(200));
3250 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 3250 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2);
3251 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(102, 206), 3251 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(102, 206),
3252 kTouchId, tes.LeapForward(50)); 3252 kTouchId, tes.LeapForward(50));
3253 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release2); 3253 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release2);
3254 3254
3255 EXPECT_TRUE(delegate->tap()); 3255 EXPECT_TRUE(delegate->tap());
3256 EXPECT_TRUE(delegate->tap_down()); 3256 EXPECT_TRUE(delegate->tap_down());
3257 EXPECT_FALSE(delegate->tap_cancel()); 3257 EXPECT_FALSE(delegate->tap_cancel());
3258 EXPECT_TRUE(delegate->begin()); 3258 EXPECT_TRUE(delegate->begin());
3259 EXPECT_TRUE(delegate->end()); 3259 EXPECT_TRUE(delegate->end());
3260 EXPECT_FALSE(delegate->scroll_begin()); 3260 EXPECT_FALSE(delegate->scroll_begin());
3261 EXPECT_FALSE(delegate->scroll_update()); 3261 EXPECT_FALSE(delegate->scroll_update());
3262 EXPECT_FALSE(delegate->scroll_end()); 3262 EXPECT_FALSE(delegate->scroll_end());
3263 3263
3264 EXPECT_EQ(2, delegate->tap_count()); 3264 EXPECT_EQ(2, delegate->tap_count());
3265 } 3265 }
3266 3266
3267 // Check that appropriate touch events generate triple tap gesture events. 3267 // Check that appropriate touch events generate triple tap gesture events.
3268 TEST_F(GestureRecognizerTest, GestureEventTripleTap) { 3268 TEST_F(GestureRecognizerTest, GestureEventTripleTap) {
3269 scoped_ptr<GestureEventConsumeDelegate> delegate( 3269 scoped_ptr<GestureEventConsumeDelegate> delegate(
3270 new GestureEventConsumeDelegate()); 3270 new GestureEventConsumeDelegate());
3271 const int kWindowWidth = 123; 3271 const int kWindowWidth = 123;
3272 const int kWindowHeight = 45; 3272 const int kWindowHeight = 45;
3273 const int kTouchId = 2; 3273 const int kTouchId = 2;
3274 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3274 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
3275 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3275 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3276 delegate.get(), -1234, bounds, root_window())); 3276 delegate.get(), -1234, bounds, root_window()));
3277 TimedEvents tes; 3277 TimedEvents tes;
3278 3278
3279 // First tap (tested in GestureEventTap) 3279 // First tap (tested in GestureEventTap)
3280 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(104, 201), 3280 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(104, 201),
3281 kTouchId, tes.Now()); 3281 kTouchId, tes.Now());
3282 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 3282 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1);
3283 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(104, 201), 3283 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(104, 201),
3284 kTouchId, tes.LeapForward(50)); 3284 kTouchId, tes.LeapForward(50));
3285 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); 3285 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1);
3286 3286
3287 EXPECT_EQ(1, delegate->tap_count()); 3287 EXPECT_EQ(1, delegate->tap_count());
3288 delegate->Reset(); 3288 delegate->Reset();
3289 3289
3290 // Second tap (tested in GestureEventDoubleTap) 3290 // Second tap (tested in GestureEventDoubleTap)
3291 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(101, 203), 3291 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(101, 203),
3292 kTouchId, tes.LeapForward(200)); 3292 kTouchId, tes.LeapForward(200));
3293 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 3293 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2);
3294 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(102, 206), 3294 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(102, 206),
3295 kTouchId, tes.LeapForward(50)); 3295 kTouchId, tes.LeapForward(50));
3296 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release2); 3296 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release2);
3297 3297
3298 EXPECT_EQ(2, delegate->tap_count()); 3298 EXPECT_EQ(2, delegate->tap_count());
3299 delegate->Reset(); 3299 delegate->Reset();
3300 3300
3301 // Third tap 3301 // Third tap
3302 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(102, 206), 3302 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(102, 206),
3303 kTouchId, tes.LeapForward(200)); 3303 kTouchId, tes.LeapForward(200));
3304 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press3); 3304 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press3);
3305 ui::TouchEvent release3(ui::ET_TOUCH_RELEASED, gfx::Point(102, 206), 3305 ui::TouchEvent release3(ui::ET_TOUCH_RELEASED, gfx::Point(102, 206),
3306 kTouchId, tes.LeapForward(50)); 3306 kTouchId, tes.LeapForward(50));
3307 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release3); 3307 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release3);
3308 3308
3309 3309
3310 EXPECT_TRUE(delegate->tap()); 3310 EXPECT_TRUE(delegate->tap());
3311 EXPECT_TRUE(delegate->tap_down()); 3311 EXPECT_TRUE(delegate->tap_down());
3312 EXPECT_FALSE(delegate->tap_cancel()); 3312 EXPECT_FALSE(delegate->tap_cancel());
3313 EXPECT_TRUE(delegate->begin()); 3313 EXPECT_TRUE(delegate->begin());
3314 EXPECT_TRUE(delegate->end()); 3314 EXPECT_TRUE(delegate->end());
3315 EXPECT_FALSE(delegate->scroll_begin()); 3315 EXPECT_FALSE(delegate->scroll_begin());
3316 EXPECT_FALSE(delegate->scroll_update()); 3316 EXPECT_FALSE(delegate->scroll_update());
3317 EXPECT_FALSE(delegate->scroll_end()); 3317 EXPECT_FALSE(delegate->scroll_end());
3318 3318
3319 EXPECT_EQ(3, delegate->tap_count()); 3319 EXPECT_EQ(3, delegate->tap_count());
3320 } 3320 }
3321 3321
3322 // Check that we don't get a double tap when the two taps are far apart. 3322 // Check that we don't get a double tap when the two taps are far apart.
3323 TEST_F(GestureRecognizerTest, TwoTapsFarApart) { 3323 TEST_F(GestureRecognizerTest, TwoTapsFarApart) {
3324 scoped_ptr<GestureEventConsumeDelegate> delegate( 3324 scoped_ptr<GestureEventConsumeDelegate> delegate(
3325 new GestureEventConsumeDelegate()); 3325 new GestureEventConsumeDelegate());
3326 const int kWindowWidth = 123; 3326 const int kWindowWidth = 123;
3327 const int kWindowHeight = 45; 3327 const int kWindowHeight = 45;
3328 const int kTouchId = 2; 3328 const int kTouchId = 2;
3329 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3329 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
3330 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3330 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3331 delegate.get(), -1234, bounds, root_window())); 3331 delegate.get(), -1234, bounds, root_window()));
3332 TimedEvents tes; 3332 TimedEvents tes;
3333 3333
3334 // First tap (tested in GestureEventTap) 3334 // First tap (tested in GestureEventTap)
3335 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 3335 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
3336 kTouchId, tes.Now()); 3336 kTouchId, tes.Now());
3337 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 3337 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1);
3338 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 3338 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
3339 kTouchId, tes.LeapForward(50)); 3339 kTouchId, tes.LeapForward(50));
3340 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); 3340 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1);
3341 delegate->Reset(); 3341 delegate->Reset();
3342 3342
3343 // Second tap, close in time but far in distance 3343 // Second tap, close in time but far in distance
3344 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(201, 201), 3344 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(201, 201),
3345 kTouchId, tes.LeapForward(200)); 3345 kTouchId, tes.LeapForward(200));
3346 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 3346 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2);
3347 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(201, 201), 3347 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(201, 201),
3348 kTouchId, tes.LeapForward(50)); 3348 kTouchId, tes.LeapForward(50));
3349 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release2); 3349 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release2);
3350 3350
3351 EXPECT_TRUE(delegate->tap()); 3351 EXPECT_TRUE(delegate->tap());
3352 EXPECT_TRUE(delegate->tap_down()); 3352 EXPECT_TRUE(delegate->tap_down());
3353 EXPECT_FALSE(delegate->tap_cancel()); 3353 EXPECT_FALSE(delegate->tap_cancel());
3354 EXPECT_TRUE(delegate->begin()); 3354 EXPECT_TRUE(delegate->begin());
3355 EXPECT_TRUE(delegate->end()); 3355 EXPECT_TRUE(delegate->end());
3356 EXPECT_FALSE(delegate->scroll_begin()); 3356 EXPECT_FALSE(delegate->scroll_begin());
3357 EXPECT_FALSE(delegate->scroll_update()); 3357 EXPECT_FALSE(delegate->scroll_update());
3358 EXPECT_FALSE(delegate->scroll_end()); 3358 EXPECT_FALSE(delegate->scroll_end());
3359 3359
3360 EXPECT_EQ(1, delegate->tap_count()); 3360 EXPECT_EQ(1, delegate->tap_count());
3361 } 3361 }
3362 3362
3363 // Check that we don't get a double tap when the two taps have a long enough 3363 // Check that we don't get a double tap when the two taps have a long enough
3364 // delay in between. 3364 // delay in between.
3365 TEST_F(GestureRecognizerTest, TwoTapsWithDelayBetween) { 3365 TEST_F(GestureRecognizerTest, TwoTapsWithDelayBetween) {
3366 scoped_ptr<GestureEventConsumeDelegate> delegate( 3366 scoped_ptr<GestureEventConsumeDelegate> delegate(
3367 new GestureEventConsumeDelegate()); 3367 new GestureEventConsumeDelegate());
3368 const int kWindowWidth = 123; 3368 const int kWindowWidth = 123;
3369 const int kWindowHeight = 45; 3369 const int kWindowHeight = 45;
3370 const int kTouchId = 2; 3370 const int kTouchId = 2;
3371 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3371 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
3372 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3372 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3373 delegate.get(), -1234, bounds, root_window())); 3373 delegate.get(), -1234, bounds, root_window()));
3374 TimedEvents tes; 3374 TimedEvents tes;
3375 3375
3376 // First tap (tested in GestureEventTap) 3376 // First tap (tested in GestureEventTap)
3377 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 3377 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
3378 kTouchId, tes.Now()); 3378 kTouchId, tes.Now());
3379 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 3379 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1);
3380 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 3380 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
3381 kTouchId, tes.LeapForward(50)); 3381 kTouchId, tes.LeapForward(50));
3382 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); 3382 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1);
3383 delegate->Reset(); 3383 delegate->Reset();
3384 3384
3385 // Second tap, close in distance but after some delay 3385 // Second tap, close in distance but after some delay
3386 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 3386 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
3387 kTouchId, tes.LeapForward(2000)); 3387 kTouchId, tes.LeapForward(2000));
3388 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 3388 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2);
3389 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 3389 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
3390 kTouchId, tes.LeapForward(50)); 3390 kTouchId, tes.LeapForward(50));
3391 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release2); 3391 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release2);
3392 3392
3393 EXPECT_TRUE(delegate->tap()); 3393 EXPECT_TRUE(delegate->tap());
3394 EXPECT_TRUE(delegate->tap_down()); 3394 EXPECT_TRUE(delegate->tap_down());
3395 EXPECT_FALSE(delegate->tap_cancel()); 3395 EXPECT_FALSE(delegate->tap_cancel());
3396 EXPECT_TRUE(delegate->begin()); 3396 EXPECT_TRUE(delegate->begin());
3397 EXPECT_TRUE(delegate->end()); 3397 EXPECT_TRUE(delegate->end());
3398 EXPECT_FALSE(delegate->scroll_begin()); 3398 EXPECT_FALSE(delegate->scroll_begin());
3399 EXPECT_FALSE(delegate->scroll_update()); 3399 EXPECT_FALSE(delegate->scroll_update());
3400 EXPECT_FALSE(delegate->scroll_end()); 3400 EXPECT_FALSE(delegate->scroll_end());
3401 3401
3402 EXPECT_EQ(1, delegate->tap_count()); 3402 EXPECT_EQ(1, delegate->tap_count());
3403 } 3403 }
3404 3404
3405 // Checks that if the bounding-box of a gesture changes because of change in 3405 // Checks that if the bounding-box of a gesture changes because of change in
3406 // radius of a touch-point, and not because of change in position, then there 3406 // radius of a touch-point, and not because of change in position, then there
3407 // are not gesture events from that. 3407 // are not gesture events from that.
3408 TEST_F(GestureRecognizerTest, BoundingBoxRadiusChange) { 3408 TEST_F(GestureRecognizerTest, BoundingBoxRadiusChange) {
3409 scoped_ptr<GestureEventConsumeDelegate> delegate( 3409 scoped_ptr<GestureEventConsumeDelegate> delegate(
3410 new GestureEventConsumeDelegate()); 3410 new GestureEventConsumeDelegate());
3411 const int kWindowWidth = 234; 3411 const int kWindowWidth = 234;
3412 const int kWindowHeight = 345; 3412 const int kWindowHeight = 345;
3413 const int kTouchId = 5, kTouchId2 = 7; 3413 const int kTouchId = 5, kTouchId2 = 7;
3414 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3414 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
3415 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3415 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3416 delegate.get(), -1234, bounds, root_window())); 3416 delegate.get(), -1234, bounds, root_window()));
3417 TimedEvents tes; 3417 TimedEvents tes;
3418 3418
3419 ui::TouchEvent press1( 3419 ui::TouchEvent press1(
3420 ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId, tes.Now()); 3420 ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId, tes.Now());
3421 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 3421 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1);
3422 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); 3422 EXPECT_TRUE(delegate->bounding_box().IsEmpty());
3423 3423
3424 delegate->Reset(); 3424 delegate->Reset();
3425 3425
3426 ui::TouchEvent press2( 3426 ui::TouchEvent press2(
3427 ui::ET_TOUCH_PRESSED, gfx::Point(201, 201), kTouchId2, 3427 ui::ET_TOUCH_PRESSED, gfx::Point(201, 201), kTouchId2,
3428 tes.LeapForward(400)); 3428 tes.LeapForward(400));
3429 press2.set_radius_x(5); 3429 press2.set_radius_x(5);
3430 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 3430 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2);
3431 EXPECT_FALSE(delegate->pinch_begin()); 3431 EXPECT_FALSE(delegate->pinch_begin());
3432 EXPECT_EQ(gfx::Rect(101, 201, 100, 0).ToString(), 3432 EXPECT_EQ(gfx::Rect(101, 201, 100, 0).ToString(),
3433 delegate->bounding_box().ToString()); 3433 delegate->bounding_box().ToString());
3434 3434
3435 delegate->Reset(); 3435 delegate->Reset();
3436 3436
3437 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(141, 201), kTouchId, 3437 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(141, 201), kTouchId,
3438 tes.LeapForward(40)); 3438 tes.LeapForward(40));
3439 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move1); 3439 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move1);
3440 EXPECT_TRUE(delegate->pinch_begin()); 3440 EXPECT_TRUE(delegate->pinch_begin());
3441 EXPECT_EQ(gfx::Rect(141, 201, 60, 0).ToString(), 3441 EXPECT_EQ(gfx::Rect(141, 201, 60, 0).ToString(),
3442 delegate->bounding_box().ToString()); 3442 delegate->bounding_box().ToString());
3443 3443
3444 delegate->Reset(); 3444 delegate->Reset();
3445 3445
3446 // The position doesn't move, but the radius changes. 3446 // The position doesn't move, but the radius changes.
3447 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(101, 201), kTouchId, 3447 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(101, 201), kTouchId,
3448 tes.LeapForward(40)); 3448 tes.LeapForward(40));
3449 move2.set_radius_x(50); 3449 move2.set_radius_x(50);
3450 move2.set_radius_y(60); 3450 move2.set_radius_y(60);
3451 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2); 3451 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move2);
3452 EXPECT_FALSE(delegate->tap()); 3452 EXPECT_FALSE(delegate->tap());
3453 EXPECT_FALSE(delegate->tap_cancel()); 3453 EXPECT_FALSE(delegate->tap_cancel());
3454 EXPECT_FALSE(delegate->scroll_update()); 3454 EXPECT_FALSE(delegate->scroll_update());
3455 EXPECT_FALSE(delegate->pinch_update()); 3455 EXPECT_FALSE(delegate->pinch_update());
3456 3456
3457 delegate->Reset(); 3457 delegate->Reset();
3458 } 3458 }
3459 3459
3460 // Checks that slow scrolls deliver the correct deltas. 3460 // Checks that slow scrolls deliver the correct deltas.
3461 // In particular, fix for http;//crbug.com/150573. 3461 // In particular, fix for http;//crbug.com/150573.
3462 TEST_F(GestureRecognizerTest, NoDriftInScroll) { 3462 TEST_F(GestureRecognizerTest, NoDriftInScroll) {
3463 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(3); 3463 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(3);
3464 ui::GestureConfiguration::set_min_scroll_delta_squared(9); 3464 ui::GestureConfiguration::set_min_scroll_delta_squared(9);
3465 scoped_ptr<GestureEventConsumeDelegate> delegate( 3465 scoped_ptr<GestureEventConsumeDelegate> delegate(
3466 new GestureEventConsumeDelegate()); 3466 new GestureEventConsumeDelegate());
3467 const int kWindowWidth = 234; 3467 const int kWindowWidth = 234;
3468 const int kWindowHeight = 345; 3468 const int kWindowHeight = 345;
3469 const int kTouchId = 5; 3469 const int kTouchId = 5;
3470 TimedEvents tes; 3470 TimedEvents tes;
3471 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3471 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
3472 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3472 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3473 delegate.get(), -1234, bounds, root_window())); 3473 delegate.get(), -1234, bounds, root_window()));
3474 3474
3475 ui::TouchEvent press1( 3475 ui::TouchEvent press1(
3476 ui::ET_TOUCH_PRESSED, gfx::Point(101, 208), kTouchId, tes.Now()); 3476 ui::ET_TOUCH_PRESSED, gfx::Point(101, 208), kTouchId, tes.Now());
3477 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 3477 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1);
3478 EXPECT_TRUE(delegate->begin()); 3478 EXPECT_TRUE(delegate->begin());
3479 3479
3480 delegate->Reset(); 3480 delegate->Reset();
3481 3481
3482 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(101, 206), kTouchId, 3482 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(101, 206), kTouchId,
3483 tes.LeapForward(40)); 3483 tes.LeapForward(40));
3484 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move1); 3484 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move1);
3485 EXPECT_FALSE(delegate->scroll_begin()); 3485 EXPECT_FALSE(delegate->scroll_begin());
3486 3486
3487 delegate->Reset(); 3487 delegate->Reset();
3488 3488
3489 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(101, 204), kTouchId, 3489 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(101, 204), kTouchId,
3490 tes.LeapForward(40)); 3490 tes.LeapForward(40));
3491 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2); 3491 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move2);
3492 EXPECT_TRUE(delegate->tap_cancel()); 3492 EXPECT_TRUE(delegate->tap_cancel());
3493 EXPECT_TRUE(delegate->scroll_begin()); 3493 EXPECT_TRUE(delegate->scroll_begin());
3494 EXPECT_TRUE(delegate->scroll_update()); 3494 EXPECT_TRUE(delegate->scroll_update());
3495 EXPECT_EQ(-4, delegate->scroll_y()); 3495 EXPECT_EQ(-4, delegate->scroll_y());
3496 EXPECT_EQ(-4, delegate->scroll_y_hint()); 3496 EXPECT_EQ(-4, delegate->scroll_y_hint());
3497 3497
3498 delegate->Reset(); 3498 delegate->Reset();
3499 3499
3500 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(101, 204), kTouchId, 3500 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(101, 204), kTouchId,
3501 tes.LeapForward(40)); 3501 tes.LeapForward(40));
3502 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move3); 3502 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move3);
3503 EXPECT_FALSE(delegate->scroll_update()); 3503 EXPECT_FALSE(delegate->scroll_update());
3504 3504
3505 delegate->Reset(); 3505 delegate->Reset();
3506 3506
3507 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(101, 203), kTouchId, 3507 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(101, 203), kTouchId,
3508 tes.LeapForward(40)); 3508 tes.LeapForward(40));
3509 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move4); 3509 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move4);
3510 EXPECT_TRUE(delegate->scroll_update()); 3510 EXPECT_TRUE(delegate->scroll_update());
3511 EXPECT_EQ(-1, delegate->scroll_y()); 3511 EXPECT_EQ(-1, delegate->scroll_y());
3512 3512
3513 delegate->Reset(); 3513 delegate->Reset();
3514 } 3514 }
3515 3515
3516 // Ensure that move events which are preventDefaulted will cause a tap 3516 // Ensure that move events which are preventDefaulted will cause a tap
3517 // cancel gesture event to be fired if the move would normally cause a 3517 // cancel gesture event to be fired if the move would normally cause a
3518 // scroll. See bug http://crbug.com/146397. 3518 // scroll. See bug http://crbug.com/146397.
3519 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveCanFireTapCancel) { 3519 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveCanFireTapCancel) {
3520 scoped_ptr<ConsumesTouchMovesDelegate> delegate( 3520 scoped_ptr<ConsumesTouchMovesDelegate> delegate(
3521 new ConsumesTouchMovesDelegate()); 3521 new ConsumesTouchMovesDelegate());
3522 const int kTouchId = 5; 3522 const int kTouchId = 5;
3523 gfx::Rect bounds(100, 200, 123, 45); 3523 gfx::Rect bounds(100, 200, 123, 45);
3524 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3524 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3525 delegate.get(), -1234, bounds, root_window())); 3525 delegate.get(), -1234, bounds, root_window()));
3526 TimedEvents tes; 3526 TimedEvents tes;
3527 3527
3528 delegate->Reset(); 3528 delegate->Reset();
3529 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 3529 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
3530 kTouchId, tes.Now()); 3530 kTouchId, tes.Now());
3531 3531
3532 delegate->set_consume_touch_move(false); 3532 delegate->set_consume_touch_move(false);
3533 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 3533 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
3534 delegate->set_consume_touch_move(true); 3534 delegate->set_consume_touch_move(true);
3535 delegate->Reset(); 3535 delegate->Reset();
3536 // Move the touch-point enough so that it would normally be considered a 3536 // Move the touch-point enough so that it would normally be considered a
3537 // scroll. But since the touch-moves will be consumed, the scroll should not 3537 // scroll. But since the touch-moves will be consumed, the scroll should not
3538 // start. 3538 // start.
3539 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get()); 3539 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get());
3540 EXPECT_FALSE(delegate->tap()); 3540 EXPECT_FALSE(delegate->tap());
3541 EXPECT_FALSE(delegate->tap_down()); 3541 EXPECT_FALSE(delegate->tap_down());
3542 EXPECT_TRUE(delegate->tap_cancel()); 3542 EXPECT_TRUE(delegate->tap_cancel());
3543 EXPECT_FALSE(delegate->begin()); 3543 EXPECT_FALSE(delegate->begin());
(...skipping 16 matching lines...) Expand all
3560 scoped_ptr<RemoveOnTouchCancelHandler> 3560 scoped_ptr<RemoveOnTouchCancelHandler>
3561 handler(new RemoveOnTouchCancelHandler()); 3561 handler(new RemoveOnTouchCancelHandler());
3562 window->AddPreTargetHandler(handler.get()); 3562 window->AddPreTargetHandler(handler.get());
3563 3563
3564 // Start a gesture sequence on |window|. Then transfer the events to NULL. 3564 // Start a gesture sequence on |window|. Then transfer the events to NULL.
3565 // Make sure |window| receives a touch-cancel event. 3565 // Make sure |window| receives a touch-cancel event.
3566 delegate->Reset(); 3566 delegate->Reset();
3567 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 3567 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
3568 kTouchId, tes.Now()); 3568 kTouchId, tes.Now());
3569 ui::TouchEvent p2(ui::ET_TOUCH_PRESSED, gfx::Point(50, 50), 1, tes.Now()); 3569 ui::TouchEvent p2(ui::ET_TOUCH_PRESSED, gfx::Point(50, 50), 1, tes.Now());
3570 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 3570 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
3571 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&p2); 3571 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&p2);
3572 EXPECT_FALSE(delegate->tap()); 3572 EXPECT_FALSE(delegate->tap());
3573 EXPECT_TRUE(delegate->tap_down()); 3573 EXPECT_TRUE(delegate->tap_down());
3574 EXPECT_TRUE(delegate->tap_cancel()); 3574 EXPECT_TRUE(delegate->tap_cancel());
3575 EXPECT_TRUE(delegate->begin()); 3575 EXPECT_TRUE(delegate->begin());
3576 EXPECT_EQ(2, handler->touch_pressed_count()); 3576 EXPECT_EQ(2, handler->touch_pressed_count());
3577 delegate->Reset(); 3577 delegate->Reset();
3578 handler->Reset(); 3578 handler->Reset();
3579 3579
3580 ui::GestureRecognizer* gesture_recognizer = ui::GestureRecognizer::Get(); 3580 ui::GestureRecognizer* gesture_recognizer = ui::GestureRecognizer::Get();
3581 EXPECT_EQ(window.get(), 3581 EXPECT_EQ(window.get(),
(...skipping 20 matching lines...) Expand all
3602 3602
3603 delegate->Reset(); 3603 delegate->Reset();
3604 3604
3605 TimerTestGestureRecognizer* gesture_recognizer = 3605 TimerTestGestureRecognizer* gesture_recognizer =
3606 new TimerTestGestureRecognizer(); 3606 new TimerTestGestureRecognizer();
3607 3607
3608 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); 3608 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer);
3609 3609
3610 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 3610 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
3611 kTouchId, tes.Now()); 3611 kTouchId, tes.Now());
3612 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 3612 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1);
3613 EXPECT_TRUE(delegate->tap_down()); 3613 EXPECT_TRUE(delegate->tap_down());
3614 EXPECT_TRUE(delegate->begin()); 3614 EXPECT_TRUE(delegate->begin());
3615 EXPECT_FALSE(delegate->tap_cancel()); 3615 EXPECT_FALSE(delegate->tap_cancel());
3616 3616
3617 // We haven't pressed long enough for a show press to occur 3617 // We haven't pressed long enough for a show press to occur
3618 EXPECT_FALSE(delegate->show_press()); 3618 EXPECT_FALSE(delegate->show_press());
3619 3619
3620 // Wait until the timer runs out 3620 // Wait until the timer runs out
3621 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_SHOW_PRESS); 3621 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_SHOW_PRESS);
3622 EXPECT_TRUE(delegate->show_press()); 3622 EXPECT_TRUE(delegate->show_press());
3623 EXPECT_FALSE(delegate->tap_cancel()); 3623 EXPECT_FALSE(delegate->tap_cancel());
3624 3624
3625 delegate->Reset(); 3625 delegate->Reset();
3626 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 3626 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
3627 kTouchId, tes.Now()); 3627 kTouchId, tes.Now());
3628 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); 3628 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1);
3629 EXPECT_FALSE(delegate->long_press()); 3629 EXPECT_FALSE(delegate->long_press());
3630 3630
3631 // Note the tap down isn't cancelled until the release 3631 // Note the tap down isn't cancelled until the release
3632 EXPECT_TRUE(delegate->tap_cancel()); 3632 EXPECT_TRUE(delegate->tap_cancel());
3633 } 3633 }
3634 3634
3635 // Check that scrolling cancels a show press 3635 // Check that scrolling cancels a show press
3636 TEST_F(GestureRecognizerTest, GestureEventShowPressCancelledByScroll) { 3636 TEST_F(GestureRecognizerTest, GestureEventShowPressCancelledByScroll) {
3637 scoped_ptr<GestureEventConsumeDelegate> delegate( 3637 scoped_ptr<GestureEventConsumeDelegate> delegate(
3638 new GestureEventConsumeDelegate()); 3638 new GestureEventConsumeDelegate());
(...skipping 11 matching lines...) Expand all
3650 new TimerTestGestureRecognizer(); 3650 new TimerTestGestureRecognizer();
3651 3651
3652 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); 3652 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer);
3653 3653
3654 TimerTestGestureSequence* gesture_sequence = 3654 TimerTestGestureSequence* gesture_sequence =
3655 static_cast<TimerTestGestureSequence*>( 3655 static_cast<TimerTestGestureSequence*>(
3656 gesture_recognizer->GetGestureSequenceForTesting(window.get())); 3656 gesture_recognizer->GetGestureSequenceForTesting(window.get()));
3657 3657
3658 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 3658 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
3659 kTouchId, tes.Now()); 3659 kTouchId, tes.Now());
3660 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 3660 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1);
3661 EXPECT_TRUE(delegate->tap_down()); 3661 EXPECT_TRUE(delegate->tap_down());
3662 3662
3663 // We haven't pressed long enough for a show press to occur 3663 // We haven't pressed long enough for a show press to occur
3664 EXPECT_FALSE(delegate->show_press()); 3664 EXPECT_FALSE(delegate->show_press());
3665 EXPECT_FALSE(delegate->tap_cancel()); 3665 EXPECT_FALSE(delegate->tap_cancel());
3666 3666
3667 // Scroll around, to cancel the show press 3667 // Scroll around, to cancel the show press
3668 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get()); 3668 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get());
3669 // Wait until the timer runs out 3669 // Wait until the timer runs out
3670 gesture_sequence->ForceTimeout(); 3670 gesture_sequence->ForceTimeout();
3671 EXPECT_FALSE(delegate->show_press()); 3671 EXPECT_FALSE(delegate->show_press());
3672 EXPECT_TRUE(delegate->tap_cancel()); 3672 EXPECT_TRUE(delegate->tap_cancel());
3673 3673
3674 delegate->Reset(); 3674 delegate->Reset();
3675 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 3675 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
3676 kTouchId, tes.LeapForward(10)); 3676 kTouchId, tes.LeapForward(10));
3677 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); 3677 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1);
3678 EXPECT_FALSE(delegate->show_press()); 3678 EXPECT_FALSE(delegate->show_press());
3679 EXPECT_FALSE(delegate->tap_cancel()); 3679 EXPECT_FALSE(delegate->tap_cancel());
3680 } 3680 }
3681 3681
3682 // Test that show press events are sent immediately on tap 3682 // Test that show press events are sent immediately on tap
3683 TEST_F(GestureRecognizerTest, GestureEventShowPressSentOnTap) { 3683 TEST_F(GestureRecognizerTest, GestureEventShowPressSentOnTap) {
3684 scoped_ptr<GestureEventConsumeDelegate> delegate( 3684 scoped_ptr<GestureEventConsumeDelegate> delegate(
3685 new GestureEventConsumeDelegate()); 3685 new GestureEventConsumeDelegate());
3686 TimedEvents tes; 3686 TimedEvents tes;
3687 const int kWindowWidth = 123; 3687 const int kWindowWidth = 123;
3688 const int kWindowHeight = 45; 3688 const int kWindowHeight = 45;
3689 const int kTouchId = 6; 3689 const int kTouchId = 6;
3690 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3690 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
3691 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3691 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3692 delegate.get(), -1234, bounds, root_window())); 3692 delegate.get(), -1234, bounds, root_window()));
3693 3693
3694 delegate->Reset(); 3694 delegate->Reset();
3695 3695
3696 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 3696 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
3697 kTouchId, tes.Now()); 3697 kTouchId, tes.Now());
3698 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 3698 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1);
3699 EXPECT_TRUE(delegate->tap_down()); 3699 EXPECT_TRUE(delegate->tap_down());
3700 3700
3701 // We haven't pressed long enough for a show press to occur 3701 // We haven't pressed long enough for a show press to occur
3702 EXPECT_FALSE(delegate->show_press()); 3702 EXPECT_FALSE(delegate->show_press());
3703 EXPECT_FALSE(delegate->tap_cancel()); 3703 EXPECT_FALSE(delegate->tap_cancel());
3704 3704
3705 delegate->Reset(); 3705 delegate->Reset();
3706 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 3706 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
3707 kTouchId, tes.LeapForward(50)); 3707 kTouchId, tes.LeapForward(50));
3708 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); 3708 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1);
3709 EXPECT_TRUE(delegate->show_press()); 3709 EXPECT_TRUE(delegate->show_press());
3710 EXPECT_FALSE(delegate->tap_cancel()); 3710 EXPECT_FALSE(delegate->tap_cancel());
3711 EXPECT_TRUE(delegate->tap()); 3711 EXPECT_TRUE(delegate->tap());
3712 } 3712 }
3713 3713
3714 } // namespace test 3714 } // namespace test
3715 } // namespace aura 3715 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/env.h ('k') | ui/aura/remote_root_window_host_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698