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

Unified Diff: content/browser/renderer_host/input/gesture_event_queue_unittest.cc

Issue 140253005: Add touch scrolling modes experimental flags (DEPRECATED) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Correct semantics to deal with ending events Created 6 years, 11 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: content/browser/renderer_host/input/gesture_event_queue_unittest.cc
diff --git a/content/browser/renderer_host/input/gesture_event_queue_unittest.cc b/content/browser/renderer_host/input/gesture_event_queue_unittest.cc
index 4743b212c36751011e42801a538b14cc20cddb4e..e1308077f820e7c78e6db0fc0d3c0cca40cca682 100644
--- a/content/browser/renderer_host/input/gesture_event_queue_unittest.cc
+++ b/content/browser/renderer_host/input/gesture_event_queue_unittest.cc
@@ -198,18 +198,24 @@ TEST_F(GestureEventQueueTest, BasicGestures) {
// Multiple gestures can be queued for a single event.
PushGesture(WebInputEvent::GestureFlingStart);
PushGesture(WebInputEvent::GestureFlingCancel);
- MoveTouchPoint(0, 1, 1);
+ ReleaseTouchPoint(0);
EXPECT_FALSE(GesturesSent());
SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureFlingStart,
WebInputEvent::GestureFlingCancel),
GetAndResetSentGestures()));
+}
+
+TEST_F(GestureEventQueueTest, BasicGesturesConsumed) {
+ // An consumed touch's gesture should be sent.
tdresser 2014/02/03 15:52:58 I'm not clear on the purpose of this comment modif
tdresser 2014/02/03 18:55:14 Done.
+ PushGesture(WebInputEvent::GestureScrollBegin);
+ PressTouchPoint(1, 1);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED);
+ EXPECT_FALSE(GesturesSent());
- // A consumed touch's gesture should not be sent.
PushGesture(WebInputEvent::GestureFlingStart);
PushGesture(WebInputEvent::GestureFlingCancel);
ReleaseTouchPoint(0);
- EXPECT_FALSE(GesturesSent());
SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED);
EXPECT_FALSE(GesturesSent());
}
@@ -230,8 +236,43 @@ TEST_F(GestureEventQueueTest, ConsumedThenNotConsumed) {
// Even if the subsequent touch had no consumer, continue dropping gestures.
PushGesture(WebInputEvent::GestureFlingStart);
ReleaseTouchPoint(0);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
+ EXPECT_FALSE(GesturesSent());
+}
+
+
+TEST_F(GestureEventQueueTest, NotConsumedThenConsumed) {
+ // A not consumed touch's gesture should be sent.
+ PushGesture(WebInputEvent::GestureScrollBegin);
+ PressTouchPoint(1, 1);
SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollBegin),
+ GetAndResetSentGestures()));
+
+ // A newly consumed gesture should not be sent.
+ PushGesture(WebInputEvent::GesturePinchBegin);
+ PressTouchPoint(10, 10);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED);
EXPECT_FALSE(GesturesSent());
+
+ // And subsequent non-consumed updates should not be sent.
+ PushGesture(WebInputEvent::GestureScrollUpdate);
+ PushGesture(WebInputEvent::GesturePinchUpdate);
+ MoveTouchPoint(0, 2, 2);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_FALSE(GesturesSent());
+
+ // End events dispatched only when their start events were.
+ PushGesture(WebInputEvent::GesturePinchEnd);
+ ReleaseTouchPoint(1);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_FALSE(GesturesSent());
+
+ PushGesture(WebInputEvent::GestureScrollEnd);
+ ReleaseTouchPoint(0);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED);
+ EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollEnd),
+ GetAndResetSentGestures()));
}
TEST_F(GestureEventQueueTest, NotConsumedThenNoConsumer) {
@@ -250,11 +291,155 @@ TEST_F(GestureEventQueueTest, NotConsumedThenNoConsumer) {
EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GesturePinchBegin),
GetAndResetSentGestures()));
- // If the subsequent touch is consumed, then the remaining gesture sequence
- // should be dropped, regardless of subsequent touch ack disposition.
+ // End events dispatched when their start events were independent
tdresser 2014/02/03 15:52:58 "when their start events were" -> "when their star
tdresser 2014/02/03 18:55:14 Done.
+ // of the ack state.
+ PushGesture(WebInputEvent::GesturePinchEnd);
+ ReleaseTouchPoint(1);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED);
+ EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GesturePinchEnd),
+ GetAndResetSentGestures()));
+
+ PushGesture(WebInputEvent::GestureScrollEnd);
+ ReleaseTouchPoint(0);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED);
+ EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollEnd),
+ GetAndResetSentGestures()));
+}
+
+TEST_F(GestureEventQueueTest, EndingEventsSent) {
+ PushGesture(WebInputEvent::GestureScrollBegin);
+ PressTouchPoint(1, 1);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollBegin),
+ GetAndResetSentGestures()));
+
+ PushGesture(WebInputEvent::GesturePinchBegin);
+ PressTouchPoint(2, 2);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GesturePinchBegin),
+ GetAndResetSentGestures()));
+
+ // Consuming the touchend event can't suppress the match end gesture.
+ PushGesture(WebInputEvent::GesturePinchEnd);
+ ReleaseTouchPoint(1);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED);
+ EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GesturePinchEnd),
+ GetAndResetSentGestures()));
+
+ // But other events in the same packet are still suppressed.
PushGesture(WebInputEvent::GestureScrollUpdate);
+ PushGesture(WebInputEvent::GestureScrollEnd);
+ ReleaseTouchPoint(0);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED);
+ EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollEnd),
+ GetAndResetSentGestures()));
+
+ // GestureScrollEnd and GestureFlingStart behave the same in this regard.
+ PushGesture(WebInputEvent::GestureScrollBegin);
+ PressTouchPoint(1, 1);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollBegin),
+ GetAndResetSentGestures()));
+
+ PushGesture(WebInputEvent::GestureFlingStart);
+ ReleaseTouchPoint(0);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED);
+ EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureFlingStart),
+ GetAndResetSentGestures()));
+}
+
+TEST_F(GestureEventQueueTest, EndingEventsNotSent) {
+ // Consuming a begin event ensures no end events are sent.
+ PushGesture(WebInputEvent::GestureScrollBegin);
+ PressTouchPoint(1, 1);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED);
+ EXPECT_FALSE(GesturesSent());
+
+ PushGesture(WebInputEvent::GesturePinchBegin);
+ PressTouchPoint(2, 2);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_FALSE(GesturesSent());
+
+ PushGesture(WebInputEvent::GesturePinchEnd);
+ ReleaseTouchPoint(1);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_FALSE(GesturesSent());
+
+ PushGesture(WebInputEvent::GestureScrollEnd);
+ ReleaseTouchPoint(0);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_FALSE(GesturesSent());
+}
+
+TEST_F(GestureEventQueueTest, IndependentPacketsAllowed) {
+ PushGesture(WebInputEvent::GestureScrollBegin);
+ PressTouchPoint(1, 1);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollBegin),
+ GetAndResetSentGestures()));
+
+ // Consuming a single scroll or pinch update should suppress only that event.
+ PushGesture(WebInputEvent::GestureScrollUpdate);
+ MoveTouchPoint(0, 2, 2);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED);
+ EXPECT_FALSE(GesturesSent());
+
+ PushGesture(WebInputEvent::GesturePinchBegin);
+ PressTouchPoint(2, 2);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GesturePinchBegin),
+ GetAndResetSentGestures()));
+
+ PushGesture(WebInputEvent::GesturePinchUpdate);
+ MoveTouchPoint(1, 2, 3);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED);
+ EXPECT_FALSE(GesturesSent());
+
+ // Subsequent updates should not be affected.
+ PushGesture(WebInputEvent::GestureScrollUpdate);
+ MoveTouchPoint(0, 4, 4);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollUpdate),
+ GetAndResetSentGestures()));
+
PushGesture(WebInputEvent::GesturePinchUpdate);
+ MoveTouchPoint(0, 4, 5);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GesturePinchUpdate),
+ GetAndResetSentGestures()));
+
+ PushGesture(WebInputEvent::GesturePinchEnd);
+ ReleaseTouchPoint(1);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED);
+ EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GesturePinchEnd),
+ GetAndResetSentGestures()));
+
+ PushGesture(WebInputEvent::GestureScrollEnd);
+ ReleaseTouchPoint(0);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED);
+ EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollEnd),
+ GetAndResetSentGestures()));
+}
+
+TEST_F(GestureEventQueueTest, IndependentPacketsNotAllowed) {
+ PushGesture(WebInputEvent::GestureScrollBegin);
+ PressTouchPoint(1, 1);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED);
+ EXPECT_FALSE(GesturesSent());
+
+ // Independent packets are never sent when the global state is to drop.
+ PushGesture(WebInputEvent::GestureScrollUpdate);
MoveTouchPoint(0, 2, 2);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_FALSE(GesturesSent());
+
+ PushGesture(WebInputEvent::GesturePinchBegin);
+ PressTouchPoint(2, 2);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_FALSE(GesturesSent());
+
+ PushGesture(WebInputEvent::GesturePinchUpdate);
+ MoveTouchPoint(1, 2, 3);
SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED);
EXPECT_FALSE(GesturesSent());
@@ -265,19 +450,19 @@ TEST_F(GestureEventQueueTest, NotConsumedThenNoConsumer) {
PushGesture(WebInputEvent::GestureScrollEnd);
ReleaseTouchPoint(0);
- SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
EXPECT_FALSE(GesturesSent());
}
TEST_F(GestureEventQueueTest, MultipleTouchSequences) {
// Queue two touch-to-gestures sequences.
- PushGesture(WebInputEvent::GestureFlingStart);
+ PushGesture(WebInputEvent::GestureTapDown);
PressTouchPoint(1, 1);
- PushGesture(WebInputEvent::GestureFlingCancel);
+ PushGesture(WebInputEvent::GestureTap);
ReleaseTouchPoint(0);
- PushGesture(WebInputEvent::GestureFlingStart);
+ PushGesture(WebInputEvent::GestureScrollBegin);
PressTouchPoint(1, 1);
- PushGesture(WebInputEvent::GestureFlingCancel);
+ PushGesture(WebInputEvent::GestureScrollEnd);
ReleaseTouchPoint(0);
// The first gesture sequence should not be allowed.
@@ -288,15 +473,18 @@ TEST_F(GestureEventQueueTest, MultipleTouchSequences) {
// The subsequent sequence should "reset" allowance.
SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
- EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureFlingStart,
- WebInputEvent::GestureFlingCancel),
+ EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollBegin,
+ WebInputEvent::GestureScrollEnd),
GetAndResetSentGestures()));
}
TEST_F(GestureEventQueueTest, FlingCancelledOnNewTouchSequence) {
// Simulate a fling.
+ PushGesture(WebInputEvent::GestureScrollBegin);
PressTouchPoint(1, 1);
SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
+ EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollBegin),
+ GetAndResetSentGestures()));
PushGesture(WebInputEvent::GestureFlingStart);
ReleaseTouchPoint(0);
SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
@@ -305,10 +493,12 @@ TEST_F(GestureEventQueueTest, FlingCancelledOnNewTouchSequence) {
// A new touch seqeuence should cancel the outstanding fling.
PressTouchPoint(1, 1);
- ReleaseTouchPoint(0);
SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureFlingCancel),
GetAndResetSentGestures()));
+ ReleaseTouchPoint(0);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
+ EXPECT_FALSE(GesturesSent());
}
TEST_F(GestureEventQueueTest, FlingCancelledOnScrollBegin) {
@@ -334,19 +524,24 @@ TEST_F(GestureEventQueueTest, FlingCancelledOnScrollBegin) {
TEST_F(GestureEventQueueTest, FlingNotCancelledIfGFCEventReceived) {
// Simulate a fling that is started then cancelled.
- PushGesture(WebInputEvent::GestureFlingStart);
+ PushGesture(WebInputEvent::GestureScrollBegin);
PressTouchPoint(1, 1);
SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
+ PushGesture(WebInputEvent::GestureFlingStart);
+ MoveTouchPoint(0, 1, 1);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
PushGesture(WebInputEvent::GestureFlingCancel);
ReleaseTouchPoint(0);
SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
- EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureFlingStart,
+ EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollBegin,
+ WebInputEvent::GestureFlingStart,
WebInputEvent::GestureFlingCancel),
GetAndResetSentGestures()));
// A new touch sequence will not inject a GestureFlingCancel, as the fling
// has already been cancelled.
PressTouchPoint(1, 1);
+ SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
ReleaseTouchPoint(0);
SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
EXPECT_FALSE(GesturesSent());

Powered by Google App Engine
This is Rietveld 408576698