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

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

Issue 1358263002: [Android] Support double-tap selection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix aura Created 5 years, 3 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 5f82dae308760c4f360824f8f30b43e9590c9113..8ae146dee20b694026976f6700bd83921f50591b 100644
--- a/ui/events/gesture_detection/gesture_provider_unittest.cc
+++ b/ui/events/gesture_detection/gesture_provider_unittest.cc
@@ -266,6 +266,12 @@ class GestureProviderTest : public testing::Test, public GestureProviderClient {
SetUpWithConfig(config);
}
+ void SetSingleTapRepeatLength(int repeat_length) {
+ GestureProvider::Config config = GetDefaultConfig();
+ config.gesture_detector_config.single_tap_repeat_length = repeat_length;
+ SetUpWithConfig(config);
+ }
+
bool HasDownEvent() const { return gesture_provider_->current_down_event(); }
protected:
@@ -2523,4 +2529,70 @@ TEST_F(GestureProviderTest, BoundingBoxForShowPressAndTapGesture) {
GetMostRecentGestureEvent().details.bounding_box_f());
}
+TEST_F(GestureProviderTest, SingleTapRepeat) {
+ SetSingleTapRepeatLength(3);
tdresser 2015/09/23 14:10:46 Do we have adequate coverage of when the repeat le
jdduke (slow) 2015/09/23 19:56:04 Probably not, I'll add a test.
+
+ gesture_provider_->SetDoubleTapSupportForPlatformEnabled(false);
+
+ base::TimeTicks event_time = base::TimeTicks::Now();
+
+ MockMotionEvent event =
+ ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+ event = ObtainMotionEvent(event_time, MotionEvent::ACTION_UP);
+ gesture_provider_->OnTouchEvent(event);
+ EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count());
+
+ // A secondary tap within the tap repeat period should increment
+ // the tap count.
+ event_time += GetValidDoubleTapDelay();
+ event = ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+ event = ObtainMotionEvent(event_time, MotionEvent::ACTION_UP);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+ EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType());
+ EXPECT_EQ(2, GetMostRecentGestureEvent().details.tap_count());
+
+ // A secondary tap within the tap repeat location threshold should increment
+ // the tap count.
+ event_time += GetValidDoubleTapDelay();
+ event = ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN, kFakeCoordX,
+ kFakeCoordY + GetTouchSlop() / 2);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+ event = ObtainMotionEvent(event_time, MotionEvent::ACTION_UP);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+ EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType());
+ EXPECT_EQ(3, GetMostRecentGestureEvent().details.tap_count());
+
+ // The tap count should reset after hitting the repeat length.
+ event_time += GetValidDoubleTapDelay();
+ event = ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+ event = ObtainMotionEvent(event_time, MotionEvent::ACTION_UP);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+ EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count());
+
+ // If double-tap is enabled, the tap repeat count should always be 1.
+ gesture_provider_->SetDoubleTapSupportForPlatformEnabled(true);
+ event_time += GetValidDoubleTapDelay();
+ event = ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+ event = ObtainMotionEvent(event_time, MotionEvent::ACTION_UP);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+ RunTasksAndWait(GetDoubleTapTimeout());
+ EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count());
+
+ event_time += GetValidDoubleTapDelay();
+ event = ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+ event = ObtainMotionEvent(event_time, MotionEvent::ACTION_UP);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+ RunTasksAndWait(GetDoubleTapTimeout());
+ EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count());
+}
+
} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698