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

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

Issue 200623003: Adopt "QuickScale" double-tap drag zoom code in the GestureProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Yeah... Created 6 years, 9 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 1be9ec7fec30c6abbc50c8a0ff020d926f58e5a4..85ced8e2a6435eedf11bae1944045761797ec3b4 100644
--- a/ui/events/gesture_detection/gesture_provider_unittest.cc
+++ b/ui/events/gesture_detection/gesture_provider_unittest.cc
@@ -405,7 +405,7 @@ TEST_F(GestureProviderTest, DoubleTap) {
EXPECT_EQ(1, double_tap.details.tap_count());
}
-TEST_F(GestureProviderTest, DoubleTapDragZoom) {
+TEST_F(GestureProviderTest, DoubleTapDragZoomBasic) {
const base::TimeTicks down_time_1 = TimeTicks::Now();
const base::TimeTicks down_time_2 = down_time_1 + kOneMicrosecond * 2;
@@ -431,75 +431,31 @@ TEST_F(GestureProviderTest, DoubleTapDragZoom) {
kFakeCoordY + 100);
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN));
- const GestureEventData* scroll_begin_gesture = GetActiveScrollBeginEvent();
- ASSERT_TRUE(!!scroll_begin_gesture);
- EXPECT_EQ(0, scroll_begin_gesture->details.scroll_x_hint());
- EXPECT_EQ(100, scroll_begin_gesture->details.scroll_y_hint());
- EXPECT_EQ(ET_GESTURE_PINCH_BEGIN, GetMostRecentGestureEventType());
+ ASSERT_EQ(ET_GESTURE_PINCH_BEGIN, GetMostRecentGestureEventType());
event = ObtainMotionEvent(down_time_2 + kOneMicrosecond * 2,
MotionEvent::ACTION_MOVE,
kFakeCoordX,
kFakeCoordY + 200);
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
- EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_UPDATE));
- EXPECT_EQ(ET_GESTURE_PINCH_UPDATE, GetMostRecentGestureEventType());
+ ASSERT_EQ(ET_GESTURE_PINCH_UPDATE, GetMostRecentGestureEventType());
+ EXPECT_LT(1.f, GetMostRecentGestureEvent().details.scale());
event = ObtainMotionEvent(down_time_2 + kOneMicrosecond * 3,
- MotionEvent::ACTION_UP,
- kFakeCoordX,
- kFakeCoordY + 200);
- EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
- EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_PINCH_END));
- EXPECT_EQ(ET_GESTURE_SCROLL_END, GetMostRecentGestureEventType());
-}
-
-TEST_F(GestureProviderTest, DoubleTapDragZoomCancelledOnSecondaryPointerDown) {
- const base::TimeTicks down_time_1 = TimeTicks::Now();
- const base::TimeTicks down_time_2 = down_time_1 + kOneMicrosecond * 2;
-
- MockMotionEvent event =
- ObtainMotionEvent(down_time_1, MotionEvent::ACTION_DOWN);
- EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
- EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
-
- event = ObtainMotionEvent(down_time_1 + kOneMicrosecond,
- MotionEvent::ACTION_UP);
- gesture_provider_->OnTouchEvent(event);
- EXPECT_EQ(ET_GESTURE_TAP_UNCONFIRMED, GetMostRecentGestureEventType());
-
- event = ObtainMotionEvent(down_time_2, MotionEvent::ACTION_DOWN);
- EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
- EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
- EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_TAP_CANCEL));
-
- event = ObtainMotionEvent(down_time_2 + kOneMicrosecond,
MotionEvent::ACTION_MOVE,
kFakeCoordX,
- kFakeCoordY - 30);
+ kFakeCoordY + 100);
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
- EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN));
- EXPECT_EQ(ET_GESTURE_PINCH_BEGIN, GetMostRecentGestureEventType());
+ ASSERT_EQ(ET_GESTURE_PINCH_UPDATE, GetMostRecentGestureEventType());
+ EXPECT_GT(1.f, GetMostRecentGestureEvent().details.scale());
- event = ObtainMotionEvent(down_time_2 + kOneMicrosecond * 2,
- MotionEvent::ACTION_POINTER_DOWN,
+ event = ObtainMotionEvent(down_time_2 + kOneMicrosecond * 4,
+ MotionEvent::ACTION_UP,
kFakeCoordX,
- kFakeCoordY - 30,
- kFakeCoordX + 50,
- kFakeCoordY + 50);
- gesture_provider_->OnTouchEvent(event);
+ kFakeCoordY - 200);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_PINCH_END));
EXPECT_EQ(ET_GESTURE_SCROLL_END, GetMostRecentGestureEventType());
- const size_t gesture_count = GetReceivedGestureCount();
-
- event = ObtainMotionEvent(down_time_2 + kOneMicrosecond * 3,
- MotionEvent::ACTION_POINTER_UP,
- kFakeCoordX,
- kFakeCoordY - 30,
- kFakeCoordX + 50,
- kFakeCoordY + 50);
- gesture_provider_->OnTouchEvent(event);
- EXPECT_EQ(gesture_count, GetReceivedGestureCount());
}
// Generate a scroll gesture and verify that the resulting scroll motion event
@@ -932,8 +888,8 @@ TEST_F(GestureProviderTest, FixedPageScaleDuringDoubleTapDragZoom) {
kFakeCoordX,
kFakeCoordY + 200);
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
- EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_UPDATE));
EXPECT_EQ(ET_GESTURE_PINCH_UPDATE, GetMostRecentGestureEventType());
+ EXPECT_LT(1.f, GetMostRecentGestureEvent().details.scale());
event = ObtainMotionEvent(down_time_2 + kOneMicrosecond * 3,
MotionEvent::ACTION_UP,
kFakeCoordX,
@@ -1010,20 +966,30 @@ TEST_F(GestureProviderTest, PinchZoom) {
secondary_coord_x += 5 * scaled_touch_slop;
secondary_coord_y += 5 * scaled_touch_slop;
-
event = ObtainMotionEvent(event_time,
MotionEvent::ACTION_MOVE,
kFakeCoordX,
kFakeCoordY,
secondary_coord_x,
secondary_coord_y);
-
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_PINCH_BEGIN));
EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN));
- EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_PINCH_UPDATE));
EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_UPDATE));
+ secondary_coord_x += 2 * scaled_touch_slop;
+ secondary_coord_y += 2 * scaled_touch_slop;
+ event = ObtainMotionEvent(event_time,
+ MotionEvent::ACTION_MOVE,
+ kFakeCoordX,
+ kFakeCoordY,
+ secondary_coord_x,
+ secondary_coord_y);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+ EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_UPDATE));
+ EXPECT_EQ(ET_GESTURE_PINCH_UPDATE, GetMostRecentGestureEventType());
+ EXPECT_LT(1.f, GetMostRecentGestureEvent().details.scale());
+
event = ObtainMotionEvent(event_time,
MotionEvent::ACTION_POINTER_UP,
kFakeCoordX,
« no previous file with comments | « ui/events/gesture_detection/gesture_provider.cc ('k') | ui/events/gesture_detection/scale_gesture_detector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698