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

Side by Side Diff: ui/events/gesture_detection/gesture_provider_unittest.cc

Issue 2843543002: Missing source pointer down events are handled. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1026 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1027 1027
1028 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetReceivedGesture(0).type()); 1028 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetReceivedGesture(0).type());
1029 EXPECT_EQ(ET_GESTURE_TWO_FINGER_TAP, GetReceivedGesture(1).type()); 1029 EXPECT_EQ(ET_GESTURE_TWO_FINGER_TAP, GetReceivedGesture(1).type());
1030 EXPECT_EQ(ET_GESTURE_SCROLL_BEGIN, GetReceivedGesture(2).type()); 1030 EXPECT_EQ(ET_GESTURE_SCROLL_BEGIN, GetReceivedGesture(2).type());
1031 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetReceivedGesture(3).type()); 1031 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetReceivedGesture(3).type());
1032 EXPECT_EQ(ET_GESTURE_SCROLL_END, GetReceivedGesture(4).type()); 1032 EXPECT_EQ(ET_GESTURE_SCROLL_END, GetReceivedGesture(4).type());
1033 EXPECT_EQ(5U, GetReceivedGestureCount()); 1033 EXPECT_EQ(5U, GetReceivedGestureCount());
1034 } 1034 }
1035 1035
1036 TEST_F(GestureProviderTest, SlopRegionCheckOnMissingSecondaryPointerDownEvent) {
tdresser 2017/05/11 16:57:27 Add a link to the bug here.
sahel 2017/05/11 17:26:19 Done.
1037 EnableTwoFingerTap(kMaxTwoFingerTapSeparation, base::TimeDelta());
1038 const float scaled_touch_slop = GetTouchSlop();
1039
1040 base::TimeTicks event_time = base::TimeTicks::Now();
1041
1042 MockMotionEvent event =
1043 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN, 0, 0);
1044 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1045
1046 // Don't send ACTION_POINTER_DOWN event to the gesture_provider.
1047 // This is for simulating the cases that the ACTION_POINTER_DOWN event is
1048 // missing from the event sequence.
1049 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_DOWN, 0, 0,
1050 kMaxTwoFingerTapSeparation / 2, 0);
1051
1052 event.MovePoint(1, 0, 3 * scaled_touch_slop);
1053 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1054
1055 event.ReleasePointAtIndex(0);
1056 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1057
1058 event.ReleasePoint();
1059 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1060
1061 // No scroll happens since the source pointer down event for the moved
1062 // pointer is not found. No two finger tap happens since one of the pointers
1063 // moved beyond its slop region.
1064 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetReceivedGesture(0).type());
1065 EXPECT_EQ(1U, GetReceivedGestureCount());
1066 }
1067
1036 TEST_F(GestureProviderTest, NoSlopRegionCheckOnThreeFingerScroll) { 1068 TEST_F(GestureProviderTest, NoSlopRegionCheckOnThreeFingerScroll) {
1037 EnableTwoFingerTap(kMaxTwoFingerTapSeparation, base::TimeDelta()); 1069 EnableTwoFingerTap(kMaxTwoFingerTapSeparation, base::TimeDelta());
1038 const float scaled_touch_slop = GetTouchSlop(); 1070 const float scaled_touch_slop = GetTouchSlop();
1039 1071
1040 base::TimeTicks event_time = base::TimeTicks::Now(); 1072 base::TimeTicks event_time = base::TimeTicks::Now();
1041 1073
1042 MockMotionEvent event = 1074 MockMotionEvent event =
1043 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN, 0, 0); 1075 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN, 0, 0);
1044 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1076 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1045 1077
(...skipping 1779 matching lines...) Expand 10 before | Expand all | Expand 10 after
2825 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN, kFakeCoordX, 2857 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN, kFakeCoordX,
2826 kFakeCoordY + GetTouchSlop() / 2); 2858 kFakeCoordY + GetTouchSlop() / 2);
2827 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 2859 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
2828 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_UP); 2860 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_UP);
2829 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 2861 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
2830 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType()); 2862 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType());
2831 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count()); 2863 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count());
2832 } 2864 }
2833 2865
2834 } // namespace ui 2866 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698