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

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

Issue 2734563002: Re-enable passthrough touch event queue. (Closed)
Patch Set: Created 3 years, 9 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 "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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 using blink::WebMouseWheelEvent; 52 using blink::WebMouseWheelEvent;
53 using blink::WebTouchEvent; 53 using blink::WebTouchEvent;
54 using blink::WebTouchPoint; 54 using blink::WebTouchPoint;
55 using ui::DidOverscrollParams; 55 using ui::DidOverscrollParams;
56 using ui::WebInputEventTraits; 56 using ui::WebInputEventTraits;
57 57
58 namespace content { 58 namespace content {
59 59
60 namespace { 60 namespace {
61 61
62 bool ShouldBlockEventStream(const blink::WebInputEvent& event) {
63 return ui::WebInputEventTraits::ShouldBlockEventStream(
64 event,
65 base::FeatureList::IsEnabled(features::kRafAlignedTouchInputEvents));
66 }
67
62 const WebInputEvent* GetInputEventFromMessage(const IPC::Message& message) { 68 const WebInputEvent* GetInputEventFromMessage(const IPC::Message& message) {
63 base::PickleIterator iter(message); 69 base::PickleIterator iter(message);
64 const char* data; 70 const char* data;
65 int data_length; 71 int data_length;
66 if (!iter.ReadData(&data, &data_length)) 72 if (!iter.ReadData(&data, &data_length))
67 return NULL; 73 return NULL;
68 return reinterpret_cast<const WebInputEvent*>(data); 74 return reinterpret_cast<const WebInputEvent*>(data);
69 } 75 }
70 76
71 WebInputEvent& GetEventWithType(WebInputEvent::Type type) { 77 WebInputEvent& GetEventWithType(WebInputEvent::Type type) {
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 989
984 // Check that the correct unhandled wheel event was received. 990 // Check that the correct unhandled wheel event was received.
985 EXPECT_EQ(2U, ack_handler_->GetAndResetAckCount()); 991 EXPECT_EQ(2U, ack_handler_->GetAndResetAckCount());
986 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, ack_handler_->ack_state()); 992 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, ack_handler_->ack_state());
987 EXPECT_EQ(ack_handler_->acked_wheel_event().deltaY, -10); 993 EXPECT_EQ(ack_handler_->acked_wheel_event().deltaY, -10);
988 } 994 }
989 995
990 TEST_F(InputRouterImplTest, TouchTypesIgnoringAck) { 996 TEST_F(InputRouterImplTest, TouchTypesIgnoringAck) {
991 OnHasTouchEventHandlers(true); 997 OnHasTouchEventHandlers(true);
992 // Only acks for TouchCancel should always be ignored. 998 // Only acks for TouchCancel should always be ignored.
993 ASSERT_TRUE(WebInputEventTraits::ShouldBlockEventStream( 999 ASSERT_TRUE(
994 GetEventWithType(WebInputEvent::TouchStart))); 1000 ShouldBlockEventStream(GetEventWithType(WebInputEvent::TouchStart)));
995 ASSERT_TRUE(WebInputEventTraits::ShouldBlockEventStream( 1001 ASSERT_TRUE(
996 GetEventWithType(WebInputEvent::TouchMove))); 1002 ShouldBlockEventStream(GetEventWithType(WebInputEvent::TouchMove)));
997 ASSERT_TRUE(WebInputEventTraits::ShouldBlockEventStream( 1003 ASSERT_TRUE(
998 GetEventWithType(WebInputEvent::TouchEnd))); 1004 ShouldBlockEventStream(GetEventWithType(WebInputEvent::TouchEnd)));
999 1005
1000 // Precede the TouchCancel with an appropriate TouchStart; 1006 // Precede the TouchCancel with an appropriate TouchStart;
1001 PressTouchPoint(1, 1); 1007 PressTouchPoint(1, 1);
1002 uint32_t touch_press_event_id = SendTouchEvent(); 1008 uint32_t touch_press_event_id = SendTouchEvent();
1003 SendTouchEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED, 1009 SendTouchEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED,
1004 touch_press_event_id); 1010 touch_press_event_id);
1005 ASSERT_EQ(1U, GetSentMessageCountAndResetSink()); 1011 ASSERT_EQ(1U, GetSentMessageCountAndResetSink());
1006 ASSERT_EQ(1U, ack_handler_->GetAndResetAckCount()); 1012 ASSERT_EQ(1U, ack_handler_->GetAndResetAckCount());
1007 ASSERT_EQ(0, client_->in_flight_event_count()); 1013 ASSERT_EQ(0, client_->in_flight_event_count());
1008 1014
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 WebInputEvent::GestureTapDown, 1052 WebInputEvent::GestureTapDown,
1047 WebInputEvent::GestureTapCancel, 1053 WebInputEvent::GestureTapCancel,
1048 WebInputEvent::GestureScrollBegin, 1054 WebInputEvent::GestureScrollBegin,
1049 WebInputEvent::GestureScrollUpdate, 1055 WebInputEvent::GestureScrollUpdate,
1050 WebInputEvent::GesturePinchBegin, 1056 WebInputEvent::GesturePinchBegin,
1051 WebInputEvent::GesturePinchUpdate, 1057 WebInputEvent::GesturePinchUpdate,
1052 WebInputEvent::GesturePinchEnd, 1058 WebInputEvent::GesturePinchEnd,
1053 WebInputEvent::GestureScrollEnd}; 1059 WebInputEvent::GestureScrollEnd};
1054 for (size_t i = 0; i < arraysize(eventTypes); ++i) { 1060 for (size_t i = 0; i < arraysize(eventTypes); ++i) {
1055 WebInputEvent::Type type = eventTypes[i]; 1061 WebInputEvent::Type type = eventTypes[i];
1056 if (WebInputEventTraits::ShouldBlockEventStream(GetEventWithType(type))) { 1062 if (ShouldBlockEventStream(GetEventWithType(type))) {
1057 SimulateGestureEvent(type, blink::WebGestureDeviceTouchscreen); 1063 SimulateGestureEvent(type, blink::WebGestureDeviceTouchscreen);
1058 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1064 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1059 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); 1065 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
1060 EXPECT_EQ(1, client_->in_flight_event_count()); 1066 EXPECT_EQ(1, client_->in_flight_event_count());
1061 EXPECT_TRUE(HasPendingEvents()); 1067 EXPECT_TRUE(HasPendingEvents());
1062 1068
1063 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1069 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1064 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); 1070 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
1065 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); 1071 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
1066 EXPECT_EQ(0, client_->in_flight_event_count()); 1072 EXPECT_EQ(0, client_->in_flight_event_count());
1067 EXPECT_FALSE(HasPendingEvents()); 1073 EXPECT_FALSE(HasPendingEvents());
1068 continue; 1074 continue;
1069 } 1075 }
1070 1076
1071 SimulateGestureEvent(type, blink::WebGestureDeviceTouchscreen); 1077 SimulateGestureEvent(type, blink::WebGestureDeviceTouchscreen);
1072 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1078 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1073 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); 1079 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
1074 EXPECT_EQ(0, client_->in_flight_event_count()); 1080 EXPECT_EQ(0, client_->in_flight_event_count());
1075 EXPECT_FALSE(HasPendingEvents()); 1081 EXPECT_FALSE(HasPendingEvents());
1076 } 1082 }
1077 } 1083 }
1078 1084
1079 TEST_F(InputRouterImplTest, MouseTypesIgnoringAck) { 1085 TEST_F(InputRouterImplTest, MouseTypesIgnoringAck) {
1080 int start_type = static_cast<int>(WebInputEvent::MouseDown); 1086 int start_type = static_cast<int>(WebInputEvent::MouseDown);
1081 int end_type = static_cast<int>(WebInputEvent::ContextMenu); 1087 int end_type = static_cast<int>(WebInputEvent::ContextMenu);
1082 ASSERT_LT(start_type, end_type); 1088 ASSERT_LT(start_type, end_type);
1083 for (int i = start_type; i <= end_type; ++i) { 1089 for (int i = start_type; i <= end_type; ++i) {
1084 WebInputEvent::Type type = static_cast<WebInputEvent::Type>(i); 1090 WebInputEvent::Type type = static_cast<WebInputEvent::Type>(i);
1085 int expected_in_flight_event_count = 1091 int expected_in_flight_event_count =
1086 !WebInputEventTraits::ShouldBlockEventStream(GetEventWithType(type)) 1092 !ShouldBlockEventStream(GetEventWithType(type)) ? 0 : 1;
1087 ? 0
1088 : 1;
1089 1093
1090 // Note: Only MouseMove ack is forwarded to the ack handler. 1094 // Note: Only MouseMove ack is forwarded to the ack handler.
1091 SimulateMouseEvent(type, 0, 0); 1095 SimulateMouseEvent(type, 0, 0);
1092 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1096 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1093 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); 1097 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
1094 EXPECT_EQ(expected_in_flight_event_count, client_->in_flight_event_count()); 1098 EXPECT_EQ(expected_in_flight_event_count, client_->in_flight_event_count());
1095 if (expected_in_flight_event_count) { 1099 if (expected_in_flight_event_count) {
1096 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1100 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1097 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); 1101 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
1098 uint32_t expected_ack_count = type == WebInputEvent::MouseMove ? 1 : 0; 1102 uint32_t expected_ack_count = type == WebInputEvent::MouseMove ? 1 : 0;
(...skipping 15 matching lines...) Expand all
1114 WebInputEvent::Char, 1118 WebInputEvent::Char,
1115 WebInputEvent::GestureScrollUpdate, 1119 WebInputEvent::GestureScrollUpdate,
1116 WebInputEvent::GestureFlingStart, 1120 WebInputEvent::GestureFlingStart,
1117 WebInputEvent::GestureFlingCancel, 1121 WebInputEvent::GestureFlingCancel,
1118 WebInputEvent::GesturePinchUpdate, 1122 WebInputEvent::GesturePinchUpdate,
1119 WebInputEvent::TouchStart, 1123 WebInputEvent::TouchStart,
1120 WebInputEvent::TouchMove 1124 WebInputEvent::TouchMove
1121 }; 1125 };
1122 for (size_t i = 0; i < arraysize(kRequiredEventAckTypes); ++i) { 1126 for (size_t i = 0; i < arraysize(kRequiredEventAckTypes); ++i) {
1123 const WebInputEvent::Type required_ack_type = kRequiredEventAckTypes[i]; 1127 const WebInputEvent::Type required_ack_type = kRequiredEventAckTypes[i];
1124 ASSERT_TRUE(WebInputEventTraits::ShouldBlockEventStream( 1128 ASSERT_TRUE(ShouldBlockEventStream(GetEventWithType(required_ack_type)));
1125 GetEventWithType(required_ack_type)));
1126 } 1129 }
1127 } 1130 }
1128 1131
1129 // Test that GestureShowPress, GestureTapDown and GestureTapCancel events don't 1132 // Test that GestureShowPress, GestureTapDown and GestureTapCancel events don't
1130 // wait for ACKs. 1133 // wait for ACKs.
1131 TEST_F(InputRouterImplTest, GestureTypesIgnoringAckInterleaved) { 1134 TEST_F(InputRouterImplTest, GestureTypesIgnoringAckInterleaved) {
1132 // Interleave a few events that do and do not ignore acks, ensuring that 1135 // Interleave a few events that do and do not ignore acks, ensuring that
1133 // ack-ignoring events aren't dispatched until all prior events which observe 1136 // ack-ignoring events aren't dispatched until all prior events which observe
1134 // their ack disposition have been dispatched. 1137 // their ack disposition have been dispatched.
1135 1138
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
1513 // Ensure touch action has been set to auto, as the touch handler has been 1516 // Ensure touch action has been set to auto, as the touch handler has been
1514 // removed. 1517 // removed.
1515 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 1518 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
1516 blink::WebGestureDeviceTouchscreen); 1519 blink::WebGestureDeviceTouchscreen);
1517 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1520 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1518 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, 1521 SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
1519 blink::WebGestureDeviceTouchscreen); 1522 blink::WebGestureDeviceTouchscreen);
1520 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1523 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1521 } 1524 }
1522 1525
1526 // Tests that async touch-moves are ack'd from the browser side.
1527 TEST_F(InputRouterImplRafAlignedTouchEnabledTest,
1528 AsyncTouchMoveAckedImmediately) {
1529 OnHasTouchEventHandlers(true);
1530
1531 PressTouchPoint(1, 1);
1532 uint32_t touch_press_event_id = SendTouchEvent();
1533 EXPECT_TRUE(client_->GetAndResetFilterEventCalled());
1534 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1535 EXPECT_FALSE(TouchEventQueueEmpty());
1536
1537 // Receive an ACK for the first touch-event.
1538 SendTouchEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED,
1539 touch_press_event_id);
1540 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
1541 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
1542 blink::WebGestureDeviceTouchscreen);
1543 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
1544 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1545 SimulateGestureEvent(WebInputEvent::GestureScrollUpdate,
1546 blink::WebGestureDeviceTouchscreen);
1547 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
1548 EXPECT_EQ(2U, GetSentMessageCountAndResetSink());
1549
1550 // Now send an async move.
1551 MoveTouchPoint(0, 5, 5);
1552 SendTouchEvent();
1553 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
1554 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1555 }
1556
1523 // Test that the double tap gesture depends on the touch action of the first 1557 // Test that the double tap gesture depends on the touch action of the first
1524 // tap. 1558 // tap.
1525 // TODO(dtapuska): Disabled for now crbug.com/697871
1526 TEST_F(InputRouterImplRafAlignedTouchEnabledTest, 1559 TEST_F(InputRouterImplRafAlignedTouchEnabledTest,
1527 DISABLED_DoubleTapGestureDependsOnFirstTap) { 1560 DoubleTapGestureDependsOnFirstTap) {
1528 OnHasTouchEventHandlers(true); 1561 OnHasTouchEventHandlers(true);
1529 1562
1530 // Sequence 1. 1563 // Sequence 1.
1531 PressTouchPoint(1, 1); 1564 PressTouchPoint(1, 1);
1532 uint32_t touch_press_event_id1 = SendTouchEvent(); 1565 uint32_t touch_press_event_id1 = SendTouchEvent();
1533 OnSetTouchAction(TOUCH_ACTION_NONE); 1566 OnSetTouchAction(TOUCH_ACTION_NONE);
1534 SendTouchEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED, 1567 SendTouchEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED,
1535 touch_press_event_id1); 1568 touch_press_event_id1);
1536 1569
1537 ReleaseTouchPoint(0); 1570 ReleaseTouchPoint(0);
1538 uint32_t touch_release_event_id = SendTouchEvent(); 1571 uint32_t touch_release_event_id = SendTouchEvent();
1539 1572
1540 // Sequence 2 1573 // Sequence 2
1541 PressTouchPoint(1, 1); 1574 PressTouchPoint(1, 1);
1542 uint32_t touch_press_event_id2 = SendTouchEvent(); 1575 uint32_t touch_press_event_id2 = SendTouchEvent();
1543 1576
1544 // First tap. 1577 // First tap.
1545 EXPECT_EQ(3U, GetSentMessageCountAndResetSink()); 1578 EXPECT_EQ(3U, GetSentMessageCountAndResetSink());
1546 SimulateGestureEvent(WebInputEvent::GestureTapDown, 1579 SimulateGestureEvent(WebInputEvent::GestureTapDown,
1547 blink::WebGestureDeviceTouchscreen); 1580 blink::WebGestureDeviceTouchscreen);
1548 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1581 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1549 1582
1550 // The GestureTapUnconfirmed is converted into a tap, as the touch action is 1583 // The GestureTapUnconfirmed is converted into a tap, as the touch action is
1551 // none. 1584 // none.
1552 SimulateGestureEvent(WebInputEvent::GestureTapUnconfirmed, 1585 SimulateGestureEvent(WebInputEvent::GestureTapUnconfirmed,
1553 blink::WebGestureDeviceTouchscreen); 1586 blink::WebGestureDeviceTouchscreen);
1554 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1587 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1555 // This test will become invalid if GestureTap stops requiring an ack. 1588 // This test will become invalid if GestureTap stops requiring an ack.
1556 ASSERT_TRUE(WebInputEventTraits::ShouldBlockEventStream( 1589 ASSERT_TRUE(
1557 GetEventWithType(WebInputEvent::GestureTap))); 1590 ShouldBlockEventStream(GetEventWithType(WebInputEvent::GestureTap)));
1558 EXPECT_EQ(3, client_->in_flight_event_count()); 1591 EXPECT_EQ(3, client_->in_flight_event_count());
1559 SendInputEventACK(WebInputEvent::GestureTap, INPUT_EVENT_ACK_STATE_CONSUMED); 1592 SendInputEventACK(WebInputEvent::GestureTap, INPUT_EVENT_ACK_STATE_CONSUMED);
1560 EXPECT_EQ(2, client_->in_flight_event_count()); 1593 EXPECT_EQ(2, client_->in_flight_event_count());
1561 1594
1562 // This tap gesture is dropped, since the GestureTapUnconfirmed was turned 1595 // This tap gesture is dropped, since the GestureTapUnconfirmed was turned
1563 // into a tap. 1596 // into a tap.
1564 SimulateGestureEvent(WebInputEvent::GestureTap, 1597 SimulateGestureEvent(WebInputEvent::GestureTap,
1565 blink::WebGestureDeviceTouchscreen); 1598 blink::WebGestureDeviceTouchscreen);
1566 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); 1599 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
1567 1600
1568 SendTouchEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED, 1601 SendTouchEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED,
1569 touch_release_event_id); 1602 touch_release_event_id);
1570 SendTouchEventACK(WebInputEvent::TouchStart, 1603 SendTouchEventACK(WebInputEvent::TouchStart,
1571 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, 1604 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS,
1572 touch_press_event_id2); 1605 touch_press_event_id2);
1573 1606
1574 // Second Tap. 1607 // Second Tap.
1575 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); 1608 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
1576 SimulateGestureEvent(WebInputEvent::GestureTapDown, 1609 SimulateGestureEvent(WebInputEvent::GestureTapDown,
1577 blink::WebGestureDeviceTouchscreen); 1610 blink::WebGestureDeviceTouchscreen);
1578 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1611 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1579 1612
1580 // Although the touch-action is now auto, the double tap still won't be 1613 // Although the touch-action is now auto, the double tap still won't be
1581 // dispatched, because the first tap occured when the touch-action was none. 1614 // dispatched, because the first tap occured when the touch-action was none.
1582 SimulateGestureEvent(WebInputEvent::GestureDoubleTap, 1615 SimulateGestureEvent(WebInputEvent::GestureDoubleTap,
1583 blink::WebGestureDeviceTouchscreen); 1616 blink::WebGestureDeviceTouchscreen);
1584 // This test will become invalid if GestureDoubleTap stops requiring an ack. 1617 // This test will become invalid if GestureDoubleTap stops requiring an ack.
1585 ASSERT_TRUE(WebInputEventTraits::ShouldBlockEventStream( 1618 ASSERT_TRUE(ShouldBlockEventStream(
1586 GetEventWithType(WebInputEvent::GestureDoubleTap))); 1619 GetEventWithType(WebInputEvent::GestureDoubleTap)));
1587 EXPECT_EQ(1, client_->in_flight_event_count()); 1620 EXPECT_EQ(1, client_->in_flight_event_count());
1588 SendInputEventACK(WebInputEvent::GestureTap, INPUT_EVENT_ACK_STATE_CONSUMED); 1621 SendInputEventACK(WebInputEvent::GestureTap, INPUT_EVENT_ACK_STATE_CONSUMED);
1589 EXPECT_EQ(0, client_->in_flight_event_count()); 1622 EXPECT_EQ(0, client_->in_flight_event_count());
1590 } 1623 }
1591 1624
1592 // Test that the double tap gesture depends on the touch action of the first 1625 // Test that the double tap gesture depends on the touch action of the first
1593 // tap. 1626 // tap.
1594 TEST_F(InputRouterImplTest, DoubleTapGestureDependsOnFirstTap) { 1627 TEST_F(InputRouterImplTest, DoubleTapGestureDependsOnFirstTap) {
1595 OnHasTouchEventHandlers(true); 1628 OnHasTouchEventHandlers(true);
(...skipping 17 matching lines...) Expand all
1613 SimulateGestureEvent(WebInputEvent::GestureTapDown, 1646 SimulateGestureEvent(WebInputEvent::GestureTapDown,
1614 blink::WebGestureDeviceTouchscreen); 1647 blink::WebGestureDeviceTouchscreen);
1615 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1648 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1616 1649
1617 // The GestureTapUnconfirmed is converted into a tap, as the touch action is 1650 // The GestureTapUnconfirmed is converted into a tap, as the touch action is
1618 // none. 1651 // none.
1619 SimulateGestureEvent(WebInputEvent::GestureTapUnconfirmed, 1652 SimulateGestureEvent(WebInputEvent::GestureTapUnconfirmed,
1620 blink::WebGestureDeviceTouchscreen); 1653 blink::WebGestureDeviceTouchscreen);
1621 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1654 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1622 // This test will become invalid if GestureTap stops requiring an ack. 1655 // This test will become invalid if GestureTap stops requiring an ack.
1623 ASSERT_TRUE(WebInputEventTraits::ShouldBlockEventStream( 1656 ASSERT_TRUE(
1624 GetEventWithType(WebInputEvent::GestureTap))); 1657 ShouldBlockEventStream(GetEventWithType(WebInputEvent::GestureTap)));
1625 EXPECT_EQ(2, client_->in_flight_event_count()); 1658 EXPECT_EQ(2, client_->in_flight_event_count());
1626 SendInputEventACK(WebInputEvent::GestureTap, 1659 SendInputEventACK(WebInputEvent::GestureTap,
1627 INPUT_EVENT_ACK_STATE_CONSUMED); 1660 INPUT_EVENT_ACK_STATE_CONSUMED);
1628 EXPECT_EQ(1, client_->in_flight_event_count()); 1661 EXPECT_EQ(1, client_->in_flight_event_count());
1629 1662
1630 // This tap gesture is dropped, since the GestureTapUnconfirmed was turned 1663 // This tap gesture is dropped, since the GestureTapUnconfirmed was turned
1631 // into a tap. 1664 // into a tap.
1632 SimulateGestureEvent(WebInputEvent::GestureTap, 1665 SimulateGestureEvent(WebInputEvent::GestureTap,
1633 blink::WebGestureDeviceTouchscreen); 1666 blink::WebGestureDeviceTouchscreen);
1634 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); 1667 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
1635 1668
1636 SendTouchEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED, 1669 SendTouchEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED,
1637 touch_release_event_id); 1670 touch_release_event_id);
1638 SendTouchEventACK(WebInputEvent::TouchStart, 1671 SendTouchEventACK(WebInputEvent::TouchStart,
1639 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, 1672 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS,
1640 touch_press_event_id2); 1673 touch_press_event_id2);
1641 1674
1642 // Second Tap. 1675 // Second Tap.
1643 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1676 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1644 SimulateGestureEvent(WebInputEvent::GestureTapDown, 1677 SimulateGestureEvent(WebInputEvent::GestureTapDown,
1645 blink::WebGestureDeviceTouchscreen); 1678 blink::WebGestureDeviceTouchscreen);
1646 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1679 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1647 1680
1648 // Although the touch-action is now auto, the double tap still won't be 1681 // Although the touch-action is now auto, the double tap still won't be
1649 // dispatched, because the first tap occured when the touch-action was none. 1682 // dispatched, because the first tap occured when the touch-action was none.
1650 SimulateGestureEvent(WebInputEvent::GestureDoubleTap, 1683 SimulateGestureEvent(WebInputEvent::GestureDoubleTap,
1651 blink::WebGestureDeviceTouchscreen); 1684 blink::WebGestureDeviceTouchscreen);
1652 // This test will become invalid if GestureDoubleTap stops requiring an ack. 1685 // This test will become invalid if GestureDoubleTap stops requiring an ack.
1653 ASSERT_TRUE(WebInputEventTraits::ShouldBlockEventStream( 1686 ASSERT_TRUE(ShouldBlockEventStream(
1654 GetEventWithType(WebInputEvent::GestureDoubleTap))); 1687 GetEventWithType(WebInputEvent::GestureDoubleTap)));
1655 EXPECT_EQ(1, client_->in_flight_event_count()); 1688 EXPECT_EQ(1, client_->in_flight_event_count());
1656 SendInputEventACK(WebInputEvent::GestureTap, INPUT_EVENT_ACK_STATE_CONSUMED); 1689 SendInputEventACK(WebInputEvent::GestureTap, INPUT_EVENT_ACK_STATE_CONSUMED);
1657 EXPECT_EQ(0, client_->in_flight_event_count()); 1690 EXPECT_EQ(0, client_->in_flight_event_count());
1658 } 1691 }
1659 1692
1660 // Test that the router will call the client's |DidFlush| after all events have 1693 // Test that the router will call the client's |DidFlush| after all events have
1661 // been dispatched following a call to |Flush|. 1694 // been dispatched following a call to |Flush|.
1662 TEST_F(InputRouterImplTest, InputFlush) { 1695 TEST_F(InputRouterImplTest, InputFlush) {
1663 EXPECT_FALSE(HasPendingEvents()); 1696 EXPECT_FALSE(HasPendingEvents());
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
2367 EXPECT_EQ(80, sent_event->data.flingStart.velocityY); 2400 EXPECT_EQ(80, sent_event->data.flingStart.velocityY);
2368 2401
2369 const WebGestureEvent* filter_event = 2402 const WebGestureEvent* filter_event =
2370 GetFilterWebInputEvent<WebGestureEvent>(); 2403 GetFilterWebInputEvent<WebGestureEvent>();
2371 TestLocationInFilterEvent(filter_event, orig); 2404 TestLocationInFilterEvent(filter_event, orig);
2372 EXPECT_EQ(30, filter_event->data.flingStart.velocityX); 2405 EXPECT_EQ(30, filter_event->data.flingStart.velocityX);
2373 EXPECT_EQ(40, filter_event->data.flingStart.velocityY); 2406 EXPECT_EQ(40, filter_event->data.flingStart.velocityY);
2374 } 2407 }
2375 2408
2376 } // namespace content 2409 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698