diff options
-rw-r--r-- | content/common/input/gesture_event_stream_validator.cc | 10 | ||||
-rw-r--r-- | content/common/input/gesture_event_stream_validator_unittest.cc | 28 |
2 files changed, 33 insertions, 5 deletions
diff --git a/content/common/input/gesture_event_stream_validator.cc b/content/common/input/gesture_event_stream_validator.cc index b95a674..eccdbe0 100644 --- a/content/common/input/gesture_event_stream_validator.cc +++ b/content/common/input/gesture_event_stream_validator.cc @@ -62,13 +62,19 @@ bool GestureEventStreamValidator::Validate(const blink::WebGestureEvent& event, error_msg->append("Missing tap end event\n"); waiting_for_tap_end_ = true; break; - case WebInputEvent::GestureTap: + case WebInputEvent::GestureTapUnconfirmed: + if (!waiting_for_tap_end_) + error_msg->append("Missing TapDown event before TapUnconfirmed\n"); + break; case WebInputEvent::GestureTapCancel: if (!waiting_for_tap_end_) - error_msg->append("Missing GestureTapDown event\n"); + error_msg->append("Missing TapDown event before TapCancel\n"); waiting_for_tap_end_ = false; break; + case WebInputEvent::GestureTap: case WebInputEvent::GestureDoubleTap: + // Both Tap and DoubleTap gestures may be synthetically inserted, and do + // not require a preceding TapDown. waiting_for_tap_end_ = false; break; default: diff --git a/content/common/input/gesture_event_stream_validator_unittest.cc b/content/common/input/gesture_event_stream_validator_unittest.cc index 2a97d8b..857dcfe 100644 --- a/content/common/input/gesture_event_stream_validator_unittest.cc +++ b/content/common/input/gesture_event_stream_validator_unittest.cc @@ -165,7 +165,7 @@ TEST(GestureEventStreamValidator, ValidTap) { EXPECT_TRUE(validator.Validate(event, &error_msg)); EXPECT_TRUE(error_msg.empty()); - event = Build(WebInputEvent::GestureTap); + event = Build(WebInputEvent::GestureTapCancel); EXPECT_TRUE(validator.Validate(event, &error_msg)); EXPECT_TRUE(error_msg.empty()); @@ -173,11 +173,20 @@ TEST(GestureEventStreamValidator, ValidTap) { EXPECT_TRUE(validator.Validate(event, &error_msg)); EXPECT_TRUE(error_msg.empty()); + event = Build(WebInputEvent::GestureTapUnconfirmed); + EXPECT_TRUE(validator.Validate(event, &error_msg)); + EXPECT_TRUE(error_msg.empty()); + event = Build(WebInputEvent::GestureTapCancel); EXPECT_TRUE(validator.Validate(event, &error_msg)); EXPECT_TRUE(error_msg.empty()); - // DoubleTap doesn't require a TapDown (unlike Tap and TapCancel). + // Tap and DoubleTap do not require a TapDown (unlike TapUnconfirmed and + // TapCancel). + event = Build(WebInputEvent::GestureTap); + EXPECT_TRUE(validator.Validate(event, &error_msg)); + EXPECT_TRUE(error_msg.empty()); + event = Build(WebInputEvent::GestureDoubleTap); EXPECT_TRUE(validator.Validate(event, &error_msg)); EXPECT_TRUE(error_msg.empty()); @@ -189,7 +198,7 @@ TEST(GestureEventStreamValidator, InvalidTap) { WebGestureEvent event; // No preceding TapDown. - event = Build(WebInputEvent::GestureTap); + event = Build(WebInputEvent::GestureTapUnconfirmed); EXPECT_FALSE(validator.Validate(event, &error_msg)); EXPECT_FALSE(error_msg.empty()); @@ -209,6 +218,19 @@ TEST(GestureEventStreamValidator, InvalidTap) { event = Build(WebInputEvent::GestureTapCancel); EXPECT_FALSE(validator.Validate(event, &error_msg)); EXPECT_FALSE(error_msg.empty()); + + // TapDown already terminated. + event = Build(WebInputEvent::GestureTapDown); + EXPECT_TRUE(validator.Validate(event, &error_msg)); + EXPECT_TRUE(error_msg.empty()); + + event = Build(WebInputEvent::GestureTap); + EXPECT_TRUE(validator.Validate(event, &error_msg)); + EXPECT_TRUE(error_msg.empty()); + + event = Build(WebInputEvent::GestureTapCancel); + EXPECT_FALSE(validator.Validate(event, &error_msg)); + EXPECT_FALSE(error_msg.empty()); } } // namespace content |