| 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 2d122fda51dcfcffaafe8952e5f8507fa471674a..262ec36cfd1d5287c91d746a08919085cecc077f 100644
|
| --- a/ui/events/gesture_detection/gesture_provider_unittest.cc
|
| +++ b/ui/events/gesture_detection/gesture_provider_unittest.cc
|
| @@ -258,6 +258,18 @@ class GestureProviderTest : public testing::Test, public GestureProviderClient {
|
| SetUpWithConfig(config);
|
| }
|
|
|
| + void SetMaxGestureBoundsLength(float max_gesture_bound_length) {
|
| + GestureProvider::Config config = GetDefaultConfig();
|
| + config.max_gesture_bounds_length = max_gesture_bound_length;
|
| + SetUpWithConfig(config);
|
| + }
|
| +
|
| + void EnableTouchMajorUseInScaling() {
|
| + GestureProvider::Config config = GetDefaultConfig();
|
| + config.scale_gesture_detector_config.use_touch_major_in_span = true;
|
| + SetUpWithConfig(config);
|
| + }
|
| +
|
| bool HasDownEvent() const { return gesture_provider_->current_down_event(); }
|
|
|
| protected:
|
| @@ -1557,9 +1569,91 @@ TEST_F(GestureProviderTest, PinchZoom) {
|
| GetMostRecentGestureEvent().details.bounding_box());
|
| }
|
|
|
| +// Verify that pinch zoom that uses touch major values sends the proper event
|
| +// sequence.
|
| +TEST_F(GestureProviderTest, PinchZoomWithTouchMajor) {
|
| + EnableTouchMajorUseInScaling();
|
| +
|
| + base::TimeTicks event_time = base::TimeTicks::Now();
|
| + const float touch_slop = GetTouchSlop();
|
| + gesture_provider_->SetMultiTouchZoomSupportEnabled(true);
|
| +
|
| + int secondary_coord_x = kFakeCoordX + 20 * touch_slop;
|
| + int secondary_coord_y = kFakeCoordY + 20 * touch_slop;
|
| +
|
| + MockMotionEvent event =
|
| + ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
|
| + EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
|
| + EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
|
| +
|
| + event = ObtainMotionEvent(event_time,
|
| + MotionEvent::ACTION_POINTER_DOWN,
|
| + kFakeCoordX,
|
| + kFakeCoordY,
|
| + secondary_coord_x,
|
| + secondary_coord_y);
|
| +
|
| + gesture_provider_->OnTouchEvent(event);
|
| + EXPECT_EQ(1U, GetReceivedGestureCount());
|
| +
|
| + secondary_coord_x += 5 * touch_slop;
|
| + secondary_coord_y += 5 * touch_slop;
|
| + event = ObtainMotionEvent(event_time,
|
| + MotionEvent::ACTION_MOVE,
|
| + kFakeCoordX,
|
| + kFakeCoordY,
|
| + secondary_coord_x,
|
| + secondary_coord_y);
|
| + EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
|
| + EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points());
|
| + EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_PINCH_BEGIN));
|
| + EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN));
|
| + EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_UPDATE));
|
| +
|
| + secondary_coord_x += 2 * touch_slop;
|
| + secondary_coord_y += 2 * touch_slop;
|
| + event = ObtainMotionEvent(event_time,
|
| + MotionEvent::ACTION_MOVE,
|
| + kFakeCoordX,
|
| + kFakeCoordY,
|
| + secondary_coord_x,
|
| + secondary_coord_y);
|
| + EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
|
| + EXPECT_EQ(ET_GESTURE_PINCH_UPDATE, GetMostRecentGestureEventType());
|
| + EXPECT_LT(1.f, GetMostRecentGestureEvent().details.scale());
|
| +
|
| + secondary_coord_x -= 2 * touch_slop;
|
| + secondary_coord_y -= 2 * touch_slop;
|
| + event = ObtainMotionEvent(event_time,
|
| + MotionEvent::ACTION_MOVE,
|
| + kFakeCoordX,
|
| + kFakeCoordY,
|
| + secondary_coord_x,
|
| + secondary_coord_y);
|
| + EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
|
| + EXPECT_EQ(ET_GESTURE_PINCH_UPDATE, GetMostRecentGestureEventType());
|
| + EXPECT_GT(1.f, GetMostRecentGestureEvent().details.scale());
|
| +
|
| + event = ObtainMotionEvent(event_time,
|
| + MotionEvent::ACTION_POINTER_UP,
|
| + kFakeCoordX,
|
| + kFakeCoordY,
|
| + secondary_coord_x,
|
| + secondary_coord_y);
|
| + EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
|
| + EXPECT_EQ(ET_GESTURE_PINCH_END, GetMostRecentGestureEventType());
|
| + EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_SCROLL_END));
|
| +
|
| + event = ObtainMotionEvent(event_time, MotionEvent::ACTION_UP);
|
| + gesture_provider_->OnTouchEvent(event);
|
| + EXPECT_EQ(ET_GESTURE_SCROLL_END, GetMostRecentGestureEventType());
|
| +}
|
| +
|
| // Verify that no accidental pinching occurs if the touch size is large relative
|
| -// to the min scaling span.
|
| -TEST_F(GestureProviderTest, NoPinchZoomWithFatFinger) {
|
| +// to the min scaling span when the touch major value is used in scaling.
|
| +TEST_F(GestureProviderTest, NoPinchZoomWithTouchMajorAndFatFinger) {
|
| + EnableTouchMajorUseInScaling();
|
| +
|
| base::TimeTicks event_time = base::TimeTicks::Now();
|
| const float kFatFingerSize = GetMinScalingSpan() * 3.f;
|
|
|
| @@ -2296,4 +2390,30 @@ TEST_F(GestureProviderTest, MinGestureBoundsLength) {
|
| GetMostRecentGestureEvent().details.bounding_box_f().height());
|
| }
|
|
|
| +TEST_F(GestureProviderTest, MaxGestureBoundsLength) {
|
| + const float kMaxGestureBoundsLength = kMockTouchRadius / 10.f;
|
| + SetMaxGestureBoundsLength(kMaxGestureBoundsLength);
|
| + 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));
|
| +
|
| + EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
|
| + EXPECT_EQ(kMaxGestureBoundsLength,
|
| + GetMostRecentGestureEvent().details.bounding_box_f().width());
|
| + EXPECT_EQ(kMaxGestureBoundsLength,
|
| + GetMostRecentGestureEvent().details.bounding_box_f().height());
|
| +
|
| + event =
|
| + ObtainMotionEvent(event_time + kOneMicrosecond, MotionEvent::ACTION_UP);
|
| + EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
|
| + EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType());
|
| + EXPECT_EQ(kMaxGestureBoundsLength,
|
| + GetMostRecentGestureEvent().details.bounding_box_f().width());
|
| + EXPECT_EQ(kMaxGestureBoundsLength,
|
| + GetMostRecentGestureEvent().details.bounding_box_f().height());
|
| +}
|
| +
|
| } // namespace ui
|
|
|