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

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

Issue 2826673005: Fix recursion in handling touch input events acks. (Closed)
Patch Set: Fix nits Created 3 years, 8 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
« no previous file with comments | « content/browser/renderer_host/input/passthrough_touch_event_queue.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/input/passthrough_touch_event_queue_unittest.cc
diff --git a/content/browser/renderer_host/input/passthrough_touch_event_queue_unittest.cc b/content/browser/renderer_host/input/passthrough_touch_event_queue_unittest.cc
index 3d9171683a5f55c2502d6124249835bdaeee0118..2bed8a6df6ed9f2e4443641f5418cb034b9f1559 100644
--- a/content/browser/renderer_host/input/passthrough_touch_event_queue_unittest.cc
+++ b/content/browser/renderer_host/input/passthrough_touch_event_queue_unittest.cc
@@ -64,15 +64,14 @@ class PassthroughTouchEventQueueTest : public testing::Test,
sent_events_ids_.push_back(event.event.unique_touch_event_id);
if (sync_ack_result_) {
auto sync_ack_result = std::move(sync_ack_result_);
- SendTouchEventAck(*sync_ack_result);
+ SendTouchEventAckWithID(*sync_ack_result,
+ event.event.unique_touch_event_id);
}
}
void OnTouchEventAck(const TouchEventWithLatencyInfo& event,
InputEventAckState ack_result) override {
++acked_event_count_;
- last_acked_event_ = event.event;
- last_acked_event_state_ = ack_result;
if (followup_touch_event_) {
std::unique_ptr<WebTouchEvent> followup_touch_event =
std::move(followup_touch_event_);
@@ -84,6 +83,8 @@ class PassthroughTouchEventQueueTest : public testing::Test,
queue_->OnGestureScrollEvent(GestureEventWithLatencyInfo(
*followup_gesture_event, ui::LatencyInfo()));
}
+ last_acked_event_ = event.event;
+ last_acked_event_state_ = ack_result;
}
void OnFilteringTouchEvent(const blink::WebTouchEvent& touch_event) override {
@@ -756,6 +757,46 @@ TEST_F(PassthroughTouchEventQueueTest, SynchronousAcks) {
EXPECT_EQ(1U, GetAndResetAckedEventCount());
}
+// Tests that touch-events acks are in order even with synchronous acks.
+TEST_F(PassthroughTouchEventQueueTest, SynchronousAcksInOrder) {
+ // TouchStart
+ PressTouchPoint(1, 1);
+ EXPECT_EQ(1U, queued_event_count());
+ EXPECT_EQ(1U, GetAndResetSentEventCount());
+ EXPECT_EQ(0U, GetAndResetAckedEventCount());
+
+ // TouchMove
+ MoveTouchPoint(0, 2, 3);
+ EXPECT_EQ(2U, queued_event_count());
+ EXPECT_EQ(1U, GetAndResetSentEventCount());
+ EXPECT_EQ(0U, GetAndResetAckedEventCount());
+
+ // Ack the TouchMove
+ SendTouchEventAckLast(INPUT_EVENT_ACK_STATE_CONSUMED);
+ EXPECT_EQ(2U, queued_event_count());
+ EXPECT_EQ(0U, GetAndResetSentEventCount());
+ EXPECT_EQ(0U, GetAndResetAckedEventCount());
+
+ // Create a touch event that will be queued synchronously by a touch ack.
+ WebTouchEvent followup_event(
+ WebInputEvent::kTouchMove, WebInputEvent::kNoModifiers,
+ ui::EventTimeStampToSeconds(ui::EventTimeForNow()));
+ followup_event.touches_length = 1;
+ followup_event.touches[0].id = 0;
+ followup_event.unique_touch_event_id = 100;
+ followup_event.touches[0].state = WebTouchPoint::kStateMoved;
+ SetFollowupEvent(followup_event);
+ SetSyncAckResult(INPUT_EVENT_ACK_STATE_CONSUMED);
+
+ // Ack the touch start, should release the |follow_up| event (and its ack).
+ SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
+
+ EXPECT_EQ(0U, queued_event_count());
+ EXPECT_EQ(1U, GetAndResetSentEventCount());
+ EXPECT_EQ(3U, GetAndResetAckedEventCount());
+ EXPECT_EQ(100U, acked_event().unique_touch_event_id);
+}
+
// Tests that followup events triggered by an immediate ack from
// TouchEventQueue::QueueEvent() are properly handled.
TEST_F(PassthroughTouchEventQueueTest, ImmediateAckWithFollowupEvents) {
@@ -774,7 +815,6 @@ TEST_F(PassthroughTouchEventQueueTest, ImmediateAckWithFollowupEvents) {
WebTouchEvent stationary_event(
WebInputEvent::kTouchMove, WebInputEvent::kNoModifiers,
ui::EventTimeStampToSeconds(ui::EventTimeForNow()));
- ;
stationary_event.touches_length = 1;
stationary_event.touches[0].id = 1;
stationary_event.touches[0].state = WebTouchPoint::kStateStationary;
« no previous file with comments | « content/browser/renderer_host/input/passthrough_touch_event_queue.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698