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

Side by Side Diff: content/browser/renderer_host/input/input_router_impl_unittest.cc

Issue 1800143002: Notify Blink about start of gesture scroll through a queued event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed touch_event_stream_validator Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <math.h> 5 #include <math.h>
6 #include <stddef.h> 6 #include <stddef.h>
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 touch_event_.SetTimestamp(timestamp); 267 touch_event_.SetTimestamp(timestamp);
268 } 268 }
269 269
270 uint32_t SendTouchEvent() { 270 uint32_t SendTouchEvent() {
271 uint32_t touch_event_id = touch_event_.uniqueTouchEventId; 271 uint32_t touch_event_id = touch_event_.uniqueTouchEventId;
272 input_router_->SendTouchEvent(TouchEventWithLatencyInfo(touch_event_)); 272 input_router_->SendTouchEvent(TouchEventWithLatencyInfo(touch_event_));
273 touch_event_.ResetPoints(); 273 touch_event_.ResetPoints();
274 return touch_event_id; 274 return touch_event_id;
275 } 275 }
276 276
277 void ProcessSyntheticInputEventAck(WebInputEvent::Type type) {
tdresser 2016/04/01 14:50:24 Let's make this method more specific - something l
mustaq 2016/04/01 18:31:04 Done.
278 ui::LatencyInfo latency_info;
279 input_router_->ProcessInputEventAck(type, INPUT_EVENT_ACK_STATE_IGNORED,
280 latency_info, 0, InputRouterImpl::IGNORING_DISPOSITION);
281 }
282
277 int PressTouchPoint(int x, int y) { 283 int PressTouchPoint(int x, int y) {
278 return touch_event_.PressPoint(x, y); 284 return touch_event_.PressPoint(x, y);
279 } 285 }
280 286
281 void MoveTouchPoint(int index, int x, int y) { 287 void MoveTouchPoint(int index, int x, int y) {
282 touch_event_.MovePoint(index, x, y); 288 touch_event_.MovePoint(index, x, y);
283 } 289 }
284 290
285 void ReleaseTouchPoint(int index) { 291 void ReleaseTouchPoint(int index) {
286 touch_event_.ReleasePoint(index); 292 touch_event_.ReleasePoint(index);
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); 1102 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
1097 EXPECT_EQ(0, client_->in_flight_event_count()); 1103 EXPECT_EQ(0, client_->in_flight_event_count());
1098 EXPECT_FALSE(HasPendingEvents()); 1104 EXPECT_FALSE(HasPendingEvents());
1099 continue; 1105 continue;
1100 } 1106 }
1101 1107
1102 SimulateGestureEvent(type, blink::WebGestureDeviceTouchscreen); 1108 SimulateGestureEvent(type, blink::WebGestureDeviceTouchscreen);
1103 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1109 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1104 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); 1110 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
1105 EXPECT_EQ(0, client_->in_flight_event_count()); 1111 EXPECT_EQ(0, client_->in_flight_event_count());
1112
1113 if (type == WebInputEvent::GestureScrollBegin)
1114 ProcessSyntheticInputEventAck(WebInputEvent::TouchScrollStarted);
1106 EXPECT_FALSE(HasPendingEvents()); 1115 EXPECT_FALSE(HasPendingEvents());
1107 } 1116 }
1108 } 1117 }
1109 1118
1110 TEST_F(InputRouterImplTest, MouseTypesIgnoringAck) { 1119 TEST_F(InputRouterImplTest, MouseTypesIgnoringAck) {
1111 int start_type = static_cast<int>(WebInputEvent::MouseDown); 1120 int start_type = static_cast<int>(WebInputEvent::MouseDown);
1112 int end_type = static_cast<int>(WebInputEvent::ContextMenu); 1121 int end_type = static_cast<int>(WebInputEvent::ContextMenu);
1113 ASSERT_LT(start_type, end_type); 1122 ASSERT_LT(start_type, end_type);
1114 for (int i = start_type; i <= end_type; ++i) { 1123 for (int i = start_type; i <= end_type; ++i) {
1115 WebInputEvent::Type type = static_cast<WebInputEvent::Type>(i); 1124 WebInputEvent::Type type = static_cast<WebInputEvent::Type>(i);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 } 1235 }
1227 1236
1228 // Test that GestureShowPress events don't get out of order due to 1237 // Test that GestureShowPress events don't get out of order due to
1229 // ignoring their acks. 1238 // ignoring their acks.
1230 TEST_F(InputRouterImplTest, GestureShowPressIsInOrder) { 1239 TEST_F(InputRouterImplTest, GestureShowPressIsInOrder) {
1231 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 1240 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
1232 blink::WebGestureDeviceTouchscreen); 1241 blink::WebGestureDeviceTouchscreen);
1233 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1242 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1234 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); 1243 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
1235 1244
1236
1237 // GesturePinchBegin ignores its ack. 1245 // GesturePinchBegin ignores its ack.
1238 SimulateGestureEvent(WebInputEvent::GesturePinchBegin, 1246 SimulateGestureEvent(WebInputEvent::GesturePinchBegin,
1239 blink::WebGestureDeviceTouchscreen); 1247 blink::WebGestureDeviceTouchscreen);
1240 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1248 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1241 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); 1249 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
1242 1250
1243 // GesturePinchUpdate waits for an ack. 1251 // GesturePinchUpdate waits for an ack.
1244 // This also verifies that GesturePinchUpdates for touchscreen are sent 1252 // This also verifies that GesturePinchUpdates for touchscreen are sent
1245 // to the renderer (in contrast to the TrackpadPinchUpdate test). 1253 // to the renderer (in contrast to the TrackpadPinchUpdate test).
1246 SimulateGestureEvent(WebInputEvent::GesturePinchUpdate, 1254 SimulateGestureEvent(WebInputEvent::GesturePinchUpdate,
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
1685 // Test that the router will call the client's |DidFlush| after all fling 1693 // Test that the router will call the client's |DidFlush| after all fling
1686 // animations have completed. 1694 // animations have completed.
1687 TEST_F(InputRouterImplTest, InputFlushAfterFling) { 1695 TEST_F(InputRouterImplTest, InputFlushAfterFling) {
1688 EXPECT_FALSE(HasPendingEvents()); 1696 EXPECT_FALSE(HasPendingEvents());
1689 1697
1690 // Simulate a fling. 1698 // Simulate a fling.
1691 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 1699 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
1692 blink::WebGestureDeviceTouchscreen); 1700 blink::WebGestureDeviceTouchscreen);
1693 SimulateGestureEvent(WebInputEvent::GestureFlingStart, 1701 SimulateGestureEvent(WebInputEvent::GestureFlingStart,
1694 blink::WebGestureDeviceTouchscreen); 1702 blink::WebGestureDeviceTouchscreen);
1703 ProcessSyntheticInputEventAck(WebInputEvent::TouchScrollStarted);
tdresser 2016/04/01 14:50:24 Shouldn't we assert somewhere that we output Touch
mustaq 2016/04/01 18:31:04 The existing tests here only care about events pas
1695 EXPECT_TRUE(HasPendingEvents()); 1704 EXPECT_TRUE(HasPendingEvents());
1696 1705
1697 // If the fling is unconsumed, the flush is complete. 1706 // If the fling is unconsumed, the flush is complete.
1698 RequestNotificationWhenFlushed(); 1707 RequestNotificationWhenFlushed();
1699 EXPECT_EQ(0U, GetAndResetDidFlushCount()); 1708 EXPECT_EQ(0U, GetAndResetDidFlushCount());
1700 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 1709 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
1701 blink::WebGestureDeviceTouchscreen); 1710 blink::WebGestureDeviceTouchscreen);
1702 SendInputEventACK(WebInputEvent::GestureFlingStart, 1711 SendInputEventACK(WebInputEvent::GestureFlingStart,
1703 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1712 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1713 ProcessSyntheticInputEventAck(WebInputEvent::TouchScrollStarted);
1704 EXPECT_FALSE(HasPendingEvents()); 1714 EXPECT_FALSE(HasPendingEvents());
1715
1705 EXPECT_EQ(1U, GetAndResetDidFlushCount()); 1716 EXPECT_EQ(1U, GetAndResetDidFlushCount());
1706 1717
1707 // Simulate a second fling. 1718 // Simulate a second fling.
1708 SimulateGestureEvent(WebInputEvent::GestureFlingStart, 1719 SimulateGestureEvent(WebInputEvent::GestureFlingStart,
1709 blink::WebGestureDeviceTouchscreen); 1720 blink::WebGestureDeviceTouchscreen);
1710 EXPECT_TRUE(HasPendingEvents()); 1721 EXPECT_TRUE(HasPendingEvents());
1711 1722
1712 // If the fling is consumed, the flush is complete only when the renderer 1723 // If the fling is consumed, the flush is complete only when the renderer
1713 // reports that is has ended. 1724 // reports that is has ended.
1714 RequestNotificationWhenFlushed(); 1725 RequestNotificationWhenFlushed();
1715 EXPECT_EQ(0U, GetAndResetDidFlushCount()); 1726 EXPECT_EQ(0U, GetAndResetDidFlushCount());
1716 SendInputEventACK(WebInputEvent::GestureFlingStart, 1727 SendInputEventACK(WebInputEvent::GestureFlingStart,
1717 INPUT_EVENT_ACK_STATE_CONSUMED); 1728 INPUT_EVENT_ACK_STATE_CONSUMED);
1718 EXPECT_TRUE(HasPendingEvents()); 1729 EXPECT_TRUE(HasPendingEvents());
1719 EXPECT_EQ(0U, GetAndResetDidFlushCount()); 1730 EXPECT_EQ(0U, GetAndResetDidFlushCount());
1720 1731
1721 // The fling end notification should signal that the router is flushed. 1732 // The fling end notification should signal that the router is flushed.
1722 input_router()->OnMessageReceived(InputHostMsg_DidStopFlinging(0)); 1733 input_router()->OnMessageReceived(InputHostMsg_DidStopFlinging(0));
1723 EXPECT_EQ(1U, GetAndResetDidFlushCount()); 1734 EXPECT_EQ(1U, GetAndResetDidFlushCount());
1724 1735
1725 // Even flings consumed by the client require a fling-end notification. 1736 // Even flings consumed by the client require a fling-end notification.
1726 client_->set_filter_state(INPUT_EVENT_ACK_STATE_CONSUMED); 1737 client_->set_filter_state(INPUT_EVENT_ACK_STATE_CONSUMED);
1727 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 1738 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
1728 blink::WebGestureDeviceTouchscreen); 1739 blink::WebGestureDeviceTouchscreen);
1729 SimulateGestureEvent(WebInputEvent::GestureFlingStart, 1740 SimulateGestureEvent(WebInputEvent::GestureFlingStart,
1730 blink::WebGestureDeviceTouchscreen); 1741 blink::WebGestureDeviceTouchscreen);
1742 ProcessSyntheticInputEventAck(WebInputEvent::TouchScrollStarted);
1731 ASSERT_TRUE(HasPendingEvents()); 1743 ASSERT_TRUE(HasPendingEvents());
1732 RequestNotificationWhenFlushed(); 1744 RequestNotificationWhenFlushed();
1733 EXPECT_EQ(0U, GetAndResetDidFlushCount()); 1745 EXPECT_EQ(0U, GetAndResetDidFlushCount());
1734 input_router()->OnMessageReceived(InputHostMsg_DidStopFlinging(0)); 1746 input_router()->OnMessageReceived(InputHostMsg_DidStopFlinging(0));
1735 EXPECT_EQ(1U, GetAndResetDidFlushCount()); 1747 EXPECT_EQ(1U, GetAndResetDidFlushCount());
1736 } 1748 }
1737 1749
1738 // Test that GesturePinchUpdate is handled specially for trackpad 1750 // Test that GesturePinchUpdate is handled specially for trackpad
1739 TEST_F(InputRouterImplTest, TouchpadPinchUpdate) { 1751 TEST_F(InputRouterImplTest, TouchpadPinchUpdate) {
1740 // GesturePinchUpdate for trackpad sends synthetic wheel events. 1752 // GesturePinchUpdate for trackpad sends synthetic wheel events.
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
2329 EXPECT_EQ(80, sent_event->data.flingStart.velocityY); 2341 EXPECT_EQ(80, sent_event->data.flingStart.velocityY);
2330 2342
2331 const WebGestureEvent* filter_event = 2343 const WebGestureEvent* filter_event =
2332 GetFilterWebInputEvent<WebGestureEvent>(); 2344 GetFilterWebInputEvent<WebGestureEvent>();
2333 TestLocationInFilterEvent(filter_event, orig); 2345 TestLocationInFilterEvent(filter_event, orig);
2334 EXPECT_EQ(30, filter_event->data.flingStart.velocityX); 2346 EXPECT_EQ(30, filter_event->data.flingStart.velocityX);
2335 EXPECT_EQ(40, filter_event->data.flingStart.velocityY); 2347 EXPECT_EQ(40, filter_event->data.flingStart.velocityY);
2336 } 2348 }
2337 2349
2338 } // namespace content 2350 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698