Chromium Code Reviews| 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 |