| 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 04ba3fcacf8afdae87dd5220e71bc646892041e0..5d9c664d02c1c1f9fc25547277e21b7c1b73f315 100644
|
| --- a/ui/events/gesture_detection/gesture_provider_unittest.cc
|
| +++ b/ui/events/gesture_detection/gesture_provider_unittest.cc
|
| @@ -131,8 +131,8 @@ class GestureProviderTest : public testing::Test, public GestureProviderClient {
|
| return sConfig;
|
| }
|
|
|
| - int GetTouchSlop() const {
|
| - return GetDefaultConfig().gesture_detector_config.scaled_touch_slop;
|
| + float GetTouchSlop() const {
|
| + return GetDefaultConfig().gesture_detector_config.touch_slop;
|
| }
|
|
|
| base::TimeDelta GetLongPressTimeout() const {
|
| @@ -156,8 +156,8 @@ class GestureProviderTest : public testing::Test, public GestureProviderClient {
|
| void CheckScrollEventSequenceForEndActionType(
|
| MotionEvent::Action end_action_type) {
|
| base::TimeTicks event_time = base::TimeTicks::Now();
|
| - const int scroll_to_x = kFakeCoordX + 100;
|
| - const int scroll_to_y = kFakeCoordY + 100;
|
| + const float scroll_to_x = kFakeCoordX + 100;
|
| + const float scroll_to_y = kFakeCoordY + 100;
|
| int motion_event_id = 0;
|
|
|
| MockMotionEvent event =
|
| @@ -533,8 +533,8 @@ TEST_F(GestureProviderTest, DoubleTapDragZoomBasic) {
|
| // Generate a scroll gesture and verify that the resulting scroll motion event
|
| // has both absolute and relative position information.
|
| TEST_F(GestureProviderTest, ScrollUpdateValues) {
|
| - const int delta_x = 16;
|
| - const int delta_y = 84;
|
| + const float delta_x = 16;
|
| + const float delta_y = 84;
|
|
|
| const base::TimeTicks event_time = TimeTicks::Now();
|
|
|
| @@ -625,8 +625,8 @@ TEST_F(GestureProviderTest, FractionalScroll) {
|
| // Generate a scroll gesture and verify that the resulting scroll begin event
|
| // has the expected hint values.
|
| TEST_F(GestureProviderTest, ScrollBeginValues) {
|
| - const int delta_x = 13;
|
| - const int delta_y = 89;
|
| + const float delta_x = 13;
|
| + const float delta_y = 89;
|
|
|
| const base::TimeTicks event_time = TimeTicks::Now();
|
|
|
| @@ -789,8 +789,8 @@ TEST_F(GestureProviderTest, NoGestureLongPressDuringDoubleTap) {
|
| // Verify that the touch slop region is removed from the first scroll delta to
|
| // avoid a jump when starting to scroll.
|
| TEST_F(GestureProviderTest, TouchSlopRemovedFromScroll) {
|
| - const int scaled_touch_slop = GetTouchSlop();
|
| - const int scroll_delta = 5;
|
| + const float touch_slop = GetTouchSlop();
|
| + const float scroll_delta = 5;
|
|
|
| base::TimeTicks event_time = base::TimeTicks::Now();
|
|
|
| @@ -801,7 +801,7 @@ TEST_F(GestureProviderTest, TouchSlopRemovedFromScroll) {
|
| event = ObtainMotionEvent(event_time + kOneMicrosecond * 2,
|
| MotionEvent::ACTION_MOVE,
|
| kFakeCoordX,
|
| - kFakeCoordY + scaled_touch_slop + scroll_delta);
|
| + kFakeCoordY + touch_slop + scroll_delta);
|
| EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
|
|
|
| EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetMostRecentGestureEventType());
|
| @@ -811,6 +811,56 @@ TEST_F(GestureProviderTest, TouchSlopRemovedFromScroll) {
|
| EXPECT_EQ(1, gesture.details.touch_points());
|
| }
|
|
|
| +// Verify that movement within the touch slop region does not generate a scroll,
|
| +// and that the slop region is correct even when using fractional coordinates.
|
| +TEST_F(GestureProviderTest, NoScrollWithinTouchSlop) {
|
| + const float touch_slop = GetTouchSlop();
|
| + const float scale_factor = 2.5f;
|
| + const int touch_slop_pixels = static_cast<int>(scale_factor * touch_slop);
|
| +
|
| + 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 + kOneMicrosecond * 2,
|
| + MotionEvent::ACTION_MOVE,
|
| + kFakeCoordX + touch_slop_pixels / scale_factor,
|
| + kFakeCoordY);
|
| + EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
|
| + EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN));
|
| +
|
| + event = ObtainMotionEvent(event_time + kOneMicrosecond * 2,
|
| + MotionEvent::ACTION_MOVE,
|
| + kFakeCoordX,
|
| + kFakeCoordY + touch_slop_pixels / scale_factor);
|
| + EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
|
| + EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN));
|
| +
|
| + event = ObtainMotionEvent(event_time + kOneMicrosecond * 2,
|
| + MotionEvent::ACTION_MOVE,
|
| + kFakeCoordX - touch_slop_pixels / scale_factor,
|
| + kFakeCoordY);
|
| + EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
|
| + EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN));
|
| +
|
| + event = ObtainMotionEvent(event_time + kOneMicrosecond * 2,
|
| + MotionEvent::ACTION_MOVE,
|
| + kFakeCoordX,
|
| + kFakeCoordY - touch_slop_pixels / scale_factor);
|
| + EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
|
| + EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN));
|
| +
|
| + event =
|
| + ObtainMotionEvent(event_time + kOneMicrosecond * 2,
|
| + MotionEvent::ACTION_MOVE,
|
| + kFakeCoordX,
|
| + kFakeCoordY + (touch_slop_pixels + 1.f) / scale_factor);
|
| + EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
|
| + EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN));
|
| +}
|
| +
|
| TEST_F(GestureProviderTest, NoDoubleTapWhenExplicitlyDisabled) {
|
| gesture_provider_->SetDoubleTapSupportForPlatformEnabled(false);
|
|
|
| @@ -1043,15 +1093,15 @@ TEST_F(GestureProviderTest, FixedPageScaleDuringDoubleTapDragZoom) {
|
| // Verify that pinch zoom sends the proper event sequence.
|
| TEST_F(GestureProviderTest, PinchZoom) {
|
| base::TimeTicks event_time = base::TimeTicks::Now();
|
| - const int scaled_touch_slop = GetTouchSlop();
|
| + const float touch_slop = GetTouchSlop();
|
| int motion_event_id = 0;
|
|
|
| gesture_provider_->SetDoubleTapSupportForPageEnabled(false);
|
| gesture_provider_->SetDoubleTapSupportForPlatformEnabled(true);
|
| gesture_provider_->SetMultiTouchSupportEnabled(true);
|
|
|
| - int secondary_coord_x = kFakeCoordX + 20 * scaled_touch_slop;
|
| - int secondary_coord_y = kFakeCoordY + 20 * scaled_touch_slop;
|
| + int secondary_coord_x = kFakeCoordX + 20 * touch_slop;
|
| + int secondary_coord_y = kFakeCoordY + 20 * touch_slop;
|
|
|
| MockMotionEvent event =
|
| ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
|
| @@ -1075,8 +1125,8 @@ TEST_F(GestureProviderTest, PinchZoom) {
|
| EXPECT_EQ(1U, GetReceivedGestureCount());
|
| EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
|
|
|
| - secondary_coord_x += 5 * scaled_touch_slop;
|
| - secondary_coord_y += 5 * scaled_touch_slop;
|
| + secondary_coord_x += 5 * touch_slop;
|
| + secondary_coord_y += 5 * touch_slop;
|
| event = ObtainMotionEvent(event_time,
|
| MotionEvent::ACTION_MOVE,
|
| kFakeCoordX,
|
| @@ -1095,8 +1145,8 @@ TEST_F(GestureProviderTest, PinchZoom) {
|
| EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN));
|
| EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_UPDATE));
|
|
|
| - secondary_coord_x += 2 * scaled_touch_slop;
|
| - secondary_coord_y += 2 * scaled_touch_slop;
|
| + secondary_coord_x += 2 * touch_slop;
|
| + secondary_coord_y += 2 * touch_slop;
|
| event = ObtainMotionEvent(event_time,
|
| MotionEvent::ACTION_MOVE,
|
| kFakeCoordX,
|
|
|