| 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 "ui/events/gesture_detection/gesture_provider.h" | 5 #include "ui/events/gesture_detection/gesture_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 event_time, MotionEvent::ACTION_MOVE, 0, scaled_touch_slop / 2, | 1057 event_time, MotionEvent::ACTION_MOVE, 0, scaled_touch_slop / 2, |
| 1058 kMaxTwoFingerTapSeparation / 2, 0, 2 * kMaxTwoFingerTapSeparation, 0); | 1058 kMaxTwoFingerTapSeparation / 2, 0, 2 * kMaxTwoFingerTapSeparation, 0); |
| 1059 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1059 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1060 | 1060 |
| 1061 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetReceivedGesture(0).type()); | 1061 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetReceivedGesture(0).type()); |
| 1062 EXPECT_EQ(ET_GESTURE_SCROLL_BEGIN, GetReceivedGesture(1).type()); | 1062 EXPECT_EQ(ET_GESTURE_SCROLL_BEGIN, GetReceivedGesture(1).type()); |
| 1063 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetReceivedGesture(2).type()); | 1063 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetReceivedGesture(2).type()); |
| 1064 EXPECT_EQ(3U, GetReceivedGestureCount()); | 1064 EXPECT_EQ(3U, GetReceivedGestureCount()); |
| 1065 } | 1065 } |
| 1066 | 1066 |
| 1067 TEST_F(GestureProviderTest, ScrollStartWithSecondaryPointer) { |
| 1068 EnableTwoFingerTap(kMaxTwoFingerTapSeparation, base::TimeDelta()); |
| 1069 const float scaled_touch_slop = GetTouchSlop(); |
| 1070 |
| 1071 base::TimeTicks event_time = base::TimeTicks::Now(); |
| 1072 |
| 1073 MockMotionEvent event = |
| 1074 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN, 0, 0); |
| 1075 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1076 |
| 1077 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_DOWN, 0, 0, |
| 1078 kMaxTwoFingerTapSeparation / 2, 0); |
| 1079 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1080 |
| 1081 // Wait for the two finger tap timeout, and put the second pointer down. |
| 1082 event_time += kOneSecond; |
| 1083 event.set_event_time(event_time); |
| 1084 event.ReleasePointAtIndex(0); |
| 1085 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1086 |
| 1087 event.MovePoint(0, kMaxTwoFingerTapSeparation / 2, 2 * scaled_touch_slop); |
| 1088 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1089 |
| 1090 event.ReleasePoint(); |
| 1091 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1092 |
| 1093 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetReceivedGesture(0).type()); |
| 1094 EXPECT_EQ(ET_GESTURE_SCROLL_BEGIN, GetReceivedGesture(1).type()); |
| 1095 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetReceivedGesture(2).type()); |
| 1096 EXPECT_EQ(ET_GESTURE_SCROLL_END, GetReceivedGesture(3).type()); |
| 1097 EXPECT_EQ(4U, GetReceivedGestureCount()); |
| 1098 } |
| 1099 |
| 1067 TEST_F(GestureProviderTest, LongPressAndTapCancelledWhenScrollBegins) { | 1100 TEST_F(GestureProviderTest, LongPressAndTapCancelledWhenScrollBegins) { |
| 1068 base::TimeTicks event_time = base::TimeTicks::Now(); | 1101 base::TimeTicks event_time = base::TimeTicks::Now(); |
| 1069 | 1102 |
| 1070 MockMotionEvent event = | 1103 MockMotionEvent event = |
| 1071 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); | 1104 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); |
| 1072 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1105 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1073 event = ObtainMotionEvent(event_time + kOneMicrosecond, | 1106 event = ObtainMotionEvent(event_time + kOneMicrosecond, |
| 1074 MotionEvent::ACTION_MOVE, | 1107 MotionEvent::ACTION_MOVE, |
| 1075 kFakeCoordX * 5, | 1108 kFakeCoordX * 5, |
| 1076 kFakeCoordY * 5); | 1109 kFakeCoordY * 5); |
| (...skipping 1683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2760 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN, kFakeCoordX, | 2793 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN, kFakeCoordX, |
| 2761 kFakeCoordY + GetTouchSlop() / 2); | 2794 kFakeCoordY + GetTouchSlop() / 2); |
| 2762 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 2795 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 2763 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_UP); | 2796 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_UP); |
| 2764 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 2797 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 2765 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType()); | 2798 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType()); |
| 2766 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count()); | 2799 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count()); |
| 2767 } | 2800 } |
| 2768 | 2801 |
| 2769 } // namespace ui | 2802 } // namespace ui |
| OLD | NEW |