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

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

Issue 2175803002: The helper functions for slop region check and subtraction are modified. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) {
tdresser 2016/07/22 15:57:45 Out of curiosity, what ended up being the solution
sahel 2016/07/22 19:46:42 Creating events with the sequence of action_down,
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 // Wait for the two finger tap timeout, and put the second pointer down.
1078 event_time += kOneSecond;
1079 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_DOWN, 0, 0,
1080 kMaxTwoFingerTapSeparation / 2, 0);
1081 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1082
1083 event.ReleasePointAt(0);
1084 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1085
1086 event.set_action(MotionEvent::ACTION_MOVE);
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698