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

Unified Diff: ui/events/gesture_detection/gesture_provider_unittest.cc

Issue 289373009: Support tap_count in ui::GestureProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Small cleanup. Created 6 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 side-by-side diff with in-line comments
Download patch
Index: ui/events/gesture_detection/gesture_provider_unittest.cc
diff --git a/ui/events/gesture_detection/gesture_provider_unittest.cc b/ui/events/gesture_detection/gesture_provider_unittest.cc
index 78a84b94ae9c5cc07953c5b1464055996bc2294e..e45d1782390a702b2f6b7fd2bfd621785fef12bd 100644
--- a/ui/events/gesture_detection/gesture_provider_unittest.cc
+++ b/ui/events/gesture_detection/gesture_provider_unittest.cc
@@ -178,6 +178,10 @@ class GestureProviderTest : public testing::Test, public GestureProviderClient {
return GetDefaultConfig().gesture_detector_config.touch_slop;
}
+ float GetDoubleTapSlop() const {
+ return GetDefaultConfig().gesture_detector_config.double_tap_slop;
+ }
+
float GetMinSwipeVelocity() const {
return GetDefaultConfig().gesture_detector_config.minimum_swipe_velocity;
}
@@ -1910,4 +1914,98 @@ TEST_F(GestureProviderTest, TwoFingerTapCancelledByDistanceBetweenPointers) {
EXPECT_EQ(1U, GetReceivedGestureCount());
}
+TEST_F(GestureProviderTest, TripleTap) {
+ const float slop = GetDoubleTapSlop();
+ gesture_provider_->SetDoubleTapSupportForPlatformEnabled(false);
+ base::TimeTicks event_time = base::TimeTicks::Now();
+
+ // First Tap.
+ MockMotionEvent event =
+ ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+
+ EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
+
+ event_time += kOneMicrosecond;
+ event = ObtainMotionEvent(
+ event_time, MotionEvent::ACTION_UP, kFakeCoordX, kFakeCoordY);
+ gesture_provider_->OnTouchEvent(event);
+ EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count());
+
+ // Second Tap.
+ event_time += kOneMicrosecond;
+ event = ObtainMotionEvent(
+ event_time, MotionEvent::ACTION_DOWN, kFakeCoordX + slop, kFakeCoordY);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+ EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
+
+ event_time += kOneMicrosecond;
+ event = ObtainMotionEvent(
+ event_time, MotionEvent::ACTION_UP, kFakeCoordX + slop, kFakeCoordY);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+
+ const GestureEventData& second_tap = GetMostRecentGestureEvent();
+ EXPECT_EQ(ET_GESTURE_TAP, second_tap.type);
+ // Ensure tap details have been set.
+ EXPECT_EQ(10, second_tap.details.bounding_box().width());
+ EXPECT_EQ(10, second_tap.details.bounding_box().height());
+ EXPECT_EQ(2, second_tap.details.tap_count());
+
+ // Third, Fourth and Fifth Taps. Taps after the third should still get a
+ // tap_count of 3, as 3 is the maximum.
+ for (int i = 0; i < 3; ++i) {
+ event_time += kOneMicrosecond;
+ // We keep tapping inside the previous tap's slop region.
+ event = ObtainMotionEvent(event_time,
+ MotionEvent::ACTION_DOWN,
+ kFakeCoordX + slop * (2 + i),
+ kFakeCoordY);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+ EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
+
+ event_time += kOneMicrosecond;
+ event = ObtainMotionEvent(event_time,
+ MotionEvent::ACTION_UP,
+ kFakeCoordX + slop * (2 + i),
+ kFakeCoordY);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+
+ const GestureEventData& third_tap = GetMostRecentGestureEvent();
+ EXPECT_EQ(ET_GESTURE_TAP, third_tap.type);
+ // Ensure tap details have been set.
+ EXPECT_EQ(10, third_tap.details.bounding_box().width());
+ EXPECT_EQ(10, third_tap.details.bounding_box().height());
+ EXPECT_EQ(3, third_tap.details.tap_count());
+ }
+
+ // Tap outside of the slop area. This should reset the |tap_count| to 1.
+ event_time += kOneMicrosecond;
+ event = ObtainMotionEvent(event_time,
+ MotionEvent::ACTION_DOWN,
+ kFakeCoordX,
+ kFakeCoordY);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+ EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
+
+ event_time += kOneMicrosecond;
+ event = ObtainMotionEvent(event_time,
+ MotionEvent::ACTION_UP,
+ kFakeCoordX,
+ kFakeCoordY);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+
+ const GestureEventData& final_tap = GetMostRecentGestureEvent();
+ EXPECT_EQ(ET_GESTURE_TAP, final_tap.type);
+ // Ensure tap details have been set.
+ EXPECT_EQ(10, final_tap.details.bounding_box().width());
+ EXPECT_EQ(10, final_tap.details.bounding_box().height());
+ EXPECT_EQ(1, final_tap.details.tap_count());
+}
+
} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698