Chromium Code Reviews| 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 833f0ab5fee55ba61af64985edb73fd6085e3fb6..6c1753b27d5ea632aed419b741416bc64540d6b5 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()); |
| + |
| + MoveTouchPoint(0, 2, 3); |
| + EXPECT_EQ(2U, queued_event_count()); |
| + EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| + EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
| + |
| + SendTouchEventAckLast(INPUT_EVENT_ACK_STATE_CONSUMED); |
|
tdresser
2017/04/18 18:57:02
Can you comment that this will ack the touchmove,
dtapuska
2017/04/18 19:56:52
Done.
|
| + EXPECT_EQ(2U, queued_event_count()); |
| + EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| + EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
| + |
| + // TouchMove |
| + // Ack the touch start, should release two events. |
| + // Create a touch event that will be queued synchronously by a touch ack. |
| + // Note, this will be triggered by all subsequent touch acks. |
|
tdresser
2017/04/18 18:57:02
I don't quite understand "this will be triggered b
dtapuska
2017/04/18 19:56:52
Done.
|
| + 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); |
| + 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) { |