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

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

Issue 1780953003: Change the non-blocking event queue to the main thread event queue. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master_wheel_regression_5
Patch Set: Force ack in renderer to be solely based on the DispatchEventType Created 4 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 <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 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 1014
1015 // Check that the correct unhandled wheel event was received. 1015 // Check that the correct unhandled wheel event was received.
1016 EXPECT_EQ(2U, ack_handler_->GetAndResetAckCount()); 1016 EXPECT_EQ(2U, ack_handler_->GetAndResetAckCount());
1017 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, ack_handler_->ack_state()); 1017 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, ack_handler_->ack_state());
1018 EXPECT_EQ(ack_handler_->acked_wheel_event().deltaY, -10); 1018 EXPECT_EQ(ack_handler_->acked_wheel_event().deltaY, -10);
1019 } 1019 }
1020 1020
1021 TEST_F(InputRouterImplTest, TouchTypesIgnoringAck) { 1021 TEST_F(InputRouterImplTest, TouchTypesIgnoringAck) {
1022 OnHasTouchEventHandlers(true); 1022 OnHasTouchEventHandlers(true);
1023 // Only acks for TouchCancel should always be ignored. 1023 // Only acks for TouchCancel should always be ignored.
1024 ASSERT_TRUE(WebInputEventTraits::WillReceiveAckFromRenderer( 1024 ASSERT_TRUE(WebInputEventTraits::ShouldBlockEventOnRenderer(
1025 GetEventWithType(WebInputEvent::TouchStart))); 1025 GetEventWithType(WebInputEvent::TouchStart)));
1026 ASSERT_TRUE(WebInputEventTraits::WillReceiveAckFromRenderer( 1026 ASSERT_TRUE(WebInputEventTraits::ShouldBlockEventOnRenderer(
1027 GetEventWithType(WebInputEvent::TouchMove))); 1027 GetEventWithType(WebInputEvent::TouchMove)));
1028 ASSERT_TRUE(WebInputEventTraits::WillReceiveAckFromRenderer( 1028 ASSERT_TRUE(WebInputEventTraits::ShouldBlockEventOnRenderer(
1029 GetEventWithType(WebInputEvent::TouchEnd))); 1029 GetEventWithType(WebInputEvent::TouchEnd)));
1030 1030
1031 // Precede the TouchCancel with an appropriate TouchStart; 1031 // Precede the TouchCancel with an appropriate TouchStart;
1032 PressTouchPoint(1, 1); 1032 PressTouchPoint(1, 1);
1033 uint32_t touch_press_event_id = SendTouchEvent(); 1033 uint32_t touch_press_event_id = SendTouchEvent();
1034 SendTouchEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED, 1034 SendTouchEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED,
1035 touch_press_event_id); 1035 touch_press_event_id);
1036 ASSERT_EQ(1U, GetSentMessageCountAndResetSink()); 1036 ASSERT_EQ(1U, GetSentMessageCountAndResetSink());
1037 ASSERT_EQ(1U, ack_handler_->GetAndResetAckCount()); 1037 ASSERT_EQ(1U, ack_handler_->GetAndResetAckCount());
1038 ASSERT_EQ(0, client_->in_flight_event_count()); 1038 ASSERT_EQ(0, client_->in_flight_event_count());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 WebInputEvent::GestureTapDown, 1077 WebInputEvent::GestureTapDown,
1078 WebInputEvent::GestureTapCancel, 1078 WebInputEvent::GestureTapCancel,
1079 WebInputEvent::GestureScrollBegin, 1079 WebInputEvent::GestureScrollBegin,
1080 WebInputEvent::GestureScrollUpdate, 1080 WebInputEvent::GestureScrollUpdate,
1081 WebInputEvent::GesturePinchBegin, 1081 WebInputEvent::GesturePinchBegin,
1082 WebInputEvent::GesturePinchUpdate, 1082 WebInputEvent::GesturePinchUpdate,
1083 WebInputEvent::GesturePinchEnd, 1083 WebInputEvent::GesturePinchEnd,
1084 WebInputEvent::GestureScrollEnd}; 1084 WebInputEvent::GestureScrollEnd};
1085 for (size_t i = 0; i < arraysize(eventTypes); ++i) { 1085 for (size_t i = 0; i < arraysize(eventTypes); ++i) {
1086 WebInputEvent::Type type = eventTypes[i]; 1086 WebInputEvent::Type type = eventTypes[i];
1087 if (WebInputEventTraits::WillReceiveAckFromRenderer( 1087 if (WebInputEventTraits::ShouldBlockEventOnRenderer(
1088 GetEventWithType(type))) { 1088 GetEventWithType(type))) {
1089 SimulateGestureEvent(type, blink::WebGestureDeviceTouchscreen); 1089 SimulateGestureEvent(type, blink::WebGestureDeviceTouchscreen);
1090 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1090 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1091 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); 1091 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
1092 EXPECT_EQ(1, client_->in_flight_event_count()); 1092 EXPECT_EQ(1, client_->in_flight_event_count());
1093 EXPECT_TRUE(HasPendingEvents()); 1093 EXPECT_TRUE(HasPendingEvents());
1094 1094
1095 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1095 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1096 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); 1096 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
1097 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); 1097 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
(...skipping 10 matching lines...) Expand all
1108 } 1108 }
1109 } 1109 }
1110 1110
1111 TEST_F(InputRouterImplTest, MouseTypesIgnoringAck) { 1111 TEST_F(InputRouterImplTest, MouseTypesIgnoringAck) {
1112 int start_type = static_cast<int>(WebInputEvent::MouseDown); 1112 int start_type = static_cast<int>(WebInputEvent::MouseDown);
1113 int end_type = static_cast<int>(WebInputEvent::ContextMenu); 1113 int end_type = static_cast<int>(WebInputEvent::ContextMenu);
1114 ASSERT_LT(start_type, end_type); 1114 ASSERT_LT(start_type, end_type);
1115 for (int i = start_type; i <= end_type; ++i) { 1115 for (int i = start_type; i <= end_type; ++i) {
1116 WebInputEvent::Type type = static_cast<WebInputEvent::Type>(i); 1116 WebInputEvent::Type type = static_cast<WebInputEvent::Type>(i);
1117 int expected_in_flight_event_count = 1117 int expected_in_flight_event_count =
1118 !WebInputEventTraits::WillReceiveAckFromRenderer(GetEventWithType(type)) 1118 !WebInputEventTraits::ShouldBlockEventOnRenderer(GetEventWithType(type))
1119 ? 0 1119 ? 0
1120 : 1; 1120 : 1;
1121 1121
1122 // Note: Only MouseMove ack is forwarded to the ack handler. 1122 // Note: Only MouseMove ack is forwarded to the ack handler.
1123 SimulateMouseEvent(type, 0, 0); 1123 SimulateMouseEvent(type, 0, 0);
1124 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1124 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1125 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); 1125 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
1126 EXPECT_EQ(expected_in_flight_event_count, client_->in_flight_event_count()); 1126 EXPECT_EQ(expected_in_flight_event_count, client_->in_flight_event_count());
1127 if (expected_in_flight_event_count) { 1127 if (expected_in_flight_event_count) {
1128 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1128 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1129 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); 1129 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
1130 uint32_t expected_ack_count = type == WebInputEvent::MouseMove ? 1 : 0; 1130 uint32_t expected_ack_count = type == WebInputEvent::MouseMove ? 1 : 0;
1131 EXPECT_EQ(expected_ack_count, ack_handler_->GetAndResetAckCount()); 1131 EXPECT_EQ(expected_ack_count, ack_handler_->GetAndResetAckCount());
1132 EXPECT_EQ(0, client_->in_flight_event_count()); 1132 EXPECT_EQ(0, client_->in_flight_event_count());
1133 } 1133 }
1134 } 1134 }
1135 } 1135 }
1136 1136
1137 // Guard against breaking changes to the list of ignored event ack types in 1137 // Guard against breaking changes to the list of ignored event ack types in
1138 // |WebInputEventTraits::WillReceiveAckFromRenderer|. 1138 // |WebInputEventTraits::ShouldBlockEventOnRenderer|.
1139 TEST_F(InputRouterImplTest, RequiredEventAckTypes) { 1139 TEST_F(InputRouterImplTest, RequiredEventAckTypes) {
1140 const WebInputEvent::Type kRequiredEventAckTypes[] = { 1140 const WebInputEvent::Type kRequiredEventAckTypes[] = {
1141 WebInputEvent::MouseMove, 1141 WebInputEvent::MouseMove,
1142 WebInputEvent::MouseWheel, 1142 WebInputEvent::MouseWheel,
1143 WebInputEvent::RawKeyDown, 1143 WebInputEvent::RawKeyDown,
1144 WebInputEvent::KeyDown, 1144 WebInputEvent::KeyDown,
1145 WebInputEvent::KeyUp, 1145 WebInputEvent::KeyUp,
1146 WebInputEvent::Char, 1146 WebInputEvent::Char,
1147 WebInputEvent::GestureScrollUpdate, 1147 WebInputEvent::GestureScrollUpdate,
1148 WebInputEvent::GestureFlingStart, 1148 WebInputEvent::GestureFlingStart,
1149 WebInputEvent::GestureFlingCancel, 1149 WebInputEvent::GestureFlingCancel,
1150 WebInputEvent::GesturePinchUpdate, 1150 WebInputEvent::GesturePinchUpdate,
1151 WebInputEvent::TouchStart, 1151 WebInputEvent::TouchStart,
1152 WebInputEvent::TouchMove 1152 WebInputEvent::TouchMove
1153 }; 1153 };
1154 for (size_t i = 0; i < arraysize(kRequiredEventAckTypes); ++i) { 1154 for (size_t i = 0; i < arraysize(kRequiredEventAckTypes); ++i) {
1155 const WebInputEvent::Type required_ack_type = kRequiredEventAckTypes[i]; 1155 const WebInputEvent::Type required_ack_type = kRequiredEventAckTypes[i];
1156 ASSERT_TRUE(WebInputEventTraits::WillReceiveAckFromRenderer( 1156 ASSERT_TRUE(WebInputEventTraits::ShouldBlockEventOnRenderer(
1157 GetEventWithType(required_ack_type))); 1157 GetEventWithType(required_ack_type)));
1158 } 1158 }
1159 } 1159 }
1160 1160
1161 // Test that GestureShowPress, GestureTapDown and GestureTapCancel events don't 1161 // Test that GestureShowPress, GestureTapDown and GestureTapCancel events don't
1162 // wait for ACKs. 1162 // wait for ACKs.
1163 TEST_F(InputRouterImplTest, GestureTypesIgnoringAckInterleaved) { 1163 TEST_F(InputRouterImplTest, GestureTypesIgnoringAckInterleaved) {
1164 // Interleave a few events that do and do not ignore acks, ensuring that 1164 // Interleave a few events that do and do not ignore acks, ensuring that
1165 // ack-ignoring events aren't dispatched until all prior events which observe 1165 // ack-ignoring events aren't dispatched until all prior events which observe
1166 // their ack disposition have been dispatched. 1166 // their ack disposition have been dispatched.
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1577 SimulateGestureEvent(WebInputEvent::GestureTapDown, 1577 SimulateGestureEvent(WebInputEvent::GestureTapDown,
1578 blink::WebGestureDeviceTouchscreen); 1578 blink::WebGestureDeviceTouchscreen);
1579 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1579 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1580 1580
1581 // The GestureTapUnconfirmed is converted into a tap, as the touch action is 1581 // The GestureTapUnconfirmed is converted into a tap, as the touch action is
1582 // none. 1582 // none.
1583 SimulateGestureEvent(WebInputEvent::GestureTapUnconfirmed, 1583 SimulateGestureEvent(WebInputEvent::GestureTapUnconfirmed,
1584 blink::WebGestureDeviceTouchscreen); 1584 blink::WebGestureDeviceTouchscreen);
1585 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1585 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1586 // This test will become invalid if GestureTap stops requiring an ack. 1586 // This test will become invalid if GestureTap stops requiring an ack.
1587 ASSERT_TRUE(WebInputEventTraits::WillReceiveAckFromRenderer( 1587 ASSERT_TRUE(WebInputEventTraits::ShouldBlockEventOnRenderer(
1588 GetEventWithType(WebInputEvent::GestureTap))); 1588 GetEventWithType(WebInputEvent::GestureTap)));
1589 EXPECT_EQ(2, client_->in_flight_event_count()); 1589 EXPECT_EQ(2, client_->in_flight_event_count());
1590 SendInputEventACK(WebInputEvent::GestureTap, 1590 SendInputEventACK(WebInputEvent::GestureTap,
1591 INPUT_EVENT_ACK_STATE_CONSUMED); 1591 INPUT_EVENT_ACK_STATE_CONSUMED);
1592 EXPECT_EQ(1, client_->in_flight_event_count()); 1592 EXPECT_EQ(1, client_->in_flight_event_count());
1593 1593
1594 // This tap gesture is dropped, since the GestureTapUnconfirmed was turned 1594 // This tap gesture is dropped, since the GestureTapUnconfirmed was turned
1595 // into a tap. 1595 // into a tap.
1596 SimulateGestureEvent(WebInputEvent::GestureTap, 1596 SimulateGestureEvent(WebInputEvent::GestureTap,
1597 blink::WebGestureDeviceTouchscreen); 1597 blink::WebGestureDeviceTouchscreen);
1598 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); 1598 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
1599 1599
1600 SendTouchEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED, 1600 SendTouchEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED,
1601 touch_release_event_id); 1601 touch_release_event_id);
1602 SendTouchEventACK(WebInputEvent::TouchStart, 1602 SendTouchEventACK(WebInputEvent::TouchStart,
1603 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, 1603 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS,
1604 touch_press_event_id2); 1604 touch_press_event_id2);
1605 1605
1606 // Second Tap. 1606 // Second Tap.
1607 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1607 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1608 SimulateGestureEvent(WebInputEvent::GestureTapDown, 1608 SimulateGestureEvent(WebInputEvent::GestureTapDown,
1609 blink::WebGestureDeviceTouchscreen); 1609 blink::WebGestureDeviceTouchscreen);
1610 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1610 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1611 1611
1612 // Although the touch-action is now auto, the double tap still won't be 1612 // Although the touch-action is now auto, the double tap still won't be
1613 // dispatched, because the first tap occured when the touch-action was none. 1613 // dispatched, because the first tap occured when the touch-action was none.
1614 SimulateGestureEvent(WebInputEvent::GestureDoubleTap, 1614 SimulateGestureEvent(WebInputEvent::GestureDoubleTap,
1615 blink::WebGestureDeviceTouchscreen); 1615 blink::WebGestureDeviceTouchscreen);
1616 // This test will become invalid if GestureDoubleTap stops requiring an ack. 1616 // This test will become invalid if GestureDoubleTap stops requiring an ack.
1617 ASSERT_TRUE(WebInputEventTraits::WillReceiveAckFromRenderer( 1617 ASSERT_TRUE(WebInputEventTraits::ShouldBlockEventOnRenderer(
1618 GetEventWithType(WebInputEvent::GestureDoubleTap))); 1618 GetEventWithType(WebInputEvent::GestureDoubleTap)));
1619 EXPECT_EQ(1, client_->in_flight_event_count()); 1619 EXPECT_EQ(1, client_->in_flight_event_count());
1620 SendInputEventACK(WebInputEvent::GestureTap, INPUT_EVENT_ACK_STATE_CONSUMED); 1620 SendInputEventACK(WebInputEvent::GestureTap, INPUT_EVENT_ACK_STATE_CONSUMED);
1621 EXPECT_EQ(0, client_->in_flight_event_count()); 1621 EXPECT_EQ(0, client_->in_flight_event_count());
1622 } 1622 }
1623 1623
1624 // Test that the router will call the client's |DidFlush| after all events have 1624 // Test that the router will call the client's |DidFlush| after all events have
1625 // been dispatched following a call to |Flush|. 1625 // been dispatched following a call to |Flush|.
1626 TEST_F(InputRouterImplTest, InputFlush) { 1626 TEST_F(InputRouterImplTest, InputFlush) {
1627 EXPECT_FALSE(HasPendingEvents()); 1627 EXPECT_FALSE(HasPendingEvents());
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
2330 EXPECT_EQ(80, sent_event->data.flingStart.velocityY); 2330 EXPECT_EQ(80, sent_event->data.flingStart.velocityY);
2331 2331
2332 const WebGestureEvent* filter_event = 2332 const WebGestureEvent* filter_event =
2333 GetFilterWebInputEvent<WebGestureEvent>(); 2333 GetFilterWebInputEvent<WebGestureEvent>();
2334 TestLocationInFilterEvent(filter_event, orig); 2334 TestLocationInFilterEvent(filter_event, orig);
2335 EXPECT_EQ(30, filter_event->data.flingStart.velocityX); 2335 EXPECT_EQ(30, filter_event->data.flingStart.velocityX);
2336 EXPECT_EQ(40, filter_event->data.flingStart.velocityY); 2336 EXPECT_EQ(40, filter_event->data.flingStart.velocityY);
2337 } 2337 }
2338 2338
2339 } // namespace content 2339 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698