| OLD | NEW |
| 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 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 GestureEventConsumeDelegate* delegate) { | 589 GestureEventConsumeDelegate* delegate) { |
| 590 int x = x_start; | 590 int x = x_start; |
| 591 int y = y_start; | 591 int y = y_start; |
| 592 | 592 |
| 593 for (int i = 0; i < num_steps; i++) { | 593 for (int i = 0; i < num_steps; i++) { |
| 594 x += dx; | 594 x += dx; |
| 595 y += dy; | 595 y += dy; |
| 596 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(x, y), | 596 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(x, y), |
| 597 touch_id, | 597 touch_id, |
| 598 base::TimeDelta::FromMilliseconds(simulated_now_)); | 598 base::TimeDelta::FromMilliseconds(simulated_now_)); |
| 599 root_window->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move); | 599 ui::EventDispatchDetails details = root_window->OnEventFromSource(&move); |
| 600 ASSERT_FALSE(details.dispatcher_destroyed); |
| 600 simulated_now_ += time_step; | 601 simulated_now_ += time_step; |
| 601 } | 602 } |
| 602 } | 603 } |
| 603 | 604 |
| 604 void SendScrollEvent(RootWindow* root_window, | 605 void SendScrollEvent(RootWindow* root_window, |
| 605 float x, | 606 float x, |
| 606 float y, | 607 float y, |
| 607 int touch_id, | 608 int touch_id, |
| 608 GestureEventConsumeDelegate* delegate) { | 609 GestureEventConsumeDelegate* delegate) { |
| 609 delegate->Reset(); | 610 delegate->Reset(); |
| 610 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(x, y), | 611 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(x, y), |
| 611 touch_id, | 612 touch_id, |
| 612 base::TimeDelta::FromMilliseconds(simulated_now_)); | 613 base::TimeDelta::FromMilliseconds(simulated_now_)); |
| 613 root_window->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move); | 614 ui::EventDispatchDetails details = root_window->OnEventFromSource(&move); |
| 615 ASSERT_FALSE(details.dispatcher_destroyed); |
| 614 simulated_now_++; | 616 simulated_now_++; |
| 615 } | 617 } |
| 616 }; | 618 }; |
| 617 | 619 |
| 618 // An event handler to keep track of events. | 620 // An event handler to keep track of events. |
| 619 class TestEventHandler : public ui::EventHandler { | 621 class TestEventHandler : public ui::EventHandler { |
| 620 public: | 622 public: |
| 621 TestEventHandler() : touch_released_count_(0), touch_pressed_count_(0), | 623 TestEventHandler() : touch_released_count_(0), touch_pressed_count_(0), |
| 622 touch_moved_count_(0), touch_stationary_count_(0), | 624 touch_moved_count_(0), touch_stationary_count_(0), |
| 623 touch_cancelled_count_(0) { | 625 touch_cancelled_count_(0) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 const int kWindowWidth = 123; | 719 const int kWindowWidth = 123; |
| 718 const int kWindowHeight = 45; | 720 const int kWindowHeight = 45; |
| 719 const int kTouchId = 2; | 721 const int kTouchId = 2; |
| 720 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 722 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 721 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 723 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 722 delegate.get(), -1234, bounds, root_window())); | 724 delegate.get(), -1234, bounds, root_window())); |
| 723 | 725 |
| 724 delegate->Reset(); | 726 delegate->Reset(); |
| 725 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 727 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 726 kTouchId, tes.Now()); | 728 kTouchId, tes.Now()); |
| 727 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 729 DispatchEventUsingWindowDispatcher(&press); |
| 728 EXPECT_FALSE(delegate->tap()); | 730 EXPECT_FALSE(delegate->tap()); |
| 729 EXPECT_FALSE(delegate->show_press()); | 731 EXPECT_FALSE(delegate->show_press()); |
| 730 EXPECT_TRUE(delegate->tap_down()); | 732 EXPECT_TRUE(delegate->tap_down()); |
| 731 EXPECT_FALSE(delegate->tap_cancel()); | 733 EXPECT_FALSE(delegate->tap_cancel()); |
| 732 EXPECT_TRUE(delegate->begin()); | 734 EXPECT_TRUE(delegate->begin()); |
| 733 EXPECT_FALSE(delegate->scroll_begin()); | 735 EXPECT_FALSE(delegate->scroll_begin()); |
| 734 EXPECT_FALSE(delegate->scroll_update()); | 736 EXPECT_FALSE(delegate->scroll_update()); |
| 735 EXPECT_FALSE(delegate->scroll_end()); | 737 EXPECT_FALSE(delegate->scroll_end()); |
| 736 EXPECT_FALSE(delegate->long_press()); | 738 EXPECT_FALSE(delegate->long_press()); |
| 737 | 739 |
| 738 delegate->Reset(); | 740 delegate->Reset(); |
| 739 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_SHOW_PRESS); | 741 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_SHOW_PRESS); |
| 740 EXPECT_TRUE(delegate->show_press()); | 742 EXPECT_TRUE(delegate->show_press()); |
| 741 EXPECT_FALSE(delegate->tap_down()); | 743 EXPECT_FALSE(delegate->tap_down()); |
| 742 | 744 |
| 743 // Make sure there is enough delay before the touch is released so that it is | 745 // Make sure there is enough delay before the touch is released so that it is |
| 744 // recognized as a tap. | 746 // recognized as a tap. |
| 745 delegate->Reset(); | 747 delegate->Reset(); |
| 746 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 748 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 747 kTouchId, tes.LeapForward(50)); | 749 kTouchId, tes.LeapForward(50)); |
| 748 | 750 |
| 749 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 751 DispatchEventUsingWindowDispatcher(&release); |
| 750 EXPECT_TRUE(delegate->tap()); | 752 EXPECT_TRUE(delegate->tap()); |
| 751 EXPECT_FALSE(delegate->tap_down()); | 753 EXPECT_FALSE(delegate->tap_down()); |
| 752 EXPECT_FALSE(delegate->tap_cancel()); | 754 EXPECT_FALSE(delegate->tap_cancel()); |
| 753 EXPECT_FALSE(delegate->begin()); | 755 EXPECT_FALSE(delegate->begin()); |
| 754 EXPECT_TRUE(delegate->end()); | 756 EXPECT_TRUE(delegate->end()); |
| 755 EXPECT_FALSE(delegate->scroll_begin()); | 757 EXPECT_FALSE(delegate->scroll_begin()); |
| 756 EXPECT_FALSE(delegate->scroll_update()); | 758 EXPECT_FALSE(delegate->scroll_update()); |
| 757 EXPECT_FALSE(delegate->scroll_end()); | 759 EXPECT_FALSE(delegate->scroll_end()); |
| 758 | 760 |
| 759 EXPECT_EQ(1, delegate->tap_count()); | 761 EXPECT_EQ(1, delegate->tap_count()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 772 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 774 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 773 delegate.get(), -1234, bounds, root_window())); | 775 delegate.get(), -1234, bounds, root_window())); |
| 774 | 776 |
| 775 // Test with no ET_TOUCH_MOVED events. | 777 // Test with no ET_TOUCH_MOVED events. |
| 776 { | 778 { |
| 777 delegate->Reset(); | 779 delegate->Reset(); |
| 778 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 780 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 779 kTouchId, tes.Now()); | 781 kTouchId, tes.Now()); |
| 780 press.set_radius_x(5); | 782 press.set_radius_x(5); |
| 781 press.set_radius_y(12); | 783 press.set_radius_y(12); |
| 782 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 784 DispatchEventUsingWindowDispatcher(&press); |
| 783 EXPECT_FALSE(delegate->tap()); | 785 EXPECT_FALSE(delegate->tap()); |
| 784 EXPECT_TRUE(delegate->tap_down()); | 786 EXPECT_TRUE(delegate->tap_down()); |
| 785 EXPECT_FALSE(delegate->tap_cancel()); | 787 EXPECT_FALSE(delegate->tap_cancel()); |
| 786 EXPECT_TRUE(delegate->begin()); | 788 EXPECT_TRUE(delegate->begin()); |
| 787 EXPECT_FALSE(delegate->scroll_begin()); | 789 EXPECT_FALSE(delegate->scroll_begin()); |
| 788 EXPECT_FALSE(delegate->scroll_update()); | 790 EXPECT_FALSE(delegate->scroll_update()); |
| 789 EXPECT_FALSE(delegate->scroll_end()); | 791 EXPECT_FALSE(delegate->scroll_end()); |
| 790 EXPECT_FALSE(delegate->long_press()); | 792 EXPECT_FALSE(delegate->long_press()); |
| 791 | 793 |
| 792 // Make sure there is enough delay before the touch is released so that it | 794 // Make sure there is enough delay before the touch is released so that it |
| 793 // is recognized as a tap. | 795 // is recognized as a tap. |
| 794 delegate->Reset(); | 796 delegate->Reset(); |
| 795 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 797 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 796 kTouchId, tes.LeapForward(50)); | 798 kTouchId, tes.LeapForward(50)); |
| 797 release.set_radius_x(5); | 799 release.set_radius_x(5); |
| 798 release.set_radius_y(12); | 800 release.set_radius_y(12); |
| 799 | 801 |
| 800 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 802 DispatchEventUsingWindowDispatcher(&release); |
| 801 EXPECT_TRUE(delegate->tap()); | 803 EXPECT_TRUE(delegate->tap()); |
| 802 EXPECT_FALSE(delegate->tap_down()); | 804 EXPECT_FALSE(delegate->tap_down()); |
| 803 EXPECT_FALSE(delegate->tap_cancel()); | 805 EXPECT_FALSE(delegate->tap_cancel()); |
| 804 EXPECT_FALSE(delegate->begin()); | 806 EXPECT_FALSE(delegate->begin()); |
| 805 EXPECT_TRUE(delegate->end()); | 807 EXPECT_TRUE(delegate->end()); |
| 806 EXPECT_FALSE(delegate->scroll_begin()); | 808 EXPECT_FALSE(delegate->scroll_begin()); |
| 807 EXPECT_FALSE(delegate->scroll_update()); | 809 EXPECT_FALSE(delegate->scroll_update()); |
| 808 EXPECT_FALSE(delegate->scroll_end()); | 810 EXPECT_FALSE(delegate->scroll_end()); |
| 809 | 811 |
| 810 EXPECT_EQ(1, delegate->tap_count()); | 812 EXPECT_EQ(1, delegate->tap_count()); |
| 811 gfx::Point actual_point(delegate->tap_location()); | 813 gfx::Point actual_point(delegate->tap_location()); |
| 812 EXPECT_EQ(24, delegate->bounding_box().width()); | 814 EXPECT_EQ(24, delegate->bounding_box().width()); |
| 813 EXPECT_EQ(24, delegate->bounding_box().height()); | 815 EXPECT_EQ(24, delegate->bounding_box().height()); |
| 814 EXPECT_EQ(101, actual_point.x()); | 816 EXPECT_EQ(101, actual_point.x()); |
| 815 EXPECT_EQ(201, actual_point.y()); | 817 EXPECT_EQ(201, actual_point.y()); |
| 816 } | 818 } |
| 817 | 819 |
| 818 // Test with no ET_TOUCH_MOVED events but different touch points and radii. | 820 // Test with no ET_TOUCH_MOVED events but different touch points and radii. |
| 819 { | 821 { |
| 820 delegate->Reset(); | 822 delegate->Reset(); |
| 821 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(365, 290), | 823 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(365, 290), |
| 822 kTouchId, tes.Now()); | 824 kTouchId, tes.Now()); |
| 823 press.set_radius_x(8); | 825 press.set_radius_x(8); |
| 824 press.set_radius_y(14); | 826 press.set_radius_y(14); |
| 825 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 827 DispatchEventUsingWindowDispatcher(&press); |
| 826 EXPECT_FALSE(delegate->tap()); | 828 EXPECT_FALSE(delegate->tap()); |
| 827 EXPECT_TRUE(delegate->tap_down()); | 829 EXPECT_TRUE(delegate->tap_down()); |
| 828 EXPECT_FALSE(delegate->tap_cancel()); | 830 EXPECT_FALSE(delegate->tap_cancel()); |
| 829 EXPECT_TRUE(delegate->begin()); | 831 EXPECT_TRUE(delegate->begin()); |
| 830 EXPECT_FALSE(delegate->scroll_begin()); | 832 EXPECT_FALSE(delegate->scroll_begin()); |
| 831 EXPECT_FALSE(delegate->scroll_update()); | 833 EXPECT_FALSE(delegate->scroll_update()); |
| 832 EXPECT_FALSE(delegate->scroll_end()); | 834 EXPECT_FALSE(delegate->scroll_end()); |
| 833 EXPECT_FALSE(delegate->long_press()); | 835 EXPECT_FALSE(delegate->long_press()); |
| 834 | 836 |
| 835 delegate->Reset(); | 837 delegate->Reset(); |
| 836 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(367, 291), | 838 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(367, 291), |
| 837 kTouchId, tes.LeapForward(50)); | 839 kTouchId, tes.LeapForward(50)); |
| 838 release.set_radius_x(20); | 840 release.set_radius_x(20); |
| 839 release.set_radius_y(13); | 841 release.set_radius_y(13); |
| 840 | 842 |
| 841 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 843 DispatchEventUsingWindowDispatcher(&release); |
| 842 EXPECT_TRUE(delegate->tap()); | 844 EXPECT_TRUE(delegate->tap()); |
| 843 EXPECT_FALSE(delegate->tap_down()); | 845 EXPECT_FALSE(delegate->tap_down()); |
| 844 EXPECT_FALSE(delegate->tap_cancel()); | 846 EXPECT_FALSE(delegate->tap_cancel()); |
| 845 EXPECT_FALSE(delegate->begin()); | 847 EXPECT_FALSE(delegate->begin()); |
| 846 EXPECT_TRUE(delegate->end()); | 848 EXPECT_TRUE(delegate->end()); |
| 847 EXPECT_FALSE(delegate->scroll_begin()); | 849 EXPECT_FALSE(delegate->scroll_begin()); |
| 848 EXPECT_FALSE(delegate->scroll_update()); | 850 EXPECT_FALSE(delegate->scroll_update()); |
| 849 EXPECT_FALSE(delegate->scroll_end()); | 851 EXPECT_FALSE(delegate->scroll_end()); |
| 850 | 852 |
| 851 EXPECT_EQ(1, delegate->tap_count()); | 853 EXPECT_EQ(1, delegate->tap_count()); |
| 852 gfx::Point actual_point(delegate->tap_location()); | 854 gfx::Point actual_point(delegate->tap_location()); |
| 853 EXPECT_EQ(40, delegate->bounding_box().width()); | 855 EXPECT_EQ(40, delegate->bounding_box().width()); |
| 854 EXPECT_EQ(40, delegate->bounding_box().height()); | 856 EXPECT_EQ(40, delegate->bounding_box().height()); |
| 855 EXPECT_EQ(367, actual_point.x()); | 857 EXPECT_EQ(367, actual_point.x()); |
| 856 EXPECT_EQ(291, actual_point.y()); | 858 EXPECT_EQ(291, actual_point.y()); |
| 857 } | 859 } |
| 858 | 860 |
| 859 // Test with a single ET_TOUCH_MOVED event. | 861 // Test with a single ET_TOUCH_MOVED event. |
| 860 { | 862 { |
| 861 delegate->Reset(); | 863 delegate->Reset(); |
| 862 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(46, 205), | 864 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(46, 205), |
| 863 kTouchId, tes.Now()); | 865 kTouchId, tes.Now()); |
| 864 press.set_radius_x(6); | 866 press.set_radius_x(6); |
| 865 press.set_radius_y(10); | 867 press.set_radius_y(10); |
| 866 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 868 DispatchEventUsingWindowDispatcher(&press); |
| 867 EXPECT_FALSE(delegate->tap()); | 869 EXPECT_FALSE(delegate->tap()); |
| 868 EXPECT_TRUE(delegate->tap_down()); | 870 EXPECT_TRUE(delegate->tap_down()); |
| 869 EXPECT_FALSE(delegate->tap_cancel()); | 871 EXPECT_FALSE(delegate->tap_cancel()); |
| 870 EXPECT_TRUE(delegate->begin()); | 872 EXPECT_TRUE(delegate->begin()); |
| 871 EXPECT_FALSE(delegate->tap_cancel()); | 873 EXPECT_FALSE(delegate->tap_cancel()); |
| 872 EXPECT_FALSE(delegate->scroll_begin()); | 874 EXPECT_FALSE(delegate->scroll_begin()); |
| 873 EXPECT_FALSE(delegate->scroll_update()); | 875 EXPECT_FALSE(delegate->scroll_update()); |
| 874 EXPECT_FALSE(delegate->scroll_end()); | 876 EXPECT_FALSE(delegate->scroll_end()); |
| 875 EXPECT_FALSE(delegate->long_press()); | 877 EXPECT_FALSE(delegate->long_press()); |
| 876 | 878 |
| 877 delegate->Reset(); | 879 delegate->Reset(); |
| 878 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(49, 204), | 880 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(49, 204), |
| 879 kTouchId, tes.LeapForward(50)); | 881 kTouchId, tes.LeapForward(50)); |
| 880 move.set_radius_x(8); | 882 move.set_radius_x(8); |
| 881 move.set_radius_y(12); | 883 move.set_radius_y(12); |
| 882 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move); | 884 DispatchEventUsingWindowDispatcher(&move); |
| 883 EXPECT_FALSE(delegate->tap()); | 885 EXPECT_FALSE(delegate->tap()); |
| 884 EXPECT_FALSE(delegate->tap_down()); | 886 EXPECT_FALSE(delegate->tap_down()); |
| 885 EXPECT_FALSE(delegate->tap_cancel()); | 887 EXPECT_FALSE(delegate->tap_cancel()); |
| 886 EXPECT_FALSE(delegate->begin()); | 888 EXPECT_FALSE(delegate->begin()); |
| 887 EXPECT_FALSE(delegate->scroll_begin()); | 889 EXPECT_FALSE(delegate->scroll_begin()); |
| 888 EXPECT_FALSE(delegate->scroll_update()); | 890 EXPECT_FALSE(delegate->scroll_update()); |
| 889 EXPECT_FALSE(delegate->scroll_end()); | 891 EXPECT_FALSE(delegate->scroll_end()); |
| 890 EXPECT_FALSE(delegate->long_press()); | 892 EXPECT_FALSE(delegate->long_press()); |
| 891 | 893 |
| 892 delegate->Reset(); | 894 delegate->Reset(); |
| 893 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(49, 204), | 895 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(49, 204), |
| 894 kTouchId, tes.LeapForward(50)); | 896 kTouchId, tes.LeapForward(50)); |
| 895 release.set_radius_x(4); | 897 release.set_radius_x(4); |
| 896 release.set_radius_y(8); | 898 release.set_radius_y(8); |
| 897 | 899 |
| 898 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 900 DispatchEventUsingWindowDispatcher(&release); |
| 899 EXPECT_TRUE(delegate->tap()); | 901 EXPECT_TRUE(delegate->tap()); |
| 900 EXPECT_FALSE(delegate->tap_down()); | 902 EXPECT_FALSE(delegate->tap_down()); |
| 901 EXPECT_FALSE(delegate->tap_cancel()); | 903 EXPECT_FALSE(delegate->tap_cancel()); |
| 902 EXPECT_FALSE(delegate->begin()); | 904 EXPECT_FALSE(delegate->begin()); |
| 903 EXPECT_TRUE(delegate->end()); | 905 EXPECT_TRUE(delegate->end()); |
| 904 EXPECT_FALSE(delegate->scroll_begin()); | 906 EXPECT_FALSE(delegate->scroll_begin()); |
| 905 EXPECT_FALSE(delegate->scroll_update()); | 907 EXPECT_FALSE(delegate->scroll_update()); |
| 906 EXPECT_FALSE(delegate->scroll_end()); | 908 EXPECT_FALSE(delegate->scroll_end()); |
| 907 | 909 |
| 908 EXPECT_EQ(1, delegate->tap_count()); | 910 EXPECT_EQ(1, delegate->tap_count()); |
| 909 gfx::Point actual_point(delegate->tap_location()); | 911 gfx::Point actual_point(delegate->tap_location()); |
| 910 EXPECT_EQ(25, delegate->bounding_box().width()); | 912 EXPECT_EQ(25, delegate->bounding_box().width()); |
| 911 EXPECT_EQ(24, delegate->bounding_box().height()); | 913 EXPECT_EQ(24, delegate->bounding_box().height()); |
| 912 EXPECT_EQ(48, actual_point.x()); | 914 EXPECT_EQ(48, actual_point.x()); |
| 913 EXPECT_EQ(204, actual_point.y()); | 915 EXPECT_EQ(204, actual_point.y()); |
| 914 } | 916 } |
| 915 | 917 |
| 916 // Test with a few ET_TOUCH_MOVED events. | 918 // Test with a few ET_TOUCH_MOVED events. |
| 917 { | 919 { |
| 918 delegate->Reset(); | 920 delegate->Reset(); |
| 919 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(400, 150), | 921 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(400, 150), |
| 920 kTouchId, tes.Now()); | 922 kTouchId, tes.Now()); |
| 921 press.set_radius_x(7); | 923 press.set_radius_x(7); |
| 922 press.set_radius_y(10); | 924 press.set_radius_y(10); |
| 923 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 925 DispatchEventUsingWindowDispatcher(&press); |
| 924 EXPECT_FALSE(delegate->tap()); | 926 EXPECT_FALSE(delegate->tap()); |
| 925 EXPECT_TRUE(delegate->tap_down()); | 927 EXPECT_TRUE(delegate->tap_down()); |
| 926 EXPECT_FALSE(delegate->tap_cancel()); | 928 EXPECT_FALSE(delegate->tap_cancel()); |
| 927 EXPECT_TRUE(delegate->begin()); | 929 EXPECT_TRUE(delegate->begin()); |
| 928 EXPECT_FALSE(delegate->scroll_begin()); | 930 EXPECT_FALSE(delegate->scroll_begin()); |
| 929 EXPECT_FALSE(delegate->scroll_update()); | 931 EXPECT_FALSE(delegate->scroll_update()); |
| 930 EXPECT_FALSE(delegate->scroll_end()); | 932 EXPECT_FALSE(delegate->scroll_end()); |
| 931 EXPECT_FALSE(delegate->long_press()); | 933 EXPECT_FALSE(delegate->long_press()); |
| 932 | 934 |
| 933 delegate->Reset(); | 935 delegate->Reset(); |
| 934 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(397, 151), | 936 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(397, 151), |
| 935 kTouchId, tes.LeapForward(50)); | 937 kTouchId, tes.LeapForward(50)); |
| 936 move.set_radius_x(13); | 938 move.set_radius_x(13); |
| 937 move.set_radius_y(12); | 939 move.set_radius_y(12); |
| 938 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move); | 940 DispatchEventUsingWindowDispatcher(&move); |
| 939 EXPECT_FALSE(delegate->tap()); | 941 EXPECT_FALSE(delegate->tap()); |
| 940 EXPECT_FALSE(delegate->tap_down()); | 942 EXPECT_FALSE(delegate->tap_down()); |
| 941 EXPECT_FALSE(delegate->tap_cancel()); | 943 EXPECT_FALSE(delegate->tap_cancel()); |
| 942 EXPECT_FALSE(delegate->begin()); | 944 EXPECT_FALSE(delegate->begin()); |
| 943 EXPECT_FALSE(delegate->scroll_begin()); | 945 EXPECT_FALSE(delegate->scroll_begin()); |
| 944 EXPECT_FALSE(delegate->scroll_update()); | 946 EXPECT_FALSE(delegate->scroll_update()); |
| 945 EXPECT_FALSE(delegate->scroll_end()); | 947 EXPECT_FALSE(delegate->scroll_end()); |
| 946 EXPECT_FALSE(delegate->long_press()); | 948 EXPECT_FALSE(delegate->long_press()); |
| 947 | 949 |
| 948 delegate->Reset(); | 950 delegate->Reset(); |
| 949 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(397, 149), | 951 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(397, 149), |
| 950 kTouchId, tes.LeapForward(50)); | 952 kTouchId, tes.LeapForward(50)); |
| 951 move1.set_radius_x(16); | 953 move1.set_radius_x(16); |
| 952 move1.set_radius_y(16); | 954 move1.set_radius_y(16); |
| 953 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move1); | 955 DispatchEventUsingWindowDispatcher(&move1); |
| 954 EXPECT_FALSE(delegate->tap()); | 956 EXPECT_FALSE(delegate->tap()); |
| 955 EXPECT_FALSE(delegate->tap_down()); | 957 EXPECT_FALSE(delegate->tap_down()); |
| 956 EXPECT_FALSE(delegate->tap_cancel()); | 958 EXPECT_FALSE(delegate->tap_cancel()); |
| 957 EXPECT_FALSE(delegate->begin()); | 959 EXPECT_FALSE(delegate->begin()); |
| 958 EXPECT_FALSE(delegate->scroll_begin()); | 960 EXPECT_FALSE(delegate->scroll_begin()); |
| 959 EXPECT_FALSE(delegate->scroll_update()); | 961 EXPECT_FALSE(delegate->scroll_update()); |
| 960 EXPECT_FALSE(delegate->scroll_end()); | 962 EXPECT_FALSE(delegate->scroll_end()); |
| 961 EXPECT_FALSE(delegate->long_press()); | 963 EXPECT_FALSE(delegate->long_press()); |
| 962 | 964 |
| 963 delegate->Reset(); | 965 delegate->Reset(); |
| 964 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(400, 150), | 966 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(400, 150), |
| 965 kTouchId, tes.LeapForward(50)); | 967 kTouchId, tes.LeapForward(50)); |
| 966 move2.set_radius_x(14); | 968 move2.set_radius_x(14); |
| 967 move2.set_radius_y(10); | 969 move2.set_radius_y(10); |
| 968 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move2); | 970 DispatchEventUsingWindowDispatcher(&move2); |
| 969 EXPECT_FALSE(delegate->tap()); | 971 EXPECT_FALSE(delegate->tap()); |
| 970 EXPECT_FALSE(delegate->tap_down()); | 972 EXPECT_FALSE(delegate->tap_down()); |
| 971 EXPECT_FALSE(delegate->tap_cancel()); | 973 EXPECT_FALSE(delegate->tap_cancel()); |
| 972 EXPECT_FALSE(delegate->begin()); | 974 EXPECT_FALSE(delegate->begin()); |
| 973 EXPECT_FALSE(delegate->scroll_begin()); | 975 EXPECT_FALSE(delegate->scroll_begin()); |
| 974 EXPECT_FALSE(delegate->scroll_update()); | 976 EXPECT_FALSE(delegate->scroll_update()); |
| 975 EXPECT_FALSE(delegate->scroll_end()); | 977 EXPECT_FALSE(delegate->scroll_end()); |
| 976 EXPECT_FALSE(delegate->long_press()); | 978 EXPECT_FALSE(delegate->long_press()); |
| 977 | 979 |
| 978 delegate->Reset(); | 980 delegate->Reset(); |
| 979 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(401, 149), | 981 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(401, 149), |
| 980 kTouchId, tes.LeapForward(50)); | 982 kTouchId, tes.LeapForward(50)); |
| 981 release.set_radius_x(8); | 983 release.set_radius_x(8); |
| 982 release.set_radius_y(9); | 984 release.set_radius_y(9); |
| 983 | 985 |
| 984 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 986 DispatchEventUsingWindowDispatcher(&release); |
| 985 EXPECT_TRUE(delegate->tap()); | 987 EXPECT_TRUE(delegate->tap()); |
| 986 EXPECT_FALSE(delegate->tap_down()); | 988 EXPECT_FALSE(delegate->tap_down()); |
| 987 EXPECT_FALSE(delegate->tap_cancel()); | 989 EXPECT_FALSE(delegate->tap_cancel()); |
| 988 EXPECT_FALSE(delegate->begin()); | 990 EXPECT_FALSE(delegate->begin()); |
| 989 EXPECT_TRUE(delegate->end()); | 991 EXPECT_TRUE(delegate->end()); |
| 990 EXPECT_FALSE(delegate->scroll_begin()); | 992 EXPECT_FALSE(delegate->scroll_begin()); |
| 991 EXPECT_FALSE(delegate->scroll_update()); | 993 EXPECT_FALSE(delegate->scroll_update()); |
| 992 EXPECT_FALSE(delegate->scroll_end()); | 994 EXPECT_FALSE(delegate->scroll_end()); |
| 993 | 995 |
| 994 EXPECT_EQ(1, delegate->tap_count()); | 996 EXPECT_EQ(1, delegate->tap_count()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1013 const int kWindowWidth = 123; | 1015 const int kWindowWidth = 123; |
| 1014 const int kWindowHeight = 45; | 1016 const int kWindowHeight = 45; |
| 1015 const int kTouchId = 5; | 1017 const int kTouchId = 5; |
| 1016 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 1018 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 1017 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1019 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1018 delegate.get(), -1234, bounds, root_window())); | 1020 delegate.get(), -1234, bounds, root_window())); |
| 1019 | 1021 |
| 1020 delegate->Reset(); | 1022 delegate->Reset(); |
| 1021 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 1023 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 1022 kTouchId, tes.Now()); | 1024 kTouchId, tes.Now()); |
| 1023 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 1025 DispatchEventUsingWindowDispatcher(&press); |
| 1024 EXPECT_2_EVENTS(delegate->events(), | 1026 EXPECT_2_EVENTS(delegate->events(), |
| 1025 ui::ET_GESTURE_BEGIN, | 1027 ui::ET_GESTURE_BEGIN, |
| 1026 ui::ET_GESTURE_TAP_DOWN); | 1028 ui::ET_GESTURE_TAP_DOWN); |
| 1027 | 1029 |
| 1028 // Move the touch-point enough so that it is considered as a scroll. This | 1030 // Move the touch-point enough so that it is considered as a scroll. This |
| 1029 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. | 1031 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. |
| 1030 // The first movement is diagonal, to ensure that we have a free scroll, | 1032 // The first movement is diagonal, to ensure that we have a free scroll, |
| 1031 // and not a rail scroll. | 1033 // and not a rail scroll. |
| 1032 tes.SendScrollEvent(dispatcher(), 111.5, 211.5, kTouchId, delegate.get()); | 1034 tes.SendScrollEvent(dispatcher(), 111.5, 211.5, kTouchId, delegate.get()); |
| 1033 EXPECT_3_EVENTS(delegate->events(), | 1035 EXPECT_3_EVENTS(delegate->events(), |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1055 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); | 1057 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); |
| 1056 EXPECT_EQ(30, delegate->scroll_x()); | 1058 EXPECT_EQ(30, delegate->scroll_x()); |
| 1057 EXPECT_EQ(4, delegate->scroll_y()); | 1059 EXPECT_EQ(4, delegate->scroll_y()); |
| 1058 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); | 1060 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
| 1059 | 1061 |
| 1060 // Release the touch. This should end the scroll. | 1062 // Release the touch. This should end the scroll. |
| 1061 delegate->Reset(); | 1063 delegate->Reset(); |
| 1062 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1064 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1063 kTouchId, | 1065 kTouchId, |
| 1064 tes.LeapForward(50)); | 1066 tes.LeapForward(50)); |
| 1065 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 1067 DispatchEventUsingWindowDispatcher(&release); |
| 1066 EXPECT_2_EVENTS(delegate->events(), | 1068 EXPECT_2_EVENTS(delegate->events(), |
| 1067 ui::ET_SCROLL_FLING_START, | 1069 ui::ET_SCROLL_FLING_START, |
| 1068 ui::ET_GESTURE_END); | 1070 ui::ET_GESTURE_END); |
| 1069 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); | 1071 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
| 1070 } | 1072 } |
| 1071 | 1073 |
| 1072 // Check that predicted scroll update positions are correct. | 1074 // Check that predicted scroll update positions are correct. |
| 1073 TEST_F(GestureRecognizerTest, GestureEventScrollPrediction) { | 1075 TEST_F(GestureRecognizerTest, GestureEventScrollPrediction) { |
| 1074 const double prediction_interval = 0.03; | 1076 const double prediction_interval = 0.03; |
| 1075 ui::GestureConfiguration::set_scroll_prediction_seconds(prediction_interval); | 1077 ui::GestureConfiguration::set_scroll_prediction_seconds(prediction_interval); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1088 gfx::Rect bounds(95, 195, kWindowWidth, kWindowHeight); | 1090 gfx::Rect bounds(95, 195, kWindowWidth, kWindowHeight); |
| 1089 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1091 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1090 delegate.get(), -1234, bounds, root_window())); | 1092 delegate.get(), -1234, bounds, root_window())); |
| 1091 | 1093 |
| 1092 delegate->Reset(); | 1094 delegate->Reset(); |
| 1093 // Tracks the total scroll since we want to verify that the correct position | 1095 // Tracks the total scroll since we want to verify that the correct position |
| 1094 // will be scrolled to throughout the prediction. | 1096 // will be scrolled to throughout the prediction. |
| 1095 gfx::Vector2dF total_scroll; | 1097 gfx::Vector2dF total_scroll; |
| 1096 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(96, 196), | 1098 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(96, 196), |
| 1097 kTouchId, tes.Now()); | 1099 kTouchId, tes.Now()); |
| 1098 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 1100 DispatchEventUsingWindowDispatcher(&press); |
| 1099 EXPECT_2_EVENTS(delegate->events(), | 1101 EXPECT_2_EVENTS(delegate->events(), |
| 1100 ui::ET_GESTURE_BEGIN, | 1102 ui::ET_GESTURE_BEGIN, |
| 1101 ui::ET_GESTURE_TAP_DOWN); | 1103 ui::ET_GESTURE_TAP_DOWN); |
| 1102 delegate->Reset(); | 1104 delegate->Reset(); |
| 1103 | 1105 |
| 1104 // Get rid of touch slop. | 1106 // Get rid of touch slop. |
| 1105 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(101, 201), | 1107 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(101, 201), |
| 1106 kTouchId, tes.Now()); | 1108 kTouchId, tes.Now()); |
| 1107 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move); | 1109 DispatchEventUsingWindowDispatcher(&move); |
| 1108 EXPECT_3_EVENTS(delegate->events(), | 1110 EXPECT_3_EVENTS(delegate->events(), |
| 1109 ui::ET_GESTURE_TAP_CANCEL, | 1111 ui::ET_GESTURE_TAP_CANCEL, |
| 1110 ui::ET_GESTURE_SCROLL_BEGIN, | 1112 ui::ET_GESTURE_SCROLL_BEGIN, |
| 1111 ui::ET_GESTURE_SCROLL_UPDATE); | 1113 ui::ET_GESTURE_SCROLL_UPDATE); |
| 1112 total_scroll.set_x(total_scroll.x() + delegate->scroll_x()); | 1114 total_scroll.set_x(total_scroll.x() + delegate->scroll_x()); |
| 1113 total_scroll.set_y(total_scroll.y() + delegate->scroll_y()); | 1115 total_scroll.set_y(total_scroll.y() + delegate->scroll_y()); |
| 1114 | 1116 |
| 1115 // Move the touch-point enough so that it is considered as a scroll. This | 1117 // Move the touch-point enough so that it is considered as a scroll. This |
| 1116 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. | 1118 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. |
| 1117 // The first movement is diagonal, to ensure that we have a free scroll, | 1119 // The first movement is diagonal, to ensure that we have a free scroll, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1148 EXPECT_EQ((int)(39 + delegate->scroll_velocity_x() * prediction_interval), | 1150 EXPECT_EQ((int)(39 + delegate->scroll_velocity_x() * prediction_interval), |
| 1149 (int)(total_scroll.x())); | 1151 (int)(total_scroll.x())); |
| 1150 EXPECT_EQ((int)(14 + delegate->scroll_velocity_y() * prediction_interval), | 1152 EXPECT_EQ((int)(14 + delegate->scroll_velocity_y() * prediction_interval), |
| 1151 (int)(total_scroll.y())); | 1153 (int)(total_scroll.y())); |
| 1152 | 1154 |
| 1153 // Release the touch. This should end the scroll. | 1155 // Release the touch. This should end the scroll. |
| 1154 delegate->Reset(); | 1156 delegate->Reset(); |
| 1155 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1157 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1156 kTouchId, | 1158 kTouchId, |
| 1157 tes.LeapForward(50)); | 1159 tes.LeapForward(50)); |
| 1158 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 1160 DispatchEventUsingWindowDispatcher(&release); |
| 1159 } | 1161 } |
| 1160 | 1162 |
| 1161 // Check that the bounding box during a scroll event is correct. | 1163 // Check that the bounding box during a scroll event is correct. |
| 1162 TEST_F(GestureRecognizerTest, GestureEventScrollBoundingBox) { | 1164 TEST_F(GestureRecognizerTest, GestureEventScrollBoundingBox) { |
| 1163 TimedEvents tes; | 1165 TimedEvents tes; |
| 1164 for (int radius = 1; radius <= 10; ++radius) { | 1166 for (int radius = 1; radius <= 10; ++radius) { |
| 1165 ui::GestureConfiguration::set_default_radius(radius); | 1167 ui::GestureConfiguration::set_default_radius(radius); |
| 1166 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1168 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1167 new GestureEventConsumeDelegate()); | 1169 new GestureEventConsumeDelegate()); |
| 1168 const int kWindowWidth = 123; | 1170 const int kWindowWidth = 123; |
| 1169 const int kWindowHeight = 45; | 1171 const int kWindowHeight = 45; |
| 1170 const int kTouchId = 5; | 1172 const int kTouchId = 5; |
| 1171 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 1173 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 1172 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1174 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1173 delegate.get(), -1234, bounds, root_window())); | 1175 delegate.get(), -1234, bounds, root_window())); |
| 1174 | 1176 |
| 1175 const int kPositionX = 101; | 1177 const int kPositionX = 101; |
| 1176 const int kPositionY = 201; | 1178 const int kPositionY = 201; |
| 1177 delegate->Reset(); | 1179 delegate->Reset(); |
| 1178 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, | 1180 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, |
| 1179 gfx::Point(kPositionX, kPositionY), | 1181 gfx::Point(kPositionX, kPositionY), |
| 1180 kTouchId, | 1182 kTouchId, |
| 1181 tes.Now()); | 1183 tes.Now()); |
| 1182 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 1184 DispatchEventUsingWindowDispatcher(&press); |
| 1183 EXPECT_EQ(gfx::Rect(kPositionX - radius, | 1185 EXPECT_EQ(gfx::Rect(kPositionX - radius, |
| 1184 kPositionY - radius, | 1186 kPositionY - radius, |
| 1185 radius * 2, | 1187 radius * 2, |
| 1186 radius * 2).ToString(), | 1188 radius * 2).ToString(), |
| 1187 delegate->bounding_box().ToString()); | 1189 delegate->bounding_box().ToString()); |
| 1188 | 1190 |
| 1189 const int kScrollAmount = 50; | 1191 const int kScrollAmount = 50; |
| 1190 tes.SendScrollEvents(dispatcher(), kPositionX, kPositionY, | 1192 tes.SendScrollEvents(dispatcher(), kPositionX, kPositionY, |
| 1191 1, 1, kTouchId, 1, kScrollAmount, delegate.get()); | 1193 1, 1, kTouchId, 1, kScrollAmount, delegate.get()); |
| 1192 EXPECT_EQ(gfx::Point(1, 1).ToString(), | 1194 EXPECT_EQ(gfx::Point(1, 1).ToString(), |
| 1193 delegate->scroll_begin_position().ToString()); | 1195 delegate->scroll_begin_position().ToString()); |
| 1194 EXPECT_EQ(gfx::Rect(kPositionX + kScrollAmount - radius, | 1196 EXPECT_EQ(gfx::Rect(kPositionX + kScrollAmount - radius, |
| 1195 kPositionY + kScrollAmount - radius, | 1197 kPositionY + kScrollAmount - radius, |
| 1196 radius * 2, | 1198 radius * 2, |
| 1197 radius * 2).ToString(), | 1199 radius * 2).ToString(), |
| 1198 delegate->bounding_box().ToString()); | 1200 delegate->bounding_box().ToString()); |
| 1199 | 1201 |
| 1200 // Release the touch. This should end the scroll. | 1202 // Release the touch. This should end the scroll. |
| 1201 delegate->Reset(); | 1203 delegate->Reset(); |
| 1202 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, | 1204 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, |
| 1203 gfx::Point(kPositionX + kScrollAmount, | 1205 gfx::Point(kPositionX + kScrollAmount, |
| 1204 kPositionY + kScrollAmount), | 1206 kPositionY + kScrollAmount), |
| 1205 kTouchId, press.time_stamp() + | 1207 kTouchId, press.time_stamp() + |
| 1206 base::TimeDelta::FromMilliseconds(50)); | 1208 base::TimeDelta::FromMilliseconds(50)); |
| 1207 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 1209 DispatchEventUsingWindowDispatcher(&release); |
| 1208 EXPECT_EQ(gfx::Rect(kPositionX + kScrollAmount - radius, | 1210 EXPECT_EQ(gfx::Rect(kPositionX + kScrollAmount - radius, |
| 1209 kPositionY + kScrollAmount - radius, | 1211 kPositionY + kScrollAmount - radius, |
| 1210 radius * 2, | 1212 radius * 2, |
| 1211 radius * 2).ToString(), | 1213 radius * 2).ToString(), |
| 1212 delegate->bounding_box().ToString()); | 1214 delegate->bounding_box().ToString()); |
| 1213 } | 1215 } |
| 1214 ui::GestureConfiguration::set_default_radius(0); | 1216 ui::GestureConfiguration::set_default_radius(0); |
| 1215 } | 1217 } |
| 1216 | 1218 |
| 1217 // Check Scroll End Events report correct velocities | 1219 // Check Scroll End Events report correct velocities |
| 1218 // if the user was on a horizontal rail | 1220 // if the user was on a horizontal rail |
| 1219 TEST_F(GestureRecognizerTest, GestureEventHorizontalRailFling) { | 1221 TEST_F(GestureRecognizerTest, GestureEventHorizontalRailFling) { |
| 1220 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1222 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1221 new GestureEventConsumeDelegate()); | 1223 new GestureEventConsumeDelegate()); |
| 1222 TimedEvents tes; | 1224 TimedEvents tes; |
| 1223 const int kTouchId = 7; | 1225 const int kTouchId = 7; |
| 1224 gfx::Rect bounds(0, 0, 1000, 1000); | 1226 gfx::Rect bounds(0, 0, 1000, 1000); |
| 1225 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1227 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1226 delegate.get(), -1234, bounds, root_window())); | 1228 delegate.get(), -1234, bounds, root_window())); |
| 1227 | 1229 |
| 1228 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), | 1230 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), |
| 1229 kTouchId, tes.Now()); | 1231 kTouchId, tes.Now()); |
| 1230 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 1232 DispatchEventUsingWindowDispatcher(&press); |
| 1231 | 1233 |
| 1232 // Get rid of touch slop. | 1234 // Get rid of touch slop. |
| 1233 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(5, 0), | 1235 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(5, 0), |
| 1234 kTouchId, tes.Now()); | 1236 kTouchId, tes.Now()); |
| 1235 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move); | 1237 DispatchEventUsingWindowDispatcher(&move); |
| 1236 delegate->Reset(); | 1238 delegate->Reset(); |
| 1237 | 1239 |
| 1238 | 1240 |
| 1239 // Move the touch-point horizontally enough that it is considered a | 1241 // Move the touch-point horizontally enough that it is considered a |
| 1240 // horizontal scroll. | 1242 // horizontal scroll. |
| 1241 tes.SendScrollEvent(dispatcher(), 25, 1, kTouchId, delegate.get()); | 1243 tes.SendScrollEvent(dispatcher(), 25, 1, kTouchId, delegate.get()); |
| 1242 EXPECT_EQ(0, delegate->scroll_y()); | 1244 EXPECT_EQ(0, delegate->scroll_y()); |
| 1243 EXPECT_EQ(1, delegate->scroll_y_ordinal()); | 1245 EXPECT_EQ(1, delegate->scroll_y_ordinal()); |
| 1244 EXPECT_EQ(20, delegate->scroll_x()); | 1246 EXPECT_EQ(20, delegate->scroll_x()); |
| 1245 EXPECT_EQ(20, delegate->scroll_x_ordinal()); | 1247 EXPECT_EQ(20, delegate->scroll_x_ordinal()); |
| 1246 | 1248 |
| 1247 // Get a high x velocity, while still staying on the rail | 1249 // Get a high x velocity, while still staying on the rail |
| 1248 tes.SendScrollEvents(dispatcher(), 1, 1, | 1250 tes.SendScrollEvents(dispatcher(), 1, 1, |
| 1249 100, 10, kTouchId, 1, | 1251 100, 10, kTouchId, 1, |
| 1250 ui::GestureConfiguration::points_buffered_for_velocity(), | 1252 ui::GestureConfiguration::points_buffered_for_velocity(), |
| 1251 delegate.get()); | 1253 delegate.get()); |
| 1252 // The y-velocity during the scroll should be 0 since this is in a horizontal | 1254 // The y-velocity during the scroll should be 0 since this is in a horizontal |
| 1253 // rail scroll. | 1255 // rail scroll. |
| 1254 EXPECT_GT(delegate->scroll_velocity_x(), 0); | 1256 EXPECT_GT(delegate->scroll_velocity_x(), 0); |
| 1255 EXPECT_EQ(0, delegate->scroll_velocity_y()); | 1257 EXPECT_EQ(0, delegate->scroll_velocity_y()); |
| 1256 | 1258 |
| 1257 delegate->Reset(); | 1259 delegate->Reset(); |
| 1258 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1260 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1259 kTouchId, tes.Now()); | 1261 kTouchId, tes.Now()); |
| 1260 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 1262 DispatchEventUsingWindowDispatcher(&release); |
| 1261 | 1263 |
| 1262 EXPECT_TRUE(delegate->fling()); | 1264 EXPECT_TRUE(delegate->fling()); |
| 1263 EXPECT_FALSE(delegate->scroll_end()); | 1265 EXPECT_FALSE(delegate->scroll_end()); |
| 1264 EXPECT_GT(delegate->velocity_x(), 0); | 1266 EXPECT_GT(delegate->velocity_x(), 0); |
| 1265 EXPECT_EQ(0, delegate->velocity_y()); | 1267 EXPECT_EQ(0, delegate->velocity_y()); |
| 1266 } | 1268 } |
| 1267 | 1269 |
| 1268 // Check Scroll End Events report correct velocities | 1270 // Check Scroll End Events report correct velocities |
| 1269 // if the user was on a vertical rail | 1271 // if the user was on a vertical rail |
| 1270 TEST_F(GestureRecognizerTest, GestureEventVerticalRailFling) { | 1272 TEST_F(GestureRecognizerTest, GestureEventVerticalRailFling) { |
| 1271 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1273 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1272 new GestureEventConsumeDelegate()); | 1274 new GestureEventConsumeDelegate()); |
| 1273 TimedEvents tes; | 1275 TimedEvents tes; |
| 1274 const int kTouchId = 7; | 1276 const int kTouchId = 7; |
| 1275 gfx::Rect bounds(0, 0, 1000, 1000); | 1277 gfx::Rect bounds(0, 0, 1000, 1000); |
| 1276 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1278 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1277 delegate.get(), -1234, bounds, root_window())); | 1279 delegate.get(), -1234, bounds, root_window())); |
| 1278 | 1280 |
| 1279 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), | 1281 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), |
| 1280 kTouchId, tes.Now()); | 1282 kTouchId, tes.Now()); |
| 1281 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 1283 DispatchEventUsingWindowDispatcher(&press); |
| 1282 | 1284 |
| 1283 // Get rid of touch slop. | 1285 // Get rid of touch slop. |
| 1284 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(0, 5), | 1286 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(0, 5), |
| 1285 kTouchId, tes.Now()); | 1287 kTouchId, tes.Now()); |
| 1286 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move); | 1288 DispatchEventUsingWindowDispatcher(&move); |
| 1287 delegate->Reset(); | 1289 delegate->Reset(); |
| 1288 | 1290 |
| 1289 // Move the touch-point vertically enough that it is considered a | 1291 // Move the touch-point vertically enough that it is considered a |
| 1290 // vertical scroll. | 1292 // vertical scroll. |
| 1291 tes.SendScrollEvent(dispatcher(), 1, 25, kTouchId, delegate.get()); | 1293 tes.SendScrollEvent(dispatcher(), 1, 25, kTouchId, delegate.get()); |
| 1292 EXPECT_EQ(20, delegate->scroll_y()); | 1294 EXPECT_EQ(20, delegate->scroll_y()); |
| 1293 EXPECT_EQ(20, delegate->scroll_y_ordinal()); | 1295 EXPECT_EQ(20, delegate->scroll_y_ordinal()); |
| 1294 EXPECT_EQ(0, delegate->scroll_x()); | 1296 EXPECT_EQ(0, delegate->scroll_x()); |
| 1295 EXPECT_EQ(1, delegate->scroll_x_ordinal()); | 1297 EXPECT_EQ(1, delegate->scroll_x_ordinal()); |
| 1296 EXPECT_EQ(0, delegate->scroll_velocity_x()); | 1298 EXPECT_EQ(0, delegate->scroll_velocity_x()); |
| 1297 EXPECT_GT(delegate->scroll_velocity_x_ordinal(), 0); | 1299 EXPECT_GT(delegate->scroll_velocity_x_ordinal(), 0); |
| 1298 | 1300 |
| 1299 // Get a high y velocity, while still staying on the rail | 1301 // Get a high y velocity, while still staying on the rail |
| 1300 tes.SendScrollEvents(dispatcher(), 1, 6, | 1302 tes.SendScrollEvents(dispatcher(), 1, 6, |
| 1301 10, 100, kTouchId, 1, | 1303 10, 100, kTouchId, 1, |
| 1302 ui::GestureConfiguration::points_buffered_for_velocity(), | 1304 ui::GestureConfiguration::points_buffered_for_velocity(), |
| 1303 delegate.get()); | 1305 delegate.get()); |
| 1304 EXPECT_EQ(0, delegate->scroll_velocity_x()); | 1306 EXPECT_EQ(0, delegate->scroll_velocity_x()); |
| 1305 EXPECT_GT(delegate->scroll_velocity_y(), 0); | 1307 EXPECT_GT(delegate->scroll_velocity_y(), 0); |
| 1306 | 1308 |
| 1307 delegate->Reset(); | 1309 delegate->Reset(); |
| 1308 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 206), | 1310 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 206), |
| 1309 kTouchId, tes.Now()); | 1311 kTouchId, tes.Now()); |
| 1310 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 1312 DispatchEventUsingWindowDispatcher(&release); |
| 1311 | 1313 |
| 1312 EXPECT_TRUE(delegate->fling()); | 1314 EXPECT_TRUE(delegate->fling()); |
| 1313 EXPECT_FALSE(delegate->scroll_end()); | 1315 EXPECT_FALSE(delegate->scroll_end()); |
| 1314 EXPECT_EQ(0, delegate->velocity_x()); | 1316 EXPECT_EQ(0, delegate->velocity_x()); |
| 1315 EXPECT_GT(delegate->velocity_y(), 0); | 1317 EXPECT_GT(delegate->velocity_y(), 0); |
| 1316 } | 1318 } |
| 1317 | 1319 |
| 1318 // Check Scroll End Events reports zero velocities | 1320 // Check Scroll End Events reports zero velocities |
| 1319 // if the user is not on a rail | 1321 // if the user is not on a rail |
| 1320 TEST_F(GestureRecognizerTest, GestureEventNonRailFling) { | 1322 TEST_F(GestureRecognizerTest, GestureEventNonRailFling) { |
| 1321 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(0); | 1323 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(0); |
| 1322 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1324 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1323 new GestureEventConsumeDelegate()); | 1325 new GestureEventConsumeDelegate()); |
| 1324 TimedEvents tes; | 1326 TimedEvents tes; |
| 1325 const int kTouchId = 7; | 1327 const int kTouchId = 7; |
| 1326 gfx::Rect bounds(0, 0, 1000, 1000); | 1328 gfx::Rect bounds(0, 0, 1000, 1000); |
| 1327 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1329 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1328 delegate.get(), -1234, bounds, root_window())); | 1330 delegate.get(), -1234, bounds, root_window())); |
| 1329 | 1331 |
| 1330 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), | 1332 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), |
| 1331 kTouchId, tes.Now()); | 1333 kTouchId, tes.Now()); |
| 1332 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 1334 DispatchEventUsingWindowDispatcher(&press); |
| 1333 | 1335 |
| 1334 // Move the touch-point such that a non-rail scroll begins | 1336 // Move the touch-point such that a non-rail scroll begins |
| 1335 tes.SendScrollEvent(dispatcher(), 20, 20, kTouchId, delegate.get()); | 1337 tes.SendScrollEvent(dispatcher(), 20, 20, kTouchId, delegate.get()); |
| 1336 EXPECT_EQ(20, delegate->scroll_y()); | 1338 EXPECT_EQ(20, delegate->scroll_y()); |
| 1337 EXPECT_EQ(20, delegate->scroll_x()); | 1339 EXPECT_EQ(20, delegate->scroll_x()); |
| 1338 | 1340 |
| 1339 tes.SendScrollEvents(dispatcher(), 1, 1, | 1341 tes.SendScrollEvents(dispatcher(), 1, 1, |
| 1340 10, 100, kTouchId, 1, | 1342 10, 100, kTouchId, 1, |
| 1341 ui::GestureConfiguration::points_buffered_for_velocity(), | 1343 ui::GestureConfiguration::points_buffered_for_velocity(), |
| 1342 delegate.get()); | 1344 delegate.get()); |
| 1343 | 1345 |
| 1344 delegate->Reset(); | 1346 delegate->Reset(); |
| 1345 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1347 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1346 kTouchId, tes.Now()); | 1348 kTouchId, tes.Now()); |
| 1347 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 1349 DispatchEventUsingWindowDispatcher(&release); |
| 1348 | 1350 |
| 1349 EXPECT_TRUE(delegate->fling()); | 1351 EXPECT_TRUE(delegate->fling()); |
| 1350 EXPECT_FALSE(delegate->scroll_end()); | 1352 EXPECT_FALSE(delegate->scroll_end()); |
| 1351 EXPECT_GT(delegate->velocity_x(), 0); | 1353 EXPECT_GT(delegate->velocity_x(), 0); |
| 1352 EXPECT_GT(delegate->velocity_y(), 0); | 1354 EXPECT_GT(delegate->velocity_y(), 0); |
| 1353 } | 1355 } |
| 1354 | 1356 |
| 1355 // Check that appropriate touch events generate long press events | 1357 // Check that appropriate touch events generate long press events |
| 1356 TEST_F(GestureRecognizerTest, GestureEventLongPress) { | 1358 TEST_F(GestureRecognizerTest, GestureEventLongPress) { |
| 1357 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1359 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1358 new GestureEventConsumeDelegate()); | 1360 new GestureEventConsumeDelegate()); |
| 1359 TimedEvents tes; | 1361 TimedEvents tes; |
| 1360 const int kWindowWidth = 123; | 1362 const int kWindowWidth = 123; |
| 1361 const int kWindowHeight = 45; | 1363 const int kWindowHeight = 45; |
| 1362 const int kTouchId = 2; | 1364 const int kTouchId = 2; |
| 1363 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 1365 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 1364 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1366 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1365 delegate.get(), -1234, bounds, root_window())); | 1367 delegate.get(), -1234, bounds, root_window())); |
| 1366 | 1368 |
| 1367 delegate->Reset(); | 1369 delegate->Reset(); |
| 1368 | 1370 |
| 1369 TimerTestGestureRecognizer* gesture_recognizer = | 1371 TimerTestGestureRecognizer* gesture_recognizer = |
| 1370 new TimerTestGestureRecognizer(); | 1372 new TimerTestGestureRecognizer(); |
| 1371 | 1373 |
| 1372 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); | 1374 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); |
| 1373 | 1375 |
| 1374 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 1376 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 1375 kTouchId, tes.Now()); | 1377 kTouchId, tes.Now()); |
| 1376 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 1378 DispatchEventUsingWindowDispatcher(&press1); |
| 1377 EXPECT_TRUE(delegate->tap_down()); | 1379 EXPECT_TRUE(delegate->tap_down()); |
| 1378 EXPECT_TRUE(delegate->begin()); | 1380 EXPECT_TRUE(delegate->begin()); |
| 1379 EXPECT_FALSE(delegate->tap_cancel()); | 1381 EXPECT_FALSE(delegate->tap_cancel()); |
| 1380 | 1382 |
| 1381 // We haven't pressed long enough for a long press to occur | 1383 // We haven't pressed long enough for a long press to occur |
| 1382 EXPECT_FALSE(delegate->long_press()); | 1384 EXPECT_FALSE(delegate->long_press()); |
| 1383 | 1385 |
| 1384 // Wait until the timer runs out | 1386 // Wait until the timer runs out |
| 1385 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS); | 1387 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS); |
| 1386 EXPECT_TRUE(delegate->long_press()); | 1388 EXPECT_TRUE(delegate->long_press()); |
| 1387 EXPECT_EQ(0, delegate->touch_id()); | 1389 EXPECT_EQ(0, delegate->touch_id()); |
| 1388 EXPECT_FALSE(delegate->tap_cancel()); | 1390 EXPECT_FALSE(delegate->tap_cancel()); |
| 1389 | 1391 |
| 1390 delegate->Reset(); | 1392 delegate->Reset(); |
| 1391 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1393 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1392 kTouchId, tes.Now()); | 1394 kTouchId, tes.Now()); |
| 1393 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1); | 1395 DispatchEventUsingWindowDispatcher(&release1); |
| 1394 EXPECT_FALSE(delegate->long_press()); | 1396 EXPECT_FALSE(delegate->long_press()); |
| 1395 | 1397 |
| 1396 // Note the tap down isn't cancelled until the release | 1398 // Note the tap down isn't cancelled until the release |
| 1397 EXPECT_TRUE(delegate->tap_cancel()); | 1399 EXPECT_TRUE(delegate->tap_cancel()); |
| 1398 } | 1400 } |
| 1399 | 1401 |
| 1400 // Check that scrolling cancels a long press | 1402 // Check that scrolling cancels a long press |
| 1401 TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByScroll) { | 1403 TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByScroll) { |
| 1402 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1404 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1403 new GestureEventConsumeDelegate()); | 1405 new GestureEventConsumeDelegate()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1415 TimerTestGestureRecognizer* gesture_recognizer = | 1417 TimerTestGestureRecognizer* gesture_recognizer = |
| 1416 new TimerTestGestureRecognizer(); | 1418 new TimerTestGestureRecognizer(); |
| 1417 TimerTestGestureSequence* gesture_sequence = | 1419 TimerTestGestureSequence* gesture_sequence = |
| 1418 static_cast<TimerTestGestureSequence*>( | 1420 static_cast<TimerTestGestureSequence*>( |
| 1419 gesture_recognizer->GetGestureSequenceForTesting(window.get())); | 1421 gesture_recognizer->GetGestureSequenceForTesting(window.get())); |
| 1420 | 1422 |
| 1421 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); | 1423 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); |
| 1422 | 1424 |
| 1423 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 1425 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 1424 kTouchId, tes.Now()); | 1426 kTouchId, tes.Now()); |
| 1425 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 1427 DispatchEventUsingWindowDispatcher(&press1); |
| 1426 EXPECT_TRUE(delegate->tap_down()); | 1428 EXPECT_TRUE(delegate->tap_down()); |
| 1427 | 1429 |
| 1428 // 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 |
| 1429 EXPECT_FALSE(delegate->long_press()); | 1431 EXPECT_FALSE(delegate->long_press()); |
| 1430 EXPECT_FALSE(delegate->tap_cancel()); | 1432 EXPECT_FALSE(delegate->tap_cancel()); |
| 1431 | 1433 |
| 1432 // Scroll around, to cancel the long press | 1434 // Scroll around, to cancel the long press |
| 1433 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get()); | 1435 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get()); |
| 1434 // Wait until the timer runs out | 1436 // Wait until the timer runs out |
| 1435 gesture_sequence->ForceTimeout(); | 1437 gesture_sequence->ForceTimeout(); |
| 1436 EXPECT_FALSE(delegate->long_press()); | 1438 EXPECT_FALSE(delegate->long_press()); |
| 1437 EXPECT_TRUE(delegate->tap_cancel()); | 1439 EXPECT_TRUE(delegate->tap_cancel()); |
| 1438 | 1440 |
| 1439 delegate->Reset(); | 1441 delegate->Reset(); |
| 1440 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1442 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1441 kTouchId, tes.LeapForward(10)); | 1443 kTouchId, tes.LeapForward(10)); |
| 1442 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1); | 1444 DispatchEventUsingWindowDispatcher(&release1); |
| 1443 EXPECT_FALSE(delegate->long_press()); | 1445 EXPECT_FALSE(delegate->long_press()); |
| 1444 EXPECT_FALSE(delegate->tap_cancel()); | 1446 EXPECT_FALSE(delegate->tap_cancel()); |
| 1445 } | 1447 } |
| 1446 | 1448 |
| 1447 // Check that appropriate touch events generate long tap events | 1449 // Check that appropriate touch events generate long tap events |
| 1448 TEST_F(GestureRecognizerTest, GestureEventLongTap) { | 1450 TEST_F(GestureRecognizerTest, GestureEventLongTap) { |
| 1449 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1451 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1450 new GestureEventConsumeDelegate()); | 1452 new GestureEventConsumeDelegate()); |
| 1451 TimedEvents tes; | 1453 TimedEvents tes; |
| 1452 const int kWindowWidth = 123; | 1454 const int kWindowWidth = 123; |
| 1453 const int kWindowHeight = 45; | 1455 const int kWindowHeight = 45; |
| 1454 const int kTouchId = 2; | 1456 const int kTouchId = 2; |
| 1455 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 1457 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 1456 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1458 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1457 delegate.get(), -1234, bounds, root_window())); | 1459 delegate.get(), -1234, bounds, root_window())); |
| 1458 | 1460 |
| 1459 delegate->Reset(); | 1461 delegate->Reset(); |
| 1460 | 1462 |
| 1461 TimerTestGestureRecognizer* gesture_recognizer = | 1463 TimerTestGestureRecognizer* gesture_recognizer = |
| 1462 new TimerTestGestureRecognizer(); | 1464 new TimerTestGestureRecognizer(); |
| 1463 | 1465 |
| 1464 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); | 1466 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); |
| 1465 | 1467 |
| 1466 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 1468 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 1467 kTouchId, tes.Now()); | 1469 kTouchId, tes.Now()); |
| 1468 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 1470 DispatchEventUsingWindowDispatcher(&press1); |
| 1469 EXPECT_TRUE(delegate->tap_down()); | 1471 EXPECT_TRUE(delegate->tap_down()); |
| 1470 EXPECT_TRUE(delegate->begin()); | 1472 EXPECT_TRUE(delegate->begin()); |
| 1471 EXPECT_FALSE(delegate->tap_cancel()); | 1473 EXPECT_FALSE(delegate->tap_cancel()); |
| 1472 | 1474 |
| 1473 // We haven't pressed long enough for a long press to occur | 1475 // We haven't pressed long enough for a long press to occur |
| 1474 EXPECT_FALSE(delegate->long_press()); | 1476 EXPECT_FALSE(delegate->long_press()); |
| 1475 | 1477 |
| 1476 // Wait until the timer runs out | 1478 // Wait until the timer runs out |
| 1477 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS); | 1479 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS); |
| 1478 EXPECT_TRUE(delegate->long_press()); | 1480 EXPECT_TRUE(delegate->long_press()); |
| 1479 EXPECT_EQ(0, delegate->touch_id()); | 1481 EXPECT_EQ(0, delegate->touch_id()); |
| 1480 EXPECT_FALSE(delegate->tap_cancel()); | 1482 EXPECT_FALSE(delegate->tap_cancel()); |
| 1481 | 1483 |
| 1482 delegate->Reset(); | 1484 delegate->Reset(); |
| 1483 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1485 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1484 kTouchId, tes.Now()); | 1486 kTouchId, tes.Now()); |
| 1485 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1); | 1487 DispatchEventUsingWindowDispatcher(&release1); |
| 1486 EXPECT_FALSE(delegate->long_press()); | 1488 EXPECT_FALSE(delegate->long_press()); |
| 1487 EXPECT_TRUE(delegate->long_tap()); | 1489 EXPECT_TRUE(delegate->long_tap()); |
| 1488 | 1490 |
| 1489 // Note the tap down isn't cancelled until the release | 1491 // Note the tap down isn't cancelled until the release |
| 1490 EXPECT_TRUE(delegate->tap_cancel()); | 1492 EXPECT_TRUE(delegate->tap_cancel()); |
| 1491 } | 1493 } |
| 1492 | 1494 |
| 1493 // Check that second tap cancels a long press | 1495 // Check that second tap cancels a long press |
| 1494 TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledBySecondTap) { | 1496 TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledBySecondTap) { |
| 1495 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1497 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1508 new TimerTestGestureRecognizer(); | 1510 new TimerTestGestureRecognizer(); |
| 1509 TimerTestGestureSequence* gesture_sequence = | 1511 TimerTestGestureSequence* gesture_sequence = |
| 1510 static_cast<TimerTestGestureSequence*>( | 1512 static_cast<TimerTestGestureSequence*>( |
| 1511 gesture_recognizer->GetGestureSequenceForTesting(window.get())); | 1513 gesture_recognizer->GetGestureSequenceForTesting(window.get())); |
| 1512 | 1514 |
| 1513 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); | 1515 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); |
| 1514 | 1516 |
| 1515 delegate->Reset(); | 1517 delegate->Reset(); |
| 1516 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 1518 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 1517 kTouchId1, tes.Now()); | 1519 kTouchId1, tes.Now()); |
| 1518 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 1520 DispatchEventUsingWindowDispatcher(&press); |
| 1519 EXPECT_TRUE(delegate->tap_down()); | 1521 EXPECT_TRUE(delegate->tap_down()); |
| 1520 EXPECT_TRUE(delegate->begin()); | 1522 EXPECT_TRUE(delegate->begin()); |
| 1521 | 1523 |
| 1522 // We haven't pressed long enough for a long press to occur | 1524 // We haven't pressed long enough for a long press to occur |
| 1523 EXPECT_FALSE(delegate->long_press()); | 1525 EXPECT_FALSE(delegate->long_press()); |
| 1524 | 1526 |
| 1525 // Second tap, to cancel the long press | 1527 // Second tap, to cancel the long press |
| 1526 delegate->Reset(); | 1528 delegate->Reset(); |
| 1527 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), | 1529 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), |
| 1528 kTouchId2, tes.Now()); | 1530 kTouchId2, tes.Now()); |
| 1529 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2); | 1531 DispatchEventUsingWindowDispatcher(&press2); |
| 1530 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap. | 1532 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap. |
| 1531 EXPECT_TRUE(delegate->tap_cancel()); | 1533 EXPECT_TRUE(delegate->tap_cancel()); |
| 1532 EXPECT_TRUE(delegate->begin()); | 1534 EXPECT_TRUE(delegate->begin()); |
| 1533 | 1535 |
| 1534 // Wait until the timer runs out | 1536 // Wait until the timer runs out |
| 1535 gesture_sequence->ForceTimeout(); | 1537 gesture_sequence->ForceTimeout(); |
| 1536 | 1538 |
| 1537 // No long press occurred | 1539 // No long press occurred |
| 1538 EXPECT_FALSE(delegate->long_press()); | 1540 EXPECT_FALSE(delegate->long_press()); |
| 1539 | 1541 |
| 1540 delegate->Reset(); | 1542 delegate->Reset(); |
| 1541 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1543 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1542 kTouchId1, tes.Now()); | 1544 kTouchId1, tes.Now()); |
| 1543 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1); | 1545 DispatchEventUsingWindowDispatcher(&release1); |
| 1544 EXPECT_FALSE(delegate->long_press()); | 1546 EXPECT_FALSE(delegate->long_press()); |
| 1545 EXPECT_TRUE(delegate->two_finger_tap()); | 1547 EXPECT_TRUE(delegate->two_finger_tap()); |
| 1546 EXPECT_FALSE(delegate->tap_cancel()); | 1548 EXPECT_FALSE(delegate->tap_cancel()); |
| 1547 } | 1549 } |
| 1548 | 1550 |
| 1549 // Check that horizontal scroll gestures cause scrolls on horizontal rails. | 1551 // Check that horizontal scroll gestures cause scrolls on horizontal rails. |
| 1550 // Also tests that horizontal rails can be broken. | 1552 // Also tests that horizontal rails can be broken. |
| 1551 TEST_F(GestureRecognizerTest, GestureEventHorizontalRailScroll) { | 1553 TEST_F(GestureRecognizerTest, GestureEventHorizontalRailScroll) { |
| 1552 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1554 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1553 new GestureEventConsumeDelegate()); | 1555 new GestureEventConsumeDelegate()); |
| 1554 TimedEvents tes; | 1556 TimedEvents tes; |
| 1555 const int kTouchId = 7; | 1557 const int kTouchId = 7; |
| 1556 gfx::Rect bounds(0, 0, 1000, 1000); | 1558 gfx::Rect bounds(0, 0, 1000, 1000); |
| 1557 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1559 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1558 delegate.get(), -1234, bounds, root_window())); | 1560 delegate.get(), -1234, bounds, root_window())); |
| 1559 | 1561 |
| 1560 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), | 1562 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), |
| 1561 kTouchId, tes.Now()); | 1563 kTouchId, tes.Now()); |
| 1562 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 1564 DispatchEventUsingWindowDispatcher(&press); |
| 1563 | 1565 |
| 1564 // Get rid of touch slop. | 1566 // Get rid of touch slop. |
| 1565 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(5, 0), | 1567 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(5, 0), |
| 1566 kTouchId, tes.Now()); | 1568 kTouchId, tes.Now()); |
| 1567 | 1569 |
| 1568 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move); | 1570 DispatchEventUsingWindowDispatcher(&move); |
| 1569 delegate->Reset(); | 1571 delegate->Reset(); |
| 1570 | 1572 |
| 1571 // Move the touch-point horizontally enough that it is considered a | 1573 // Move the touch-point horizontally enough that it is considered a |
| 1572 // horizontal scroll. | 1574 // horizontal scroll. |
| 1573 tes.SendScrollEvent(dispatcher(), 25, 1, kTouchId, delegate.get()); | 1575 tes.SendScrollEvent(dispatcher(), 25, 1, kTouchId, delegate.get()); |
| 1574 EXPECT_EQ(0, delegate->scroll_y()); | 1576 EXPECT_EQ(0, delegate->scroll_y()); |
| 1575 EXPECT_EQ(20, delegate->scroll_x()); | 1577 EXPECT_EQ(20, delegate->scroll_x()); |
| 1576 | 1578 |
| 1577 tes.SendScrollEvent(dispatcher(), 30, 6, kTouchId, delegate.get()); | 1579 tes.SendScrollEvent(dispatcher(), 30, 6, kTouchId, delegate.get()); |
| 1578 EXPECT_TRUE(delegate->scroll_update()); | 1580 EXPECT_TRUE(delegate->scroll_update()); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1606 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1608 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1607 new GestureEventConsumeDelegate()); | 1609 new GestureEventConsumeDelegate()); |
| 1608 TimedEvents tes; | 1610 TimedEvents tes; |
| 1609 const int kTouchId = 7; | 1611 const int kTouchId = 7; |
| 1610 gfx::Rect bounds(0, 0, 1000, 1000); | 1612 gfx::Rect bounds(0, 0, 1000, 1000); |
| 1611 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1613 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1612 delegate.get(), -1234, bounds, root_window())); | 1614 delegate.get(), -1234, bounds, root_window())); |
| 1613 | 1615 |
| 1614 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), | 1616 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), |
| 1615 kTouchId, tes.Now()); | 1617 kTouchId, tes.Now()); |
| 1616 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 1618 DispatchEventUsingWindowDispatcher(&press); |
| 1617 | 1619 |
| 1618 // Get rid of touch slop. | 1620 // Get rid of touch slop. |
| 1619 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(0, 5), | 1621 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(0, 5), |
| 1620 kTouchId, tes.Now()); | 1622 kTouchId, tes.Now()); |
| 1621 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move); | 1623 DispatchEventUsingWindowDispatcher(&move); |
| 1622 delegate->Reset(); | 1624 delegate->Reset(); |
| 1623 | 1625 |
| 1624 // Move the touch-point vertically enough that it is considered a | 1626 // Move the touch-point vertically enough that it is considered a |
| 1625 // vertical scroll. | 1627 // vertical scroll. |
| 1626 tes.SendScrollEvent(dispatcher(), 1, 25, kTouchId, delegate.get()); | 1628 tes.SendScrollEvent(dispatcher(), 1, 25, kTouchId, delegate.get()); |
| 1627 EXPECT_EQ(0, delegate->scroll_x()); | 1629 EXPECT_EQ(0, delegate->scroll_x()); |
| 1628 EXPECT_EQ(20, delegate->scroll_y()); | 1630 EXPECT_EQ(20, delegate->scroll_y()); |
| 1629 | 1631 |
| 1630 tes.SendScrollEvent(dispatcher(), 6, 30, kTouchId, delegate.get()); | 1632 tes.SendScrollEvent(dispatcher(), 6, 30, kTouchId, delegate.get()); |
| 1631 EXPECT_TRUE(delegate->scroll_update()); | 1633 EXPECT_TRUE(delegate->scroll_update()); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1666 const int kWindowWidth = 123; | 1668 const int kWindowWidth = 123; |
| 1667 const int kWindowHeight = 45; | 1669 const int kWindowHeight = 45; |
| 1668 const int kTouchId = 3; | 1670 const int kTouchId = 3; |
| 1669 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 1671 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 1670 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1672 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1671 delegate.get(), -1234, bounds, root_window())); | 1673 delegate.get(), -1234, bounds, root_window())); |
| 1672 | 1674 |
| 1673 delegate->Reset(); | 1675 delegate->Reset(); |
| 1674 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 1676 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 1675 kTouchId, tes.Now()); | 1677 kTouchId, tes.Now()); |
| 1676 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 1678 DispatchEventUsingWindowDispatcher(&press); |
| 1677 EXPECT_FALSE(delegate->tap()); | 1679 EXPECT_FALSE(delegate->tap()); |
| 1678 EXPECT_TRUE(delegate->tap_down()); | 1680 EXPECT_TRUE(delegate->tap_down()); |
| 1679 EXPECT_FALSE(delegate->tap_cancel()); | 1681 EXPECT_FALSE(delegate->tap_cancel()); |
| 1680 EXPECT_FALSE(delegate->scroll_begin()); | 1682 EXPECT_FALSE(delegate->scroll_begin()); |
| 1681 EXPECT_FALSE(delegate->scroll_update()); | 1683 EXPECT_FALSE(delegate->scroll_update()); |
| 1682 EXPECT_FALSE(delegate->scroll_end()); | 1684 EXPECT_FALSE(delegate->scroll_end()); |
| 1683 | 1685 |
| 1684 // Make sure there is enough delay before the touch is released so that it is | 1686 // Make sure there is enough delay before the touch is released so that it is |
| 1685 // recognized as a tap. | 1687 // recognized as a tap. |
| 1686 delegate->Reset(); | 1688 delegate->Reset(); |
| 1687 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1689 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1688 kTouchId, tes.LeapForward(50)); | 1690 kTouchId, tes.LeapForward(50)); |
| 1689 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 1691 DispatchEventUsingWindowDispatcher(&release); |
| 1690 EXPECT_TRUE(delegate->tap()); | 1692 EXPECT_TRUE(delegate->tap()); |
| 1691 EXPECT_FALSE(delegate->tap_down()); | 1693 EXPECT_FALSE(delegate->tap_down()); |
| 1692 EXPECT_FALSE(delegate->tap_cancel()); | 1694 EXPECT_FALSE(delegate->tap_cancel()); |
| 1693 EXPECT_FALSE(delegate->scroll_begin()); | 1695 EXPECT_FALSE(delegate->scroll_begin()); |
| 1694 EXPECT_FALSE(delegate->scroll_update()); | 1696 EXPECT_FALSE(delegate->scroll_update()); |
| 1695 EXPECT_FALSE(delegate->scroll_end()); | 1697 EXPECT_FALSE(delegate->scroll_end()); |
| 1696 | 1698 |
| 1697 // Now, do a scroll gesture. Delay it sufficiently so that it doesn't trigger | 1699 // Now, do a scroll gesture. Delay it sufficiently so that it doesn't trigger |
| 1698 // a double-tap. | 1700 // a double-tap. |
| 1699 delegate->Reset(); | 1701 delegate->Reset(); |
| 1700 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 1702 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 1701 kTouchId, tes.LeapForward(1000)); | 1703 kTouchId, tes.LeapForward(1000)); |
| 1702 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 1704 DispatchEventUsingWindowDispatcher(&press1); |
| 1703 EXPECT_FALSE(delegate->tap()); | 1705 EXPECT_FALSE(delegate->tap()); |
| 1704 EXPECT_TRUE(delegate->tap_down()); | 1706 EXPECT_TRUE(delegate->tap_down()); |
| 1705 EXPECT_FALSE(delegate->tap_cancel()); | 1707 EXPECT_FALSE(delegate->tap_cancel()); |
| 1706 EXPECT_FALSE(delegate->scroll_begin()); | 1708 EXPECT_FALSE(delegate->scroll_begin()); |
| 1707 EXPECT_FALSE(delegate->scroll_update()); | 1709 EXPECT_FALSE(delegate->scroll_update()); |
| 1708 EXPECT_FALSE(delegate->scroll_end()); | 1710 EXPECT_FALSE(delegate->scroll_end()); |
| 1709 | 1711 |
| 1710 // Get rid of touch slop. | 1712 // Get rid of touch slop. |
| 1711 ui::TouchEvent move_remove_slop(ui::ET_TOUCH_MOVED, gfx::Point(106, 206), | 1713 ui::TouchEvent move_remove_slop(ui::ET_TOUCH_MOVED, gfx::Point(106, 206), |
| 1712 kTouchId, tes.Now()); | 1714 kTouchId, tes.Now()); |
| 1713 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move_remove_slop); | 1715 DispatchEventUsingWindowDispatcher(&move_remove_slop); |
| 1714 EXPECT_TRUE(delegate->tap_cancel()); | 1716 EXPECT_TRUE(delegate->tap_cancel()); |
| 1715 EXPECT_TRUE(delegate->scroll_begin()); | 1717 EXPECT_TRUE(delegate->scroll_begin()); |
| 1716 EXPECT_FALSE(delegate->scroll_update()); | 1718 EXPECT_FALSE(delegate->scroll_update()); |
| 1717 EXPECT_EQ(5, delegate->scroll_x_hint()); | 1719 EXPECT_EQ(5, delegate->scroll_x_hint()); |
| 1718 EXPECT_EQ(5, delegate->scroll_y_hint()); | 1720 EXPECT_EQ(5, delegate->scroll_y_hint()); |
| 1719 | 1721 |
| 1720 delegate->Reset(); | 1722 delegate->Reset(); |
| 1721 | 1723 |
| 1722 // Move the touch-point enough so that it is considered as a scroll. This | 1724 // Move the touch-point enough so that it is considered as a scroll. This |
| 1723 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. | 1725 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. |
| 1724 // The first movement is diagonal, to ensure that we have a free scroll, | 1726 // The first movement is diagonal, to ensure that we have a free scroll, |
| 1725 // and not a rail scroll. | 1727 // and not a rail scroll. |
| 1726 delegate->Reset(); | 1728 delegate->Reset(); |
| 1727 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(135, 235), | 1729 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(135, 235), |
| 1728 kTouchId, tes.Now()); | 1730 kTouchId, tes.Now()); |
| 1729 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move); | 1731 DispatchEventUsingWindowDispatcher(&move); |
| 1730 EXPECT_FALSE(delegate->tap()); | 1732 EXPECT_FALSE(delegate->tap()); |
| 1731 EXPECT_FALSE(delegate->tap_down()); | 1733 EXPECT_FALSE(delegate->tap_down()); |
| 1732 EXPECT_FALSE(delegate->tap_cancel()); | 1734 EXPECT_FALSE(delegate->tap_cancel()); |
| 1733 EXPECT_FALSE(delegate->scroll_begin()); | 1735 EXPECT_FALSE(delegate->scroll_begin()); |
| 1734 EXPECT_TRUE(delegate->scroll_update()); | 1736 EXPECT_TRUE(delegate->scroll_update()); |
| 1735 EXPECT_FALSE(delegate->scroll_end()); | 1737 EXPECT_FALSE(delegate->scroll_end()); |
| 1736 EXPECT_EQ(29, delegate->scroll_x()); | 1738 EXPECT_EQ(29, delegate->scroll_x()); |
| 1737 EXPECT_EQ(29, delegate->scroll_y()); | 1739 EXPECT_EQ(29, delegate->scroll_y()); |
| 1738 | 1740 |
| 1739 // Move some more to generate a few more scroll updates. | 1741 // Move some more to generate a few more scroll updates. |
| 1740 delegate->Reset(); | 1742 delegate->Reset(); |
| 1741 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(115, 216), | 1743 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(115, 216), |
| 1742 kTouchId, tes.Now()); | 1744 kTouchId, tes.Now()); |
| 1743 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move1); | 1745 DispatchEventUsingWindowDispatcher(&move1); |
| 1744 EXPECT_FALSE(delegate->tap()); | 1746 EXPECT_FALSE(delegate->tap()); |
| 1745 EXPECT_FALSE(delegate->tap_down()); | 1747 EXPECT_FALSE(delegate->tap_down()); |
| 1746 EXPECT_FALSE(delegate->tap_cancel()); | 1748 EXPECT_FALSE(delegate->tap_cancel()); |
| 1747 EXPECT_FALSE(delegate->scroll_begin()); | 1749 EXPECT_FALSE(delegate->scroll_begin()); |
| 1748 EXPECT_TRUE(delegate->scroll_update()); | 1750 EXPECT_TRUE(delegate->scroll_update()); |
| 1749 EXPECT_FALSE(delegate->scroll_end()); | 1751 EXPECT_FALSE(delegate->scroll_end()); |
| 1750 EXPECT_EQ(-20, delegate->scroll_x()); | 1752 EXPECT_EQ(-20, delegate->scroll_x()); |
| 1751 EXPECT_EQ(-19, delegate->scroll_y()); | 1753 EXPECT_EQ(-19, delegate->scroll_y()); |
| 1752 EXPECT_EQ(0, delegate->scroll_x_hint()); | 1754 EXPECT_EQ(0, delegate->scroll_x_hint()); |
| 1753 EXPECT_EQ(0, delegate->scroll_y_hint()); | 1755 EXPECT_EQ(0, delegate->scroll_y_hint()); |
| 1754 | 1756 |
| 1755 delegate->Reset(); | 1757 delegate->Reset(); |
| 1756 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(145, 220), | 1758 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(145, 220), |
| 1757 kTouchId, tes.Now()); | 1759 kTouchId, tes.Now()); |
| 1758 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move2); | 1760 DispatchEventUsingWindowDispatcher(&move2); |
| 1759 EXPECT_FALSE(delegate->tap()); | 1761 EXPECT_FALSE(delegate->tap()); |
| 1760 EXPECT_FALSE(delegate->tap_down()); | 1762 EXPECT_FALSE(delegate->tap_down()); |
| 1761 EXPECT_FALSE(delegate->tap_cancel()); | 1763 EXPECT_FALSE(delegate->tap_cancel()); |
| 1762 EXPECT_FALSE(delegate->scroll_begin()); | 1764 EXPECT_FALSE(delegate->scroll_begin()); |
| 1763 EXPECT_TRUE(delegate->scroll_update()); | 1765 EXPECT_TRUE(delegate->scroll_update()); |
| 1764 EXPECT_FALSE(delegate->scroll_end()); | 1766 EXPECT_FALSE(delegate->scroll_end()); |
| 1765 EXPECT_EQ(30, delegate->scroll_x()); | 1767 EXPECT_EQ(30, delegate->scroll_x()); |
| 1766 EXPECT_EQ(4, delegate->scroll_y()); | 1768 EXPECT_EQ(4, delegate->scroll_y()); |
| 1767 | 1769 |
| 1768 // Release the touch. This should end the scroll. | 1770 // Release the touch. This should end the scroll. |
| 1769 delegate->Reset(); | 1771 delegate->Reset(); |
| 1770 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1772 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1771 kTouchId, tes.Now()); | 1773 kTouchId, tes.Now()); |
| 1772 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1); | 1774 DispatchEventUsingWindowDispatcher(&release1); |
| 1773 EXPECT_FALSE(delegate->tap()); | 1775 EXPECT_FALSE(delegate->tap()); |
| 1774 EXPECT_FALSE(delegate->tap_down()); | 1776 EXPECT_FALSE(delegate->tap_down()); |
| 1775 EXPECT_FALSE(delegate->tap_cancel()); | 1777 EXPECT_FALSE(delegate->tap_cancel()); |
| 1776 EXPECT_FALSE(delegate->scroll_begin()); | 1778 EXPECT_FALSE(delegate->scroll_begin()); |
| 1777 EXPECT_FALSE(delegate->scroll_update()); | 1779 EXPECT_FALSE(delegate->scroll_update()); |
| 1778 EXPECT_FALSE(delegate->scroll_end()); | 1780 EXPECT_FALSE(delegate->scroll_end()); |
| 1779 EXPECT_TRUE(delegate->fling()); | 1781 EXPECT_TRUE(delegate->fling()); |
| 1780 } | 1782 } |
| 1781 | 1783 |
| 1782 TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) { | 1784 TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) { |
| 1783 scoped_ptr<QueueTouchEventDelegate> queued_delegate( | 1785 scoped_ptr<QueueTouchEventDelegate> queued_delegate( |
| 1784 new QueueTouchEventDelegate(dispatcher())); | 1786 new QueueTouchEventDelegate(dispatcher())); |
| 1785 const int kWindowWidth = 123; | 1787 const int kWindowWidth = 123; |
| 1786 const int kWindowHeight = 45; | 1788 const int kWindowHeight = 45; |
| 1787 const int kTouchId1 = 6; | 1789 const int kTouchId1 = 6; |
| 1788 const int kTouchId2 = 4; | 1790 const int kTouchId2 = 4; |
| 1789 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 1791 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 1790 scoped_ptr<aura::Window> queue(CreateTestWindowWithDelegate( | 1792 scoped_ptr<aura::Window> queue(CreateTestWindowWithDelegate( |
| 1791 queued_delegate.get(), -1234, bounds, root_window())); | 1793 queued_delegate.get(), -1234, bounds, root_window())); |
| 1792 | 1794 |
| 1793 queued_delegate->set_window(queue.get()); | 1795 queued_delegate->set_window(queue.get()); |
| 1794 | 1796 |
| 1795 // Touch down on the window. This should not generate any gesture event. | 1797 // Touch down on the window. This should not generate any gesture event. |
| 1796 queued_delegate->Reset(); | 1798 queued_delegate->Reset(); |
| 1797 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 1799 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 1798 kTouchId1, GetTime()); | 1800 kTouchId1, GetTime()); |
| 1799 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 1801 DispatchEventUsingWindowDispatcher(&press); |
| 1800 EXPECT_FALSE(queued_delegate->tap()); | 1802 EXPECT_FALSE(queued_delegate->tap()); |
| 1801 EXPECT_FALSE(queued_delegate->tap_down()); | 1803 EXPECT_FALSE(queued_delegate->tap_down()); |
| 1802 EXPECT_FALSE(queued_delegate->tap_cancel()); | 1804 EXPECT_FALSE(queued_delegate->tap_cancel()); |
| 1803 EXPECT_FALSE(queued_delegate->begin()); | 1805 EXPECT_FALSE(queued_delegate->begin()); |
| 1804 EXPECT_FALSE(queued_delegate->scroll_begin()); | 1806 EXPECT_FALSE(queued_delegate->scroll_begin()); |
| 1805 EXPECT_FALSE(queued_delegate->scroll_update()); | 1807 EXPECT_FALSE(queued_delegate->scroll_update()); |
| 1806 EXPECT_FALSE(queued_delegate->scroll_end()); | 1808 EXPECT_FALSE(queued_delegate->scroll_end()); |
| 1807 | 1809 |
| 1808 // Introduce some delay before the touch is released so that it is recognized | 1810 // Introduce some delay before the touch is released so that it is recognized |
| 1809 // as a tap. However, this still should not create any gesture events. | 1811 // as a tap. However, this still should not create any gesture events. |
| 1810 queued_delegate->Reset(); | 1812 queued_delegate->Reset(); |
| 1811 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1813 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1812 kTouchId1, press.time_stamp() + | 1814 kTouchId1, press.time_stamp() + |
| 1813 base::TimeDelta::FromMilliseconds(50)); | 1815 base::TimeDelta::FromMilliseconds(50)); |
| 1814 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 1816 DispatchEventUsingWindowDispatcher(&release); |
| 1815 EXPECT_FALSE(queued_delegate->tap()); | 1817 EXPECT_FALSE(queued_delegate->tap()); |
| 1816 EXPECT_FALSE(queued_delegate->tap_down()); | 1818 EXPECT_FALSE(queued_delegate->tap_down()); |
| 1817 EXPECT_FALSE(queued_delegate->tap_cancel()); | 1819 EXPECT_FALSE(queued_delegate->tap_cancel()); |
| 1818 EXPECT_FALSE(queued_delegate->begin()); | 1820 EXPECT_FALSE(queued_delegate->begin()); |
| 1819 EXPECT_FALSE(queued_delegate->end()); | 1821 EXPECT_FALSE(queued_delegate->end()); |
| 1820 EXPECT_FALSE(queued_delegate->scroll_begin()); | 1822 EXPECT_FALSE(queued_delegate->scroll_begin()); |
| 1821 EXPECT_FALSE(queued_delegate->scroll_update()); | 1823 EXPECT_FALSE(queued_delegate->scroll_update()); |
| 1822 EXPECT_FALSE(queued_delegate->scroll_end()); | 1824 EXPECT_FALSE(queued_delegate->scroll_end()); |
| 1823 | 1825 |
| 1824 // Create another window, and place a touch-down on it. This should create a | 1826 // Create another window, and place a touch-down on it. This should create a |
| 1825 // tap-down gesture. | 1827 // tap-down gesture. |
| 1826 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1828 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1827 new GestureEventConsumeDelegate()); | 1829 new GestureEventConsumeDelegate()); |
| 1828 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1830 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1829 delegate.get(), -2345, gfx::Rect(0, 0, 50, 50), root_window())); | 1831 delegate.get(), -2345, gfx::Rect(0, 0, 50, 50), root_window())); |
| 1830 delegate->Reset(); | 1832 delegate->Reset(); |
| 1831 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 20), | 1833 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 20), |
| 1832 kTouchId2, GetTime()); | 1834 kTouchId2, GetTime()); |
| 1833 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2); | 1835 DispatchEventUsingWindowDispatcher(&press2); |
| 1834 EXPECT_FALSE(delegate->tap()); | 1836 EXPECT_FALSE(delegate->tap()); |
| 1835 EXPECT_TRUE(delegate->tap_down()); | 1837 EXPECT_TRUE(delegate->tap_down()); |
| 1836 EXPECT_FALSE(delegate->tap_cancel()); | 1838 EXPECT_FALSE(delegate->tap_cancel()); |
| 1837 EXPECT_FALSE(queued_delegate->begin()); | 1839 EXPECT_FALSE(queued_delegate->begin()); |
| 1838 EXPECT_FALSE(queued_delegate->end()); | 1840 EXPECT_FALSE(queued_delegate->end()); |
| 1839 EXPECT_FALSE(delegate->scroll_begin()); | 1841 EXPECT_FALSE(delegate->scroll_begin()); |
| 1840 EXPECT_FALSE(delegate->scroll_update()); | 1842 EXPECT_FALSE(delegate->scroll_update()); |
| 1841 EXPECT_FALSE(delegate->scroll_end()); | 1843 EXPECT_FALSE(delegate->scroll_end()); |
| 1842 | 1844 |
| 1843 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(10, 20), | 1845 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(10, 20), |
| 1844 kTouchId2, GetTime()); | 1846 kTouchId2, GetTime()); |
| 1845 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release2); | 1847 DispatchEventUsingWindowDispatcher(&release2); |
| 1846 | 1848 |
| 1847 // Process the first queued event. | 1849 // Process the first queued event. |
| 1848 queued_delegate->Reset(); | 1850 queued_delegate->Reset(); |
| 1849 queued_delegate->ReceivedAck(); | 1851 queued_delegate->ReceivedAck(); |
| 1850 EXPECT_FALSE(queued_delegate->tap()); | 1852 EXPECT_FALSE(queued_delegate->tap()); |
| 1851 EXPECT_TRUE(queued_delegate->tap_down()); | 1853 EXPECT_TRUE(queued_delegate->tap_down()); |
| 1852 EXPECT_TRUE(queued_delegate->begin()); | 1854 EXPECT_TRUE(queued_delegate->begin()); |
| 1853 EXPECT_FALSE(queued_delegate->tap_cancel()); | 1855 EXPECT_FALSE(queued_delegate->tap_cancel()); |
| 1854 EXPECT_FALSE(queued_delegate->end()); | 1856 EXPECT_FALSE(queued_delegate->end()); |
| 1855 EXPECT_FALSE(queued_delegate->scroll_begin()); | 1857 EXPECT_FALSE(queued_delegate->scroll_begin()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1866 EXPECT_TRUE(queued_delegate->end()); | 1868 EXPECT_TRUE(queued_delegate->end()); |
| 1867 EXPECT_FALSE(queued_delegate->scroll_begin()); | 1869 EXPECT_FALSE(queued_delegate->scroll_begin()); |
| 1868 EXPECT_FALSE(queued_delegate->scroll_update()); | 1870 EXPECT_FALSE(queued_delegate->scroll_update()); |
| 1869 EXPECT_FALSE(queued_delegate->scroll_end()); | 1871 EXPECT_FALSE(queued_delegate->scroll_end()); |
| 1870 | 1872 |
| 1871 // Start all over. Press on the first window, then press again on the second | 1873 // Start all over. Press on the first window, then press again on the second |
| 1872 // window. The second press should still go to the first window. | 1874 // window. The second press should still go to the first window. |
| 1873 queued_delegate->Reset(); | 1875 queued_delegate->Reset(); |
| 1874 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 1876 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 1875 kTouchId1, GetTime()); | 1877 kTouchId1, GetTime()); |
| 1876 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press3); | 1878 DispatchEventUsingWindowDispatcher(&press3); |
| 1877 EXPECT_FALSE(queued_delegate->tap()); | 1879 EXPECT_FALSE(queued_delegate->tap()); |
| 1878 EXPECT_FALSE(queued_delegate->tap_down()); | 1880 EXPECT_FALSE(queued_delegate->tap_down()); |
| 1879 EXPECT_FALSE(queued_delegate->tap_cancel()); | 1881 EXPECT_FALSE(queued_delegate->tap_cancel()); |
| 1880 EXPECT_FALSE(queued_delegate->begin()); | 1882 EXPECT_FALSE(queued_delegate->begin()); |
| 1881 EXPECT_FALSE(queued_delegate->end()); | 1883 EXPECT_FALSE(queued_delegate->end()); |
| 1882 EXPECT_FALSE(queued_delegate->begin()); | 1884 EXPECT_FALSE(queued_delegate->begin()); |
| 1883 EXPECT_FALSE(queued_delegate->end()); | 1885 EXPECT_FALSE(queued_delegate->end()); |
| 1884 EXPECT_FALSE(queued_delegate->scroll_begin()); | 1886 EXPECT_FALSE(queued_delegate->scroll_begin()); |
| 1885 EXPECT_FALSE(queued_delegate->scroll_update()); | 1887 EXPECT_FALSE(queued_delegate->scroll_update()); |
| 1886 EXPECT_FALSE(queued_delegate->scroll_end()); | 1888 EXPECT_FALSE(queued_delegate->scroll_end()); |
| 1887 | 1889 |
| 1888 queued_delegate->Reset(); | 1890 queued_delegate->Reset(); |
| 1889 delegate->Reset(); | 1891 delegate->Reset(); |
| 1890 ui::TouchEvent press4(ui::ET_TOUCH_PRESSED, gfx::Point(103, 203), | 1892 ui::TouchEvent press4(ui::ET_TOUCH_PRESSED, gfx::Point(103, 203), |
| 1891 kTouchId2, GetTime()); | 1893 kTouchId2, GetTime()); |
| 1892 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press4); | 1894 DispatchEventUsingWindowDispatcher(&press4); |
| 1893 EXPECT_FALSE(delegate->tap()); | 1895 EXPECT_FALSE(delegate->tap()); |
| 1894 EXPECT_FALSE(delegate->tap_down()); | 1896 EXPECT_FALSE(delegate->tap_down()); |
| 1895 EXPECT_FALSE(delegate->tap_cancel()); | 1897 EXPECT_FALSE(delegate->tap_cancel()); |
| 1896 EXPECT_FALSE(delegate->begin()); | 1898 EXPECT_FALSE(delegate->begin()); |
| 1897 EXPECT_FALSE(delegate->end()); | 1899 EXPECT_FALSE(delegate->end()); |
| 1898 EXPECT_FALSE(delegate->scroll_begin()); | 1900 EXPECT_FALSE(delegate->scroll_begin()); |
| 1899 EXPECT_FALSE(delegate->scroll_update()); | 1901 EXPECT_FALSE(delegate->scroll_update()); |
| 1900 EXPECT_FALSE(delegate->scroll_end()); | 1902 EXPECT_FALSE(delegate->scroll_end()); |
| 1901 EXPECT_FALSE(queued_delegate->tap()); | 1903 EXPECT_FALSE(queued_delegate->tap()); |
| 1902 EXPECT_FALSE(queued_delegate->tap_down()); | 1904 EXPECT_FALSE(queued_delegate->tap_down()); |
| 1903 EXPECT_FALSE(queued_delegate->tap_cancel()); | 1905 EXPECT_FALSE(queued_delegate->tap_cancel()); |
| 1904 EXPECT_FALSE(queued_delegate->begin()); | 1906 EXPECT_FALSE(queued_delegate->begin()); |
| 1905 EXPECT_FALSE(queued_delegate->end()); | 1907 EXPECT_FALSE(queued_delegate->end()); |
| 1906 EXPECT_FALSE(queued_delegate->scroll_begin()); | 1908 EXPECT_FALSE(queued_delegate->scroll_begin()); |
| 1907 EXPECT_FALSE(queued_delegate->scroll_update()); | 1909 EXPECT_FALSE(queued_delegate->scroll_update()); |
| 1908 EXPECT_FALSE(queued_delegate->scroll_end()); | 1910 EXPECT_FALSE(queued_delegate->scroll_end()); |
| 1909 | 1911 |
| 1910 // Move the second touch-point enough so that it is considered a pinch. This | 1912 // Move the second touch-point enough so that it is considered a pinch. This |
| 1911 // should generate both SCROLL_BEGIN and PINCH_BEGIN gestures. | 1913 // should generate both SCROLL_BEGIN and PINCH_BEGIN gestures. |
| 1912 queued_delegate->Reset(); | 1914 queued_delegate->Reset(); |
| 1913 delegate->Reset(); | 1915 delegate->Reset(); |
| 1914 int x_move = ui::GestureConfiguration::max_touch_move_in_pixels_for_click(); | 1916 int x_move = ui::GestureConfiguration::max_touch_move_in_pixels_for_click(); |
| 1915 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(103 + x_move, 203), | 1917 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(103 + x_move, 203), |
| 1916 kTouchId2, GetTime()); | 1918 kTouchId2, GetTime()); |
| 1917 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move); | 1919 DispatchEventUsingWindowDispatcher(&move); |
| 1918 EXPECT_FALSE(delegate->tap()); | 1920 EXPECT_FALSE(delegate->tap()); |
| 1919 EXPECT_FALSE(delegate->tap_down()); | 1921 EXPECT_FALSE(delegate->tap_down()); |
| 1920 EXPECT_FALSE(delegate->tap_cancel()); | 1922 EXPECT_FALSE(delegate->tap_cancel()); |
| 1921 EXPECT_FALSE(delegate->begin()); | 1923 EXPECT_FALSE(delegate->begin()); |
| 1922 EXPECT_FALSE(delegate->scroll_begin()); | 1924 EXPECT_FALSE(delegate->scroll_begin()); |
| 1923 EXPECT_FALSE(delegate->scroll_update()); | 1925 EXPECT_FALSE(delegate->scroll_update()); |
| 1924 EXPECT_FALSE(delegate->scroll_end()); | 1926 EXPECT_FALSE(delegate->scroll_end()); |
| 1925 EXPECT_FALSE(queued_delegate->tap()); | 1927 EXPECT_FALSE(queued_delegate->tap()); |
| 1926 EXPECT_FALSE(queued_delegate->tap_down()); | 1928 EXPECT_FALSE(queued_delegate->tap_down()); |
| 1927 EXPECT_FALSE(queued_delegate->tap_cancel()); | 1929 EXPECT_FALSE(queued_delegate->tap_cancel()); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1976 new GestureEventConsumeDelegate()); | 1978 new GestureEventConsumeDelegate()); |
| 1977 TimedEvents tes; | 1979 TimedEvents tes; |
| 1978 const int kWindowWidth = 300; | 1980 const int kWindowWidth = 300; |
| 1979 const int kWindowHeight = 400; | 1981 const int kWindowHeight = 400; |
| 1980 const int kTouchId1 = 5; | 1982 const int kTouchId1 = 5; |
| 1981 const int kTouchId2 = 3; | 1983 const int kTouchId2 = 3; |
| 1982 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); | 1984 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); |
| 1983 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1985 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1984 delegate.get(), -1234, bounds, root_window())); | 1986 delegate.get(), -1234, bounds, root_window())); |
| 1985 | 1987 |
| 1986 aura::RootWindow* root = dispatcher(); | |
| 1987 | |
| 1988 delegate->Reset(); | 1988 delegate->Reset(); |
| 1989 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 1989 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 1990 kTouchId1, tes.Now()); | 1990 kTouchId1, tes.Now()); |
| 1991 root->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 1991 DispatchEventUsingWindowDispatcher(&press); |
| 1992 EXPECT_2_EVENTS(delegate->events(), | 1992 EXPECT_2_EVENTS(delegate->events(), |
| 1993 ui::ET_GESTURE_BEGIN, | 1993 ui::ET_GESTURE_BEGIN, |
| 1994 ui::ET_GESTURE_TAP_DOWN); | 1994 ui::ET_GESTURE_TAP_DOWN); |
| 1995 | 1995 |
| 1996 // Move the touch-point enough so that it is considered as a scroll. This | 1996 // Move the touch-point enough so that it is considered as a scroll. This |
| 1997 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. | 1997 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. |
| 1998 delegate->Reset(); | 1998 delegate->Reset(); |
| 1999 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(130, 301), | 1999 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(130, 301), |
| 2000 kTouchId1, tes.Now()); | 2000 kTouchId1, tes.Now()); |
| 2001 root->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move); | 2001 DispatchEventUsingWindowDispatcher(&move); |
| 2002 EXPECT_3_EVENTS(delegate->events(), | 2002 EXPECT_3_EVENTS(delegate->events(), |
| 2003 ui::ET_GESTURE_TAP_CANCEL, | 2003 ui::ET_GESTURE_TAP_CANCEL, |
| 2004 ui::ET_GESTURE_SCROLL_BEGIN, | 2004 ui::ET_GESTURE_SCROLL_BEGIN, |
| 2005 ui::ET_GESTURE_SCROLL_UPDATE); | 2005 ui::ET_GESTURE_SCROLL_UPDATE); |
| 2006 | 2006 |
| 2007 // Press the second finger. It should cause pinch-begin. Note that we will not | 2007 // Press the second finger. It should cause pinch-begin. Note that we will not |
| 2008 // transition to two finger tap here because the touch points are far enough. | 2008 // transition to two finger tap here because the touch points are far enough. |
| 2009 delegate->Reset(); | 2009 delegate->Reset(); |
| 2010 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), | 2010 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), |
| 2011 kTouchId2, tes.Now()); | 2011 kTouchId2, tes.Now()); |
| 2012 root->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2); | 2012 DispatchEventUsingWindowDispatcher(&press2); |
| 2013 EXPECT_2_EVENTS(delegate->events(), | 2013 EXPECT_2_EVENTS(delegate->events(), |
| 2014 ui::ET_GESTURE_BEGIN, | 2014 ui::ET_GESTURE_BEGIN, |
| 2015 ui::ET_GESTURE_PINCH_BEGIN); | 2015 ui::ET_GESTURE_PINCH_BEGIN); |
| 2016 EXPECT_EQ(gfx::Rect(10, 10, 120, 291).ToString(), | 2016 EXPECT_EQ(gfx::Rect(10, 10, 120, 291).ToString(), |
| 2017 delegate->bounding_box().ToString()); | 2017 delegate->bounding_box().ToString()); |
| 2018 | 2018 |
| 2019 // Move the first finger. | 2019 // Move the first finger. |
| 2020 delegate->Reset(); | 2020 delegate->Reset(); |
| 2021 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(95, 201), | 2021 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(95, 201), |
| 2022 kTouchId1, tes.Now()); | 2022 kTouchId1, tes.Now()); |
| 2023 root->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move3); | 2023 DispatchEventUsingWindowDispatcher(&move3); |
| 2024 EXPECT_2_EVENTS(delegate->events(), | 2024 EXPECT_2_EVENTS(delegate->events(), |
| 2025 ui::ET_GESTURE_PINCH_UPDATE, | 2025 ui::ET_GESTURE_PINCH_UPDATE, |
| 2026 ui::ET_GESTURE_SCROLL_UPDATE); | 2026 ui::ET_GESTURE_SCROLL_UPDATE); |
| 2027 EXPECT_EQ(gfx::Rect(10, 10, 85, 191).ToString(), | 2027 EXPECT_EQ(gfx::Rect(10, 10, 85, 191).ToString(), |
| 2028 delegate->bounding_box().ToString()); | 2028 delegate->bounding_box().ToString()); |
| 2029 | 2029 |
| 2030 // Now move the second finger. | 2030 // Now move the second finger. |
| 2031 delegate->Reset(); | 2031 delegate->Reset(); |
| 2032 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(55, 15), | 2032 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(55, 15), |
| 2033 kTouchId2, tes.Now()); | 2033 kTouchId2, tes.Now()); |
| 2034 root->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move4); | 2034 DispatchEventUsingWindowDispatcher(&move4); |
| 2035 EXPECT_2_EVENTS(delegate->events(), | 2035 EXPECT_2_EVENTS(delegate->events(), |
| 2036 ui::ET_GESTURE_PINCH_UPDATE, | 2036 ui::ET_GESTURE_PINCH_UPDATE, |
| 2037 ui::ET_GESTURE_SCROLL_UPDATE); | 2037 ui::ET_GESTURE_SCROLL_UPDATE); |
| 2038 EXPECT_EQ(gfx::Rect(55, 15, 40, 186).ToString(), | 2038 EXPECT_EQ(gfx::Rect(55, 15, 40, 186).ToString(), |
| 2039 delegate->bounding_box().ToString()); | 2039 delegate->bounding_box().ToString()); |
| 2040 | 2040 |
| 2041 // Release the first finger. This should end pinch. | 2041 // Release the first finger. This should end pinch. |
| 2042 delegate->Reset(); | 2042 delegate->Reset(); |
| 2043 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 2043 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 2044 kTouchId1, tes.Now()); | 2044 kTouchId1, tes.Now()); |
| 2045 root->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 2045 DispatchEventUsingWindowDispatcher(&release); |
| 2046 EXPECT_2_EVENTS(delegate->events(), | 2046 EXPECT_2_EVENTS(delegate->events(), |
| 2047 ui::ET_GESTURE_PINCH_END, | 2047 ui::ET_GESTURE_PINCH_END, |
| 2048 ui::ET_GESTURE_END); | 2048 ui::ET_GESTURE_END); |
| 2049 EXPECT_EQ(gfx::Rect(55, 15, 46, 186).ToString(), | 2049 EXPECT_EQ(gfx::Rect(55, 15, 46, 186).ToString(), |
| 2050 delegate->bounding_box().ToString()); | 2050 delegate->bounding_box().ToString()); |
| 2051 | 2051 |
| 2052 // Move the second finger. This should still generate a scroll. | 2052 // Move the second finger. This should still generate a scroll. |
| 2053 delegate->Reset(); | 2053 delegate->Reset(); |
| 2054 ui::TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), | 2054 ui::TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), |
| 2055 kTouchId2, tes.Now()); | 2055 kTouchId2, tes.Now()); |
| 2056 root->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move5); | 2056 DispatchEventUsingWindowDispatcher(&move5); |
| 2057 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); | 2057 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); |
| 2058 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); | 2058 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
| 2059 } | 2059 } |
| 2060 | 2060 |
| 2061 TEST_F(GestureRecognizerTest, GestureEventPinchFromScrollFromPinch) { | 2061 TEST_F(GestureRecognizerTest, GestureEventPinchFromScrollFromPinch) { |
| 2062 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2062 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2063 new GestureEventConsumeDelegate()); | 2063 new GestureEventConsumeDelegate()); |
| 2064 TimedEvents tes; | 2064 TimedEvents tes; |
| 2065 const int kWindowWidth = 300; | 2065 const int kWindowWidth = 300; |
| 2066 const int kWindowHeight = 400; | 2066 const int kWindowHeight = 400; |
| 2067 const int kTouchId1 = 5; | 2067 const int kTouchId1 = 5; |
| 2068 const int kTouchId2 = 3; | 2068 const int kTouchId2 = 3; |
| 2069 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); | 2069 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); |
| 2070 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2070 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2071 delegate.get(), -1234, bounds, root_window())); | 2071 delegate.get(), -1234, bounds, root_window())); |
| 2072 | 2072 |
| 2073 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), | 2073 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), |
| 2074 kTouchId1, tes.Now()); | 2074 kTouchId1, tes.Now()); |
| 2075 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 2075 DispatchEventUsingWindowDispatcher(&press); |
| 2076 delegate->Reset(); | 2076 delegate->Reset(); |
| 2077 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), | 2077 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), |
| 2078 kTouchId2, tes.Now()); | 2078 kTouchId2, tes.Now()); |
| 2079 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2); | 2079 DispatchEventUsingWindowDispatcher(&press2); |
| 2080 EXPECT_FALSE(delegate->pinch_begin()); | 2080 EXPECT_FALSE(delegate->pinch_begin()); |
| 2081 | 2081 |
| 2082 // Touch move triggers pinch begin. | 2082 // Touch move triggers pinch begin. |
| 2083 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId1, delegate.get()); | 2083 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId1, delegate.get()); |
| 2084 EXPECT_TRUE(delegate->pinch_begin()); | 2084 EXPECT_TRUE(delegate->pinch_begin()); |
| 2085 EXPECT_FALSE(delegate->pinch_update()); | 2085 EXPECT_FALSE(delegate->pinch_update()); |
| 2086 | 2086 |
| 2087 // Touch move triggers pinch update. | 2087 // Touch move triggers pinch update. |
| 2088 tes.SendScrollEvent(dispatcher(), 160, 200, kTouchId1, delegate.get()); | 2088 tes.SendScrollEvent(dispatcher(), 160, 200, kTouchId1, delegate.get()); |
| 2089 EXPECT_FALSE(delegate->pinch_begin()); | 2089 EXPECT_FALSE(delegate->pinch_begin()); |
| 2090 EXPECT_TRUE(delegate->pinch_update()); | 2090 EXPECT_TRUE(delegate->pinch_update()); |
| 2091 | 2091 |
| 2092 // Pinch has started, now release the second finger | 2092 // Pinch has started, now release the second finger |
| 2093 delegate->Reset(); | 2093 delegate->Reset(); |
| 2094 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 2094 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 2095 kTouchId1, tes.Now()); | 2095 kTouchId1, tes.Now()); |
| 2096 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 2096 DispatchEventUsingWindowDispatcher(&release); |
| 2097 EXPECT_TRUE(delegate->pinch_end()); | 2097 EXPECT_TRUE(delegate->pinch_end()); |
| 2098 | 2098 |
| 2099 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId2, delegate.get()); | 2099 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId2, delegate.get()); |
| 2100 EXPECT_TRUE(delegate->scroll_update()); | 2100 EXPECT_TRUE(delegate->scroll_update()); |
| 2101 | 2101 |
| 2102 // Pinch again | 2102 // Pinch again |
| 2103 delegate->Reset(); | 2103 delegate->Reset(); |
| 2104 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), | 2104 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), |
| 2105 kTouchId1, tes.Now()); | 2105 kTouchId1, tes.Now()); |
| 2106 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press3); | 2106 DispatchEventUsingWindowDispatcher(&press3); |
| 2107 // Now the touch points are close. So we will go into two finger tap. | 2107 // Now the touch points are close. So we will go into two finger tap. |
| 2108 // Move the touch-point enough to break two-finger-tap and enter pinch. | 2108 // Move the touch-point enough to break two-finger-tap and enter pinch. |
| 2109 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(101, 202), | 2109 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(101, 202), |
| 2110 kTouchId1, tes.Now()); | 2110 kTouchId1, tes.Now()); |
| 2111 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move2); | 2111 DispatchEventUsingWindowDispatcher(&move2); |
| 2112 EXPECT_TRUE(delegate->pinch_begin()); | 2112 EXPECT_TRUE(delegate->pinch_begin()); |
| 2113 | 2113 |
| 2114 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId1, delegate.get()); | 2114 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId1, delegate.get()); |
| 2115 EXPECT_TRUE(delegate->pinch_update()); | 2115 EXPECT_TRUE(delegate->pinch_update()); |
| 2116 } | 2116 } |
| 2117 | 2117 |
| 2118 TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) { | 2118 TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) { |
| 2119 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2119 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2120 new GestureEventConsumeDelegate()); | 2120 new GestureEventConsumeDelegate()); |
| 2121 TimedEvents tes; | 2121 TimedEvents tes; |
| 2122 const int kWindowWidth = 300; | 2122 const int kWindowWidth = 300; |
| 2123 const int kWindowHeight = 400; | 2123 const int kWindowHeight = 400; |
| 2124 const int kTouchId1 = 3; | 2124 const int kTouchId1 = 3; |
| 2125 const int kTouchId2 = 5; | 2125 const int kTouchId2 = 5; |
| 2126 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); | 2126 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); |
| 2127 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2127 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2128 delegate.get(), -1234, bounds, root_window())); | 2128 delegate.get(), -1234, bounds, root_window())); |
| 2129 | 2129 |
| 2130 aura::RootWindow* root = dispatcher(); | |
| 2131 | |
| 2132 delegate->Reset(); | 2130 delegate->Reset(); |
| 2133 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), | 2131 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), |
| 2134 kTouchId1, tes.Now()); | 2132 kTouchId1, tes.Now()); |
| 2135 root->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 2133 DispatchEventUsingWindowDispatcher(&press); |
| 2136 EXPECT_2_EVENTS(delegate->events(), | 2134 EXPECT_2_EVENTS(delegate->events(), |
| 2137 ui::ET_GESTURE_BEGIN, | 2135 ui::ET_GESTURE_BEGIN, |
| 2138 ui::ET_GESTURE_TAP_DOWN); | 2136 ui::ET_GESTURE_TAP_DOWN); |
| 2139 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); | 2137 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
| 2140 | 2138 |
| 2141 // Press the second finger far enough to break two finger tap. | 2139 // Press the second finger far enough to break two finger tap. |
| 2142 delegate->Reset(); | 2140 delegate->Reset(); |
| 2143 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), | 2141 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), |
| 2144 kTouchId2, tes.Now()); | 2142 kTouchId2, tes.Now()); |
| 2145 root->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2); | 2143 DispatchEventUsingWindowDispatcher(&press2); |
| 2146 EXPECT_2_EVENTS(delegate->events(), | 2144 EXPECT_2_EVENTS(delegate->events(), |
| 2147 ui::ET_GESTURE_TAP_CANCEL, | 2145 ui::ET_GESTURE_TAP_CANCEL, |
| 2148 ui::ET_GESTURE_BEGIN); | 2146 ui::ET_GESTURE_BEGIN); |
| 2149 EXPECT_EQ(gfx::Rect(10, 10, 91, 291).ToString(), | 2147 EXPECT_EQ(gfx::Rect(10, 10, 91, 291).ToString(), |
| 2150 delegate->bounding_box().ToString()); | 2148 delegate->bounding_box().ToString()); |
| 2151 | 2149 |
| 2152 // Move the first finger. | 2150 // Move the first finger. |
| 2153 delegate->Reset(); | 2151 delegate->Reset(); |
| 2154 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(65, 201), | 2152 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(65, 201), |
| 2155 kTouchId1, tes.Now()); | 2153 kTouchId1, tes.Now()); |
| 2156 root->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move3); | 2154 DispatchEventUsingWindowDispatcher(&move3); |
| 2157 EXPECT_2_EVENTS(delegate->events(), | 2155 EXPECT_2_EVENTS(delegate->events(), |
| 2158 ui::ET_GESTURE_PINCH_BEGIN, | 2156 ui::ET_GESTURE_PINCH_BEGIN, |
| 2159 ui::ET_GESTURE_SCROLL_BEGIN); | 2157 ui::ET_GESTURE_SCROLL_BEGIN); |
| 2160 EXPECT_EQ(gfx::Rect(10, 10, 55, 191).ToString(), | 2158 EXPECT_EQ(gfx::Rect(10, 10, 55, 191).ToString(), |
| 2161 delegate->bounding_box().ToString()); | 2159 delegate->bounding_box().ToString()); |
| 2162 | 2160 |
| 2163 // Now move the second finger. | 2161 // Now move the second finger. |
| 2164 delegate->Reset(); | 2162 delegate->Reset(); |
| 2165 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(55, 15), | 2163 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(55, 15), |
| 2166 kTouchId2, tes.Now()); | 2164 kTouchId2, tes.Now()); |
| 2167 root->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move4); | 2165 DispatchEventUsingWindowDispatcher(&move4); |
| 2168 EXPECT_2_EVENTS(delegate->events(), | 2166 EXPECT_2_EVENTS(delegate->events(), |
| 2169 ui::ET_GESTURE_PINCH_UPDATE, | 2167 ui::ET_GESTURE_PINCH_UPDATE, |
| 2170 ui::ET_GESTURE_SCROLL_UPDATE); | 2168 ui::ET_GESTURE_SCROLL_UPDATE); |
| 2171 EXPECT_EQ(gfx::Rect(55, 15, 10, 186).ToString(), | 2169 EXPECT_EQ(gfx::Rect(55, 15, 10, 186).ToString(), |
| 2172 delegate->bounding_box().ToString()); | 2170 delegate->bounding_box().ToString()); |
| 2173 | 2171 |
| 2174 // Release the first finger. This should end pinch. | 2172 // Release the first finger. This should end pinch. |
| 2175 delegate->Reset(); | 2173 delegate->Reset(); |
| 2176 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 2174 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 2177 kTouchId1, tes.LeapForward(10)); | 2175 kTouchId1, tes.LeapForward(10)); |
| 2178 root->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 2176 DispatchEventUsingWindowDispatcher(&release); |
| 2179 EXPECT_2_EVENTS(delegate->events(), | 2177 EXPECT_2_EVENTS(delegate->events(), |
| 2180 ui::ET_GESTURE_PINCH_END, | 2178 ui::ET_GESTURE_PINCH_END, |
| 2181 ui::ET_GESTURE_END); | 2179 ui::ET_GESTURE_END); |
| 2182 EXPECT_EQ(gfx::Rect(55, 15, 46, 186).ToString(), | 2180 EXPECT_EQ(gfx::Rect(55, 15, 46, 186).ToString(), |
| 2183 delegate->bounding_box().ToString()); | 2181 delegate->bounding_box().ToString()); |
| 2184 | 2182 |
| 2185 // Move the second finger. This should still generate a scroll. | 2183 // Move the second finger. This should still generate a scroll. |
| 2186 delegate->Reset(); | 2184 delegate->Reset(); |
| 2187 ui::TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), | 2185 ui::TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), |
| 2188 kTouchId2, tes.Now()); | 2186 kTouchId2, tes.Now()); |
| 2189 root->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move5); | 2187 DispatchEventUsingWindowDispatcher(&move5); |
| 2190 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); | 2188 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); |
| 2191 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); | 2189 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
| 2192 } | 2190 } |
| 2193 | 2191 |
| 2194 TEST_F(GestureRecognizerTest, GestureEventIgnoresDisconnectedEvents) { | 2192 TEST_F(GestureRecognizerTest, GestureEventIgnoresDisconnectedEvents) { |
| 2195 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2193 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2196 new GestureEventConsumeDelegate()); | 2194 new GestureEventConsumeDelegate()); |
| 2197 TimedEvents tes; | 2195 TimedEvents tes; |
| 2198 | 2196 |
| 2199 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 2197 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 2200 6, tes.Now()); | 2198 6, tes.Now()); |
| 2201 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1); | 2199 DispatchEventUsingWindowDispatcher(&release1); |
| 2202 EXPECT_FALSE(delegate->tap()); | 2200 EXPECT_FALSE(delegate->tap()); |
| 2203 EXPECT_FALSE(delegate->tap_down()); | 2201 EXPECT_FALSE(delegate->tap_down()); |
| 2204 } | 2202 } |
| 2205 | 2203 |
| 2206 // Check that a touch is locked to the window of the closest current touch | 2204 // Check that a touch is locked to the window of the closest current touch |
| 2207 // within max_separation_for_gesture_touches_in_pixels | 2205 // within max_separation_for_gesture_touches_in_pixels |
| 2208 TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) { | 2206 TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) { |
| 2209 ui::GestureRecognizer* gesture_recognizer = new ui::GestureRecognizerImpl(); | 2207 ui::GestureRecognizer* gesture_recognizer = new ui::GestureRecognizerImpl(); |
| 2210 TimedEvents tes; | 2208 TimedEvents tes; |
| 2211 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); | 2209 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2229 | 2227 |
| 2230 // Instantiate windows with |window_bounds| and touch each window at | 2228 // Instantiate windows with |window_bounds| and touch each window at |
| 2231 // its origin. | 2229 // its origin. |
| 2232 for (int i = 0; i < kNumWindows; ++i) { | 2230 for (int i = 0; i < kNumWindows; ++i) { |
| 2233 delegates[i] = new GestureEventConsumeDelegate(); | 2231 delegates[i] = new GestureEventConsumeDelegate(); |
| 2234 windows[i] = CreateTestWindowWithDelegate( | 2232 windows[i] = CreateTestWindowWithDelegate( |
| 2235 delegates[i], i, window_bounds[i], root_window()); | 2233 delegates[i], i, window_bounds[i], root_window()); |
| 2236 windows[i]->set_id(i); | 2234 windows[i]->set_id(i); |
| 2237 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, window_bounds[i].origin(), | 2235 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, window_bounds[i].origin(), |
| 2238 i, tes.Now()); | 2236 i, tes.Now()); |
| 2239 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 2237 DispatchEventUsingWindowDispatcher(&press); |
| 2240 } | 2238 } |
| 2241 | 2239 |
| 2242 // Touches should now be associated with the closest touch within | 2240 // Touches should now be associated with the closest touch within |
| 2243 // ui::GestureConfiguration::max_separation_for_gesture_touches_in_pixels | 2241 // ui::GestureConfiguration::max_separation_for_gesture_touches_in_pixels |
| 2244 target = gesture_recognizer->GetTargetForLocation(gfx::Point(11, 11), -1); | 2242 target = gesture_recognizer->GetTargetForLocation(gfx::Point(11, 11), -1); |
| 2245 EXPECT_EQ("0", WindowIDAsString(target)); | 2243 EXPECT_EQ("0", WindowIDAsString(target)); |
| 2246 target = gesture_recognizer->GetTargetForLocation(gfx::Point(511, 11), -1); | 2244 target = gesture_recognizer->GetTargetForLocation(gfx::Point(511, 11), -1); |
| 2247 EXPECT_EQ("1", WindowIDAsString(target)); | 2245 EXPECT_EQ("1", WindowIDAsString(target)); |
| 2248 target = gesture_recognizer->GetTargetForLocation(gfx::Point(11, 511), -1); | 2246 target = gesture_recognizer->GetTargetForLocation(gfx::Point(11, 511), -1); |
| 2249 EXPECT_EQ("2", WindowIDAsString(target)); | 2247 EXPECT_EQ("2", WindowIDAsString(target)); |
| 2250 target = gesture_recognizer->GetTargetForLocation(gfx::Point(511, 511), -1); | 2248 target = gesture_recognizer->GetTargetForLocation(gfx::Point(511, 511), -1); |
| 2251 EXPECT_EQ("3", WindowIDAsString(target)); | 2249 EXPECT_EQ("3", WindowIDAsString(target)); |
| 2252 | 2250 |
| 2253 // Add a touch in the middle associated with windows[2] | 2251 // Add a touch in the middle associated with windows[2] |
| 2254 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 500), | 2252 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 500), |
| 2255 kNumWindows, tes.Now()); | 2253 kNumWindows, tes.Now()); |
| 2256 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 2254 DispatchEventUsingWindowDispatcher(&press); |
| 2257 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(250, 250), | 2255 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(250, 250), |
| 2258 kNumWindows, tes.Now()); | 2256 kNumWindows, tes.Now()); |
| 2259 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move); | 2257 DispatchEventUsingWindowDispatcher(&move); |
| 2260 | 2258 |
| 2261 target = gesture_recognizer->GetTargetForLocation(gfx::Point(250, 250), -1); | 2259 target = gesture_recognizer->GetTargetForLocation(gfx::Point(250, 250), -1); |
| 2262 EXPECT_EQ("2", WindowIDAsString(target)); | 2260 EXPECT_EQ("2", WindowIDAsString(target)); |
| 2263 | 2261 |
| 2264 // Make sure that ties are broken by distance to a current touch | 2262 // Make sure that ties are broken by distance to a current touch |
| 2265 // Closer to the point in the bottom right. | 2263 // Closer to the point in the bottom right. |
| 2266 target = gesture_recognizer->GetTargetForLocation(gfx::Point(380, 380), -1); | 2264 target = gesture_recognizer->GetTargetForLocation(gfx::Point(380, 380), -1); |
| 2267 EXPECT_EQ("3", WindowIDAsString(target)); | 2265 EXPECT_EQ("3", WindowIDAsString(target)); |
| 2268 | 2266 |
| 2269 // This touch is closer to the point in the middle | 2267 // This touch is closer to the point in the middle |
| 2270 target = gesture_recognizer->GetTargetForLocation(gfx::Point(300, 300), -1); | 2268 target = gesture_recognizer->GetTargetForLocation(gfx::Point(300, 300), -1); |
| 2271 EXPECT_EQ("2", WindowIDAsString(target)); | 2269 EXPECT_EQ("2", WindowIDAsString(target)); |
| 2272 | 2270 |
| 2273 // A touch too far from other touches won't be locked to anything | 2271 // A touch too far from other touches won't be locked to anything |
| 2274 target = gesture_recognizer->GetTargetForLocation(gfx::Point(1000, 1000), -1); | 2272 target = gesture_recognizer->GetTargetForLocation(gfx::Point(1000, 1000), -1); |
| 2275 EXPECT_TRUE(target == NULL); | 2273 EXPECT_TRUE(target == NULL); |
| 2276 | 2274 |
| 2277 // Move a touch associated with windows[2] to 1000, 1000 | 2275 // Move a touch associated with windows[2] to 1000, 1000 |
| 2278 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(1000, 1000), | 2276 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(1000, 1000), |
| 2279 kNumWindows, tes.Now()); | 2277 kNumWindows, tes.Now()); |
| 2280 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move2); | 2278 DispatchEventUsingWindowDispatcher(&move2); |
| 2281 | 2279 |
| 2282 target = gesture_recognizer->GetTargetForLocation(gfx::Point(1000, 1000), -1); | 2280 target = gesture_recognizer->GetTargetForLocation(gfx::Point(1000, 1000), -1); |
| 2283 EXPECT_EQ("2", WindowIDAsString(target)); | 2281 EXPECT_EQ("2", WindowIDAsString(target)); |
| 2284 | 2282 |
| 2285 for (int i = 0; i < kNumWindows; ++i) { | 2283 for (int i = 0; i < kNumWindows; ++i) { |
| 2286 // Delete windows before deleting delegates. | 2284 // Delete windows before deleting delegates. |
| 2287 delete windows[i]; | 2285 delete windows[i]; |
| 2288 delete delegates[i]; | 2286 delete delegates[i]; |
| 2289 } | 2287 } |
| 2290 } | 2288 } |
| 2291 | 2289 |
| 2292 // Check that a touch's target will not be effected by a touch on a different | 2290 // Check that a touch's target will not be effected by a touch on a different |
| 2293 // screen. | 2291 // screen. |
| 2294 TEST_F(GestureRecognizerTest, GestureEventTouchLockIgnoresOtherScreens) { | 2292 TEST_F(GestureRecognizerTest, GestureEventTouchLockIgnoresOtherScreens) { |
| 2295 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2293 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2296 new GestureEventConsumeDelegate()); | 2294 new GestureEventConsumeDelegate()); |
| 2297 gfx::Rect bounds(0, 0, 10, 10); | 2295 gfx::Rect bounds(0, 0, 10, 10); |
| 2298 scoped_ptr<aura::Window> window( | 2296 scoped_ptr<aura::Window> window( |
| 2299 CreateTestWindowWithDelegate(delegate.get(), 0, bounds, root_window())); | 2297 CreateTestWindowWithDelegate(delegate.get(), 0, bounds, root_window())); |
| 2300 | 2298 |
| 2301 const int kTouchId1 = 8; | 2299 const int kTouchId1 = 8; |
| 2302 const int kTouchId2 = 2; | 2300 const int kTouchId2 = 2; |
| 2303 TimedEvents tes; | 2301 TimedEvents tes; |
| 2304 | 2302 |
| 2305 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(5, 5), | 2303 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(5, 5), |
| 2306 kTouchId1, tes.Now()); | 2304 kTouchId1, tes.Now()); |
| 2307 press1.set_source_device_id(1); | 2305 press1.set_source_device_id(1); |
| 2308 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 2306 DispatchEventUsingWindowDispatcher(&press1); |
| 2309 | 2307 |
| 2310 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(20, 20), | 2308 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(20, 20), |
| 2311 kTouchId2, tes.Now()); | 2309 kTouchId2, tes.Now()); |
| 2312 press2.set_source_device_id(2); | 2310 press2.set_source_device_id(2); |
| 2313 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2); | 2311 DispatchEventUsingWindowDispatcher(&press2); |
| 2314 | 2312 |
| 2315 // The second press should not have been locked to the same target as the | 2313 // The second press should not have been locked to the same target as the |
| 2316 // first, as they occured on different displays. | 2314 // first, as they occured on different displays. |
| 2317 EXPECT_NE( | 2315 EXPECT_NE( |
| 2318 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press1), | 2316 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press1), |
| 2319 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press2)); | 2317 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press2)); |
| 2320 } | 2318 } |
| 2321 | 2319 |
| 2322 // Check that touch events outside the root window are still handled | 2320 // Check that touch events outside the root window are still handled |
| 2323 // by the root window's gesture sequence. | 2321 // by the root window's gesture sequence. |
| 2324 TEST_F(GestureRecognizerTest, GestureEventOutsideRootWindowTap) { | 2322 TEST_F(GestureRecognizerTest, GestureEventOutsideRootWindowTap) { |
| 2325 TestGestureRecognizer* gesture_recognizer = | 2323 TestGestureRecognizer* gesture_recognizer = |
| 2326 new TestGestureRecognizer(); | 2324 new TestGestureRecognizer(); |
| 2327 TimedEvents tes; | 2325 TimedEvents tes; |
| 2328 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); | 2326 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); |
| 2329 | 2327 |
| 2330 scoped_ptr<aura::Window> window(CreateTestWindowWithBounds( | 2328 scoped_ptr<aura::Window> window(CreateTestWindowWithBounds( |
| 2331 gfx::Rect(-100, -100, 2000, 2000), root_window())); | 2329 gfx::Rect(-100, -100, 2000, 2000), root_window())); |
| 2332 | 2330 |
| 2333 ui::GestureSequence* window_gesture_sequence = | 2331 ui::GestureSequence* window_gesture_sequence = |
| 2334 gesture_recognizer->GetGestureSequenceForTesting(window.get()); | 2332 gesture_recognizer->GetGestureSequenceForTesting(window.get()); |
| 2335 | 2333 |
| 2336 ui::GestureSequence* root_window_gesture_sequence = | 2334 ui::GestureSequence* root_window_gesture_sequence = |
| 2337 gesture_recognizer->GetGestureSequenceForTesting(root_window()); | 2335 gesture_recognizer->GetGestureSequenceForTesting(root_window()); |
| 2338 | 2336 |
| 2339 gfx::Point pos1(-10, -10); | 2337 gfx::Point pos1(-10, -10); |
| 2340 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, pos1, 0, tes.Now()); | 2338 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, pos1, 0, tes.Now()); |
| 2341 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 2339 DispatchEventUsingWindowDispatcher(&press1); |
| 2342 | 2340 |
| 2343 gfx::Point pos2(1000, 1000); | 2341 gfx::Point pos2(1000, 1000); |
| 2344 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, pos2, 1, tes.Now()); | 2342 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, pos2, 1, tes.Now()); |
| 2345 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2); | 2343 DispatchEventUsingWindowDispatcher(&press2); |
| 2346 | 2344 |
| 2347 // As these presses were outside the root window, they should be | 2345 // As these presses were outside the root window, they should be |
| 2348 // associated with the root window. | 2346 // associated with the root window. |
| 2349 EXPECT_EQ(0, window_gesture_sequence->point_count()); | 2347 EXPECT_EQ(0, window_gesture_sequence->point_count()); |
| 2350 EXPECT_EQ(2, root_window_gesture_sequence->point_count()); | 2348 EXPECT_EQ(2, root_window_gesture_sequence->point_count()); |
| 2351 } | 2349 } |
| 2352 | 2350 |
| 2353 TEST_F(GestureRecognizerTest, NoTapWithPreventDefaultedRelease) { | 2351 TEST_F(GestureRecognizerTest, NoTapWithPreventDefaultedRelease) { |
| 2354 scoped_ptr<QueueTouchEventDelegate> delegate( | 2352 scoped_ptr<QueueTouchEventDelegate> delegate( |
| 2355 new QueueTouchEventDelegate(dispatcher())); | 2353 new QueueTouchEventDelegate(dispatcher())); |
| 2356 TimedEvents tes; | 2354 TimedEvents tes; |
| 2357 const int kTouchId = 2; | 2355 const int kTouchId = 2; |
| 2358 gfx::Rect bounds(100, 200, 100, 100); | 2356 gfx::Rect bounds(100, 200, 100, 100); |
| 2359 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2357 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2360 delegate.get(), -1234, bounds, root_window())); | 2358 delegate.get(), -1234, bounds, root_window())); |
| 2361 delegate->set_window(window.get()); | 2359 delegate->set_window(window.get()); |
| 2362 | 2360 |
| 2363 delegate->Reset(); | 2361 delegate->Reset(); |
| 2364 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 2362 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 2365 kTouchId, tes.Now()); | 2363 kTouchId, tes.Now()); |
| 2366 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 2364 DispatchEventUsingWindowDispatcher(&press); |
| 2367 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 2365 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 2368 kTouchId, tes.LeapForward(50)); | 2366 kTouchId, tes.LeapForward(50)); |
| 2369 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 2367 DispatchEventUsingWindowDispatcher(&release); |
| 2370 | 2368 |
| 2371 delegate->Reset(); | 2369 delegate->Reset(); |
| 2372 delegate->ReceivedAck(); | 2370 delegate->ReceivedAck(); |
| 2373 EXPECT_TRUE(delegate->tap_down()); | 2371 EXPECT_TRUE(delegate->tap_down()); |
| 2374 delegate->Reset(); | 2372 delegate->Reset(); |
| 2375 delegate->ReceivedAckPreventDefaulted(); | 2373 delegate->ReceivedAckPreventDefaulted(); |
| 2376 EXPECT_FALSE(delegate->tap()); | 2374 EXPECT_FALSE(delegate->tap()); |
| 2377 EXPECT_TRUE(delegate->tap_cancel()); | 2375 EXPECT_TRUE(delegate->tap_cancel()); |
| 2378 } | 2376 } |
| 2379 | 2377 |
| 2380 TEST_F(GestureRecognizerTest, PinchScrollWithPreventDefaultedRelease) { | 2378 TEST_F(GestureRecognizerTest, PinchScrollWithPreventDefaultedRelease) { |
| 2381 scoped_ptr<QueueTouchEventDelegate> delegate( | 2379 scoped_ptr<QueueTouchEventDelegate> delegate( |
| 2382 new QueueTouchEventDelegate(dispatcher())); | 2380 new QueueTouchEventDelegate(dispatcher())); |
| 2383 TimedEvents tes; | 2381 TimedEvents tes; |
| 2384 const int kTouchId1 = 7; | 2382 const int kTouchId1 = 7; |
| 2385 const int kTouchId2 = 5; | 2383 const int kTouchId2 = 5; |
| 2386 gfx::Rect bounds(10, 20, 100, 100); | 2384 gfx::Rect bounds(10, 20, 100, 100); |
| 2387 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2385 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2388 delegate.get(), -1234, bounds, root_window())); | 2386 delegate.get(), -1234, bounds, root_window())); |
| 2389 delegate->set_window(window.get()); | 2387 delegate->set_window(window.get()); |
| 2390 | 2388 |
| 2391 { | 2389 { |
| 2392 delegate->Reset(); | 2390 delegate->Reset(); |
| 2393 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(15, 25), kTouchId1, | 2391 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(15, 25), kTouchId1, |
| 2394 tes.Now()); | 2392 tes.Now()); |
| 2395 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(20, 95), kTouchId1, | 2393 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(20, 95), kTouchId1, |
| 2396 tes.LeapForward(200)); | 2394 tes.LeapForward(200)); |
| 2397 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(15, 25), kTouchId1, | 2395 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(15, 25), kTouchId1, |
| 2398 tes.LeapForward(50)); | 2396 tes.LeapForward(50)); |
| 2399 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 2397 DispatchEventUsingWindowDispatcher(&press); |
| 2400 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move); | 2398 DispatchEventUsingWindowDispatcher(&move); |
| 2401 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 2399 DispatchEventUsingWindowDispatcher(&release); |
| 2402 delegate->Reset(); | 2400 delegate->Reset(); |
| 2403 | 2401 |
| 2404 // Ack the press event. | 2402 // Ack the press event. |
| 2405 delegate->ReceivedAck(); | 2403 delegate->ReceivedAck(); |
| 2406 EXPECT_TRUE(delegate->tap_down()); | 2404 EXPECT_TRUE(delegate->tap_down()); |
| 2407 delegate->Reset(); | 2405 delegate->Reset(); |
| 2408 | 2406 |
| 2409 // Ack the move event. | 2407 // Ack the move event. |
| 2410 delegate->ReceivedAck(); | 2408 delegate->ReceivedAck(); |
| 2411 EXPECT_TRUE(delegate->tap_cancel()); | 2409 EXPECT_TRUE(delegate->tap_cancel()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2425 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(15, 25), kTouchId1, | 2423 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(15, 25), kTouchId1, |
| 2426 tes.LeapForward(50)); | 2424 tes.LeapForward(50)); |
| 2427 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(55, 25), kTouchId2, | 2425 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(55, 25), kTouchId2, |
| 2428 tes.Now()); | 2426 tes.Now()); |
| 2429 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(45, 85), kTouchId2, | 2427 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(45, 85), kTouchId2, |
| 2430 tes.LeapForward(1000)); | 2428 tes.LeapForward(1000)); |
| 2431 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(45, 85), kTouchId2, | 2429 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(45, 85), kTouchId2, |
| 2432 tes.LeapForward(14)); | 2430 tes.LeapForward(14)); |
| 2433 | 2431 |
| 2434 // Do a pinch. | 2432 // Do a pinch. |
| 2435 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 2433 DispatchEventUsingWindowDispatcher(&press); |
| 2436 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move); | 2434 DispatchEventUsingWindowDispatcher(&move); |
| 2437 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2); | 2435 DispatchEventUsingWindowDispatcher(&press2); |
| 2438 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move2); | 2436 DispatchEventUsingWindowDispatcher(&move2); |
| 2439 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 2437 DispatchEventUsingWindowDispatcher(&release); |
| 2440 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release2); | 2438 DispatchEventUsingWindowDispatcher(&release2); |
| 2441 | 2439 |
| 2442 // Ack the press and move events. | 2440 // Ack the press and move events. |
| 2443 delegate->Reset(); | 2441 delegate->Reset(); |
| 2444 delegate->ReceivedAck(); | 2442 delegate->ReceivedAck(); |
| 2445 EXPECT_TRUE(delegate->begin()); | 2443 EXPECT_TRUE(delegate->begin()); |
| 2446 EXPECT_TRUE(delegate->tap_down()); | 2444 EXPECT_TRUE(delegate->tap_down()); |
| 2447 | 2445 |
| 2448 delegate->Reset(); | 2446 delegate->Reset(); |
| 2449 delegate->ReceivedAck(); | 2447 delegate->ReceivedAck(); |
| 2450 EXPECT_TRUE(delegate->scroll_begin()); | 2448 EXPECT_TRUE(delegate->scroll_begin()); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2577 TestGestureRecognizer* gesture_recognizer = | 2575 TestGestureRecognizer* gesture_recognizer = |
| 2578 new TestGestureRecognizer(); | 2576 new TestGestureRecognizer(); |
| 2579 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); | 2577 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); |
| 2580 TimedEvents tes; | 2578 TimedEvents tes; |
| 2581 | 2579 |
| 2582 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2580 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2583 delegate.get(), -1234, gfx::Rect(10, 10, 300, 300), root_window())); | 2581 delegate.get(), -1234, gfx::Rect(10, 10, 300, 300), root_window())); |
| 2584 | 2582 |
| 2585 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(45, 45), 7, tes.Now()); | 2583 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(45, 45), 7, tes.Now()); |
| 2586 press.set_radius_x(40); | 2584 press.set_radius_x(40); |
| 2587 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 2585 DispatchEventUsingWindowDispatcher(&press); |
| 2588 EXPECT_TRUE(delegate->tap_down()); | 2586 EXPECT_TRUE(delegate->tap_down()); |
| 2589 EXPECT_EQ(gfx::Rect(5, 5, 80, 80).ToString(), | 2587 EXPECT_EQ(gfx::Rect(5, 5, 80, 80).ToString(), |
| 2590 delegate->bounding_box().ToString()); | 2588 delegate->bounding_box().ToString()); |
| 2591 delegate->Reset(); | 2589 delegate->Reset(); |
| 2592 | 2590 |
| 2593 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(55, 45), 7, tes.Now()); | 2591 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(55, 45), 7, tes.Now()); |
| 2594 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2); | 2592 DispatchEventUsingWindowDispatcher(&press2); |
| 2595 | 2593 |
| 2596 // This new press should not generate a tap-down. | 2594 // This new press should not generate a tap-down. |
| 2597 EXPECT_FALSE(delegate->begin()); | 2595 EXPECT_FALSE(delegate->begin()); |
| 2598 EXPECT_FALSE(delegate->tap_down()); | 2596 EXPECT_FALSE(delegate->tap_down()); |
| 2599 EXPECT_FALSE(delegate->tap_cancel()); | 2597 EXPECT_FALSE(delegate->tap_cancel()); |
| 2600 EXPECT_FALSE(delegate->scroll_begin()); | 2598 EXPECT_FALSE(delegate->scroll_begin()); |
| 2601 } | 2599 } |
| 2602 | 2600 |
| 2603 TEST_F(GestureRecognizerTest, TwoFingerTap) { | 2601 TEST_F(GestureRecognizerTest, TwoFingerTap) { |
| 2604 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2602 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2605 new GestureEventConsumeDelegate()); | 2603 new GestureEventConsumeDelegate()); |
| 2606 const int kWindowWidth = 123; | 2604 const int kWindowWidth = 123; |
| 2607 const int kWindowHeight = 45; | 2605 const int kWindowHeight = 45; |
| 2608 const int kTouchId1 = 2; | 2606 const int kTouchId1 = 2; |
| 2609 const int kTouchId2 = 3; | 2607 const int kTouchId2 = 3; |
| 2610 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 2608 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 2611 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2609 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2612 delegate.get(), -1234, bounds, root_window())); | 2610 delegate.get(), -1234, bounds, root_window())); |
| 2613 TimedEvents tes; | 2611 TimedEvents tes; |
| 2614 | 2612 |
| 2615 delegate->Reset(); | 2613 delegate->Reset(); |
| 2616 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 2614 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 2617 kTouchId1, tes.Now()); | 2615 kTouchId1, tes.Now()); |
| 2618 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 2616 DispatchEventUsingWindowDispatcher(&press1); |
| 2619 EXPECT_FALSE(delegate->tap()); | 2617 EXPECT_FALSE(delegate->tap()); |
| 2620 EXPECT_TRUE(delegate->tap_down()); | 2618 EXPECT_TRUE(delegate->tap_down()); |
| 2621 EXPECT_FALSE(delegate->tap_cancel()); | 2619 EXPECT_FALSE(delegate->tap_cancel()); |
| 2622 EXPECT_FALSE(delegate->scroll_begin()); | 2620 EXPECT_FALSE(delegate->scroll_begin()); |
| 2623 EXPECT_FALSE(delegate->scroll_update()); | 2621 EXPECT_FALSE(delegate->scroll_update()); |
| 2624 EXPECT_FALSE(delegate->scroll_end()); | 2622 EXPECT_FALSE(delegate->scroll_end()); |
| 2625 EXPECT_FALSE(delegate->long_press()); | 2623 EXPECT_FALSE(delegate->long_press()); |
| 2626 EXPECT_FALSE(delegate->two_finger_tap()); | 2624 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2627 | 2625 |
| 2628 delegate->Reset(); | 2626 delegate->Reset(); |
| 2629 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), | 2627 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), |
| 2630 kTouchId2, tes.Now()); | 2628 kTouchId2, tes.Now()); |
| 2631 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2); | 2629 DispatchEventUsingWindowDispatcher(&press2); |
| 2632 EXPECT_FALSE(delegate->tap()); | 2630 EXPECT_FALSE(delegate->tap()); |
| 2633 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap. | 2631 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap. |
| 2634 EXPECT_TRUE(delegate->tap_cancel()); | 2632 EXPECT_TRUE(delegate->tap_cancel()); |
| 2635 EXPECT_FALSE(delegate->scroll_begin()); | 2633 EXPECT_FALSE(delegate->scroll_begin()); |
| 2636 EXPECT_FALSE(delegate->scroll_update()); | 2634 EXPECT_FALSE(delegate->scroll_update()); |
| 2637 EXPECT_FALSE(delegate->scroll_end()); | 2635 EXPECT_FALSE(delegate->scroll_end()); |
| 2638 EXPECT_FALSE(delegate->long_press()); | 2636 EXPECT_FALSE(delegate->long_press()); |
| 2639 EXPECT_FALSE(delegate->two_finger_tap()); | 2637 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2640 | 2638 |
| 2641 // Little bit of touch move should not affect our state. | 2639 // Little bit of touch move should not affect our state. |
| 2642 delegate->Reset(); | 2640 delegate->Reset(); |
| 2643 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(102, 202), | 2641 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(102, 202), |
| 2644 kTouchId1, tes.Now()); | 2642 kTouchId1, tes.Now()); |
| 2645 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move1); | 2643 DispatchEventUsingWindowDispatcher(&move1); |
| 2646 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(131, 202), | 2644 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(131, 202), |
| 2647 kTouchId2, tes.Now()); | 2645 kTouchId2, tes.Now()); |
| 2648 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move2); | 2646 DispatchEventUsingWindowDispatcher(&move2); |
| 2649 EXPECT_FALSE(delegate->tap()); | 2647 EXPECT_FALSE(delegate->tap()); |
| 2650 EXPECT_FALSE(delegate->tap_down()); | 2648 EXPECT_FALSE(delegate->tap_down()); |
| 2651 EXPECT_FALSE(delegate->tap_cancel()); | 2649 EXPECT_FALSE(delegate->tap_cancel()); |
| 2652 EXPECT_FALSE(delegate->scroll_begin()); | 2650 EXPECT_FALSE(delegate->scroll_begin()); |
| 2653 EXPECT_FALSE(delegate->scroll_update()); | 2651 EXPECT_FALSE(delegate->scroll_update()); |
| 2654 EXPECT_FALSE(delegate->scroll_end()); | 2652 EXPECT_FALSE(delegate->scroll_end()); |
| 2655 EXPECT_FALSE(delegate->long_press()); | 2653 EXPECT_FALSE(delegate->long_press()); |
| 2656 EXPECT_FALSE(delegate->two_finger_tap()); | 2654 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2657 | 2655 |
| 2658 // Make sure there is enough delay before the touch is released so that it is | 2656 // Make sure there is enough delay before the touch is released so that it is |
| 2659 // recognized as a tap. | 2657 // recognized as a tap. |
| 2660 delegate->Reset(); | 2658 delegate->Reset(); |
| 2661 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 2659 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 2662 kTouchId1, tes.LeapForward(50)); | 2660 kTouchId1, tes.LeapForward(50)); |
| 2663 | 2661 |
| 2664 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1); | 2662 DispatchEventUsingWindowDispatcher(&release1); |
| 2665 EXPECT_FALSE(delegate->tap()); | 2663 EXPECT_FALSE(delegate->tap()); |
| 2666 EXPECT_FALSE(delegate->tap_down()); | 2664 EXPECT_FALSE(delegate->tap_down()); |
| 2667 EXPECT_FALSE(delegate->tap_cancel()); | 2665 EXPECT_FALSE(delegate->tap_cancel()); |
| 2668 EXPECT_FALSE(delegate->scroll_begin()); | 2666 EXPECT_FALSE(delegate->scroll_begin()); |
| 2669 EXPECT_FALSE(delegate->scroll_update()); | 2667 EXPECT_FALSE(delegate->scroll_update()); |
| 2670 EXPECT_FALSE(delegate->scroll_end()); | 2668 EXPECT_FALSE(delegate->scroll_end()); |
| 2671 EXPECT_TRUE(delegate->two_finger_tap()); | 2669 EXPECT_TRUE(delegate->two_finger_tap()); |
| 2672 | 2670 |
| 2673 // Lift second finger. | 2671 // Lift second finger. |
| 2674 // Make sure there is enough delay before the touch is released so that it is | 2672 // Make sure there is enough delay before the touch is released so that it is |
| 2675 // recognized as a tap. | 2673 // recognized as a tap. |
| 2676 delegate->Reset(); | 2674 delegate->Reset(); |
| 2677 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(130, 201), | 2675 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(130, 201), |
| 2678 kTouchId2, tes.LeapForward(50)); | 2676 kTouchId2, tes.LeapForward(50)); |
| 2679 | 2677 |
| 2680 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release2); | 2678 DispatchEventUsingWindowDispatcher(&release2); |
| 2681 EXPECT_FALSE(delegate->tap()); | 2679 EXPECT_FALSE(delegate->tap()); |
| 2682 EXPECT_FALSE(delegate->tap_down()); | 2680 EXPECT_FALSE(delegate->tap_down()); |
| 2683 EXPECT_FALSE(delegate->tap_cancel()); | 2681 EXPECT_FALSE(delegate->tap_cancel()); |
| 2684 EXPECT_FALSE(delegate->scroll_begin()); | 2682 EXPECT_FALSE(delegate->scroll_begin()); |
| 2685 EXPECT_FALSE(delegate->scroll_update()); | 2683 EXPECT_FALSE(delegate->scroll_update()); |
| 2686 EXPECT_FALSE(delegate->scroll_end()); | 2684 EXPECT_FALSE(delegate->scroll_end()); |
| 2687 EXPECT_TRUE(delegate->fling()); | 2685 EXPECT_TRUE(delegate->fling()); |
| 2688 EXPECT_FALSE(delegate->two_finger_tap()); | 2686 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2689 } | 2687 } |
| 2690 | 2688 |
| 2691 TEST_F(GestureRecognizerTest, TwoFingerTapExpired) { | 2689 TEST_F(GestureRecognizerTest, TwoFingerTapExpired) { |
| 2692 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2690 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2693 new GestureEventConsumeDelegate()); | 2691 new GestureEventConsumeDelegate()); |
| 2694 const int kWindowWidth = 123; | 2692 const int kWindowWidth = 123; |
| 2695 const int kWindowHeight = 45; | 2693 const int kWindowHeight = 45; |
| 2696 const int kTouchId1 = 2; | 2694 const int kTouchId1 = 2; |
| 2697 const int kTouchId2 = 3; | 2695 const int kTouchId2 = 3; |
| 2698 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 2696 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 2699 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2697 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2700 delegate.get(), -1234, bounds, root_window())); | 2698 delegate.get(), -1234, bounds, root_window())); |
| 2701 TimedEvents tes; | 2699 TimedEvents tes; |
| 2702 | 2700 |
| 2703 delegate->Reset(); | 2701 delegate->Reset(); |
| 2704 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 2702 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 2705 kTouchId1, tes.Now()); | 2703 kTouchId1, tes.Now()); |
| 2706 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 2704 DispatchEventUsingWindowDispatcher(&press1); |
| 2707 | 2705 |
| 2708 delegate->Reset(); | 2706 delegate->Reset(); |
| 2709 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), | 2707 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), |
| 2710 kTouchId2, tes.Now()); | 2708 kTouchId2, tes.Now()); |
| 2711 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2); | 2709 DispatchEventUsingWindowDispatcher(&press2); |
| 2712 | 2710 |
| 2713 // Send release event after sufficient delay so that two finger time expires. | 2711 // Send release event after sufficient delay so that two finger time expires. |
| 2714 delegate->Reset(); | 2712 delegate->Reset(); |
| 2715 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 2713 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 2716 kTouchId1, tes.LeapForward(1000)); | 2714 kTouchId1, tes.LeapForward(1000)); |
| 2717 | 2715 |
| 2718 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1); | 2716 DispatchEventUsingWindowDispatcher(&release1); |
| 2719 EXPECT_FALSE(delegate->two_finger_tap()); | 2717 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2720 | 2718 |
| 2721 // Lift second finger. | 2719 // Lift second finger. |
| 2722 // Make sure there is enough delay before the touch is released so that it is | 2720 // Make sure there is enough delay before the touch is released so that it is |
| 2723 // recognized as a tap. | 2721 // recognized as a tap. |
| 2724 delegate->Reset(); | 2722 delegate->Reset(); |
| 2725 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(130, 201), | 2723 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(130, 201), |
| 2726 kTouchId2, tes.LeapForward(50)); | 2724 kTouchId2, tes.LeapForward(50)); |
| 2727 | 2725 |
| 2728 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release2); | 2726 DispatchEventUsingWindowDispatcher(&release2); |
| 2729 EXPECT_FALSE(delegate->two_finger_tap()); | 2727 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2730 } | 2728 } |
| 2731 | 2729 |
| 2732 TEST_F(GestureRecognizerTest, TwoFingerTapChangesToPinch) { | 2730 TEST_F(GestureRecognizerTest, TwoFingerTapChangesToPinch) { |
| 2733 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2731 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2734 new GestureEventConsumeDelegate()); | 2732 new GestureEventConsumeDelegate()); |
| 2735 const int kWindowWidth = 123; | 2733 const int kWindowWidth = 123; |
| 2736 const int kWindowHeight = 45; | 2734 const int kWindowHeight = 45; |
| 2737 const int kTouchId1 = 2; | 2735 const int kTouchId1 = 2; |
| 2738 const int kTouchId2 = 3; | 2736 const int kTouchId2 = 3; |
| 2739 TimedEvents tes; | 2737 TimedEvents tes; |
| 2740 | 2738 |
| 2741 // Test moving first finger | 2739 // Test moving first finger |
| 2742 { | 2740 { |
| 2743 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 2741 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 2744 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2742 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2745 delegate.get(), -1234, bounds, root_window())); | 2743 delegate.get(), -1234, bounds, root_window())); |
| 2746 | 2744 |
| 2747 delegate->Reset(); | 2745 delegate->Reset(); |
| 2748 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 2746 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 2749 kTouchId1, tes.Now()); | 2747 kTouchId1, tes.Now()); |
| 2750 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 2748 DispatchEventUsingWindowDispatcher(&press1); |
| 2751 | 2749 |
| 2752 delegate->Reset(); | 2750 delegate->Reset(); |
| 2753 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), | 2751 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), |
| 2754 kTouchId2, tes.Now()); | 2752 kTouchId2, tes.Now()); |
| 2755 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2); | 2753 DispatchEventUsingWindowDispatcher(&press2); |
| 2756 | 2754 |
| 2757 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId1, delegate.get()); | 2755 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId1, delegate.get()); |
| 2758 EXPECT_FALSE(delegate->two_finger_tap()); | 2756 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2759 EXPECT_TRUE(delegate->pinch_begin()); | 2757 EXPECT_TRUE(delegate->pinch_begin()); |
| 2760 | 2758 |
| 2761 // Make sure there is enough delay before the touch is released so that it | 2759 // Make sure there is enough delay before the touch is released so that it |
| 2762 // is recognized as a tap. | 2760 // is recognized as a tap. |
| 2763 delegate->Reset(); | 2761 delegate->Reset(); |
| 2764 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 2762 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 2765 kTouchId2, tes.LeapForward(50)); | 2763 kTouchId2, tes.LeapForward(50)); |
| 2766 | 2764 |
| 2767 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 2765 DispatchEventUsingWindowDispatcher(&release); |
| 2768 EXPECT_FALSE(delegate->two_finger_tap()); | 2766 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2769 EXPECT_TRUE(delegate->pinch_end()); | 2767 EXPECT_TRUE(delegate->pinch_end()); |
| 2770 } | 2768 } |
| 2771 | 2769 |
| 2772 // Test moving second finger | 2770 // Test moving second finger |
| 2773 { | 2771 { |
| 2774 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 2772 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 2775 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2773 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2776 delegate.get(), -1234, bounds, root_window())); | 2774 delegate.get(), -1234, bounds, root_window())); |
| 2777 | 2775 |
| 2778 delegate->Reset(); | 2776 delegate->Reset(); |
| 2779 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 2777 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 2780 kTouchId1, tes.Now()); | 2778 kTouchId1, tes.Now()); |
| 2781 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 2779 DispatchEventUsingWindowDispatcher(&press1); |
| 2782 | 2780 |
| 2783 delegate->Reset(); | 2781 delegate->Reset(); |
| 2784 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), | 2782 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), |
| 2785 kTouchId2, tes.Now()); | 2783 kTouchId2, tes.Now()); |
| 2786 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2); | 2784 DispatchEventUsingWindowDispatcher(&press2); |
| 2787 | 2785 |
| 2788 tes.SendScrollEvent(dispatcher(), 101, 230, kTouchId2, delegate.get()); | 2786 tes.SendScrollEvent(dispatcher(), 101, 230, kTouchId2, delegate.get()); |
| 2789 EXPECT_FALSE(delegate->two_finger_tap()); | 2787 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2790 EXPECT_TRUE(delegate->pinch_begin()); | 2788 EXPECT_TRUE(delegate->pinch_begin()); |
| 2791 | 2789 |
| 2792 // Make sure there is enough delay before the touch is released so that it | 2790 // Make sure there is enough delay before the touch is released so that it |
| 2793 // is recognized as a tap. | 2791 // is recognized as a tap. |
| 2794 delegate->Reset(); | 2792 delegate->Reset(); |
| 2795 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 2793 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 2796 kTouchId1, tes.LeapForward(50)); | 2794 kTouchId1, tes.LeapForward(50)); |
| 2797 | 2795 |
| 2798 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 2796 DispatchEventUsingWindowDispatcher(&release); |
| 2799 EXPECT_FALSE(delegate->two_finger_tap()); | 2797 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2800 EXPECT_TRUE(delegate->pinch_end()); | 2798 EXPECT_TRUE(delegate->pinch_end()); |
| 2801 } | 2799 } |
| 2802 } | 2800 } |
| 2803 | 2801 |
| 2804 TEST_F(GestureRecognizerTest, NoTwoFingerTapWhenFirstFingerHasScrolled) { | 2802 TEST_F(GestureRecognizerTest, NoTwoFingerTapWhenFirstFingerHasScrolled) { |
| 2805 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2803 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2806 new GestureEventConsumeDelegate()); | 2804 new GestureEventConsumeDelegate()); |
| 2807 const int kWindowWidth = 123; | 2805 const int kWindowWidth = 123; |
| 2808 const int kWindowHeight = 45; | 2806 const int kWindowHeight = 45; |
| 2809 const int kTouchId1 = 2; | 2807 const int kTouchId1 = 2; |
| 2810 const int kTouchId2 = 3; | 2808 const int kTouchId2 = 3; |
| 2811 TimedEvents tes; | 2809 TimedEvents tes; |
| 2812 | 2810 |
| 2813 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 2811 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 2814 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2812 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2815 delegate.get(), -1234, bounds, root_window())); | 2813 delegate.get(), -1234, bounds, root_window())); |
| 2816 | 2814 |
| 2817 delegate->Reset(); | 2815 delegate->Reset(); |
| 2818 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 2816 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 2819 kTouchId1, tes.Now()); | 2817 kTouchId1, tes.Now()); |
| 2820 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 2818 DispatchEventUsingWindowDispatcher(&press1); |
| 2821 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId1, delegate.get()); | 2819 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId1, delegate.get()); |
| 2822 | 2820 |
| 2823 delegate->Reset(); | 2821 delegate->Reset(); |
| 2824 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), | 2822 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), |
| 2825 kTouchId2, tes.Now()); | 2823 kTouchId2, tes.Now()); |
| 2826 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2); | 2824 DispatchEventUsingWindowDispatcher(&press2); |
| 2827 | 2825 |
| 2828 EXPECT_TRUE(delegate->pinch_begin()); | 2826 EXPECT_TRUE(delegate->pinch_begin()); |
| 2829 | 2827 |
| 2830 // Make sure there is enough delay before the touch is released so that it | 2828 // Make sure there is enough delay before the touch is released so that it |
| 2831 // is recognized as a tap. | 2829 // is recognized as a tap. |
| 2832 delegate->Reset(); | 2830 delegate->Reset(); |
| 2833 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 2831 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 2834 kTouchId2, tes.LeapForward(50)); | 2832 kTouchId2, tes.LeapForward(50)); |
| 2835 | 2833 |
| 2836 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 2834 DispatchEventUsingWindowDispatcher(&release); |
| 2837 EXPECT_FALSE(delegate->two_finger_tap()); | 2835 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2838 EXPECT_TRUE(delegate->pinch_end()); | 2836 EXPECT_TRUE(delegate->pinch_end()); |
| 2839 } | 2837 } |
| 2840 | 2838 |
| 2841 TEST_F(GestureRecognizerTest, MultiFingerSwipe) { | 2839 TEST_F(GestureRecognizerTest, MultiFingerSwipe) { |
| 2842 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2840 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2843 new GestureEventConsumeDelegate()); | 2841 new GestureEventConsumeDelegate()); |
| 2844 const int kWindowWidth = 123; | 2842 const int kWindowWidth = 123; |
| 2845 const int kWindowHeight = 45; | 2843 const int kWindowHeight = 45; |
| 2846 | 2844 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2889 | 2887 |
| 2890 // Test canceling first finger. | 2888 // Test canceling first finger. |
| 2891 { | 2889 { |
| 2892 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 2890 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 2893 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2891 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2894 delegate.get(), -1234, bounds, root_window())); | 2892 delegate.get(), -1234, bounds, root_window())); |
| 2895 | 2893 |
| 2896 delegate->Reset(); | 2894 delegate->Reset(); |
| 2897 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 2895 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 2898 kTouchId1, tes.Now()); | 2896 kTouchId1, tes.Now()); |
| 2899 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 2897 DispatchEventUsingWindowDispatcher(&press1); |
| 2900 | 2898 |
| 2901 delegate->Reset(); | 2899 delegate->Reset(); |
| 2902 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), | 2900 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), |
| 2903 kTouchId2, tes.Now()); | 2901 kTouchId2, tes.Now()); |
| 2904 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2); | 2902 DispatchEventUsingWindowDispatcher(&press2); |
| 2905 | 2903 |
| 2906 delegate->Reset(); | 2904 delegate->Reset(); |
| 2907 ui::TouchEvent cancel(ui::ET_TOUCH_CANCELLED, gfx::Point(130, 201), | 2905 ui::TouchEvent cancel(ui::ET_TOUCH_CANCELLED, gfx::Point(130, 201), |
| 2908 kTouchId1, tes.Now()); | 2906 kTouchId1, tes.Now()); |
| 2909 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&cancel); | 2907 DispatchEventUsingWindowDispatcher(&cancel); |
| 2910 EXPECT_FALSE(delegate->two_finger_tap()); | 2908 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2911 | 2909 |
| 2912 // Make sure there is enough delay before the touch is released so that it | 2910 // Make sure there is enough delay before the touch is released so that it |
| 2913 // is recognized as a tap. | 2911 // is recognized as a tap. |
| 2914 delegate->Reset(); | 2912 delegate->Reset(); |
| 2915 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 2913 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 2916 kTouchId2, tes.LeapForward(50)); | 2914 kTouchId2, tes.LeapForward(50)); |
| 2917 | 2915 |
| 2918 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 2916 DispatchEventUsingWindowDispatcher(&release); |
| 2919 EXPECT_FALSE(delegate->two_finger_tap()); | 2917 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2920 } | 2918 } |
| 2921 | 2919 |
| 2922 // Test canceling second finger | 2920 // Test canceling second finger |
| 2923 { | 2921 { |
| 2924 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 2922 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 2925 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2923 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2926 delegate.get(), -1234, bounds, root_window())); | 2924 delegate.get(), -1234, bounds, root_window())); |
| 2927 | 2925 |
| 2928 delegate->Reset(); | 2926 delegate->Reset(); |
| 2929 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 2927 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 2930 kTouchId1, tes.Now()); | 2928 kTouchId1, tes.Now()); |
| 2931 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 2929 DispatchEventUsingWindowDispatcher(&press1); |
| 2932 | 2930 |
| 2933 delegate->Reset(); | 2931 delegate->Reset(); |
| 2934 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), | 2932 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), |
| 2935 kTouchId2, tes.Now()); | 2933 kTouchId2, tes.Now()); |
| 2936 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2); | 2934 DispatchEventUsingWindowDispatcher(&press2); |
| 2937 | 2935 |
| 2938 delegate->Reset(); | 2936 delegate->Reset(); |
| 2939 ui::TouchEvent cancel(ui::ET_TOUCH_CANCELLED, gfx::Point(130, 201), | 2937 ui::TouchEvent cancel(ui::ET_TOUCH_CANCELLED, gfx::Point(130, 201), |
| 2940 kTouchId2, tes.Now()); | 2938 kTouchId2, tes.Now()); |
| 2941 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&cancel); | 2939 DispatchEventUsingWindowDispatcher(&cancel); |
| 2942 EXPECT_FALSE(delegate->two_finger_tap()); | 2940 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2943 | 2941 |
| 2944 // Make sure there is enough delay before the touch is released so that it | 2942 // Make sure there is enough delay before the touch is released so that it |
| 2945 // is recognized as a tap. | 2943 // is recognized as a tap. |
| 2946 delegate->Reset(); | 2944 delegate->Reset(); |
| 2947 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 2945 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 2948 kTouchId1, tes.LeapForward(50)); | 2946 kTouchId1, tes.LeapForward(50)); |
| 2949 | 2947 |
| 2950 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 2948 DispatchEventUsingWindowDispatcher(&release); |
| 2951 EXPECT_FALSE(delegate->two_finger_tap()); | 2949 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2952 } | 2950 } |
| 2953 } | 2951 } |
| 2954 | 2952 |
| 2955 TEST_F(GestureRecognizerTest, VeryWideTwoFingerTouchDownShouldBeAPinch) { | 2953 TEST_F(GestureRecognizerTest, VeryWideTwoFingerTouchDownShouldBeAPinch) { |
| 2956 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2954 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2957 new GestureEventConsumeDelegate()); | 2955 new GestureEventConsumeDelegate()); |
| 2958 const int kWindowWidth = 523; | 2956 const int kWindowWidth = 523; |
| 2959 const int kWindowHeight = 45; | 2957 const int kWindowHeight = 45; |
| 2960 const int kTouchId1 = 2; | 2958 const int kTouchId1 = 2; |
| 2961 const int kTouchId2 = 3; | 2959 const int kTouchId2 = 3; |
| 2962 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 2960 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 2963 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2961 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2964 delegate.get(), -1234, bounds, root_window())); | 2962 delegate.get(), -1234, bounds, root_window())); |
| 2965 TimedEvents tes; | 2963 TimedEvents tes; |
| 2966 | 2964 |
| 2967 delegate->Reset(); | 2965 delegate->Reset(); |
| 2968 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 2966 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 2969 kTouchId1, tes.Now()); | 2967 kTouchId1, tes.Now()); |
| 2970 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 2968 DispatchEventUsingWindowDispatcher(&press1); |
| 2971 EXPECT_FALSE(delegate->tap()); | 2969 EXPECT_FALSE(delegate->tap()); |
| 2972 EXPECT_TRUE(delegate->tap_down()); | 2970 EXPECT_TRUE(delegate->tap_down()); |
| 2973 EXPECT_FALSE(delegate->tap_cancel()); | 2971 EXPECT_FALSE(delegate->tap_cancel()); |
| 2974 EXPECT_FALSE(delegate->scroll_begin()); | 2972 EXPECT_FALSE(delegate->scroll_begin()); |
| 2975 EXPECT_FALSE(delegate->scroll_update()); | 2973 EXPECT_FALSE(delegate->scroll_update()); |
| 2976 EXPECT_FALSE(delegate->scroll_end()); | 2974 EXPECT_FALSE(delegate->scroll_end()); |
| 2977 EXPECT_FALSE(delegate->long_press()); | 2975 EXPECT_FALSE(delegate->long_press()); |
| 2978 EXPECT_FALSE(delegate->two_finger_tap()); | 2976 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2979 | 2977 |
| 2980 delegate->Reset(); | 2978 delegate->Reset(); |
| 2981 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(430, 201), | 2979 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(430, 201), |
| 2982 kTouchId2, tes.Now()); | 2980 kTouchId2, tes.Now()); |
| 2983 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2); | 2981 DispatchEventUsingWindowDispatcher(&press2); |
| 2984 EXPECT_FALSE(delegate->tap()); | 2982 EXPECT_FALSE(delegate->tap()); |
| 2985 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap. | 2983 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap. |
| 2986 EXPECT_TRUE(delegate->tap_cancel()); | 2984 EXPECT_TRUE(delegate->tap_cancel()); |
| 2987 EXPECT_FALSE(delegate->scroll_begin()); | 2985 EXPECT_FALSE(delegate->scroll_begin()); |
| 2988 EXPECT_FALSE(delegate->scroll_update()); | 2986 EXPECT_FALSE(delegate->scroll_update()); |
| 2989 EXPECT_FALSE(delegate->scroll_end()); | 2987 EXPECT_FALSE(delegate->scroll_end()); |
| 2990 EXPECT_FALSE(delegate->long_press()); | 2988 EXPECT_FALSE(delegate->long_press()); |
| 2991 EXPECT_FALSE(delegate->two_finger_tap()); | 2989 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2992 EXPECT_FALSE(delegate->pinch_begin()); | 2990 EXPECT_FALSE(delegate->pinch_begin()); |
| 2993 | 2991 |
| 2994 delegate->Reset(); | 2992 delegate->Reset(); |
| 2995 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(530, 301), | 2993 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(530, 301), |
| 2996 kTouchId2, tes.Now()); | 2994 kTouchId2, tes.Now()); |
| 2997 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move2); | 2995 DispatchEventUsingWindowDispatcher(&move2); |
| 2998 EXPECT_FALSE(delegate->tap()); | 2996 EXPECT_FALSE(delegate->tap()); |
| 2999 EXPECT_FALSE(delegate->tap_down()); | 2997 EXPECT_FALSE(delegate->tap_down()); |
| 3000 EXPECT_FALSE(delegate->tap_cancel()); | 2998 EXPECT_FALSE(delegate->tap_cancel()); |
| 3001 // Pinch & Scroll only when there is enough movement. | 2999 // Pinch & Scroll only when there is enough movement. |
| 3002 EXPECT_TRUE(delegate->scroll_begin()); | 3000 EXPECT_TRUE(delegate->scroll_begin()); |
| 3003 EXPECT_FALSE(delegate->scroll_update()); | 3001 EXPECT_FALSE(delegate->scroll_update()); |
| 3004 EXPECT_FALSE(delegate->scroll_end()); | 3002 EXPECT_FALSE(delegate->scroll_end()); |
| 3005 EXPECT_FALSE(delegate->long_press()); | 3003 EXPECT_FALSE(delegate->long_press()); |
| 3006 EXPECT_FALSE(delegate->two_finger_tap()); | 3004 EXPECT_FALSE(delegate->two_finger_tap()); |
| 3007 EXPECT_TRUE(delegate->pinch_begin()); | 3005 EXPECT_TRUE(delegate->pinch_begin()); |
| 3008 } | 3006 } |
| 3009 | 3007 |
| 3010 // Verifies if a window is the target of multiple touch-ids and we hide the | 3008 // Verifies if a window is the target of multiple touch-ids and we hide the |
| 3011 // window everything is cleaned up correctly. | 3009 // window everything is cleaned up correctly. |
| 3012 TEST_F(GestureRecognizerTest, FlushAllOnHide) { | 3010 TEST_F(GestureRecognizerTest, FlushAllOnHide) { |
| 3013 scoped_ptr<GestureEventConsumeDelegate> delegate( | 3011 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 3014 new GestureEventConsumeDelegate()); | 3012 new GestureEventConsumeDelegate()); |
| 3015 gfx::Rect bounds(0, 0, 200, 200); | 3013 gfx::Rect bounds(0, 0, 200, 200); |
| 3016 scoped_ptr<aura::Window> window( | 3014 scoped_ptr<aura::Window> window( |
| 3017 CreateTestWindowWithDelegate(delegate.get(), 0, bounds, root_window())); | 3015 CreateTestWindowWithDelegate(delegate.get(), 0, bounds, root_window())); |
| 3018 const int kTouchId1 = 8; | 3016 const int kTouchId1 = 8; |
| 3019 const int kTouchId2 = 2; | 3017 const int kTouchId2 = 2; |
| 3020 TimedEvents tes; | 3018 TimedEvents tes; |
| 3021 | 3019 |
| 3022 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), | 3020 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), |
| 3023 kTouchId1, tes.Now()); | 3021 kTouchId1, tes.Now()); |
| 3024 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 3022 DispatchEventUsingWindowDispatcher(&press1); |
| 3025 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(20, 20), | 3023 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(20, 20), |
| 3026 kTouchId2, tes.Now()); | 3024 kTouchId2, tes.Now()); |
| 3027 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2); | 3025 DispatchEventUsingWindowDispatcher(&press2); |
| 3028 window->Hide(); | 3026 window->Hide(); |
| 3029 EXPECT_EQ(NULL, | 3027 EXPECT_EQ(NULL, |
| 3030 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press1)); | 3028 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press1)); |
| 3031 EXPECT_EQ(NULL, | 3029 EXPECT_EQ(NULL, |
| 3032 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press2)); | 3030 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press2)); |
| 3033 } | 3031 } |
| 3034 | 3032 |
| 3035 TEST_F(GestureRecognizerTest, LongPressTimerStopsOnPreventDefaultedTouchMoves) { | 3033 TEST_F(GestureRecognizerTest, LongPressTimerStopsOnPreventDefaultedTouchMoves) { |
| 3036 scoped_ptr<QueueTouchEventDelegate> delegate( | 3034 scoped_ptr<QueueTouchEventDelegate> delegate( |
| 3037 new QueueTouchEventDelegate(dispatcher())); | 3035 new QueueTouchEventDelegate(dispatcher())); |
| 3038 const int kTouchId = 2; | 3036 const int kTouchId = 2; |
| 3039 gfx::Rect bounds(100, 200, 100, 100); | 3037 gfx::Rect bounds(100, 200, 100, 100); |
| 3040 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3038 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3041 delegate.get(), -1234, bounds, root_window())); | 3039 delegate.get(), -1234, bounds, root_window())); |
| 3042 delegate->set_window(window.get()); | 3040 delegate->set_window(window.get()); |
| 3043 TimedEvents tes; | 3041 TimedEvents tes; |
| 3044 | 3042 |
| 3045 TimerTestGestureRecognizer* gesture_recognizer = | 3043 TimerTestGestureRecognizer* gesture_recognizer = |
| 3046 new TimerTestGestureRecognizer(); | 3044 new TimerTestGestureRecognizer(); |
| 3047 TimerTestGestureSequence* gesture_sequence = | 3045 TimerTestGestureSequence* gesture_sequence = |
| 3048 static_cast<TimerTestGestureSequence*>( | 3046 static_cast<TimerTestGestureSequence*>( |
| 3049 gesture_recognizer->GetGestureSequenceForTesting(window.get())); | 3047 gesture_recognizer->GetGestureSequenceForTesting(window.get())); |
| 3050 | 3048 |
| 3051 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); | 3049 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); |
| 3052 | 3050 |
| 3053 delegate->Reset(); | 3051 delegate->Reset(); |
| 3054 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 3052 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 3055 kTouchId, tes.Now()); | 3053 kTouchId, tes.Now()); |
| 3056 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 3054 DispatchEventUsingWindowDispatcher(&press); |
| 3057 // Scroll around, to cancel the long press | 3055 // Scroll around, to cancel the long press |
| 3058 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get()); | 3056 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get()); |
| 3059 | 3057 |
| 3060 delegate->Reset(); | 3058 delegate->Reset(); |
| 3061 delegate->ReceivedAck(); | 3059 delegate->ReceivedAck(); |
| 3062 EXPECT_TRUE(delegate->tap_down()); | 3060 EXPECT_TRUE(delegate->tap_down()); |
| 3063 EXPECT_TRUE(gesture_sequence->IsTimerRunning()); | 3061 EXPECT_TRUE(gesture_sequence->IsTimerRunning()); |
| 3064 | 3062 |
| 3065 delegate->Reset(); | 3063 delegate->Reset(); |
| 3066 delegate->ReceivedAckPreventDefaulted(); | 3064 delegate->ReceivedAckPreventDefaulted(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3099 const int kWindowHeight = 45; | 3097 const int kWindowHeight = 45; |
| 3100 const int kTouchId = 5; | 3098 const int kTouchId = 5; |
| 3101 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3099 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 3102 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3100 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3103 delegate.get(), -1234, bounds, root_window())); | 3101 delegate.get(), -1234, bounds, root_window())); |
| 3104 TimedEvents tes; | 3102 TimedEvents tes; |
| 3105 | 3103 |
| 3106 delegate->Reset(); | 3104 delegate->Reset(); |
| 3107 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 3105 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 3108 kTouchId, tes.Now()); | 3106 kTouchId, tes.Now()); |
| 3109 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 3107 DispatchEventUsingWindowDispatcher(&press); |
| 3110 EXPECT_FALSE(delegate->tap()); | 3108 EXPECT_FALSE(delegate->tap()); |
| 3111 EXPECT_TRUE(delegate->tap_down()); | 3109 EXPECT_TRUE(delegate->tap_down()); |
| 3112 EXPECT_FALSE(delegate->tap_cancel()); | 3110 EXPECT_FALSE(delegate->tap_cancel()); |
| 3113 EXPECT_TRUE(delegate->begin()); | 3111 EXPECT_TRUE(delegate->begin()); |
| 3114 EXPECT_FALSE(delegate->scroll_begin()); | 3112 EXPECT_FALSE(delegate->scroll_begin()); |
| 3115 EXPECT_FALSE(delegate->scroll_update()); | 3113 EXPECT_FALSE(delegate->scroll_update()); |
| 3116 EXPECT_FALSE(delegate->scroll_end()); | 3114 EXPECT_FALSE(delegate->scroll_end()); |
| 3117 | 3115 |
| 3118 // Move the touch-point enough so that it would normally be considered a | 3116 // Move the touch-point enough so that it would normally be considered a |
| 3119 // scroll. But since the touch-moves will be consumed, the scroll should not | 3117 // scroll. But since the touch-moves will be consumed, the scroll should not |
| 3120 // start. | 3118 // start. |
| 3121 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get()); | 3119 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get()); |
| 3122 EXPECT_FALSE(delegate->tap()); | 3120 EXPECT_FALSE(delegate->tap()); |
| 3123 EXPECT_FALSE(delegate->tap_down()); | 3121 EXPECT_FALSE(delegate->tap_down()); |
| 3124 EXPECT_TRUE(delegate->tap_cancel()); | 3122 EXPECT_TRUE(delegate->tap_cancel()); |
| 3125 EXPECT_FALSE(delegate->begin()); | 3123 EXPECT_FALSE(delegate->begin()); |
| 3126 EXPECT_FALSE(delegate->scroll_begin()); | 3124 EXPECT_FALSE(delegate->scroll_begin()); |
| 3127 EXPECT_FALSE(delegate->scroll_update()); | 3125 EXPECT_FALSE(delegate->scroll_update()); |
| 3128 EXPECT_FALSE(delegate->scroll_end()); | 3126 EXPECT_FALSE(delegate->scroll_end()); |
| 3129 | 3127 |
| 3130 // Release the touch back at the start point. This should end without causing | 3128 // Release the touch back at the start point. This should end without causing |
| 3131 // a tap. | 3129 // a tap. |
| 3132 delegate->Reset(); | 3130 delegate->Reset(); |
| 3133 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(130, 230), | 3131 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(130, 230), |
| 3134 kTouchId, tes.LeapForward(50)); | 3132 kTouchId, tes.LeapForward(50)); |
| 3135 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 3133 DispatchEventUsingWindowDispatcher(&release); |
| 3136 EXPECT_FALSE(delegate->tap()); | 3134 EXPECT_FALSE(delegate->tap()); |
| 3137 EXPECT_FALSE(delegate->tap_down()); | 3135 EXPECT_FALSE(delegate->tap_down()); |
| 3138 EXPECT_FALSE(delegate->tap_cancel()); | 3136 EXPECT_FALSE(delegate->tap_cancel()); |
| 3139 EXPECT_FALSE(delegate->begin()); | 3137 EXPECT_FALSE(delegate->begin()); |
| 3140 EXPECT_TRUE(delegate->end()); | 3138 EXPECT_TRUE(delegate->end()); |
| 3141 EXPECT_FALSE(delegate->scroll_begin()); | 3139 EXPECT_FALSE(delegate->scroll_begin()); |
| 3142 EXPECT_FALSE(delegate->scroll_update()); | 3140 EXPECT_FALSE(delegate->scroll_update()); |
| 3143 EXPECT_FALSE(delegate->scroll_end()); | 3141 EXPECT_FALSE(delegate->scroll_end()); |
| 3144 } | 3142 } |
| 3145 | 3143 |
| 3146 // Tests the behavior of 2F scroll when all the touch-move events are consumed. | 3144 // Tests the behavior of 2F scroll when all the touch-move events are consumed. |
| 3147 TEST_F(GestureRecognizerTest, GestureEventScrollTwoFingerTouchMoveConsumed) { | 3145 TEST_F(GestureRecognizerTest, GestureEventScrollTwoFingerTouchMoveConsumed) { |
| 3148 scoped_ptr<ConsumesTouchMovesDelegate> delegate( | 3146 scoped_ptr<ConsumesTouchMovesDelegate> delegate( |
| 3149 new ConsumesTouchMovesDelegate()); | 3147 new ConsumesTouchMovesDelegate()); |
| 3150 const int kWindowWidth = 123; | 3148 const int kWindowWidth = 123; |
| 3151 const int kWindowHeight = 100; | 3149 const int kWindowHeight = 100; |
| 3152 const int kTouchId1 = 2; | 3150 const int kTouchId1 = 2; |
| 3153 const int kTouchId2 = 3; | 3151 const int kTouchId2 = 3; |
| 3154 TimedEvents tes; | 3152 TimedEvents tes; |
| 3155 | 3153 |
| 3156 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3154 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 3157 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3155 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3158 delegate.get(), -1234, bounds, root_window())); | 3156 delegate.get(), -1234, bounds, root_window())); |
| 3159 | 3157 |
| 3160 delegate->Reset(); | 3158 delegate->Reset(); |
| 3161 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 3159 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 3162 kTouchId1, tes.Now()); | 3160 kTouchId1, tes.Now()); |
| 3163 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 3161 DispatchEventUsingWindowDispatcher(&press1); |
| 3164 tes.SendScrollEvent(dispatcher(), 131, 231, kTouchId1, delegate.get()); | 3162 tes.SendScrollEvent(dispatcher(), 131, 231, kTouchId1, delegate.get()); |
| 3165 | 3163 |
| 3166 // First finger touches down and moves. | 3164 // First finger touches down and moves. |
| 3167 EXPECT_FALSE(delegate->tap()); | 3165 EXPECT_FALSE(delegate->tap()); |
| 3168 EXPECT_FALSE(delegate->scroll_begin()); | 3166 EXPECT_FALSE(delegate->scroll_begin()); |
| 3169 EXPECT_FALSE(delegate->scroll_update()); | 3167 EXPECT_FALSE(delegate->scroll_update()); |
| 3170 EXPECT_FALSE(delegate->scroll_end()); | 3168 EXPECT_FALSE(delegate->scroll_end()); |
| 3171 | 3169 |
| 3172 delegate->Reset(); | 3170 delegate->Reset(); |
| 3173 // Second finger touches down and moves. | 3171 // Second finger touches down and moves. |
| 3174 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), | 3172 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), |
| 3175 kTouchId2, tes.LeapForward(50)); | 3173 kTouchId2, tes.LeapForward(50)); |
| 3176 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2); | 3174 DispatchEventUsingWindowDispatcher(&press2); |
| 3177 tes.SendScrollEvent(dispatcher(), 161, 231, kTouchId2, delegate.get()); | 3175 tes.SendScrollEvent(dispatcher(), 161, 231, kTouchId2, delegate.get()); |
| 3178 | 3176 |
| 3179 // PinchBegin & ScrollBegin were not sent if the touch-move events were | 3177 // PinchBegin & ScrollBegin were not sent if the touch-move events were |
| 3180 // consumed. | 3178 // consumed. |
| 3181 EXPECT_FALSE(delegate->pinch_begin()); | 3179 EXPECT_FALSE(delegate->pinch_begin()); |
| 3182 EXPECT_FALSE(delegate->scroll_begin()); | 3180 EXPECT_FALSE(delegate->scroll_begin()); |
| 3183 | 3181 |
| 3184 EXPECT_FALSE(delegate->tap()); | 3182 EXPECT_FALSE(delegate->tap()); |
| 3185 EXPECT_FALSE(delegate->two_finger_tap()); | 3183 EXPECT_FALSE(delegate->two_finger_tap()); |
| 3186 | 3184 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3223 | 3221 |
| 3224 EXPECT_FALSE(delegate->pinch_begin()); | 3222 EXPECT_FALSE(delegate->pinch_begin()); |
| 3225 EXPECT_FALSE(delegate->pinch_update()); | 3223 EXPECT_FALSE(delegate->pinch_update()); |
| 3226 EXPECT_FALSE(delegate->pinch_end()); | 3224 EXPECT_FALSE(delegate->pinch_end()); |
| 3227 | 3225 |
| 3228 delegate->Reset(); | 3226 delegate->Reset(); |
| 3229 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 3227 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 3230 kTouchId1, tes.Now()); | 3228 kTouchId1, tes.Now()); |
| 3231 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(130, 201), | 3229 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(130, 201), |
| 3232 kTouchId2, tes.Now()); | 3230 kTouchId2, tes.Now()); |
| 3233 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1); | 3231 DispatchEventUsingWindowDispatcher(&release1); |
| 3234 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release2); | 3232 DispatchEventUsingWindowDispatcher(&release2); |
| 3235 | 3233 |
| 3236 EXPECT_FALSE(delegate->tap()); | 3234 EXPECT_FALSE(delegate->tap()); |
| 3237 // Touch release is not consumed, so we still see two finger tap. | 3235 // Touch release is not consumed, so we still see two finger tap. |
| 3238 EXPECT_TRUE(delegate->two_finger_tap()); | 3236 EXPECT_TRUE(delegate->two_finger_tap()); |
| 3239 | 3237 |
| 3240 // Should not see PinchEnd & ScrollEnd. | 3238 // Should not see PinchEnd & ScrollEnd. |
| 3241 EXPECT_FALSE(delegate->scroll_begin()); | 3239 EXPECT_FALSE(delegate->scroll_begin()); |
| 3242 EXPECT_FALSE(delegate->scroll_update()); | 3240 EXPECT_FALSE(delegate->scroll_update()); |
| 3243 EXPECT_FALSE(delegate->scroll_end()); | 3241 EXPECT_FALSE(delegate->scroll_end()); |
| 3244 | 3242 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3257 const int kWindowHeight = 45; | 3255 const int kWindowHeight = 45; |
| 3258 const int kTouchId = 5; | 3256 const int kTouchId = 5; |
| 3259 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3257 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 3260 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3258 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3261 delegate.get(), -1234, bounds, root_window())); | 3259 delegate.get(), -1234, bounds, root_window())); |
| 3262 TimedEvents tes; | 3260 TimedEvents tes; |
| 3263 | 3261 |
| 3264 delegate->Reset(); | 3262 delegate->Reset(); |
| 3265 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 3263 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 3266 kTouchId, tes.Now()); | 3264 kTouchId, tes.Now()); |
| 3267 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 3265 DispatchEventUsingWindowDispatcher(&press); |
| 3268 EXPECT_FALSE(delegate->tap()); | 3266 EXPECT_FALSE(delegate->tap()); |
| 3269 EXPECT_TRUE(delegate->tap_down()); | 3267 EXPECT_TRUE(delegate->tap_down()); |
| 3270 EXPECT_FALSE(delegate->tap_cancel()); | 3268 EXPECT_FALSE(delegate->tap_cancel()); |
| 3271 EXPECT_TRUE(delegate->begin()); | 3269 EXPECT_TRUE(delegate->begin()); |
| 3272 EXPECT_FALSE(delegate->scroll_begin()); | 3270 EXPECT_FALSE(delegate->scroll_begin()); |
| 3273 EXPECT_FALSE(delegate->scroll_update()); | 3271 EXPECT_FALSE(delegate->scroll_update()); |
| 3274 EXPECT_FALSE(delegate->scroll_end()); | 3272 EXPECT_FALSE(delegate->scroll_end()); |
| 3275 | 3273 |
| 3276 // Move the touch-point enough so that it would normally be considered a | 3274 // Move the touch-point enough so that it would normally be considered a |
| 3277 // scroll. But since the touch-moves will be consumed, the scroll should not | 3275 // 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 Loading... |
| 3324 EXPECT_FALSE(delegate->scroll_begin()); | 3322 EXPECT_FALSE(delegate->scroll_begin()); |
| 3325 EXPECT_FALSE(delegate->scroll_update()); | 3323 EXPECT_FALSE(delegate->scroll_update()); |
| 3326 EXPECT_FALSE(delegate->scroll_end()); | 3324 EXPECT_FALSE(delegate->scroll_end()); |
| 3327 EXPECT_EQ(0, delegate->scroll_x()); | 3325 EXPECT_EQ(0, delegate->scroll_x()); |
| 3328 EXPECT_EQ(0, delegate->scroll_y()); | 3326 EXPECT_EQ(0, delegate->scroll_y()); |
| 3329 | 3327 |
| 3330 // Release the touch. | 3328 // Release the touch. |
| 3331 delegate->Reset(); | 3329 delegate->Reset(); |
| 3332 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 3330 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 3333 kTouchId, tes.LeapForward(50)); | 3331 kTouchId, tes.LeapForward(50)); |
| 3334 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 3332 DispatchEventUsingWindowDispatcher(&release); |
| 3335 EXPECT_FALSE(delegate->tap()); | 3333 EXPECT_FALSE(delegate->tap()); |
| 3336 EXPECT_FALSE(delegate->tap_down()); | 3334 EXPECT_FALSE(delegate->tap_down()); |
| 3337 EXPECT_FALSE(delegate->tap_cancel()); | 3335 EXPECT_FALSE(delegate->tap_cancel()); |
| 3338 EXPECT_FALSE(delegate->begin()); | 3336 EXPECT_FALSE(delegate->begin()); |
| 3339 EXPECT_TRUE(delegate->end()); | 3337 EXPECT_TRUE(delegate->end()); |
| 3340 EXPECT_FALSE(delegate->scroll_begin()); | 3338 EXPECT_FALSE(delegate->scroll_begin()); |
| 3341 EXPECT_FALSE(delegate->scroll_update()); | 3339 EXPECT_FALSE(delegate->scroll_update()); |
| 3342 EXPECT_FALSE(delegate->scroll_end()); | 3340 EXPECT_FALSE(delegate->scroll_end()); |
| 3343 EXPECT_FALSE(delegate->fling()); | 3341 EXPECT_FALSE(delegate->fling()); |
| 3344 } | 3342 } |
| 3345 | 3343 |
| 3346 // Check that appropriate touch events generate double tap gesture events. | 3344 // Check that appropriate touch events generate double tap gesture events. |
| 3347 TEST_F(GestureRecognizerTest, GestureEventDoubleTap) { | 3345 TEST_F(GestureRecognizerTest, GestureEventDoubleTap) { |
| 3348 scoped_ptr<GestureEventConsumeDelegate> delegate( | 3346 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 3349 new GestureEventConsumeDelegate()); | 3347 new GestureEventConsumeDelegate()); |
| 3350 const int kWindowWidth = 123; | 3348 const int kWindowWidth = 123; |
| 3351 const int kWindowHeight = 45; | 3349 const int kWindowHeight = 45; |
| 3352 const int kTouchId = 2; | 3350 const int kTouchId = 2; |
| 3353 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3351 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 3354 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3352 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3355 delegate.get(), -1234, bounds, root_window())); | 3353 delegate.get(), -1234, bounds, root_window())); |
| 3356 TimedEvents tes; | 3354 TimedEvents tes; |
| 3357 | 3355 |
| 3358 // First tap (tested in GestureEventTap) | 3356 // First tap (tested in GestureEventTap) |
| 3359 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(104, 201), | 3357 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(104, 201), |
| 3360 kTouchId, tes.Now()); | 3358 kTouchId, tes.Now()); |
| 3361 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 3359 DispatchEventUsingWindowDispatcher(&press1); |
| 3362 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(104, 201), | 3360 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(104, 201), |
| 3363 kTouchId, tes.LeapForward(50)); | 3361 kTouchId, tes.LeapForward(50)); |
| 3364 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1); | 3362 DispatchEventUsingWindowDispatcher(&release1); |
| 3365 delegate->Reset(); | 3363 delegate->Reset(); |
| 3366 | 3364 |
| 3367 // Second tap | 3365 // Second tap |
| 3368 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(101, 203), | 3366 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(101, 203), |
| 3369 kTouchId, tes.LeapForward(200)); | 3367 kTouchId, tes.LeapForward(200)); |
| 3370 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2); | 3368 DispatchEventUsingWindowDispatcher(&press2); |
| 3371 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(102, 206), | 3369 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(102, 206), |
| 3372 kTouchId, tes.LeapForward(50)); | 3370 kTouchId, tes.LeapForward(50)); |
| 3373 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release2); | 3371 DispatchEventUsingWindowDispatcher(&release2); |
| 3374 | 3372 |
| 3375 EXPECT_TRUE(delegate->tap()); | 3373 EXPECT_TRUE(delegate->tap()); |
| 3376 EXPECT_TRUE(delegate->tap_down()); | 3374 EXPECT_TRUE(delegate->tap_down()); |
| 3377 EXPECT_FALSE(delegate->tap_cancel()); | 3375 EXPECT_FALSE(delegate->tap_cancel()); |
| 3378 EXPECT_TRUE(delegate->begin()); | 3376 EXPECT_TRUE(delegate->begin()); |
| 3379 EXPECT_TRUE(delegate->end()); | 3377 EXPECT_TRUE(delegate->end()); |
| 3380 EXPECT_FALSE(delegate->scroll_begin()); | 3378 EXPECT_FALSE(delegate->scroll_begin()); |
| 3381 EXPECT_FALSE(delegate->scroll_update()); | 3379 EXPECT_FALSE(delegate->scroll_update()); |
| 3382 EXPECT_FALSE(delegate->scroll_end()); | 3380 EXPECT_FALSE(delegate->scroll_end()); |
| 3383 | 3381 |
| 3384 EXPECT_EQ(2, delegate->tap_count()); | 3382 EXPECT_EQ(2, delegate->tap_count()); |
| 3385 } | 3383 } |
| 3386 | 3384 |
| 3387 // Check that appropriate touch events generate triple tap gesture events. | 3385 // Check that appropriate touch events generate triple tap gesture events. |
| 3388 TEST_F(GestureRecognizerTest, GestureEventTripleTap) { | 3386 TEST_F(GestureRecognizerTest, GestureEventTripleTap) { |
| 3389 scoped_ptr<GestureEventConsumeDelegate> delegate( | 3387 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 3390 new GestureEventConsumeDelegate()); | 3388 new GestureEventConsumeDelegate()); |
| 3391 const int kWindowWidth = 123; | 3389 const int kWindowWidth = 123; |
| 3392 const int kWindowHeight = 45; | 3390 const int kWindowHeight = 45; |
| 3393 const int kTouchId = 2; | 3391 const int kTouchId = 2; |
| 3394 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3392 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 3395 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3393 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3396 delegate.get(), -1234, bounds, root_window())); | 3394 delegate.get(), -1234, bounds, root_window())); |
| 3397 TimedEvents tes; | 3395 TimedEvents tes; |
| 3398 | 3396 |
| 3399 // First tap (tested in GestureEventTap) | 3397 // First tap (tested in GestureEventTap) |
| 3400 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(104, 201), | 3398 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(104, 201), |
| 3401 kTouchId, tes.Now()); | 3399 kTouchId, tes.Now()); |
| 3402 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 3400 DispatchEventUsingWindowDispatcher(&press1); |
| 3403 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(104, 201), | 3401 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(104, 201), |
| 3404 kTouchId, tes.LeapForward(50)); | 3402 kTouchId, tes.LeapForward(50)); |
| 3405 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1); | 3403 DispatchEventUsingWindowDispatcher(&release1); |
| 3406 | 3404 |
| 3407 EXPECT_EQ(1, delegate->tap_count()); | 3405 EXPECT_EQ(1, delegate->tap_count()); |
| 3408 delegate->Reset(); | 3406 delegate->Reset(); |
| 3409 | 3407 |
| 3410 // Second tap (tested in GestureEventDoubleTap) | 3408 // Second tap (tested in GestureEventDoubleTap) |
| 3411 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(101, 203), | 3409 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(101, 203), |
| 3412 kTouchId, tes.LeapForward(200)); | 3410 kTouchId, tes.LeapForward(200)); |
| 3413 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2); | 3411 DispatchEventUsingWindowDispatcher(&press2); |
| 3414 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(102, 206), | 3412 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(102, 206), |
| 3415 kTouchId, tes.LeapForward(50)); | 3413 kTouchId, tes.LeapForward(50)); |
| 3416 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release2); | 3414 DispatchEventUsingWindowDispatcher(&release2); |
| 3417 | 3415 |
| 3418 EXPECT_EQ(2, delegate->tap_count()); | 3416 EXPECT_EQ(2, delegate->tap_count()); |
| 3419 delegate->Reset(); | 3417 delegate->Reset(); |
| 3420 | 3418 |
| 3421 // Third tap | 3419 // Third tap |
| 3422 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(102, 206), | 3420 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(102, 206), |
| 3423 kTouchId, tes.LeapForward(200)); | 3421 kTouchId, tes.LeapForward(200)); |
| 3424 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press3); | 3422 DispatchEventUsingWindowDispatcher(&press3); |
| 3425 ui::TouchEvent release3(ui::ET_TOUCH_RELEASED, gfx::Point(102, 206), | 3423 ui::TouchEvent release3(ui::ET_TOUCH_RELEASED, gfx::Point(102, 206), |
| 3426 kTouchId, tes.LeapForward(50)); | 3424 kTouchId, tes.LeapForward(50)); |
| 3427 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release3); | 3425 DispatchEventUsingWindowDispatcher(&release3); |
| 3428 | 3426 |
| 3429 | 3427 |
| 3430 EXPECT_TRUE(delegate->tap()); | 3428 EXPECT_TRUE(delegate->tap()); |
| 3431 EXPECT_TRUE(delegate->tap_down()); | 3429 EXPECT_TRUE(delegate->tap_down()); |
| 3432 EXPECT_FALSE(delegate->tap_cancel()); | 3430 EXPECT_FALSE(delegate->tap_cancel()); |
| 3433 EXPECT_TRUE(delegate->begin()); | 3431 EXPECT_TRUE(delegate->begin()); |
| 3434 EXPECT_TRUE(delegate->end()); | 3432 EXPECT_TRUE(delegate->end()); |
| 3435 EXPECT_FALSE(delegate->scroll_begin()); | 3433 EXPECT_FALSE(delegate->scroll_begin()); |
| 3436 EXPECT_FALSE(delegate->scroll_update()); | 3434 EXPECT_FALSE(delegate->scroll_update()); |
| 3437 EXPECT_FALSE(delegate->scroll_end()); | 3435 EXPECT_FALSE(delegate->scroll_end()); |
| 3438 | 3436 |
| 3439 EXPECT_EQ(3, delegate->tap_count()); | 3437 EXPECT_EQ(3, delegate->tap_count()); |
| 3440 } | 3438 } |
| 3441 | 3439 |
| 3442 // Check that we don't get a double tap when the two taps are far apart. | 3440 // Check that we don't get a double tap when the two taps are far apart. |
| 3443 TEST_F(GestureRecognizerTest, TwoTapsFarApart) { | 3441 TEST_F(GestureRecognizerTest, TwoTapsFarApart) { |
| 3444 scoped_ptr<GestureEventConsumeDelegate> delegate( | 3442 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 3445 new GestureEventConsumeDelegate()); | 3443 new GestureEventConsumeDelegate()); |
| 3446 const int kWindowWidth = 123; | 3444 const int kWindowWidth = 123; |
| 3447 const int kWindowHeight = 45; | 3445 const int kWindowHeight = 45; |
| 3448 const int kTouchId = 2; | 3446 const int kTouchId = 2; |
| 3449 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3447 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 3450 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3448 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3451 delegate.get(), -1234, bounds, root_window())); | 3449 delegate.get(), -1234, bounds, root_window())); |
| 3452 TimedEvents tes; | 3450 TimedEvents tes; |
| 3453 | 3451 |
| 3454 // First tap (tested in GestureEventTap) | 3452 // First tap (tested in GestureEventTap) |
| 3455 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 3453 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 3456 kTouchId, tes.Now()); | 3454 kTouchId, tes.Now()); |
| 3457 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 3455 DispatchEventUsingWindowDispatcher(&press1); |
| 3458 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 3456 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 3459 kTouchId, tes.LeapForward(50)); | 3457 kTouchId, tes.LeapForward(50)); |
| 3460 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1); | 3458 DispatchEventUsingWindowDispatcher(&release1); |
| 3461 delegate->Reset(); | 3459 delegate->Reset(); |
| 3462 | 3460 |
| 3463 // Second tap, close in time but far in distance | 3461 // Second tap, close in time but far in distance |
| 3464 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(201, 201), | 3462 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(201, 201), |
| 3465 kTouchId, tes.LeapForward(200)); | 3463 kTouchId, tes.LeapForward(200)); |
| 3466 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2); | 3464 DispatchEventUsingWindowDispatcher(&press2); |
| 3467 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(201, 201), | 3465 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(201, 201), |
| 3468 kTouchId, tes.LeapForward(50)); | 3466 kTouchId, tes.LeapForward(50)); |
| 3469 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release2); | 3467 DispatchEventUsingWindowDispatcher(&release2); |
| 3470 | 3468 |
| 3471 EXPECT_TRUE(delegate->tap()); | 3469 EXPECT_TRUE(delegate->tap()); |
| 3472 EXPECT_TRUE(delegate->tap_down()); | 3470 EXPECT_TRUE(delegate->tap_down()); |
| 3473 EXPECT_FALSE(delegate->tap_cancel()); | 3471 EXPECT_FALSE(delegate->tap_cancel()); |
| 3474 EXPECT_TRUE(delegate->begin()); | 3472 EXPECT_TRUE(delegate->begin()); |
| 3475 EXPECT_TRUE(delegate->end()); | 3473 EXPECT_TRUE(delegate->end()); |
| 3476 EXPECT_FALSE(delegate->scroll_begin()); | 3474 EXPECT_FALSE(delegate->scroll_begin()); |
| 3477 EXPECT_FALSE(delegate->scroll_update()); | 3475 EXPECT_FALSE(delegate->scroll_update()); |
| 3478 EXPECT_FALSE(delegate->scroll_end()); | 3476 EXPECT_FALSE(delegate->scroll_end()); |
| 3479 | 3477 |
| 3480 EXPECT_EQ(1, delegate->tap_count()); | 3478 EXPECT_EQ(1, delegate->tap_count()); |
| 3481 } | 3479 } |
| 3482 | 3480 |
| 3483 // Check that we don't get a double tap when the two taps have a long enough | 3481 // Check that we don't get a double tap when the two taps have a long enough |
| 3484 // delay in between. | 3482 // delay in between. |
| 3485 TEST_F(GestureRecognizerTest, TwoTapsWithDelayBetween) { | 3483 TEST_F(GestureRecognizerTest, TwoTapsWithDelayBetween) { |
| 3486 scoped_ptr<GestureEventConsumeDelegate> delegate( | 3484 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 3487 new GestureEventConsumeDelegate()); | 3485 new GestureEventConsumeDelegate()); |
| 3488 const int kWindowWidth = 123; | 3486 const int kWindowWidth = 123; |
| 3489 const int kWindowHeight = 45; | 3487 const int kWindowHeight = 45; |
| 3490 const int kTouchId = 2; | 3488 const int kTouchId = 2; |
| 3491 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3489 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 3492 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3490 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3493 delegate.get(), -1234, bounds, root_window())); | 3491 delegate.get(), -1234, bounds, root_window())); |
| 3494 TimedEvents tes; | 3492 TimedEvents tes; |
| 3495 | 3493 |
| 3496 // First tap (tested in GestureEventTap) | 3494 // First tap (tested in GestureEventTap) |
| 3497 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 3495 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 3498 kTouchId, tes.Now()); | 3496 kTouchId, tes.Now()); |
| 3499 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 3497 DispatchEventUsingWindowDispatcher(&press1); |
| 3500 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 3498 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 3501 kTouchId, tes.LeapForward(50)); | 3499 kTouchId, tes.LeapForward(50)); |
| 3502 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1); | 3500 DispatchEventUsingWindowDispatcher(&release1); |
| 3503 delegate->Reset(); | 3501 delegate->Reset(); |
| 3504 | 3502 |
| 3505 // Second tap, close in distance but after some delay | 3503 // Second tap, close in distance but after some delay |
| 3506 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 3504 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 3507 kTouchId, tes.LeapForward(2000)); | 3505 kTouchId, tes.LeapForward(2000)); |
| 3508 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2); | 3506 DispatchEventUsingWindowDispatcher(&press2); |
| 3509 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 3507 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 3510 kTouchId, tes.LeapForward(50)); | 3508 kTouchId, tes.LeapForward(50)); |
| 3511 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release2); | 3509 DispatchEventUsingWindowDispatcher(&release2); |
| 3512 | 3510 |
| 3513 EXPECT_TRUE(delegate->tap()); | 3511 EXPECT_TRUE(delegate->tap()); |
| 3514 EXPECT_TRUE(delegate->tap_down()); | 3512 EXPECT_TRUE(delegate->tap_down()); |
| 3515 EXPECT_FALSE(delegate->tap_cancel()); | 3513 EXPECT_FALSE(delegate->tap_cancel()); |
| 3516 EXPECT_TRUE(delegate->begin()); | 3514 EXPECT_TRUE(delegate->begin()); |
| 3517 EXPECT_TRUE(delegate->end()); | 3515 EXPECT_TRUE(delegate->end()); |
| 3518 EXPECT_FALSE(delegate->scroll_begin()); | 3516 EXPECT_FALSE(delegate->scroll_begin()); |
| 3519 EXPECT_FALSE(delegate->scroll_update()); | 3517 EXPECT_FALSE(delegate->scroll_update()); |
| 3520 EXPECT_FALSE(delegate->scroll_end()); | 3518 EXPECT_FALSE(delegate->scroll_end()); |
| 3521 | 3519 |
| 3522 EXPECT_EQ(1, delegate->tap_count()); | 3520 EXPECT_EQ(1, delegate->tap_count()); |
| 3523 } | 3521 } |
| 3524 | 3522 |
| 3525 // Checks that if the bounding-box of a gesture changes because of change in | 3523 // Checks that if the bounding-box of a gesture changes because of change in |
| 3526 // radius of a touch-point, and not because of change in position, then there | 3524 // radius of a touch-point, and not because of change in position, then there |
| 3527 // are not gesture events from that. | 3525 // are not gesture events from that. |
| 3528 TEST_F(GestureRecognizerTest, BoundingBoxRadiusChange) { | 3526 TEST_F(GestureRecognizerTest, BoundingBoxRadiusChange) { |
| 3529 scoped_ptr<GestureEventConsumeDelegate> delegate( | 3527 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 3530 new GestureEventConsumeDelegate()); | 3528 new GestureEventConsumeDelegate()); |
| 3531 const int kWindowWidth = 234; | 3529 const int kWindowWidth = 234; |
| 3532 const int kWindowHeight = 345; | 3530 const int kWindowHeight = 345; |
| 3533 const int kTouchId = 5, kTouchId2 = 7; | 3531 const int kTouchId = 5, kTouchId2 = 7; |
| 3534 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3532 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 3535 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3533 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3536 delegate.get(), -1234, bounds, root_window())); | 3534 delegate.get(), -1234, bounds, root_window())); |
| 3537 TimedEvents tes; | 3535 TimedEvents tes; |
| 3538 | 3536 |
| 3539 ui::TouchEvent press1( | 3537 ui::TouchEvent press1( |
| 3540 ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId, tes.Now()); | 3538 ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId, tes.Now()); |
| 3541 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 3539 DispatchEventUsingWindowDispatcher(&press1); |
| 3542 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); | 3540 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
| 3543 | 3541 |
| 3544 delegate->Reset(); | 3542 delegate->Reset(); |
| 3545 | 3543 |
| 3546 ui::TouchEvent press2( | 3544 ui::TouchEvent press2( |
| 3547 ui::ET_TOUCH_PRESSED, gfx::Point(201, 201), kTouchId2, | 3545 ui::ET_TOUCH_PRESSED, gfx::Point(201, 201), kTouchId2, |
| 3548 tes.LeapForward(400)); | 3546 tes.LeapForward(400)); |
| 3549 press2.set_radius_x(5); | 3547 press2.set_radius_x(5); |
| 3550 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2); | 3548 DispatchEventUsingWindowDispatcher(&press2); |
| 3551 EXPECT_FALSE(delegate->pinch_begin()); | 3549 EXPECT_FALSE(delegate->pinch_begin()); |
| 3552 EXPECT_EQ(gfx::Rect(101, 201, 100, 0).ToString(), | 3550 EXPECT_EQ(gfx::Rect(101, 201, 100, 0).ToString(), |
| 3553 delegate->bounding_box().ToString()); | 3551 delegate->bounding_box().ToString()); |
| 3554 | 3552 |
| 3555 delegate->Reset(); | 3553 delegate->Reset(); |
| 3556 | 3554 |
| 3557 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(141, 201), kTouchId, | 3555 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(141, 201), kTouchId, |
| 3558 tes.LeapForward(40)); | 3556 tes.LeapForward(40)); |
| 3559 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move1); | 3557 DispatchEventUsingWindowDispatcher(&move1); |
| 3560 EXPECT_TRUE(delegate->pinch_begin()); | 3558 EXPECT_TRUE(delegate->pinch_begin()); |
| 3561 EXPECT_EQ(gfx::Rect(141, 201, 60, 0).ToString(), | 3559 EXPECT_EQ(gfx::Rect(141, 201, 60, 0).ToString(), |
| 3562 delegate->bounding_box().ToString()); | 3560 delegate->bounding_box().ToString()); |
| 3563 | 3561 |
| 3564 delegate->Reset(); | 3562 delegate->Reset(); |
| 3565 | 3563 |
| 3566 // The position doesn't move, but the radius changes. | 3564 // The position doesn't move, but the radius changes. |
| 3567 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(101, 201), kTouchId, | 3565 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(101, 201), kTouchId, |
| 3568 tes.LeapForward(40)); | 3566 tes.LeapForward(40)); |
| 3569 move2.set_radius_x(50); | 3567 move2.set_radius_x(50); |
| 3570 move2.set_radius_y(60); | 3568 move2.set_radius_y(60); |
| 3571 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move2); | 3569 DispatchEventUsingWindowDispatcher(&move2); |
| 3572 EXPECT_FALSE(delegate->tap()); | 3570 EXPECT_FALSE(delegate->tap()); |
| 3573 EXPECT_FALSE(delegate->tap_cancel()); | 3571 EXPECT_FALSE(delegate->tap_cancel()); |
| 3574 EXPECT_FALSE(delegate->scroll_update()); | 3572 EXPECT_FALSE(delegate->scroll_update()); |
| 3575 EXPECT_FALSE(delegate->pinch_update()); | 3573 EXPECT_FALSE(delegate->pinch_update()); |
| 3576 | 3574 |
| 3577 delegate->Reset(); | 3575 delegate->Reset(); |
| 3578 } | 3576 } |
| 3579 | 3577 |
| 3580 // Checks that slow scrolls deliver the correct deltas. | 3578 // Checks that slow scrolls deliver the correct deltas. |
| 3581 // In particular, fix for http;//crbug.com/150573. | 3579 // In particular, fix for http;//crbug.com/150573. |
| 3582 TEST_F(GestureRecognizerTest, NoDriftInScroll) { | 3580 TEST_F(GestureRecognizerTest, NoDriftInScroll) { |
| 3583 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(3); | 3581 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(3); |
| 3584 ui::GestureConfiguration::set_min_scroll_delta_squared(9); | 3582 ui::GestureConfiguration::set_min_scroll_delta_squared(9); |
| 3585 scoped_ptr<GestureEventConsumeDelegate> delegate( | 3583 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 3586 new GestureEventConsumeDelegate()); | 3584 new GestureEventConsumeDelegate()); |
| 3587 const int kWindowWidth = 234; | 3585 const int kWindowWidth = 234; |
| 3588 const int kWindowHeight = 345; | 3586 const int kWindowHeight = 345; |
| 3589 const int kTouchId = 5; | 3587 const int kTouchId = 5; |
| 3590 TimedEvents tes; | 3588 TimedEvents tes; |
| 3591 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3589 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 3592 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3590 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3593 delegate.get(), -1234, bounds, root_window())); | 3591 delegate.get(), -1234, bounds, root_window())); |
| 3594 | 3592 |
| 3595 ui::TouchEvent press1( | 3593 ui::TouchEvent press1( |
| 3596 ui::ET_TOUCH_PRESSED, gfx::Point(101, 208), kTouchId, tes.Now()); | 3594 ui::ET_TOUCH_PRESSED, gfx::Point(101, 208), kTouchId, tes.Now()); |
| 3597 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 3595 DispatchEventUsingWindowDispatcher(&press1); |
| 3598 EXPECT_TRUE(delegate->begin()); | 3596 EXPECT_TRUE(delegate->begin()); |
| 3599 | 3597 |
| 3600 delegate->Reset(); | 3598 delegate->Reset(); |
| 3601 | 3599 |
| 3602 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(101, 206), kTouchId, | 3600 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(101, 206), kTouchId, |
| 3603 tes.LeapForward(40)); | 3601 tes.LeapForward(40)); |
| 3604 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move1); | 3602 DispatchEventUsingWindowDispatcher(&move1); |
| 3605 EXPECT_FALSE(delegate->scroll_begin()); | 3603 EXPECT_FALSE(delegate->scroll_begin()); |
| 3606 | 3604 |
| 3607 delegate->Reset(); | 3605 delegate->Reset(); |
| 3608 | 3606 |
| 3609 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(101, 204), kTouchId, | 3607 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(101, 204), kTouchId, |
| 3610 tes.LeapForward(40)); | 3608 tes.LeapForward(40)); |
| 3611 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move2); | 3609 DispatchEventUsingWindowDispatcher(&move2); |
| 3612 EXPECT_TRUE(delegate->tap_cancel()); | 3610 EXPECT_TRUE(delegate->tap_cancel()); |
| 3613 EXPECT_TRUE(delegate->scroll_begin()); | 3611 EXPECT_TRUE(delegate->scroll_begin()); |
| 3614 EXPECT_TRUE(delegate->scroll_update()); | 3612 EXPECT_TRUE(delegate->scroll_update()); |
| 3615 // 3 px consumed by touch slop region. | 3613 // 3 px consumed by touch slop region. |
| 3616 EXPECT_EQ(-1, delegate->scroll_y()); | 3614 EXPECT_EQ(-1, delegate->scroll_y()); |
| 3617 EXPECT_EQ(-4, delegate->scroll_y_hint()); | 3615 EXPECT_EQ(-4, delegate->scroll_y_hint()); |
| 3618 | 3616 |
| 3619 delegate->Reset(); | 3617 delegate->Reset(); |
| 3620 | 3618 |
| 3621 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(101, 204), kTouchId, | 3619 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(101, 204), kTouchId, |
| 3622 tes.LeapForward(40)); | 3620 tes.LeapForward(40)); |
| 3623 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move3); | 3621 DispatchEventUsingWindowDispatcher(&move3); |
| 3624 EXPECT_FALSE(delegate->scroll_update()); | 3622 EXPECT_FALSE(delegate->scroll_update()); |
| 3625 | 3623 |
| 3626 delegate->Reset(); | 3624 delegate->Reset(); |
| 3627 | 3625 |
| 3628 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(101, 203), kTouchId, | 3626 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(101, 203), kTouchId, |
| 3629 tes.LeapForward(40)); | 3627 tes.LeapForward(40)); |
| 3630 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move4); | 3628 DispatchEventUsingWindowDispatcher(&move4); |
| 3631 EXPECT_TRUE(delegate->scroll_update()); | 3629 EXPECT_TRUE(delegate->scroll_update()); |
| 3632 EXPECT_EQ(-1, delegate->scroll_y()); | 3630 EXPECT_EQ(-1, delegate->scroll_y()); |
| 3633 | 3631 |
| 3634 delegate->Reset(); | 3632 delegate->Reset(); |
| 3635 } | 3633 } |
| 3636 | 3634 |
| 3637 // Ensure that move events which are preventDefaulted will cause a tap | 3635 // Ensure that move events which are preventDefaulted will cause a tap |
| 3638 // cancel gesture event to be fired if the move would normally cause a | 3636 // cancel gesture event to be fired if the move would normally cause a |
| 3639 // scroll. See bug http://crbug.com/146397. | 3637 // scroll. See bug http://crbug.com/146397. |
| 3640 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveCanFireTapCancel) { | 3638 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveCanFireTapCancel) { |
| 3641 scoped_ptr<ConsumesTouchMovesDelegate> delegate( | 3639 scoped_ptr<ConsumesTouchMovesDelegate> delegate( |
| 3642 new ConsumesTouchMovesDelegate()); | 3640 new ConsumesTouchMovesDelegate()); |
| 3643 const int kTouchId = 5; | 3641 const int kTouchId = 5; |
| 3644 gfx::Rect bounds(100, 200, 123, 45); | 3642 gfx::Rect bounds(100, 200, 123, 45); |
| 3645 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3643 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3646 delegate.get(), -1234, bounds, root_window())); | 3644 delegate.get(), -1234, bounds, root_window())); |
| 3647 TimedEvents tes; | 3645 TimedEvents tes; |
| 3648 | 3646 |
| 3649 delegate->Reset(); | 3647 delegate->Reset(); |
| 3650 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 3648 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 3651 kTouchId, tes.Now()); | 3649 kTouchId, tes.Now()); |
| 3652 | 3650 |
| 3653 delegate->set_consume_touch_move(false); | 3651 delegate->set_consume_touch_move(false); |
| 3654 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 3652 DispatchEventUsingWindowDispatcher(&press); |
| 3655 delegate->set_consume_touch_move(true); | 3653 delegate->set_consume_touch_move(true); |
| 3656 delegate->Reset(); | 3654 delegate->Reset(); |
| 3657 // Move the touch-point enough so that it would normally be considered a | 3655 // Move the touch-point enough so that it would normally be considered a |
| 3658 // scroll. But since the touch-moves will be consumed, the scroll should not | 3656 // scroll. But since the touch-moves will be consumed, the scroll should not |
| 3659 // start. | 3657 // start. |
| 3660 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get()); | 3658 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get()); |
| 3661 EXPECT_FALSE(delegate->tap()); | 3659 EXPECT_FALSE(delegate->tap()); |
| 3662 EXPECT_FALSE(delegate->tap_down()); | 3660 EXPECT_FALSE(delegate->tap_down()); |
| 3663 EXPECT_TRUE(delegate->tap_cancel()); | 3661 EXPECT_TRUE(delegate->tap_cancel()); |
| 3664 EXPECT_FALSE(delegate->begin()); | 3662 EXPECT_FALSE(delegate->begin()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 3681 scoped_ptr<RemoveOnTouchCancelHandler> | 3679 scoped_ptr<RemoveOnTouchCancelHandler> |
| 3682 handler(new RemoveOnTouchCancelHandler()); | 3680 handler(new RemoveOnTouchCancelHandler()); |
| 3683 window->AddPreTargetHandler(handler.get()); | 3681 window->AddPreTargetHandler(handler.get()); |
| 3684 | 3682 |
| 3685 // Start a gesture sequence on |window|. Then transfer the events to NULL. | 3683 // Start a gesture sequence on |window|. Then transfer the events to NULL. |
| 3686 // Make sure |window| receives a touch-cancel event. | 3684 // Make sure |window| receives a touch-cancel event. |
| 3687 delegate->Reset(); | 3685 delegate->Reset(); |
| 3688 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 3686 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 3689 kTouchId, tes.Now()); | 3687 kTouchId, tes.Now()); |
| 3690 ui::TouchEvent p2(ui::ET_TOUCH_PRESSED, gfx::Point(50, 50), 1, tes.Now()); | 3688 ui::TouchEvent p2(ui::ET_TOUCH_PRESSED, gfx::Point(50, 50), 1, tes.Now()); |
| 3691 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 3689 DispatchEventUsingWindowDispatcher(&press); |
| 3692 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&p2); | 3690 DispatchEventUsingWindowDispatcher(&p2); |
| 3693 EXPECT_FALSE(delegate->tap()); | 3691 EXPECT_FALSE(delegate->tap()); |
| 3694 EXPECT_TRUE(delegate->tap_down()); | 3692 EXPECT_TRUE(delegate->tap_down()); |
| 3695 EXPECT_TRUE(delegate->tap_cancel()); | 3693 EXPECT_TRUE(delegate->tap_cancel()); |
| 3696 EXPECT_TRUE(delegate->begin()); | 3694 EXPECT_TRUE(delegate->begin()); |
| 3697 EXPECT_EQ(2, handler->touch_pressed_count()); | 3695 EXPECT_EQ(2, handler->touch_pressed_count()); |
| 3698 delegate->Reset(); | 3696 delegate->Reset(); |
| 3699 handler->Reset(); | 3697 handler->Reset(); |
| 3700 | 3698 |
| 3701 ui::GestureRecognizer* gesture_recognizer = ui::GestureRecognizer::Get(); | 3699 ui::GestureRecognizer* gesture_recognizer = ui::GestureRecognizer::Get(); |
| 3702 EXPECT_EQ(window.get(), | 3700 EXPECT_EQ(window.get(), |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3723 | 3721 |
| 3724 delegate->Reset(); | 3722 delegate->Reset(); |
| 3725 | 3723 |
| 3726 TimerTestGestureRecognizer* gesture_recognizer = | 3724 TimerTestGestureRecognizer* gesture_recognizer = |
| 3727 new TimerTestGestureRecognizer(); | 3725 new TimerTestGestureRecognizer(); |
| 3728 | 3726 |
| 3729 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); | 3727 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); |
| 3730 | 3728 |
| 3731 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 3729 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 3732 kTouchId, tes.Now()); | 3730 kTouchId, tes.Now()); |
| 3733 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 3731 DispatchEventUsingWindowDispatcher(&press1); |
| 3734 EXPECT_TRUE(delegate->tap_down()); | 3732 EXPECT_TRUE(delegate->tap_down()); |
| 3735 EXPECT_TRUE(delegate->begin()); | 3733 EXPECT_TRUE(delegate->begin()); |
| 3736 EXPECT_FALSE(delegate->tap_cancel()); | 3734 EXPECT_FALSE(delegate->tap_cancel()); |
| 3737 | 3735 |
| 3738 // We haven't pressed long enough for a show press to occur | 3736 // We haven't pressed long enough for a show press to occur |
| 3739 EXPECT_FALSE(delegate->show_press()); | 3737 EXPECT_FALSE(delegate->show_press()); |
| 3740 | 3738 |
| 3741 // Wait until the timer runs out | 3739 // Wait until the timer runs out |
| 3742 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_SHOW_PRESS); | 3740 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_SHOW_PRESS); |
| 3743 EXPECT_TRUE(delegate->show_press()); | 3741 EXPECT_TRUE(delegate->show_press()); |
| 3744 EXPECT_FALSE(delegate->tap_cancel()); | 3742 EXPECT_FALSE(delegate->tap_cancel()); |
| 3745 | 3743 |
| 3746 delegate->Reset(); | 3744 delegate->Reset(); |
| 3747 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 3745 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 3748 kTouchId, tes.Now()); | 3746 kTouchId, tes.Now()); |
| 3749 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1); | 3747 DispatchEventUsingWindowDispatcher(&release1); |
| 3750 EXPECT_FALSE(delegate->long_press()); | 3748 EXPECT_FALSE(delegate->long_press()); |
| 3751 | 3749 |
| 3752 // Note the tap down isn't cancelled until the release | 3750 // Note the tap down isn't cancelled until the release |
| 3753 EXPECT_TRUE(delegate->tap_cancel()); | 3751 EXPECT_TRUE(delegate->tap_cancel()); |
| 3754 } | 3752 } |
| 3755 | 3753 |
| 3756 // Check that scrolling cancels a show press | 3754 // Check that scrolling cancels a show press |
| 3757 TEST_F(GestureRecognizerTest, GestureEventShowPressCancelledByScroll) { | 3755 TEST_F(GestureRecognizerTest, GestureEventShowPressCancelledByScroll) { |
| 3758 scoped_ptr<GestureEventConsumeDelegate> delegate( | 3756 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 3759 new GestureEventConsumeDelegate()); | 3757 new GestureEventConsumeDelegate()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3771 new TimerTestGestureRecognizer(); | 3769 new TimerTestGestureRecognizer(); |
| 3772 | 3770 |
| 3773 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); | 3771 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); |
| 3774 | 3772 |
| 3775 TimerTestGestureSequence* gesture_sequence = | 3773 TimerTestGestureSequence* gesture_sequence = |
| 3776 static_cast<TimerTestGestureSequence*>( | 3774 static_cast<TimerTestGestureSequence*>( |
| 3777 gesture_recognizer->GetGestureSequenceForTesting(window.get())); | 3775 gesture_recognizer->GetGestureSequenceForTesting(window.get())); |
| 3778 | 3776 |
| 3779 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 3777 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 3780 kTouchId, tes.Now()); | 3778 kTouchId, tes.Now()); |
| 3781 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 3779 DispatchEventUsingWindowDispatcher(&press1); |
| 3782 EXPECT_TRUE(delegate->tap_down()); | 3780 EXPECT_TRUE(delegate->tap_down()); |
| 3783 | 3781 |
| 3784 // We haven't pressed long enough for a show press to occur | 3782 // We haven't pressed long enough for a show press to occur |
| 3785 EXPECT_FALSE(delegate->show_press()); | 3783 EXPECT_FALSE(delegate->show_press()); |
| 3786 EXPECT_FALSE(delegate->tap_cancel()); | 3784 EXPECT_FALSE(delegate->tap_cancel()); |
| 3787 | 3785 |
| 3788 // Scroll around, to cancel the show press | 3786 // Scroll around, to cancel the show press |
| 3789 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get()); | 3787 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get()); |
| 3790 // Wait until the timer runs out | 3788 // Wait until the timer runs out |
| 3791 gesture_sequence->ForceTimeout(); | 3789 gesture_sequence->ForceTimeout(); |
| 3792 EXPECT_FALSE(delegate->show_press()); | 3790 EXPECT_FALSE(delegate->show_press()); |
| 3793 EXPECT_TRUE(delegate->tap_cancel()); | 3791 EXPECT_TRUE(delegate->tap_cancel()); |
| 3794 | 3792 |
| 3795 delegate->Reset(); | 3793 delegate->Reset(); |
| 3796 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 3794 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 3797 kTouchId, tes.LeapForward(10)); | 3795 kTouchId, tes.LeapForward(10)); |
| 3798 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1); | 3796 DispatchEventUsingWindowDispatcher(&release1); |
| 3799 EXPECT_FALSE(delegate->show_press()); | 3797 EXPECT_FALSE(delegate->show_press()); |
| 3800 EXPECT_FALSE(delegate->tap_cancel()); | 3798 EXPECT_FALSE(delegate->tap_cancel()); |
| 3801 } | 3799 } |
| 3802 | 3800 |
| 3803 // Test that show press events are sent immediately on tap | 3801 // Test that show press events are sent immediately on tap |
| 3804 TEST_F(GestureRecognizerTest, GestureEventShowPressSentOnTap) { | 3802 TEST_F(GestureRecognizerTest, GestureEventShowPressSentOnTap) { |
| 3805 scoped_ptr<GestureEventConsumeDelegate> delegate( | 3803 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 3806 new GestureEventConsumeDelegate()); | 3804 new GestureEventConsumeDelegate()); |
| 3807 TimedEvents tes; | 3805 TimedEvents tes; |
| 3808 const int kWindowWidth = 123; | 3806 const int kWindowWidth = 123; |
| 3809 const int kWindowHeight = 45; | 3807 const int kWindowHeight = 45; |
| 3810 const int kTouchId = 6; | 3808 const int kTouchId = 6; |
| 3811 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3809 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 3812 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3810 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3813 delegate.get(), -1234, bounds, root_window())); | 3811 delegate.get(), -1234, bounds, root_window())); |
| 3814 | 3812 |
| 3815 delegate->Reset(); | 3813 delegate->Reset(); |
| 3816 | 3814 |
| 3817 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 3815 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 3818 kTouchId, tes.Now()); | 3816 kTouchId, tes.Now()); |
| 3819 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 3817 DispatchEventUsingWindowDispatcher(&press1); |
| 3820 EXPECT_TRUE(delegate->tap_down()); | 3818 EXPECT_TRUE(delegate->tap_down()); |
| 3821 | 3819 |
| 3822 // We haven't pressed long enough for a show press to occur | 3820 // We haven't pressed long enough for a show press to occur |
| 3823 EXPECT_FALSE(delegate->show_press()); | 3821 EXPECT_FALSE(delegate->show_press()); |
| 3824 EXPECT_FALSE(delegate->tap_cancel()); | 3822 EXPECT_FALSE(delegate->tap_cancel()); |
| 3825 | 3823 |
| 3826 delegate->Reset(); | 3824 delegate->Reset(); |
| 3827 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 3825 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 3828 kTouchId, tes.LeapForward(50)); | 3826 kTouchId, tes.LeapForward(50)); |
| 3829 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1); | 3827 DispatchEventUsingWindowDispatcher(&release1); |
| 3830 EXPECT_TRUE(delegate->show_press()); | 3828 EXPECT_TRUE(delegate->show_press()); |
| 3831 EXPECT_FALSE(delegate->tap_cancel()); | 3829 EXPECT_FALSE(delegate->tap_cancel()); |
| 3832 EXPECT_TRUE(delegate->tap()); | 3830 EXPECT_TRUE(delegate->tap()); |
| 3833 } | 3831 } |
| 3834 | 3832 |
| 3835 // Test that consuming the first move touch event prevents a scroll. | 3833 // Test that consuming the first move touch event prevents a scroll. |
| 3836 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveScrollTest) { | 3834 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveScrollTest) { |
| 3837 scoped_ptr<QueueTouchEventDelegate> delegate( | 3835 scoped_ptr<QueueTouchEventDelegate> delegate( |
| 3838 new QueueTouchEventDelegate(dispatcher())); | 3836 new QueueTouchEventDelegate(dispatcher())); |
| 3839 TimedEvents tes; | 3837 TimedEvents tes; |
| 3840 const int kTouchId = 7; | 3838 const int kTouchId = 7; |
| 3841 gfx::Rect bounds(0, 0, 1000, 1000); | 3839 gfx::Rect bounds(0, 0, 1000, 1000); |
| 3842 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3840 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3843 delegate.get(), -1234, bounds, root_window())); | 3841 delegate.get(), -1234, bounds, root_window())); |
| 3844 | 3842 |
| 3845 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), | 3843 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), |
| 3846 kTouchId, tes.Now()); | 3844 kTouchId, tes.Now()); |
| 3847 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 3845 DispatchEventUsingWindowDispatcher(&press); |
| 3848 delegate->ReceivedAck(); | 3846 delegate->ReceivedAck(); |
| 3849 | 3847 |
| 3850 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(2, 2), | 3848 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(2, 2), |
| 3851 kTouchId, tes.Now()); | 3849 kTouchId, tes.Now()); |
| 3852 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move1); | 3850 DispatchEventUsingWindowDispatcher(&move1); |
| 3853 delegate->ReceivedAckPreventDefaulted(); | 3851 delegate->ReceivedAckPreventDefaulted(); |
| 3854 | 3852 |
| 3855 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), | 3853 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), |
| 3856 kTouchId, tes.Now()); | 3854 kTouchId, tes.Now()); |
| 3857 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move2); | 3855 DispatchEventUsingWindowDispatcher(&move2); |
| 3858 delegate->ReceivedAck(); | 3856 delegate->ReceivedAck(); |
| 3859 | 3857 |
| 3860 EXPECT_FALSE(delegate->scroll_begin()); | 3858 EXPECT_FALSE(delegate->scroll_begin()); |
| 3861 EXPECT_FALSE(delegate->scroll_update()); | 3859 EXPECT_FALSE(delegate->scroll_update()); |
| 3862 } | 3860 } |
| 3863 | 3861 |
| 3864 // Test that consuming the first touch move event of a touch point doesn't | 3862 // Test that consuming the first touch move event of a touch point doesn't |
| 3865 // prevent pinching once an additional touch has been pressed. | 3863 // prevent pinching once an additional touch has been pressed. |
| 3866 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMovePinchTest) { | 3864 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMovePinchTest) { |
| 3867 scoped_ptr<QueueTouchEventDelegate> delegate( | 3865 scoped_ptr<QueueTouchEventDelegate> delegate( |
| 3868 new QueueTouchEventDelegate(dispatcher())); | 3866 new QueueTouchEventDelegate(dispatcher())); |
| 3869 TimedEvents tes; | 3867 TimedEvents tes; |
| 3870 const int kTouchId1 = 7; | 3868 const int kTouchId1 = 7; |
| 3871 const int kTouchId2 = 4; | 3869 const int kTouchId2 = 4; |
| 3872 gfx::Rect bounds(0, 0, 1000, 1000); | 3870 gfx::Rect bounds(0, 0, 1000, 1000); |
| 3873 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3871 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3874 delegate.get(), -1234, bounds, root_window())); | 3872 delegate.get(), -1234, bounds, root_window())); |
| 3875 | 3873 |
| 3876 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), | 3874 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), |
| 3877 kTouchId1, tes.Now()); | 3875 kTouchId1, tes.Now()); |
| 3878 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 3876 DispatchEventUsingWindowDispatcher(&press1); |
| 3879 delegate->ReceivedAck(); | 3877 delegate->ReceivedAck(); |
| 3880 | 3878 |
| 3881 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(2, 2), | 3879 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(2, 2), |
| 3882 kTouchId1, tes.Now()); | 3880 kTouchId1, tes.Now()); |
| 3883 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move1); | 3881 DispatchEventUsingWindowDispatcher(&move1); |
| 3884 delegate->ReceivedAckPreventDefaulted(); | 3882 delegate->ReceivedAckPreventDefaulted(); |
| 3885 | 3883 |
| 3886 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), | 3884 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), |
| 3887 kTouchId1, tes.Now()); | 3885 kTouchId1, tes.Now()); |
| 3888 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move2); | 3886 DispatchEventUsingWindowDispatcher(&move2); |
| 3889 delegate->ReceivedAck(); | 3887 delegate->ReceivedAck(); |
| 3890 | 3888 |
| 3891 // We can't scroll, because a move has been consumed. | 3889 // We can't scroll, because a move has been consumed. |
| 3892 EXPECT_FALSE(delegate->scroll_begin()); | 3890 EXPECT_FALSE(delegate->scroll_begin()); |
| 3893 EXPECT_FALSE(delegate->scroll_update()); | 3891 EXPECT_FALSE(delegate->scroll_update()); |
| 3894 EXPECT_FALSE(delegate->pinch_begin()); | 3892 EXPECT_FALSE(delegate->pinch_begin()); |
| 3895 | 3893 |
| 3896 // An additional press will allow us to pinch. | 3894 // An additional press will allow us to pinch. |
| 3897 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), | 3895 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), |
| 3898 kTouchId2, tes.Now()); | 3896 kTouchId2, tes.Now()); |
| 3899 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2); | 3897 DispatchEventUsingWindowDispatcher(&press2); |
| 3900 delegate->ReceivedAck(); | 3898 delegate->ReceivedAck(); |
| 3901 | 3899 |
| 3902 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), | 3900 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), |
| 3903 kTouchId2, tes.Now()); | 3901 kTouchId2, tes.Now()); |
| 3904 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move3); | 3902 DispatchEventUsingWindowDispatcher(&move3); |
| 3905 delegate->ReceivedAck(); | 3903 delegate->ReceivedAck(); |
| 3906 | 3904 |
| 3907 EXPECT_TRUE(delegate->pinch_begin()); | 3905 EXPECT_TRUE(delegate->pinch_begin()); |
| 3908 EXPECT_FALSE(delegate->pinch_update()); | 3906 EXPECT_FALSE(delegate->pinch_update()); |
| 3909 | 3907 |
| 3910 delegate->Reset(); | 3908 delegate->Reset(); |
| 3911 | 3909 |
| 3912 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(40, 40), | 3910 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(40, 40), |
| 3913 kTouchId2, tes.Now()); | 3911 kTouchId2, tes.Now()); |
| 3914 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move4); | 3912 DispatchEventUsingWindowDispatcher(&move4); |
| 3915 delegate->ReceivedAck(); | 3913 delegate->ReceivedAck(); |
| 3916 | 3914 |
| 3917 EXPECT_TRUE(delegate->pinch_update()); | 3915 EXPECT_TRUE(delegate->pinch_update()); |
| 3918 EXPECT_EQ(10, delegate->scroll_x()); | 3916 EXPECT_EQ(10, delegate->scroll_x()); |
| 3919 EXPECT_EQ(10, delegate->scroll_y()); | 3917 EXPECT_EQ(10, delegate->scroll_y()); |
| 3920 } | 3918 } |
| 3921 | 3919 |
| 3922 // Test that consuming the first move touch doesn't prevent a tap. | 3920 // Test that consuming the first move touch doesn't prevent a tap. |
| 3923 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveTapTest) { | 3921 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveTapTest) { |
| 3924 scoped_ptr<QueueTouchEventDelegate> delegate( | 3922 scoped_ptr<QueueTouchEventDelegate> delegate( |
| 3925 new QueueTouchEventDelegate(dispatcher())); | 3923 new QueueTouchEventDelegate(dispatcher())); |
| 3926 TimedEvents tes; | 3924 TimedEvents tes; |
| 3927 const int kTouchId = 7; | 3925 const int kTouchId = 7; |
| 3928 gfx::Rect bounds(0, 0, 1000, 1000); | 3926 gfx::Rect bounds(0, 0, 1000, 1000); |
| 3929 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3927 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3930 delegate.get(), -1234, bounds, root_window())); | 3928 delegate.get(), -1234, bounds, root_window())); |
| 3931 | 3929 |
| 3932 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), | 3930 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), |
| 3933 kTouchId, tes.Now()); | 3931 kTouchId, tes.Now()); |
| 3934 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 3932 DispatchEventUsingWindowDispatcher(&press); |
| 3935 delegate->ReceivedAck(); | 3933 delegate->ReceivedAck(); |
| 3936 | 3934 |
| 3937 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(2, 2), | 3935 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(2, 2), |
| 3938 kTouchId, tes.Now()); | 3936 kTouchId, tes.Now()); |
| 3939 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move); | 3937 DispatchEventUsingWindowDispatcher(&move); |
| 3940 delegate->ReceivedAckPreventDefaulted(); | 3938 delegate->ReceivedAckPreventDefaulted(); |
| 3941 | 3939 |
| 3942 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(2, 2), | 3940 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(2, 2), |
| 3943 kTouchId, tes.LeapForward(50)); | 3941 kTouchId, tes.LeapForward(50)); |
| 3944 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 3942 DispatchEventUsingWindowDispatcher(&release); |
| 3945 delegate->ReceivedAck(); | 3943 delegate->ReceivedAck(); |
| 3946 | 3944 |
| 3947 EXPECT_TRUE(delegate->tap()); | 3945 EXPECT_TRUE(delegate->tap()); |
| 3948 } | 3946 } |
| 3949 | 3947 |
| 3950 // Test that consuming the first move touch doesn't prevent a long press. | 3948 // Test that consuming the first move touch doesn't prevent a long press. |
| 3951 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveLongPressTest) { | 3949 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveLongPressTest) { |
| 3952 scoped_ptr<QueueTouchEventDelegate> delegate( | 3950 scoped_ptr<QueueTouchEventDelegate> delegate( |
| 3953 new QueueTouchEventDelegate(dispatcher())); | 3951 new QueueTouchEventDelegate(dispatcher())); |
| 3954 TimedEvents tes; | 3952 TimedEvents tes; |
| 3955 const int kWindowWidth = 123; | 3953 const int kWindowWidth = 123; |
| 3956 const int kWindowHeight = 45; | 3954 const int kWindowHeight = 45; |
| 3957 const int kTouchId = 2; | 3955 const int kTouchId = 2; |
| 3958 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3956 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 3959 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3957 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3960 delegate.get(), -1234, bounds, root_window())); | 3958 delegate.get(), -1234, bounds, root_window())); |
| 3961 | 3959 |
| 3962 delegate->Reset(); | 3960 delegate->Reset(); |
| 3963 | 3961 |
| 3964 TimerTestGestureRecognizer* gesture_recognizer = | 3962 TimerTestGestureRecognizer* gesture_recognizer = |
| 3965 new TimerTestGestureRecognizer(); | 3963 new TimerTestGestureRecognizer(); |
| 3966 | 3964 |
| 3967 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); | 3965 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); |
| 3968 | 3966 |
| 3969 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 3967 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 3970 kTouchId, tes.Now()); | 3968 kTouchId, tes.Now()); |
| 3971 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | 3969 DispatchEventUsingWindowDispatcher(&press1); |
| 3972 delegate->ReceivedAck(); | 3970 delegate->ReceivedAck(); |
| 3973 | 3971 |
| 3974 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(103, 203), | 3972 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(103, 203), |
| 3975 kTouchId, tes.Now()); | 3973 kTouchId, tes.Now()); |
| 3976 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move); | 3974 DispatchEventUsingWindowDispatcher(&move); |
| 3977 delegate->ReceivedAckPreventDefaulted(); | 3975 delegate->ReceivedAckPreventDefaulted(); |
| 3978 | 3976 |
| 3979 // Wait until the timer runs out | 3977 // Wait until the timer runs out |
| 3980 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS); | 3978 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS); |
| 3981 EXPECT_TRUE(delegate->long_press()); | 3979 EXPECT_TRUE(delegate->long_press()); |
| 3982 } | 3980 } |
| 3983 | 3981 |
| 3984 // Tests that the deltas are correct when leaving the slop region very slowly. | 3982 // Tests that the deltas are correct when leaving the slop region very slowly. |
| 3985 TEST_F(GestureRecognizerTest, TestExceedingSlopSlowly) { | 3983 TEST_F(GestureRecognizerTest, TestExceedingSlopSlowly) { |
| 3986 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(3); | 3984 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(3); |
| 3987 scoped_ptr<GestureEventConsumeDelegate> delegate( | 3985 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 3988 new GestureEventConsumeDelegate()); | 3986 new GestureEventConsumeDelegate()); |
| 3989 const int kWindowWidth = 234; | 3987 const int kWindowWidth = 234; |
| 3990 const int kWindowHeight = 345; | 3988 const int kWindowHeight = 345; |
| 3991 const int kTouchId = 5; | 3989 const int kTouchId = 5; |
| 3992 TimedEvents tes; | 3990 TimedEvents tes; |
| 3993 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); | 3991 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); |
| 3994 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3992 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3995 delegate.get(), -1234, bounds, root_window())); | 3993 delegate.get(), -1234, bounds, root_window())); |
| 3996 | 3994 |
| 3997 ui::TouchEvent press( | 3995 ui::TouchEvent press( |
| 3998 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), kTouchId, tes.Now()); | 3996 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), kTouchId, tes.Now()); |
| 3999 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 3997 DispatchEventUsingWindowDispatcher(&press); |
| 4000 EXPECT_FALSE(delegate->scroll_begin()); | 3998 EXPECT_FALSE(delegate->scroll_begin()); |
| 4001 EXPECT_FALSE(delegate->scroll_update()); | 3999 EXPECT_FALSE(delegate->scroll_update()); |
| 4002 delegate->Reset(); | 4000 delegate->Reset(); |
| 4003 | 4001 |
| 4004 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(11, 10), kTouchId, | 4002 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(11, 10), kTouchId, |
| 4005 tes.LeapForward(40)); | 4003 tes.LeapForward(40)); |
| 4006 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move1); | 4004 DispatchEventUsingWindowDispatcher(&move1); |
| 4007 EXPECT_FALSE(delegate->scroll_begin()); | 4005 EXPECT_FALSE(delegate->scroll_begin()); |
| 4008 EXPECT_FALSE(delegate->scroll_update()); | 4006 EXPECT_FALSE(delegate->scroll_update()); |
| 4009 EXPECT_EQ(0, delegate->scroll_x()); | 4007 EXPECT_EQ(0, delegate->scroll_x()); |
| 4010 EXPECT_EQ(0, delegate->scroll_x_hint()); | 4008 EXPECT_EQ(0, delegate->scroll_x_hint()); |
| 4011 delegate->Reset(); | 4009 delegate->Reset(); |
| 4012 | 4010 |
| 4013 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(12, 10), kTouchId, | 4011 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(12, 10), kTouchId, |
| 4014 tes.LeapForward(40)); | 4012 tes.LeapForward(40)); |
| 4015 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move2); | 4013 DispatchEventUsingWindowDispatcher(&move2); |
| 4016 EXPECT_FALSE(delegate->scroll_begin()); | 4014 EXPECT_FALSE(delegate->scroll_begin()); |
| 4017 EXPECT_FALSE(delegate->scroll_update()); | 4015 EXPECT_FALSE(delegate->scroll_update()); |
| 4018 EXPECT_EQ(0, delegate->scroll_x()); | 4016 EXPECT_EQ(0, delegate->scroll_x()); |
| 4019 EXPECT_EQ(0, delegate->scroll_x_hint()); | 4017 EXPECT_EQ(0, delegate->scroll_x_hint()); |
| 4020 delegate->Reset(); | 4018 delegate->Reset(); |
| 4021 | 4019 |
| 4022 | 4020 |
| 4023 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(13, 10), kTouchId, | 4021 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(13, 10), kTouchId, |
| 4024 tes.LeapForward(40)); | 4022 tes.LeapForward(40)); |
| 4025 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move3); | 4023 DispatchEventUsingWindowDispatcher(&move3); |
| 4026 EXPECT_TRUE(delegate->scroll_begin()); | 4024 EXPECT_TRUE(delegate->scroll_begin()); |
| 4027 EXPECT_FALSE(delegate->scroll_update()); | 4025 EXPECT_FALSE(delegate->scroll_update()); |
| 4028 EXPECT_EQ(0, delegate->scroll_x()); | 4026 EXPECT_EQ(0, delegate->scroll_x()); |
| 4029 EXPECT_EQ(3, delegate->scroll_x_hint()); | 4027 EXPECT_EQ(3, delegate->scroll_x_hint()); |
| 4030 delegate->Reset(); | 4028 delegate->Reset(); |
| 4031 | 4029 |
| 4032 | 4030 |
| 4033 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(14, 10), kTouchId, | 4031 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(14, 10), kTouchId, |
| 4034 tes.LeapForward(40)); | 4032 tes.LeapForward(40)); |
| 4035 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move4); | 4033 DispatchEventUsingWindowDispatcher(&move4); |
| 4036 EXPECT_FALSE(delegate->scroll_begin()); | 4034 EXPECT_FALSE(delegate->scroll_begin()); |
| 4037 EXPECT_TRUE(delegate->scroll_update()); | 4035 EXPECT_TRUE(delegate->scroll_update()); |
| 4038 EXPECT_EQ(1, delegate->scroll_x()); | 4036 EXPECT_EQ(1, delegate->scroll_x()); |
| 4039 EXPECT_EQ(0, delegate->scroll_x_hint()); | 4037 EXPECT_EQ(0, delegate->scroll_x_hint()); |
| 4040 delegate->Reset(); | 4038 delegate->Reset(); |
| 4041 | 4039 |
| 4042 } | 4040 } |
| 4043 | 4041 |
| 4044 } // namespace test | 4042 } // namespace test |
| 4045 } // namespace aura | 4043 } // namespace aura |
| OLD | NEW |