| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 124 |
| 125 const GestureEventData* GetActiveScrollBeginEvent() const { | 125 const GestureEventData* GetActiveScrollBeginEvent() const { |
| 126 return active_scroll_begin_event_ ? active_scroll_begin_event_.get() : NULL; | 126 return active_scroll_begin_event_ ? active_scroll_begin_event_.get() : NULL; |
| 127 } | 127 } |
| 128 | 128 |
| 129 const GestureProvider::Config& GetDefaultConfig() const { | 129 const GestureProvider::Config& GetDefaultConfig() const { |
| 130 static GestureProvider::Config sConfig = CreateDefaultConfig(); | 130 static GestureProvider::Config sConfig = CreateDefaultConfig(); |
| 131 return sConfig; | 131 return sConfig; |
| 132 } | 132 } |
| 133 | 133 |
| 134 int GetTouchSlop() const { | 134 float GetTouchSlop() const { |
| 135 return GetDefaultConfig().gesture_detector_config.scaled_touch_slop; | 135 return GetDefaultConfig().gesture_detector_config.touch_slop; |
| 136 } | 136 } |
| 137 | 137 |
| 138 base::TimeDelta GetLongPressTimeout() const { | 138 base::TimeDelta GetLongPressTimeout() const { |
| 139 return GetDefaultConfig().gesture_detector_config.longpress_timeout; | 139 return GetDefaultConfig().gesture_detector_config.longpress_timeout; |
| 140 } | 140 } |
| 141 | 141 |
| 142 base::TimeDelta GetShowPressTimeout() const { | 142 base::TimeDelta GetShowPressTimeout() const { |
| 143 return GetDefaultConfig().gesture_detector_config.showpress_timeout; | 143 return GetDefaultConfig().gesture_detector_config.showpress_timeout; |
| 144 } | 144 } |
| 145 | 145 |
| 146 void SetBeginEndTypesEnabled(bool enabled) { | 146 void SetBeginEndTypesEnabled(bool enabled) { |
| 147 GestureProvider::Config config = GetDefaultConfig(); | 147 GestureProvider::Config config = GetDefaultConfig(); |
| 148 config.gesture_begin_end_types_enabled = true; | 148 config.gesture_begin_end_types_enabled = true; |
| 149 gesture_provider_.reset(new GestureProvider(config, this)); | 149 gesture_provider_.reset(new GestureProvider(config, this)); |
| 150 gesture_provider_->SetMultiTouchSupportEnabled(false); | 150 gesture_provider_->SetMultiTouchSupportEnabled(false); |
| 151 } | 151 } |
| 152 | 152 |
| 153 bool HasDownEvent() const { return gesture_provider_->current_down_event(); } | 153 bool HasDownEvent() const { return gesture_provider_->current_down_event(); } |
| 154 | 154 |
| 155 protected: | 155 protected: |
| 156 void CheckScrollEventSequenceForEndActionType( | 156 void CheckScrollEventSequenceForEndActionType( |
| 157 MotionEvent::Action end_action_type) { | 157 MotionEvent::Action end_action_type) { |
| 158 base::TimeTicks event_time = base::TimeTicks::Now(); | 158 base::TimeTicks event_time = base::TimeTicks::Now(); |
| 159 const int scroll_to_x = kFakeCoordX + 100; | 159 const float scroll_to_x = kFakeCoordX + 100; |
| 160 const int scroll_to_y = kFakeCoordY + 100; | 160 const float scroll_to_y = kFakeCoordY + 100; |
| 161 int motion_event_id = 0; | 161 int motion_event_id = 0; |
| 162 | 162 |
| 163 MockMotionEvent event = | 163 MockMotionEvent event = |
| 164 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); | 164 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); |
| 165 event.SetId(++motion_event_id); | 165 event.SetId(++motion_event_id); |
| 166 | 166 |
| 167 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 167 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 168 | 168 |
| 169 event = ObtainMotionEvent(event_time + kOneSecond, | 169 event = ObtainMotionEvent(event_time + kOneSecond, |
| 170 MotionEvent::ACTION_MOVE, | 170 MotionEvent::ACTION_MOVE, |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 kFakeCoordX, | 526 kFakeCoordX, |
| 527 kFakeCoordY - 200); | 527 kFakeCoordY - 200); |
| 528 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 528 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 529 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_PINCH_END)); | 529 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_PINCH_END)); |
| 530 EXPECT_EQ(ET_GESTURE_SCROLL_END, GetMostRecentGestureEventType()); | 530 EXPECT_EQ(ET_GESTURE_SCROLL_END, GetMostRecentGestureEventType()); |
| 531 } | 531 } |
| 532 | 532 |
| 533 // Generate a scroll gesture and verify that the resulting scroll motion event | 533 // Generate a scroll gesture and verify that the resulting scroll motion event |
| 534 // has both absolute and relative position information. | 534 // has both absolute and relative position information. |
| 535 TEST_F(GestureProviderTest, ScrollUpdateValues) { | 535 TEST_F(GestureProviderTest, ScrollUpdateValues) { |
| 536 const int delta_x = 16; | 536 const float delta_x = 16; |
| 537 const int delta_y = 84; | 537 const float delta_y = 84; |
| 538 | 538 |
| 539 const base::TimeTicks event_time = TimeTicks::Now(); | 539 const base::TimeTicks event_time = TimeTicks::Now(); |
| 540 | 540 |
| 541 MockMotionEvent event = | 541 MockMotionEvent event = |
| 542 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); | 542 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); |
| 543 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 543 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 544 | 544 |
| 545 // Move twice so that we get two ET_GESTURE_SCROLL_UPDATE events and can | 545 // Move twice so that we get two ET_GESTURE_SCROLL_UPDATE events and can |
| 546 // compare the relative and absolute coordinates. | 546 // compare the relative and absolute coordinates. |
| 547 event = ObtainMotionEvent(event_time + kOneMicrosecond, | 547 event = ObtainMotionEvent(event_time + kOneMicrosecond, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 EXPECT_LE(gesture.details.scroll_y(), ((int)delta_y) + 1); | 618 EXPECT_LE(gesture.details.scroll_y(), ((int)delta_y) + 1); |
| 619 | 619 |
| 620 // And that there has been no horizontal motion at all. | 620 // And that there has been no horizontal motion at all. |
| 621 EXPECT_EQ(0, gesture.details.scroll_x()); | 621 EXPECT_EQ(0, gesture.details.scroll_x()); |
| 622 } | 622 } |
| 623 } | 623 } |
| 624 | 624 |
| 625 // Generate a scroll gesture and verify that the resulting scroll begin event | 625 // Generate a scroll gesture and verify that the resulting scroll begin event |
| 626 // has the expected hint values. | 626 // has the expected hint values. |
| 627 TEST_F(GestureProviderTest, ScrollBeginValues) { | 627 TEST_F(GestureProviderTest, ScrollBeginValues) { |
| 628 const int delta_x = 13; | 628 const float delta_x = 13; |
| 629 const int delta_y = 89; | 629 const float delta_y = 89; |
| 630 | 630 |
| 631 const base::TimeTicks event_time = TimeTicks::Now(); | 631 const base::TimeTicks event_time = TimeTicks::Now(); |
| 632 | 632 |
| 633 MockMotionEvent event = | 633 MockMotionEvent event = |
| 634 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); | 634 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); |
| 635 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 635 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 636 | 636 |
| 637 // Move twice such that the first event isn't sufficient to start | 637 // Move twice such that the first event isn't sufficient to start |
| 638 // scrolling on it's own. | 638 // scrolling on it's own. |
| 639 event = ObtainMotionEvent(event_time + kOneMicrosecond, | 639 event = ObtainMotionEvent(event_time + kOneMicrosecond, |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 782 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 783 EXPECT_EQ(ET_GESTURE_SCROLL_END, GetMostRecentGestureEventType()); | 783 EXPECT_EQ(ET_GESTURE_SCROLL_END, GetMostRecentGestureEventType()); |
| 784 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); | 784 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); |
| 785 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 785 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); |
| 786 EXPECT_FALSE(gesture_provider_->IsDoubleTapInProgress()); | 786 EXPECT_FALSE(gesture_provider_->IsDoubleTapInProgress()); |
| 787 } | 787 } |
| 788 | 788 |
| 789 // Verify that the touch slop region is removed from the first scroll delta to | 789 // Verify that the touch slop region is removed from the first scroll delta to |
| 790 // avoid a jump when starting to scroll. | 790 // avoid a jump when starting to scroll. |
| 791 TEST_F(GestureProviderTest, TouchSlopRemovedFromScroll) { | 791 TEST_F(GestureProviderTest, TouchSlopRemovedFromScroll) { |
| 792 const int scaled_touch_slop = GetTouchSlop(); | 792 const float touch_slop = GetTouchSlop(); |
| 793 const int scroll_delta = 5; | 793 const float scroll_delta = 5; |
| 794 | 794 |
| 795 base::TimeTicks event_time = base::TimeTicks::Now(); | 795 base::TimeTicks event_time = base::TimeTicks::Now(); |
| 796 | 796 |
| 797 MockMotionEvent event = | 797 MockMotionEvent event = |
| 798 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); | 798 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); |
| 799 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 799 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 800 | 800 |
| 801 event = ObtainMotionEvent(event_time + kOneMicrosecond * 2, | 801 event = ObtainMotionEvent(event_time + kOneMicrosecond * 2, |
| 802 MotionEvent::ACTION_MOVE, | 802 MotionEvent::ACTION_MOVE, |
| 803 kFakeCoordX, | 803 kFakeCoordX, |
| 804 kFakeCoordY + scaled_touch_slop + scroll_delta); | 804 kFakeCoordY + touch_slop + scroll_delta); |
| 805 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 805 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 806 | 806 |
| 807 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetMostRecentGestureEventType()); | 807 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetMostRecentGestureEventType()); |
| 808 GestureEventData gesture = GetMostRecentGestureEvent(); | 808 GestureEventData gesture = GetMostRecentGestureEvent(); |
| 809 EXPECT_EQ(0, gesture.details.scroll_x()); | 809 EXPECT_EQ(0, gesture.details.scroll_x()); |
| 810 EXPECT_EQ(scroll_delta, gesture.details.scroll_y()); | 810 EXPECT_EQ(scroll_delta, gesture.details.scroll_y()); |
| 811 EXPECT_EQ(1, gesture.details.touch_points()); | 811 EXPECT_EQ(1, gesture.details.touch_points()); |
| 812 } | 812 } |
| 813 | 813 |
| 814 // Verify that movement within the touch slop region does not generate a scroll, |
| 815 // and that the slop region is correct even when using fractional coordinates. |
| 816 TEST_F(GestureProviderTest, NoScrollWithinTouchSlop) { |
| 817 const float touch_slop = GetTouchSlop(); |
| 818 const float scale_factor = 2.5f; |
| 819 const int touch_slop_pixels = static_cast<int>(scale_factor * touch_slop); |
| 820 |
| 821 base::TimeTicks event_time = base::TimeTicks::Now(); |
| 822 |
| 823 MockMotionEvent event = |
| 824 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); |
| 825 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 826 |
| 827 event = ObtainMotionEvent(event_time + kOneMicrosecond * 2, |
| 828 MotionEvent::ACTION_MOVE, |
| 829 kFakeCoordX + touch_slop_pixels / scale_factor, |
| 830 kFakeCoordY); |
| 831 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 832 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN)); |
| 833 |
| 834 event = ObtainMotionEvent(event_time + kOneMicrosecond * 2, |
| 835 MotionEvent::ACTION_MOVE, |
| 836 kFakeCoordX, |
| 837 kFakeCoordY + touch_slop_pixels / scale_factor); |
| 838 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 839 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN)); |
| 840 |
| 841 event = ObtainMotionEvent(event_time + kOneMicrosecond * 2, |
| 842 MotionEvent::ACTION_MOVE, |
| 843 kFakeCoordX - touch_slop_pixels / scale_factor, |
| 844 kFakeCoordY); |
| 845 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 846 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN)); |
| 847 |
| 848 event = ObtainMotionEvent(event_time + kOneMicrosecond * 2, |
| 849 MotionEvent::ACTION_MOVE, |
| 850 kFakeCoordX, |
| 851 kFakeCoordY - touch_slop_pixels / scale_factor); |
| 852 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 853 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN)); |
| 854 |
| 855 event = |
| 856 ObtainMotionEvent(event_time + kOneMicrosecond * 2, |
| 857 MotionEvent::ACTION_MOVE, |
| 858 kFakeCoordX, |
| 859 kFakeCoordY + (touch_slop_pixels + 1.f) / scale_factor); |
| 860 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 861 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN)); |
| 862 } |
| 863 |
| 814 TEST_F(GestureProviderTest, NoDoubleTapWhenExplicitlyDisabled) { | 864 TEST_F(GestureProviderTest, NoDoubleTapWhenExplicitlyDisabled) { |
| 815 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(false); | 865 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(false); |
| 816 | 866 |
| 817 base::TimeTicks event_time = base::TimeTicks::Now(); | 867 base::TimeTicks event_time = base::TimeTicks::Now(); |
| 818 MockMotionEvent event = ObtainMotionEvent( | 868 MockMotionEvent event = ObtainMotionEvent( |
| 819 event_time, MotionEvent::ACTION_DOWN, kFakeCoordX, kFakeCoordY); | 869 event_time, MotionEvent::ACTION_DOWN, kFakeCoordX, kFakeCoordY); |
| 820 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 870 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 821 EXPECT_EQ(1U, GetReceivedGestureCount()); | 871 EXPECT_EQ(1U, GetReceivedGestureCount()); |
| 822 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); | 872 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); |
| 823 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 873 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1036 MotionEvent::ACTION_UP, | 1086 MotionEvent::ACTION_UP, |
| 1037 kFakeCoordX, | 1087 kFakeCoordX, |
| 1038 kFakeCoordY + 200); | 1088 kFakeCoordY + 200); |
| 1039 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1089 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1040 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_PINCH_END)); | 1090 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_PINCH_END)); |
| 1041 } | 1091 } |
| 1042 | 1092 |
| 1043 // Verify that pinch zoom sends the proper event sequence. | 1093 // Verify that pinch zoom sends the proper event sequence. |
| 1044 TEST_F(GestureProviderTest, PinchZoom) { | 1094 TEST_F(GestureProviderTest, PinchZoom) { |
| 1045 base::TimeTicks event_time = base::TimeTicks::Now(); | 1095 base::TimeTicks event_time = base::TimeTicks::Now(); |
| 1046 const int scaled_touch_slop = GetTouchSlop(); | 1096 const float touch_slop = GetTouchSlop(); |
| 1047 int motion_event_id = 0; | 1097 int motion_event_id = 0; |
| 1048 | 1098 |
| 1049 gesture_provider_->SetDoubleTapSupportForPageEnabled(false); | 1099 gesture_provider_->SetDoubleTapSupportForPageEnabled(false); |
| 1050 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(true); | 1100 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(true); |
| 1051 gesture_provider_->SetMultiTouchSupportEnabled(true); | 1101 gesture_provider_->SetMultiTouchSupportEnabled(true); |
| 1052 | 1102 |
| 1053 int secondary_coord_x = kFakeCoordX + 20 * scaled_touch_slop; | 1103 int secondary_coord_x = kFakeCoordX + 20 * touch_slop; |
| 1054 int secondary_coord_y = kFakeCoordY + 20 * scaled_touch_slop; | 1104 int secondary_coord_y = kFakeCoordY + 20 * touch_slop; |
| 1055 | 1105 |
| 1056 MockMotionEvent event = | 1106 MockMotionEvent event = |
| 1057 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); | 1107 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); |
| 1058 event.SetId(++motion_event_id); | 1108 event.SetId(++motion_event_id); |
| 1059 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1109 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1060 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); | 1110 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); |
| 1061 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 1111 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); |
| 1062 | 1112 |
| 1063 // Toggling double-tap support should not take effect until the next sequence. | 1113 // Toggling double-tap support should not take effect until the next sequence. |
| 1064 gesture_provider_->SetDoubleTapSupportForPageEnabled(true); | 1114 gesture_provider_->SetDoubleTapSupportForPageEnabled(true); |
| 1065 | 1115 |
| 1066 event = ObtainMotionEvent(event_time, | 1116 event = ObtainMotionEvent(event_time, |
| 1067 MotionEvent::ACTION_POINTER_DOWN, | 1117 MotionEvent::ACTION_POINTER_DOWN, |
| 1068 kFakeCoordX, | 1118 kFakeCoordX, |
| 1069 kFakeCoordY, | 1119 kFakeCoordY, |
| 1070 secondary_coord_x, | 1120 secondary_coord_x, |
| 1071 secondary_coord_y); | 1121 secondary_coord_y); |
| 1072 event.SetId(++motion_event_id); | 1122 event.SetId(++motion_event_id); |
| 1073 | 1123 |
| 1074 gesture_provider_->OnTouchEvent(event); | 1124 gesture_provider_->OnTouchEvent(event); |
| 1075 EXPECT_EQ(1U, GetReceivedGestureCount()); | 1125 EXPECT_EQ(1U, GetReceivedGestureCount()); |
| 1076 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 1126 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); |
| 1077 | 1127 |
| 1078 secondary_coord_x += 5 * scaled_touch_slop; | 1128 secondary_coord_x += 5 * touch_slop; |
| 1079 secondary_coord_y += 5 * scaled_touch_slop; | 1129 secondary_coord_y += 5 * touch_slop; |
| 1080 event = ObtainMotionEvent(event_time, | 1130 event = ObtainMotionEvent(event_time, |
| 1081 MotionEvent::ACTION_MOVE, | 1131 MotionEvent::ACTION_MOVE, |
| 1082 kFakeCoordX, | 1132 kFakeCoordX, |
| 1083 kFakeCoordY, | 1133 kFakeCoordY, |
| 1084 secondary_coord_x, | 1134 secondary_coord_x, |
| 1085 secondary_coord_y); | 1135 secondary_coord_y); |
| 1086 event.SetId(++motion_event_id); | 1136 event.SetId(++motion_event_id); |
| 1087 | 1137 |
| 1088 // Toggling double-tap support should not take effect until the next sequence. | 1138 // Toggling double-tap support should not take effect until the next sequence. |
| 1089 gesture_provider_->SetDoubleTapSupportForPageEnabled(false); | 1139 gesture_provider_->SetDoubleTapSupportForPageEnabled(false); |
| 1090 | 1140 |
| 1091 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1141 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1092 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); | 1142 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); |
| 1093 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); | 1143 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); |
| 1094 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_PINCH_BEGIN)); | 1144 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_PINCH_BEGIN)); |
| 1095 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN)); | 1145 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN)); |
| 1096 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_UPDATE)); | 1146 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_UPDATE)); |
| 1097 | 1147 |
| 1098 secondary_coord_x += 2 * scaled_touch_slop; | 1148 secondary_coord_x += 2 * touch_slop; |
| 1099 secondary_coord_y += 2 * scaled_touch_slop; | 1149 secondary_coord_y += 2 * touch_slop; |
| 1100 event = ObtainMotionEvent(event_time, | 1150 event = ObtainMotionEvent(event_time, |
| 1101 MotionEvent::ACTION_MOVE, | 1151 MotionEvent::ACTION_MOVE, |
| 1102 kFakeCoordX, | 1152 kFakeCoordX, |
| 1103 kFakeCoordY, | 1153 kFakeCoordY, |
| 1104 secondary_coord_x, | 1154 secondary_coord_x, |
| 1105 secondary_coord_y); | 1155 secondary_coord_y); |
| 1106 event.SetId(++motion_event_id); | 1156 event.SetId(++motion_event_id); |
| 1107 | 1157 |
| 1108 // Toggling double-tap support should not take effect until the next sequence. | 1158 // Toggling double-tap support should not take effect until the next sequence. |
| 1109 gesture_provider_->SetDoubleTapSupportForPageEnabled(true); | 1159 gesture_provider_->SetDoubleTapSupportForPageEnabled(true); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1329 | 1379 |
| 1330 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_CANCEL); | 1380 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_CANCEL); |
| 1331 event.pointer_count = 1; | 1381 event.pointer_count = 1; |
| 1332 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1382 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1333 EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType()); | 1383 EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType()); |
| 1334 EXPECT_EQ(12U, GetReceivedGestureCount()); | 1384 EXPECT_EQ(12U, GetReceivedGestureCount()); |
| 1335 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 1385 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); |
| 1336 } | 1386 } |
| 1337 | 1387 |
| 1338 } // namespace ui | 1388 } // namespace ui |
| OLD | NEW |