Index: content/browser/renderer_host/input/touch_event_queue_unittest.cc |
diff --git a/content/browser/renderer_host/input/touch_event_queue_unittest.cc b/content/browser/renderer_host/input/touch_event_queue_unittest.cc |
index fcd5ce8d07b4ba1c8b25408d73129788b71e3e5f..6f9a273576125ebd0a5c70f6b0b8049878d94b2b 100644 |
--- a/content/browser/renderer_host/input/touch_event_queue_unittest.cc |
+++ b/content/browser/renderer_host/input/touch_event_queue_unittest.cc |
@@ -1935,7 +1935,7 @@ TEST_F(TouchEventQueueTest, AsyncTouchThrottledAfterScroll) { |
EXPECT_TRUE(sent_event().cancelable); |
EXPECT_FALSE(HasPendingAsyncTouchMove()); |
EXPECT_EQ(WebInputEvent::TouchMove, sent_event().type); |
- EXPECT_EQ(WebTouchPoint::StateMoved, sent_event().touches[0].state); |
+ EXPECT_EQ(WebTouchPoint::StateStationary, sent_event().touches[0].state); |
EXPECT_EQ(WebTouchPoint::StateMoved, sent_event().touches[1].state); |
EXPECT_EQ(1U, queued_event_count()); |
EXPECT_EQ(1U, GetAndResetSentEventCount()); |
@@ -2225,4 +2225,60 @@ TEST_F(TouchEventQueueTest, UnseenTouchPointerIdsNotForwarded) { |
EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
} |
+// Tests that touches state is correct in TouchMove events. |
+TEST_F(TouchEventQueueTest, TouchMoveTouchesState) { |
+ PressTouchPoint(1, 1); |
+ PressTouchPoint(2, 2); |
+ PressTouchPoint(3, 3); |
+ PressTouchPoint(4, 4); |
+ EXPECT_EQ(4U, queued_event_count()); |
+ EXPECT_EQ(1U, GetAndResetSentEventCount()); |
+ |
+ // Receive ACK for the first three touch-events |
+ SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
+ SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
+ SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
+ EXPECT_EQ(1U, queued_event_count()); |
+ |
+ // Test current touches state before sending TouchMoves |
+ const WebTouchEvent& event1 = sent_event(); |
+ EXPECT_EQ(WebInputEvent::TouchStart, event1.type); |
+ EXPECT_EQ(WebTouchPoint::StateStationary, event1.touches[0].state); |
+ EXPECT_EQ(WebTouchPoint::StateStationary, event1.touches[1].state); |
+ EXPECT_EQ(WebTouchPoint::StateStationary, event1.touches[2].state); |
+ EXPECT_EQ(WebTouchPoint::StatePressed, event1.touches[3].state); |
+ |
+ // Move x-position for 1st touch, y-position for 2nd touch |
+ // and do not move other touches. |
+ MoveTouchPoints(0, 1.1, 1, 1, 2, 20.001); |
+ MoveTouchPoints(2, 3, 3, 3, 4, 4); |
+ EXPECT_EQ(2U, queued_event_count()); |
+ |
+ // Receive an ACK for the last TouchPress event |
+ SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
+ |
+ // 1st TouchMove is sent. Test for touches state. |
+ const WebTouchEvent& event2 = sent_event(); |
+ EXPECT_EQ(WebInputEvent::TouchMove, event2.type); |
+ EXPECT_EQ(WebTouchPoint::StateMoved, event2.touches[0].state); |
+ EXPECT_EQ(WebTouchPoint::StateMoved, event2.touches[1].state); |
+ EXPECT_EQ(WebTouchPoint::StateStationary, event2.touches[2].state); |
+ EXPECT_EQ(WebTouchPoint::StateStationary, event2.touches[3].state); |
+ |
+ // Move only 4th touch but not others. |
+ MoveTouchPoints(0, 1.1, 1, 1, 2, 20.001); |
+ MoveTouchPoints(2, 3, 3, 3, 4.1, 4.1); |
+ |
+ // Receive an ACK for previous (1st) TouchMove |
+ SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
+ |
+ // 2nd TouchMove is sent. Test for touches state. |
+ const WebTouchEvent& event3 = sent_event(); |
+ EXPECT_EQ(WebInputEvent::TouchMove, event3.type); |
+ EXPECT_EQ(WebTouchPoint::StateStationary, event3.touches[0].state); |
+ EXPECT_EQ(WebTouchPoint::StateStationary, event3.touches[1].state); |
+ EXPECT_EQ(WebTouchPoint::StateStationary, event3.touches[2].state); |
+ EXPECT_EQ(WebTouchPoint::StateMoved, event3.touches[3].state); |
+} |
+ |
} // namespace content |