| OLD | NEW |
| 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 "content/browser/renderer_host/input/input_router_impl.h" | 5 #include "content/browser/renderer_host/input/input_router_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 } | 143 } |
| 144 | 144 |
| 145 return true; | 145 return true; |
| 146 } | 146 } |
| 147 #endif // defined(USE_AURA) | 147 #endif // defined(USE_AURA) |
| 148 | 148 |
| 149 } // namespace | 149 } // namespace |
| 150 | 150 |
| 151 class InputRouterImplTest : public testing::Test { | 151 class InputRouterImplTest : public testing::Test { |
| 152 public: | 152 public: |
| 153 InputRouterImplTest(bool raf_aligned_touch = false) { | 153 InputRouterImplTest(bool raf_aligned_touch = true) { |
| 154 if (raf_aligned_touch) { | 154 if (raf_aligned_touch) { |
| 155 feature_list_.InitFromCommandLine( | 155 feature_list_.InitFromCommandLine( |
| 156 features::kRafAlignedTouchInputEvents.name, ""); | 156 features::kRafAlignedTouchInputEvents.name, ""); |
| 157 } else { | 157 } else { |
| 158 feature_list_.InitFromCommandLine( | 158 feature_list_.InitFromCommandLine( |
| 159 "", features::kRafAlignedTouchInputEvents.name); | 159 "", features::kRafAlignedTouchInputEvents.name); |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 | 162 |
| 163 ~InputRouterImplTest() override {} | 163 ~InputRouterImplTest() override {} |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 std::unique_ptr<InputRouterImpl> input_router_; | 369 std::unique_ptr<InputRouterImpl> input_router_; |
| 370 | 370 |
| 371 private: | 371 private: |
| 372 base::MessageLoopForUI message_loop_; | 372 base::MessageLoopForUI message_loop_; |
| 373 SyntheticWebTouchEvent touch_event_; | 373 SyntheticWebTouchEvent touch_event_; |
| 374 | 374 |
| 375 base::test::ScopedFeatureList feature_list_; | 375 base::test::ScopedFeatureList feature_list_; |
| 376 std::unique_ptr<TestBrowserContext> browser_context_; | 376 std::unique_ptr<TestBrowserContext> browser_context_; |
| 377 }; | 377 }; |
| 378 | 378 |
| 379 class InputRouterImplRafAlignedTouchEnabledTest : public InputRouterImplTest { | 379 class InputRouterImplRafAlignedTouchDisabledTest : public InputRouterImplTest { |
| 380 public: | 380 public: |
| 381 InputRouterImplRafAlignedTouchEnabledTest() : InputRouterImplTest(true) {} | 381 InputRouterImplRafAlignedTouchDisabledTest() : InputRouterImplTest(false) {} |
| 382 }; | 382 }; |
| 383 | 383 |
| 384 TEST_F(InputRouterImplTest, CoalescesRangeSelection) { | 384 TEST_F(InputRouterImplTest, CoalescesRangeSelection) { |
| 385 input_router_->SendInput(std::unique_ptr<IPC::Message>( | 385 input_router_->SendInput(std::unique_ptr<IPC::Message>( |
| 386 new InputMsg_SelectRange(0, gfx::Point(1, 2), gfx::Point(3, 4)))); | 386 new InputMsg_SelectRange(0, gfx::Point(1, 2), gfx::Point(3, 4)))); |
| 387 ExpectIPCMessageWithArg2<InputMsg_SelectRange>( | 387 ExpectIPCMessageWithArg2<InputMsg_SelectRange>( |
| 388 process_->sink().GetMessageAt(0), | 388 process_->sink().GetMessageAt(0), |
| 389 gfx::Point(1, 2), | 389 gfx::Point(1, 2), |
| 390 gfx::Point(3, 4)); | 390 gfx::Point(3, 4)); |
| 391 EXPECT_EQ(1u, GetSentMessageCountAndResetSink()); | 391 EXPECT_EQ(1u, GetSentMessageCountAndResetSink()); |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 799 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 800 | 800 |
| 801 // After the final ack, the queue should be empty. | 801 // After the final ack, the queue should be empty. |
| 802 SendInputEventACK(WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED); | 802 SendInputEventACK(WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED); |
| 803 base::RunLoop().RunUntilIdle(); | 803 base::RunLoop().RunUntilIdle(); |
| 804 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); | 804 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
| 805 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 805 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 806 } | 806 } |
| 807 | 807 |
| 808 // Tests that touch-events are queued properly. | 808 // Tests that touch-events are queued properly. |
| 809 TEST_F(InputRouterImplTest, TouchEventQueue) { | 809 TEST_F(InputRouterImplRafAlignedTouchDisabledTest, TouchEventQueue) { |
| 810 OnHasTouchEventHandlers(true); | 810 OnHasTouchEventHandlers(true); |
| 811 | 811 |
| 812 PressTouchPoint(1, 1); | 812 PressTouchPoint(1, 1); |
| 813 uint32_t touch_press_event_id = SendTouchEvent(); | 813 uint32_t touch_press_event_id = SendTouchEvent(); |
| 814 EXPECT_TRUE(client_->GetAndResetFilterEventCalled()); | 814 EXPECT_TRUE(client_->GetAndResetFilterEventCalled()); |
| 815 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 815 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 816 EXPECT_FALSE(TouchEventQueueEmpty()); | 816 EXPECT_FALSE(TouchEventQueueEmpty()); |
| 817 | 817 |
| 818 // The second touch should not be sent since one is already in queue. | 818 // The second touch should not be sent since one is already in queue. |
| 819 MoveTouchPoint(0, 5, 5); | 819 MoveTouchPoint(0, 5, 5); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 833 | 833 |
| 834 SendTouchEventACK(WebInputEvent::TouchMove, INPUT_EVENT_ACK_STATE_CONSUMED, | 834 SendTouchEventACK(WebInputEvent::TouchMove, INPUT_EVENT_ACK_STATE_CONSUMED, |
| 835 touch_move_event_id); | 835 touch_move_event_id); |
| 836 EXPECT_TRUE(TouchEventQueueEmpty()); | 836 EXPECT_TRUE(TouchEventQueueEmpty()); |
| 837 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); | 837 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
| 838 EXPECT_EQ(WebInputEvent::TouchMove, | 838 EXPECT_EQ(WebInputEvent::TouchMove, |
| 839 ack_handler_->acked_touch_event().event.type()); | 839 ack_handler_->acked_touch_event().event.type()); |
| 840 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 840 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 841 } | 841 } |
| 842 | 842 |
| 843 // Tests that touch-events are sent properly. |
| 844 TEST_F(InputRouterImplTest, TouchEventQueue) { |
| 845 OnHasTouchEventHandlers(true); |
| 846 |
| 847 PressTouchPoint(1, 1); |
| 848 uint32_t touch_press_event_id = SendTouchEvent(); |
| 849 EXPECT_TRUE(client_->GetAndResetFilterEventCalled()); |
| 850 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 851 EXPECT_FALSE(TouchEventQueueEmpty()); |
| 852 |
| 853 // The second touch should be sent right away. |
| 854 MoveTouchPoint(0, 5, 5); |
| 855 uint32_t touch_move_event_id = SendTouchEvent(); |
| 856 EXPECT_TRUE(client_->GetAndResetFilterEventCalled()); |
| 857 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 858 EXPECT_FALSE(TouchEventQueueEmpty()); |
| 859 |
| 860 // Receive an ACK for the first touch-event. |
| 861 SendTouchEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED, |
| 862 touch_press_event_id); |
| 863 EXPECT_FALSE(TouchEventQueueEmpty()); |
| 864 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
| 865 EXPECT_EQ(WebInputEvent::TouchStart, |
| 866 ack_handler_->acked_touch_event().event.type()); |
| 867 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 868 |
| 869 SendTouchEventACK(WebInputEvent::TouchMove, INPUT_EVENT_ACK_STATE_CONSUMED, |
| 870 touch_move_event_id); |
| 871 EXPECT_TRUE(TouchEventQueueEmpty()); |
| 872 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
| 873 EXPECT_EQ(WebInputEvent::TouchMove, |
| 874 ack_handler_->acked_touch_event().event.type()); |
| 875 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 876 } |
| 877 |
| 843 // Tests that the touch-queue is emptied after a page stops listening for touch | 878 // Tests that the touch-queue is emptied after a page stops listening for touch |
| 844 // events and the outstanding ack is received. | 879 // events and the outstanding ack is received. |
| 845 TEST_F(InputRouterImplTest, TouchEventQueueFlush) { | 880 TEST_F(InputRouterImplTest, TouchEventQueueFlush) { |
| 846 OnHasTouchEventHandlers(true); | 881 OnHasTouchEventHandlers(true); |
| 847 EXPECT_TRUE(client_->has_touch_handler()); | 882 EXPECT_TRUE(client_->has_touch_handler()); |
| 848 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 883 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 849 EXPECT_TRUE(TouchEventQueueEmpty()); | 884 EXPECT_TRUE(TouchEventQueueEmpty()); |
| 850 | 885 |
| 851 // Send a touch-press event. | 886 // Send a touch-press event. |
| 852 PressTouchPoint(1, 1); | 887 PressTouchPoint(1, 1); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 WebInputEvent::GestureScrollBegin, | 1089 WebInputEvent::GestureScrollBegin, |
| 1055 WebInputEvent::GestureScrollUpdate, | 1090 WebInputEvent::GestureScrollUpdate, |
| 1056 WebInputEvent::GesturePinchBegin, | 1091 WebInputEvent::GesturePinchBegin, |
| 1057 WebInputEvent::GesturePinchUpdate, | 1092 WebInputEvent::GesturePinchUpdate, |
| 1058 WebInputEvent::GesturePinchEnd, | 1093 WebInputEvent::GesturePinchEnd, |
| 1059 WebInputEvent::GestureScrollEnd}; | 1094 WebInputEvent::GestureScrollEnd}; |
| 1060 for (size_t i = 0; i < arraysize(eventTypes); ++i) { | 1095 for (size_t i = 0; i < arraysize(eventTypes); ++i) { |
| 1061 WebInputEvent::Type type = eventTypes[i]; | 1096 WebInputEvent::Type type = eventTypes[i]; |
| 1062 if (ShouldBlockEventStream(GetEventWithType(type))) { | 1097 if (ShouldBlockEventStream(GetEventWithType(type))) { |
| 1063 SimulateGestureEvent(type, blink::WebGestureDeviceTouchscreen); | 1098 SimulateGestureEvent(type, blink::WebGestureDeviceTouchscreen); |
| 1064 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1099 if (type == WebInputEvent::GestureScrollUpdate) |
| 1100 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); |
| 1101 else |
| 1102 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 1065 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); | 1103 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
| 1066 EXPECT_EQ(1, client_->in_flight_event_count()); | 1104 EXPECT_EQ(1, client_->in_flight_event_count()); |
| 1067 EXPECT_TRUE(HasPendingEvents()); | 1105 EXPECT_TRUE(HasPendingEvents()); |
| 1068 | 1106 |
| 1069 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1107 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1070 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 1108 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 1071 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); | 1109 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
| 1072 EXPECT_EQ(0, client_->in_flight_event_count()); | 1110 EXPECT_EQ(0, client_->in_flight_event_count()); |
| 1073 EXPECT_FALSE(HasPendingEvents()); | 1111 EXPECT_FALSE(HasPendingEvents()); |
| 1074 continue; | 1112 continue; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 // their ack disposition have been dispatched. | 1175 // their ack disposition have been dispatched. |
| 1138 | 1176 |
| 1139 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1177 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 1140 blink::WebGestureDeviceTouchscreen); | 1178 blink::WebGestureDeviceTouchscreen); |
| 1141 ASSERT_EQ(1U, GetSentMessageCountAndResetSink()); | 1179 ASSERT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 1142 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); | 1180 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
| 1143 EXPECT_EQ(0, client_->in_flight_event_count()); | 1181 EXPECT_EQ(0, client_->in_flight_event_count()); |
| 1144 | 1182 |
| 1145 SimulateGestureEvent(WebInputEvent::GestureScrollUpdate, | 1183 SimulateGestureEvent(WebInputEvent::GestureScrollUpdate, |
| 1146 blink::WebGestureDeviceTouchscreen); | 1184 blink::WebGestureDeviceTouchscreen); |
| 1147 ASSERT_EQ(1U, GetSentMessageCountAndResetSink()); | 1185 ASSERT_EQ(2U, GetSentMessageCountAndResetSink()); |
| 1148 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); | 1186 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
| 1149 EXPECT_EQ(1, client_->in_flight_event_count()); | 1187 EXPECT_EQ(1, client_->in_flight_event_count()); |
| 1150 | 1188 |
| 1151 SimulateGestureEvent(WebInputEvent::GestureTapDown, | 1189 SimulateGestureEvent(WebInputEvent::GestureTapDown, |
| 1152 blink::WebGestureDeviceTouchscreen); | 1190 blink::WebGestureDeviceTouchscreen); |
| 1153 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 1191 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 1154 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); | 1192 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
| 1155 EXPECT_EQ(1, client_->in_flight_event_count()); | 1193 EXPECT_EQ(1, client_->in_flight_event_count()); |
| 1156 | 1194 |
| 1157 SimulateGestureEvent(WebInputEvent::GestureScrollUpdate, | 1195 SimulateGestureEvent(WebInputEvent::GestureScrollUpdate, |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1389 ReleaseTouchPoint(0); | 1427 ReleaseTouchPoint(0); |
| 1390 uint32_t touch_release_event_id2 = SendTouchEvent(); | 1428 uint32_t touch_release_event_id2 = SendTouchEvent(); |
| 1391 | 1429 |
| 1392 SendTouchEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED, | 1430 SendTouchEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED, |
| 1393 touch_press_event_id1); | 1431 touch_press_event_id1); |
| 1394 SendTouchEventACK(WebInputEvent::TouchMove, INPUT_EVENT_ACK_STATE_CONSUMED, | 1432 SendTouchEventACK(WebInputEvent::TouchMove, INPUT_EVENT_ACK_STATE_CONSUMED, |
| 1395 touch_move_event_id1); | 1433 touch_move_event_id1); |
| 1396 | 1434 |
| 1397 // Ensure touch action is still none, as the next touch start hasn't been | 1435 // Ensure touch action is still none, as the next touch start hasn't been |
| 1398 // acked yet. ScrollBegin and ScrollEnd don't require acks. | 1436 // acked yet. ScrollBegin and ScrollEnd don't require acks. |
| 1399 EXPECT_EQ(3U, GetSentMessageCountAndResetSink()); | 1437 EXPECT_EQ(6U, GetSentMessageCountAndResetSink()); |
| 1400 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1438 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 1401 blink::WebGestureDeviceTouchscreen); | 1439 blink::WebGestureDeviceTouchscreen); |
| 1402 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 1440 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 1403 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, | 1441 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
| 1404 blink::WebGestureDeviceTouchscreen); | 1442 blink::WebGestureDeviceTouchscreen); |
| 1405 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 1443 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 1406 | 1444 |
| 1407 // This allows the next touch sequence to start. | 1445 // This allows the next touch sequence to start. |
| 1408 SendTouchEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED, | 1446 SendTouchEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED, |
| 1409 touch_release_event_id1); | 1447 touch_release_event_id1); |
| 1410 | 1448 |
| 1411 // Ensure touch action has been set to auto, as a new touch sequence has | 1449 // Ensure touch action has been set to auto, as a new touch sequence has |
| 1412 // started. | 1450 // started. |
| 1413 SendTouchEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED, | 1451 SendTouchEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED, |
| 1414 touch_press_event_id2); | 1452 touch_press_event_id2); |
| 1415 SendTouchEventACK(WebInputEvent::TouchMove, INPUT_EVENT_ACK_STATE_CONSUMED, | 1453 SendTouchEventACK(WebInputEvent::TouchMove, INPUT_EVENT_ACK_STATE_CONSUMED, |
| 1416 touch_move_event_id2); | 1454 touch_move_event_id2); |
| 1417 EXPECT_EQ(3U, GetSentMessageCountAndResetSink()); | 1455 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 1418 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1456 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 1419 blink::WebGestureDeviceTouchscreen); | 1457 blink::WebGestureDeviceTouchscreen); |
| 1420 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1458 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 1421 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, | 1459 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
| 1422 blink::WebGestureDeviceTouchscreen); | 1460 blink::WebGestureDeviceTouchscreen); |
| 1423 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1461 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 1424 SendTouchEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED, | 1462 SendTouchEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED, |
| 1425 touch_release_event_id2); | 1463 touch_release_event_id2); |
| 1426 } | 1464 } |
| 1427 | 1465 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1447 // Sequence 2 | 1485 // Sequence 2 |
| 1448 PressTouchPoint(1, 1); | 1486 PressTouchPoint(1, 1); |
| 1449 uint32_t touch_press_event_id2 = SendTouchEvent(); | 1487 uint32_t touch_press_event_id2 = SendTouchEvent(); |
| 1450 MoveTouchPoint(0, 50, 50); | 1488 MoveTouchPoint(0, 50, 50); |
| 1451 SendTouchEvent(); | 1489 SendTouchEvent(); |
| 1452 ReleaseTouchPoint(0); | 1490 ReleaseTouchPoint(0); |
| 1453 SendTouchEvent(); | 1491 SendTouchEvent(); |
| 1454 | 1492 |
| 1455 // Ensure we have touch-action:none. ScrollBegin and ScrollEnd don't require | 1493 // Ensure we have touch-action:none. ScrollBegin and ScrollEnd don't require |
| 1456 // acks. | 1494 // acks. |
| 1457 EXPECT_EQ(3U, GetSentMessageCountAndResetSink()); | 1495 EXPECT_EQ(6U, GetSentMessageCountAndResetSink()); |
| 1458 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1496 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 1459 blink::WebGestureDeviceTouchscreen); | 1497 blink::WebGestureDeviceTouchscreen); |
| 1460 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 1498 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 1461 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, | 1499 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
| 1462 blink::WebGestureDeviceTouchscreen); | 1500 blink::WebGestureDeviceTouchscreen); |
| 1463 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 1501 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 1464 | 1502 |
| 1465 SendTouchEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED, | 1503 SendTouchEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED, |
| 1466 touch_release_event_id1); | 1504 touch_release_event_id1); |
| 1467 SendTouchEventACK(WebInputEvent::TouchStart, | 1505 SendTouchEventACK(WebInputEvent::TouchStart, |
| 1468 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, | 1506 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, |
| 1469 touch_press_event_id2); | 1507 touch_press_event_id2); |
| 1470 | 1508 |
| 1471 // Ensure touch action has been set to auto, as the touch had no consumer. | 1509 // Ensure touch action has been set to auto, as the touch had no consumer. |
| 1472 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1510 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 1473 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1511 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 1474 blink::WebGestureDeviceTouchscreen); | 1512 blink::WebGestureDeviceTouchscreen); |
| 1475 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1513 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 1476 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, | 1514 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
| 1477 blink::WebGestureDeviceTouchscreen); | 1515 blink::WebGestureDeviceTouchscreen); |
| 1478 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1516 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 1479 } | 1517 } |
| 1480 | 1518 |
| 1481 // Test that TouchActionFilter::ResetTouchAction is called when the touch | 1519 // Test that TouchActionFilter::ResetTouchAction is called when the touch |
| 1482 // handler is removed. | 1520 // handler is removed. |
| 1483 TEST_F(InputRouterImplTest, TouchActionResetWhenTouchHandlerRemoved) { | 1521 TEST_F(InputRouterImplTest, TouchActionResetWhenTouchHandlerRemoved) { |
| 1484 // Touch sequence with touch handler. | 1522 // Touch sequence with touch handler. |
| 1485 OnHasTouchEventHandlers(true); | 1523 OnHasTouchEventHandlers(true); |
| 1486 PressTouchPoint(1, 1); | 1524 PressTouchPoint(1, 1); |
| 1487 uint32_t touch_press_event_id = SendTouchEvent(); | 1525 uint32_t touch_press_event_id = SendTouchEvent(); |
| 1488 MoveTouchPoint(0, 50, 50); | 1526 MoveTouchPoint(0, 50, 50); |
| 1489 uint32_t touch_move_event_id = SendTouchEvent(); | 1527 uint32_t touch_move_event_id = SendTouchEvent(); |
| 1490 OnSetTouchAction(TOUCH_ACTION_NONE); | 1528 OnSetTouchAction(TOUCH_ACTION_NONE); |
| 1491 ReleaseTouchPoint(0); | 1529 ReleaseTouchPoint(0); |
| 1492 uint32_t touch_release_event_id = SendTouchEvent(); | 1530 uint32_t touch_release_event_id = SendTouchEvent(); |
| 1493 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1531 EXPECT_EQ(3U, GetSentMessageCountAndResetSink()); |
| 1494 | 1532 |
| 1495 // Ensure we have touch-action:none, suppressing scroll events. | 1533 // Ensure we have touch-action:none, suppressing scroll events. |
| 1496 SendTouchEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED, | 1534 SendTouchEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED, |
| 1497 touch_press_event_id); | 1535 touch_press_event_id); |
| 1498 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1536 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 1499 SendTouchEventACK(WebInputEvent::TouchMove, | 1537 SendTouchEventACK(WebInputEvent::TouchMove, |
| 1500 INPUT_EVENT_ACK_STATE_NOT_CONSUMED, touch_move_event_id); | 1538 INPUT_EVENT_ACK_STATE_NOT_CONSUMED, touch_move_event_id); |
| 1501 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1539 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 1502 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1540 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 1503 blink::WebGestureDeviceTouchscreen); | 1541 blink::WebGestureDeviceTouchscreen); |
| 1504 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 1542 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 1505 | 1543 |
| 1506 SendTouchEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_NOT_CONSUMED, | 1544 SendTouchEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_NOT_CONSUMED, |
| 1507 touch_release_event_id); | 1545 touch_release_event_id); |
| 1508 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, | 1546 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
| 1509 blink::WebGestureDeviceTouchscreen); | 1547 blink::WebGestureDeviceTouchscreen); |
| 1510 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 1548 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 1511 | 1549 |
| 1512 // Sequence without a touch handler. Note that in this case, the view may not | 1550 // Sequence without a touch handler. Note that in this case, the view may not |
| 1513 // necessarily forward touches to the router (as no touch handler exists). | 1551 // necessarily forward touches to the router (as no touch handler exists). |
| 1514 OnHasTouchEventHandlers(false); | 1552 OnHasTouchEventHandlers(false); |
| 1515 | 1553 |
| 1516 // Ensure touch action has been set to auto, as the touch handler has been | 1554 // Ensure touch action has been set to auto, as the touch handler has been |
| 1517 // removed. | 1555 // removed. |
| 1518 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1556 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 1519 blink::WebGestureDeviceTouchscreen); | 1557 blink::WebGestureDeviceTouchscreen); |
| 1520 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1558 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 1521 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, | 1559 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
| 1522 blink::WebGestureDeviceTouchscreen); | 1560 blink::WebGestureDeviceTouchscreen); |
| 1523 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1561 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 1524 } | 1562 } |
| 1525 | 1563 |
| 1526 // Tests that async touch-moves are ack'd from the browser side. | 1564 // Tests that async touch-moves are ack'd from the browser side. |
| 1527 TEST_F(InputRouterImplRafAlignedTouchEnabledTest, | 1565 TEST_F(InputRouterImplTest, AsyncTouchMoveAckedImmediately) { |
| 1528 AsyncTouchMoveAckedImmediately) { | |
| 1529 OnHasTouchEventHandlers(true); | 1566 OnHasTouchEventHandlers(true); |
| 1530 | 1567 |
| 1531 PressTouchPoint(1, 1); | 1568 PressTouchPoint(1, 1); |
| 1532 uint32_t touch_press_event_id = SendTouchEvent(); | 1569 uint32_t touch_press_event_id = SendTouchEvent(); |
| 1533 EXPECT_TRUE(client_->GetAndResetFilterEventCalled()); | 1570 EXPECT_TRUE(client_->GetAndResetFilterEventCalled()); |
| 1534 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1571 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 1535 EXPECT_FALSE(TouchEventQueueEmpty()); | 1572 EXPECT_FALSE(TouchEventQueueEmpty()); |
| 1536 | 1573 |
| 1537 // Receive an ACK for the first touch-event. | 1574 // Receive an ACK for the first touch-event. |
| 1538 SendTouchEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED, | 1575 SendTouchEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1549 | 1586 |
| 1550 // Now send an async move. | 1587 // Now send an async move. |
| 1551 MoveTouchPoint(0, 5, 5); | 1588 MoveTouchPoint(0, 5, 5); |
| 1552 SendTouchEvent(); | 1589 SendTouchEvent(); |
| 1553 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); | 1590 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
| 1554 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1591 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 1555 } | 1592 } |
| 1556 | 1593 |
| 1557 // Test that the double tap gesture depends on the touch action of the first | 1594 // Test that the double tap gesture depends on the touch action of the first |
| 1558 // tap. | 1595 // tap. |
| 1559 TEST_F(InputRouterImplRafAlignedTouchEnabledTest, | 1596 TEST_F(InputRouterImplTest, DoubleTapGestureDependsOnFirstTap) { |
| 1560 DoubleTapGestureDependsOnFirstTap) { | |
| 1561 OnHasTouchEventHandlers(true); | 1597 OnHasTouchEventHandlers(true); |
| 1562 | 1598 |
| 1563 // Sequence 1. | 1599 // Sequence 1. |
| 1564 PressTouchPoint(1, 1); | 1600 PressTouchPoint(1, 1); |
| 1565 uint32_t touch_press_event_id1 = SendTouchEvent(); | 1601 uint32_t touch_press_event_id1 = SendTouchEvent(); |
| 1566 OnSetTouchAction(TOUCH_ACTION_NONE); | 1602 OnSetTouchAction(TOUCH_ACTION_NONE); |
| 1567 SendTouchEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED, | 1603 SendTouchEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED, |
| 1568 touch_press_event_id1); | 1604 touch_press_event_id1); |
| 1569 | 1605 |
| 1570 ReleaseTouchPoint(0); | 1606 ReleaseTouchPoint(0); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1617 // This test will become invalid if GestureDoubleTap stops requiring an ack. | 1653 // This test will become invalid if GestureDoubleTap stops requiring an ack. |
| 1618 ASSERT_TRUE(ShouldBlockEventStream( | 1654 ASSERT_TRUE(ShouldBlockEventStream( |
| 1619 GetEventWithType(WebInputEvent::GestureDoubleTap))); | 1655 GetEventWithType(WebInputEvent::GestureDoubleTap))); |
| 1620 EXPECT_EQ(1, client_->in_flight_event_count()); | 1656 EXPECT_EQ(1, client_->in_flight_event_count()); |
| 1621 SendInputEventACK(WebInputEvent::GestureTap, INPUT_EVENT_ACK_STATE_CONSUMED); | 1657 SendInputEventACK(WebInputEvent::GestureTap, INPUT_EVENT_ACK_STATE_CONSUMED); |
| 1622 EXPECT_EQ(0, client_->in_flight_event_count()); | 1658 EXPECT_EQ(0, client_->in_flight_event_count()); |
| 1623 } | 1659 } |
| 1624 | 1660 |
| 1625 // Test that the double tap gesture depends on the touch action of the first | 1661 // Test that the double tap gesture depends on the touch action of the first |
| 1626 // tap. | 1662 // tap. |
| 1627 TEST_F(InputRouterImplTest, DoubleTapGestureDependsOnFirstTap) { | 1663 TEST_F(InputRouterImplRafAlignedTouchDisabledTest, |
| 1664 DoubleTapGestureDependsOnFirstTap) { |
| 1628 OnHasTouchEventHandlers(true); | 1665 OnHasTouchEventHandlers(true); |
| 1629 | 1666 |
| 1630 // Sequence 1. | 1667 // Sequence 1. |
| 1631 PressTouchPoint(1, 1); | 1668 PressTouchPoint(1, 1); |
| 1632 uint32_t touch_press_event_id1 = SendTouchEvent(); | 1669 uint32_t touch_press_event_id1 = SendTouchEvent(); |
| 1633 OnSetTouchAction(TOUCH_ACTION_NONE); | 1670 OnSetTouchAction(TOUCH_ACTION_NONE); |
| 1634 SendTouchEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED, | 1671 SendTouchEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED, |
| 1635 touch_press_event_id1); | 1672 touch_press_event_id1); |
| 1636 | 1673 |
| 1637 ReleaseTouchPoint(0); | 1674 ReleaseTouchPoint(0); |
| (...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2400 EXPECT_EQ(80, sent_event->data.flingStart.velocityY); | 2437 EXPECT_EQ(80, sent_event->data.flingStart.velocityY); |
| 2401 | 2438 |
| 2402 const WebGestureEvent* filter_event = | 2439 const WebGestureEvent* filter_event = |
| 2403 GetFilterWebInputEvent<WebGestureEvent>(); | 2440 GetFilterWebInputEvent<WebGestureEvent>(); |
| 2404 TestLocationInFilterEvent(filter_event, orig); | 2441 TestLocationInFilterEvent(filter_event, orig); |
| 2405 EXPECT_EQ(30, filter_event->data.flingStart.velocityX); | 2442 EXPECT_EQ(30, filter_event->data.flingStart.velocityX); |
| 2406 EXPECT_EQ(40, filter_event->data.flingStart.velocityY); | 2443 EXPECT_EQ(40, filter_event->data.flingStart.velocityY); |
| 2407 } | 2444 } |
| 2408 | 2445 |
| 2409 } // namespace content | 2446 } // namespace content |
| OLD | NEW |