| Index: ui/events/gesture_detection/touch_disposition_gesture_filter_unittest.cc
|
| diff --git a/ui/events/gesture_detection/touch_disposition_gesture_filter_unittest.cc b/ui/events/gesture_detection/touch_disposition_gesture_filter_unittest.cc
|
| index eb77e64859b1f21aa3c89c3fd1afaae85e188e85..18bb71b3f9107e3265834856847972b3b0c13ee8 100644
|
| --- a/ui/events/gesture_detection/touch_disposition_gesture_filter_unittest.cc
|
| +++ b/ui/events/gesture_detection/touch_disposition_gesture_filter_unittest.cc
|
| @@ -134,13 +134,25 @@ class TouchDispositionGestureFilterTest
|
| }
|
|
|
| void SendTouchEventAck(bool event_consumed) {
|
| - queue_->OnTouchEventAck(event_consumed);
|
| + queue_->OnTouchEventAckForQueueFront(event_consumed);
|
| }
|
|
|
| void SendTouchConsumedAck() { SendTouchEventAck(true); }
|
|
|
| void SendTouchNotConsumedAck() { SendTouchEventAck(false); }
|
|
|
| + void SendTouchEventAckForQueueBack(bool event_consumed) {
|
| + queue_->OnTouchEventAckForQueueBack(event_consumed);
|
| + }
|
| +
|
| + void SendTouchConsumedAckForQueueBack() {
|
| + SendTouchEventAckForQueueBack(true);
|
| + }
|
| +
|
| + void SendTouchNotConsumedAckForQueueBack() {
|
| + SendTouchEventAckForQueueBack(false);
|
| + }
|
| +
|
| void PushGesture(EventType type) {
|
| pending_gesture_packet_.Push(CreateGesture(type));
|
| }
|
| @@ -233,10 +245,10 @@ class TouchDispositionGestureFilterTest
|
| 0,
|
| MotionEvent::TOOL_TYPE_FINGER,
|
| base::TimeTicks(),
|
| - touch_event_.GetX(0),
|
| - touch_event_.GetY(0),
|
| - touch_event_.GetRawX(0),
|
| - touch_event_.GetRawY(0),
|
| + x,
|
| + y,
|
| + 0,
|
| + 0,
|
| 1,
|
| gfx::RectF(x - diameter / 2, y - diameter / 2, diameter, diameter),
|
| kDefaultEventFlags);
|
| @@ -702,20 +714,20 @@ TEST_F(TouchDispositionGestureFilterTest, FlingCancelledOnScrollBegin) {
|
|
|
| TEST_F(TouchDispositionGestureFilterTest, FlingNotCancelledIfGFCEventReceived) {
|
| // Simulate a fling that is started then cancelled.
|
| - PushGesture(ET_GESTURE_SCROLL_BEGIN);
|
| - PressTouchPoint(1, 1);
|
| + PushGesture(ET_GESTURE_SCROLL_BEGIN, 1, 1, 0);
|
| + PressTouchPoint(0, 0);
|
| SendTouchNotConsumedAck();
|
| - PushGesture(ET_SCROLL_FLING_START);
|
| - MoveTouchPoint(0, 2, 3);
|
| + PushGesture(ET_SCROLL_FLING_START, 2, 2, 0);
|
| + MoveTouchPoint(0, 0, 0);
|
| SendTouchNotConsumedAck();
|
| - PushGesture(ET_SCROLL_FLING_CANCEL);
|
| + PushGesture(ET_SCROLL_FLING_CANCEL, 3, 3, 0);
|
| ReleaseTouchPoint();
|
| SendTouchNotConsumedAck();
|
| EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SCROLL_BEGIN,
|
| ET_SCROLL_FLING_START,
|
| ET_SCROLL_FLING_CANCEL),
|
| GetAndResetSentGestures()));
|
| - EXPECT_EQ(LastSentGestureLocation(), gfx::PointF(2, 3));
|
| + EXPECT_EQ(LastSentGestureLocation(), gfx::PointF(3, 3));
|
|
|
| // A new touch sequence will not inject a ET_SCROLL_FLING_CANCEL, as the fling
|
| // has already been cancelled.
|
| @@ -743,20 +755,20 @@ TEST_F(TouchDispositionGestureFilterTest, TapCancelledWhenScrollBegins) {
|
| }
|
|
|
| TEST_F(TouchDispositionGestureFilterTest, TapCancelledWhenTouchConsumed) {
|
| - PushGesture(ET_GESTURE_TAP_DOWN);
|
| - PressTouchPoint(1, 1);
|
| + PushGesture(ET_GESTURE_TAP_DOWN, 1, 1, 0);
|
| + PressTouchPoint(0, 0);
|
| SendTouchNotConsumedAck();
|
| EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_TAP_DOWN),
|
| GetAndResetSentGestures()));
|
|
|
| // If the subsequent touch is consumed, the tap should be cancelled.
|
| - PushGesture(ET_GESTURE_SCROLL_BEGIN);
|
| - MoveTouchPoint(0, 2, 2);
|
| + PushGesture(ET_GESTURE_SCROLL_BEGIN, 2, 2, 0);
|
| + MoveTouchPoint(0, 0, 0);
|
| SendTouchConsumedAck();
|
| EXPECT_TRUE(
|
| GesturesMatch(Gestures(ET_GESTURE_TAP_CANCEL, ET_GESTURE_SCROLL_BEGIN),
|
| GetAndResetSentGestures()));
|
| - EXPECT_EQ(LastSentGestureLocation(), gfx::PointF(1, 1));
|
| + EXPECT_EQ(gfx::PointF(2, 2), LastSentGestureLocation());
|
| }
|
|
|
| TEST_F(TouchDispositionGestureFilterTest,
|
| @@ -979,32 +991,32 @@ TEST_F(TouchDispositionGestureFilterTest, TapAndScrollCancelledOnTouchCancel) {
|
| TEST_F(TouchDispositionGestureFilterTest,
|
| ConsumedScrollUpdateMakesFlingScrollEnd) {
|
| // A consumed touch's gesture should not be sent.
|
| - PushGesture(ET_GESTURE_BEGIN);
|
| - PushGesture(ET_GESTURE_SCROLL_BEGIN);
|
| - PressTouchPoint(1, 1);
|
| + PushGesture(ET_GESTURE_BEGIN, 0, 0, 0);
|
| + PushGesture(ET_GESTURE_SCROLL_BEGIN, 1, 1, 0);
|
| + PressTouchPoint(0, 0);
|
| SendTouchNotConsumedAck();
|
|
|
| EXPECT_TRUE(
|
| GesturesMatch(Gestures(ET_GESTURE_BEGIN, ET_GESTURE_SCROLL_BEGIN),
|
| GetAndResetSentGestures()));
|
|
|
| - PushGesture(ET_GESTURE_SCROLL_UPDATE);
|
| - MoveTouchPoint(0, 2, 2);
|
| + PushGesture(ET_GESTURE_SCROLL_UPDATE, 2, 2, 0);
|
| + MoveTouchPoint(0, 0, 0);
|
| SendTouchConsumedAck();
|
| EXPECT_FALSE(GesturesSent());
|
|
|
| - PushGesture(ET_SCROLL_FLING_START);
|
| - PushGesture(ET_SCROLL_FLING_CANCEL);
|
| - PushGesture(ET_GESTURE_END);
|
| + PushGesture(ET_SCROLL_FLING_START, 3, 3, 0);
|
| + PushGesture(ET_SCROLL_FLING_CANCEL, 4, 4, 0);
|
| + PushGesture(ET_GESTURE_END, 5, 5, 0);
|
| ReleaseTouchPoint();
|
| SendTouchNotConsumedAck();
|
| EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SCROLL_END, ET_GESTURE_END),
|
| GetAndResetSentGestures()));
|
| - EXPECT_EQ(LastSentGestureLocation(), gfx::PointF(2, 2));
|
| + EXPECT_EQ(LastSentGestureLocation(), gfx::PointF(5, 5));
|
|
|
| - PushGesture(ET_GESTURE_BEGIN);
|
| - PushGesture(ET_GESTURE_SCROLL_BEGIN);
|
| - PressTouchPoint(1, 1);
|
| + PushGesture(ET_GESTURE_BEGIN, 6, 6, 0);
|
| + PushGesture(ET_GESTURE_SCROLL_BEGIN, 7, 7, 0);
|
| + PressTouchPoint(0, 0);
|
| SendTouchNotConsumedAck();
|
| EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_BEGIN, ET_GESTURE_SCROLL_BEGIN),
|
| GetAndResetSentGestures()));
|
| @@ -1189,4 +1201,62 @@ TEST_F(TouchDispositionGestureFilterTest, PreviousScrollPrevented) {
|
| .details.previous_scroll_update_in_sequence_prevented());
|
| }
|
|
|
| +TEST_F(TouchDispositionGestureFilterTest, AckQueueBack) {
|
| + PushGesture(ET_GESTURE_BEGIN, 1, 1, 0);
|
| + PressTouchPoint(1, 1);
|
| + SendTouchNotConsumedAck();
|
| +
|
| + PushGesture(ET_GESTURE_SCROLL_BEGIN, 2, 2, 0);
|
| + MoveTouchPoint(0, 1, 1);
|
| + SendTouchNotConsumedAck();
|
| + GetAndResetSentGestures();
|
| +
|
| + // Pending touch move.
|
| + PushGesture(ET_GESTURE_SCROLL_UPDATE, 3, 3, 0);
|
| + MoveTouchPoint(0, 1, 1);
|
| + EXPECT_FALSE(GesturesSent());
|
| +
|
| + // Additional pending touch move.
|
| + PushGesture(ET_GESTURE_SCROLL_UPDATE, 4, 4, 0);
|
| + MoveTouchPoint(0, 1, 1);
|
| +
|
| + // Ack back of the queue consumed.
|
| + SendTouchConsumedAckForQueueBack();
|
| +
|
| + // Ack the pending touch.
|
| + GetAndResetSentGestures();
|
| + SendTouchNotConsumedAck();
|
| +
|
| + // The consumed touch doesn't produce a gesture.
|
| + EXPECT_TRUE(GesturesMatch(
|
| + Gestures(ET_GESTURE_SCROLL_UPDATE),
|
| + GetAndResetSentGestures()));
|
| + EXPECT_EQ(gfx::PointF(3, 3), LastSentGestureLocation());
|
| +
|
| + // Pending touch move.
|
| + PushGesture(ET_GESTURE_SCROLL_UPDATE, 5, 5, 0);
|
| + MoveTouchPoint(0, 1, 1);
|
| + EXPECT_FALSE(GesturesSent());
|
| +
|
| + // Ack back of the queue unconsumed (twice).
|
| + PushGesture(ET_GESTURE_SCROLL_UPDATE, 6, 6, 0);
|
| + MoveTouchPoint(0, 6, 6);
|
| + SendTouchNotConsumedAckForQueueBack();
|
| +
|
| + PushGesture(ET_GESTURE_SCROLL_UPDATE, 7, 7, 0);
|
| + MoveTouchPoint(0, 7, 7);
|
| + SendTouchNotConsumedAckForQueueBack();
|
| +
|
| + // Ack the pending touch.
|
| + GetAndResetSentGestures();
|
| + SendTouchNotConsumedAck();
|
| +
|
| + // Both touches have now been acked.
|
| + EXPECT_TRUE(
|
| + GesturesMatch(Gestures(ET_GESTURE_SCROLL_UPDATE, ET_GESTURE_SCROLL_UPDATE,
|
| + ET_GESTURE_SCROLL_UPDATE),
|
| + GetAndResetSentGestures()));
|
| + EXPECT_EQ(gfx::PointF(7, 7), LastSentGestureLocation());
|
| +}
|
| +
|
| } // namespace ui
|
|
|