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

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

Issue 44983003: Events ignoring ack disposition receive synthetic acks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: jdduke comments. Created 7 years, 1 month 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/immediate_input_router_unittest.cc
diff --git a/content/browser/renderer_host/input/immediate_input_router_unittest.cc b/content/browser/renderer_host/input/immediate_input_router_unittest.cc
index 5162555a788848a567027accc7c3a693fbe0012c..cddc2ad5ec8e79d37731c67450251848675d5359 100644
--- a/content/browser/renderer_host/input/immediate_input_router_unittest.cc
+++ b/content/browser/renderer_host/input/immediate_input_router_unittest.cc
@@ -558,4 +558,127 @@ TEST_F(ImmediateInputRouterTest, UnhandledWheelEvent) {
EXPECT_EQ(ack_handler_->acked_wheel_event().deltaY, -5);
}
+// Test that GestureShowPress, GestureTapDown and GestureTapCancel events don't
+// wait for ACKs.
+TEST_F(ImmediateInputRouterTest, GestureTypesIgnoringAck) {
+ // The show press, tap down and tap cancel events will be acked immediately,
+ // since they ignore ack disposition.
+ SimulateGestureEvent(WebInputEvent::GestureShowPress,
+ WebGestureEvent::Touchscreen);
+ EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
+
+ SimulateGestureEvent(WebInputEvent::GestureTapDown,
+ WebGestureEvent::Touchscreen);
+ EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
+
+ SimulateGestureEvent(WebInputEvent::GestureTapCancel,
+ WebGestureEvent::Touchscreen);
+ EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
+
+ // Interleave a few events that do and do not ignore acks, ensuring that
+ // ack-ignoring events aren't dispatched until all prior events which observe
+ // their ack disposition have been dispatched.
+ SimulateGestureEvent(WebInputEvent::GesturePinchBegin,
+ WebGestureEvent::Touchpad);
+ ASSERT_EQ(1U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
+
+ SimulateGestureEvent(WebInputEvent::GestureTapDown,
+ WebGestureEvent::Touchscreen);
+ EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
+
+ SimulateGestureEvent(WebInputEvent::GesturePinchUpdate,
+ WebGestureEvent::Touchpad);
+ EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
+
+ SimulateGestureEvent(WebInputEvent::GestureShowPress,
+ WebGestureEvent::Touchscreen);
+ EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
+
+ SimulateGestureEvent(WebInputEvent::GesturePinchEnd,
+ WebGestureEvent::Touchpad);
+ EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
+
+ SimulateGestureEvent(WebInputEvent::GestureTapCancel,
+ WebGestureEvent::Touchscreen);
+ EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
+
+ // Now ack each event. Ack-ignoring events should not be dispatched until all
+ // prior events which observe ack disposition have been fired, at which
+ // point they should be sent immediately.
+ SendInputEventACK(WebInputEvent::GesturePinchBegin,
+ INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_EQ(2U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(2U, ack_handler_->GetAndResetAckCount());
+
+ // For events which ignore ack disposition, non-synthetic acks are ignored.
+ SendInputEventACK(WebInputEvent::GestureTapDown,
+ INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
+
+ SendInputEventACK(WebInputEvent::GesturePinchUpdate,
+ INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_EQ(2U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(2U, ack_handler_->GetAndResetAckCount());
+
+ // For events which ignore ack disposition, non-synthetic acks are ignored.
+ SendInputEventACK(WebInputEvent::GestureShowPress,
+ INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
+
+ SendInputEventACK(WebInputEvent::GesturePinchEnd,
+ INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(2U, ack_handler_->GetAndResetAckCount());
+
+ // For events which ignore ack disposition, non-synthetic acks are ignored.
+ SendInputEventACK(WebInputEvent::GestureTapCancel,
+ INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
+}
+
+// Test that GestureShowPress events don't get out of order due to
+// ignoring their acks.
+TEST_F(ImmediateInputRouterTest, GestureShowPressIsInOrder) {
+ SimulateGestureEvent(WebInputEvent::GestureTap,
+ WebGestureEvent::Touchscreen);
+
+ EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
+
+ SimulateGestureEvent(WebInputEvent::GestureShowPress,
+ WebGestureEvent::Touchscreen);
+
+ EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
+ // The ShowPress, though it ignores ack, is still stuck in the queue
+ // behind the Tap which requires an ack.
+ EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
+
+ SimulateGestureEvent(WebInputEvent::GestureShowPress,
+ WebGestureEvent::Touchscreen);
+
+ EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
+ // ShowPress has entered the queue.
+ EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
+
+ SendInputEventACK(WebInputEvent::GestureTap,
+ INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+
+ // Now that the Tap has been ACKed, the ShowPress events should receive
+ // synthetics acks, and fire immediately.
+ EXPECT_EQ(2U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(3U, ack_handler_->GetAndResetAckCount());
+}
+
} // namespace content
« no previous file with comments | « content/browser/renderer_host/input/immediate_input_router.cc ('k') | content/common/input/web_input_event_traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698