| 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 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1029 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1029 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1030 | 1030 |
| 1031 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetReceivedGesture(0).type()); | 1031 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetReceivedGesture(0).type()); |
| 1032 EXPECT_EQ(ET_GESTURE_TWO_FINGER_TAP, GetReceivedGesture(1).type()); | 1032 EXPECT_EQ(ET_GESTURE_TWO_FINGER_TAP, GetReceivedGesture(1).type()); |
| 1033 EXPECT_EQ(ET_GESTURE_SCROLL_BEGIN, GetReceivedGesture(2).type()); | 1033 EXPECT_EQ(ET_GESTURE_SCROLL_BEGIN, GetReceivedGesture(2).type()); |
| 1034 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetReceivedGesture(3).type()); | 1034 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetReceivedGesture(3).type()); |
| 1035 EXPECT_EQ(ET_GESTURE_SCROLL_END, GetReceivedGesture(4).type()); | 1035 EXPECT_EQ(ET_GESTURE_SCROLL_END, GetReceivedGesture(4).type()); |
| 1036 EXPECT_EQ(5U, GetReceivedGestureCount()); | 1036 EXPECT_EQ(5U, GetReceivedGestureCount()); |
| 1037 } | 1037 } |
| 1038 | 1038 |
| 1039 // This test simulates cases like (crbug.com/704426) in which some of the events |
| 1040 // are missing from the event stream. |
| 1041 TEST_F(GestureProviderTest, SlopRegionCheckOnMissingSecondaryPointerDownEvent) { |
| 1042 EnableTwoFingerTap(kMaxTwoFingerTapSeparation, base::TimeDelta()); |
| 1043 const float scaled_touch_slop = GetTouchSlop(); |
| 1044 |
| 1045 base::TimeTicks event_time = base::TimeTicks::Now(); |
| 1046 |
| 1047 MockMotionEvent event = |
| 1048 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN, 0, 0); |
| 1049 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1050 |
| 1051 // Don't send ACTION_POINTER_DOWN event to the gesture_provider. |
| 1052 // This is for simulating the cases that the ACTION_POINTER_DOWN event is |
| 1053 // missing from the event sequence. |
| 1054 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_DOWN, 0, 0, |
| 1055 kMaxTwoFingerTapSeparation / 2, 0); |
| 1056 |
| 1057 event.MovePoint(1, 0, 3 * scaled_touch_slop); |
| 1058 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1059 |
| 1060 event.ReleasePointAtIndex(0); |
| 1061 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1062 |
| 1063 event.ReleasePoint(); |
| 1064 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1065 |
| 1066 // No scroll happens since the source pointer down event for the moved |
| 1067 // pointer is not found. No two finger tap happens since one of the pointers |
| 1068 // moved beyond its slop region. |
| 1069 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetReceivedGesture(0).type()); |
| 1070 EXPECT_EQ(1U, GetReceivedGestureCount()); |
| 1071 } |
| 1072 |
| 1039 TEST_F(GestureProviderTest, NoSlopRegionCheckOnThreeFingerScroll) { | 1073 TEST_F(GestureProviderTest, NoSlopRegionCheckOnThreeFingerScroll) { |
| 1040 EnableTwoFingerTap(kMaxTwoFingerTapSeparation, base::TimeDelta()); | 1074 EnableTwoFingerTap(kMaxTwoFingerTapSeparation, base::TimeDelta()); |
| 1041 const float scaled_touch_slop = GetTouchSlop(); | 1075 const float scaled_touch_slop = GetTouchSlop(); |
| 1042 | 1076 |
| 1043 base::TimeTicks event_time = base::TimeTicks::Now(); | 1077 base::TimeTicks event_time = base::TimeTicks::Now(); |
| 1044 | 1078 |
| 1045 MockMotionEvent event = | 1079 MockMotionEvent event = |
| 1046 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN, 0, 0); | 1080 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN, 0, 0); |
| 1047 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1081 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1048 | 1082 |
| (...skipping 1779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2828 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN, kFakeCoordX, | 2862 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN, kFakeCoordX, |
| 2829 kFakeCoordY + GetTouchSlop() / 2); | 2863 kFakeCoordY + GetTouchSlop() / 2); |
| 2830 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 2864 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 2831 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_UP); | 2865 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_UP); |
| 2832 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 2866 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 2833 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType()); | 2867 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType()); |
| 2834 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count()); | 2868 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count()); |
| 2835 } | 2869 } |
| 2836 | 2870 |
| 2837 } // namespace ui | 2871 } // namespace ui |
| OLD | NEW |