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

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: Add test for single synchronous ack. 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 63ef7d2820766ba1df4ea9acee7c8bc3573a39eb..4ceb2786288f04b4a9801585a54803dfa2dc3acb 100644
--- a/content/browser/renderer_host/input/immediate_input_router_unittest.cc
+++ b/content/browser/renderer_host/input/immediate_input_router_unittest.cc
@@ -129,6 +129,11 @@ class ImmediateInputRouterTest : public InputRouterTest {
return static_cast<ImmediateInputRouter*>(input_router_.get());
}
+ unsigned GestureEventQueueSize() {
jdduke (slow) 2013/11/07 15:57:42 Nit: size_t
tdresser 2013/11/07 22:12:01 Done.
+ return input_router()->gesture_event_filter_->
+ coalesced_gesture_events_.size();
+ }
+
bool no_touch_to_renderer() {
return input_router()->touch_event_queue_->no_touch_to_renderer();
}
@@ -558,4 +563,146 @@ 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(0U, GestureEventQueueSize());
+ EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
+
+ SimulateGestureEvent(WebInputEvent::GestureTapDown,
+ WebGestureEvent::Touchscreen);
+ EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(0U, GestureEventQueueSize());
+ EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
+
+ SimulateGestureEvent(WebInputEvent::GestureTapCancel,
+ WebGestureEvent::Touchscreen);
+ EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(0U, GestureEventQueueSize());
+ 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());
+ ASSERT_EQ(1U, GestureEventQueueSize());
+ EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
+
+ SimulateGestureEvent(WebInputEvent::GestureTapDown,
+ WebGestureEvent::Touchscreen);
+ EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(2U, GestureEventQueueSize());
+ EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
+
+ SimulateGestureEvent(WebInputEvent::GesturePinchUpdate,
+ WebGestureEvent::Touchpad);
+ EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(3U, GestureEventQueueSize());
+ EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
+
+ SimulateGestureEvent(WebInputEvent::GestureShowPress,
+ WebGestureEvent::Touchscreen);
+ EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(4U, GestureEventQueueSize());
+ EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
+
+ SimulateGestureEvent(WebInputEvent::GesturePinchEnd,
+ WebGestureEvent::Touchpad);
+ EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(5U, GestureEventQueueSize());
+ EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
+
+ SimulateGestureEvent(WebInputEvent::GestureTapCancel,
+ WebGestureEvent::Touchscreen);
+ EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(6U, GestureEventQueueSize());
+ 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(4U, GestureEventQueueSize());
+ 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(4U, GestureEventQueueSize());
+ EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
+
+ SendInputEventACK(WebInputEvent::GesturePinchUpdate,
+ INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_EQ(2U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(2U, GestureEventQueueSize());
+ 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(2U, GestureEventQueueSize());
+ EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
+
+ SendInputEventACK(WebInputEvent::GesturePinchEnd,
+ INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(0U, GestureEventQueueSize());
+ 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, GestureEventQueueSize());
+ 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(1U, GestureEventQueueSize());
+ 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(2U, GestureEventQueueSize());
+ EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
+
+ SimulateGestureEvent(WebInputEvent::GestureShowPress,
+ WebGestureEvent::Touchscreen);
+
+ EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
+ // ShowPress has entered the queue.
+ EXPECT_EQ(3U, GestureEventQueueSize());
+ 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(0U, GestureEventQueueSize());
+ EXPECT_EQ(3U, ack_handler_->GetAndResetAckCount());
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698