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 <math.h> | 5 #include <math.h> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 ack_handler_.reset(new MockInputAckHandler()); | 148 ack_handler_.reset(new MockInputAckHandler()); |
149 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 149 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
150 command_line->AppendSwitch(switches::kValidateInputEventStream); | 150 command_line->AppendSwitch(switches::kValidateInputEventStream); |
151 input_router_.reset(new InputRouterImpl(process_.get(), | 151 input_router_.reset(new InputRouterImpl(process_.get(), |
152 client_.get(), | 152 client_.get(), |
153 ack_handler_.get(), | 153 ack_handler_.get(), |
154 MSG_ROUTING_NONE, | 154 MSG_ROUTING_NONE, |
155 config_)); | 155 config_)); |
156 client_->set_input_router(input_router()); | 156 client_->set_input_router(input_router()); |
157 ack_handler_->set_input_router(input_router()); | 157 ack_handler_->set_input_router(input_router()); |
| 158 sent_events_ids_.clear(); |
| 159 all_sent_events_ids_.clear(); |
158 } | 160 } |
159 | 161 |
160 void TearDown() override { | 162 void TearDown() override { |
161 // Process all pending tasks to avoid leaks. | 163 // Process all pending tasks to avoid leaks. |
162 base::MessageLoop::current()->RunUntilIdle(); | 164 base::MessageLoop::current()->RunUntilIdle(); |
163 | 165 |
164 input_router_.reset(); | 166 input_router_.reset(); |
165 client_.reset(); | 167 client_.reset(); |
166 process_.reset(); | 168 process_.reset(); |
167 browser_context_.reset(); | 169 browser_context_.reset(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 velocity_x, velocity_y, source_device)); | 245 velocity_x, velocity_y, source_device)); |
244 } | 246 } |
245 | 247 |
246 void SetTouchTimestamp(base::TimeDelta timestamp) { | 248 void SetTouchTimestamp(base::TimeDelta timestamp) { |
247 touch_event_.SetTimestamp(timestamp); | 249 touch_event_.SetTimestamp(timestamp); |
248 } | 250 } |
249 | 251 |
250 void SendTouchEvent() { | 252 void SendTouchEvent() { |
251 input_router_->SendTouchEvent(TouchEventWithLatencyInfo(touch_event_)); | 253 input_router_->SendTouchEvent(TouchEventWithLatencyInfo(touch_event_)); |
252 touch_event_.ResetPoints(); | 254 touch_event_.ResetPoints(); |
| 255 SetLastEventID(); |
253 } | 256 } |
254 | 257 |
255 int PressTouchPoint(int x, int y) { | 258 int PressTouchPoint(int x, int y) { |
256 return touch_event_.PressPoint(x, y); | 259 return touch_event_.PressPoint(x, y); |
257 } | 260 } |
258 | 261 |
259 void MoveTouchPoint(int index, int x, int y) { | 262 void MoveTouchPoint(int index, int x, int y) { |
260 touch_event_.MovePoint(index, x, y); | 263 touch_event_.MovePoint(index, x, y); |
261 } | 264 } |
262 | 265 |
263 void ReleaseTouchPoint(int index) { | 266 void ReleaseTouchPoint(int index) { |
264 touch_event_.ReleasePoint(index); | 267 touch_event_.ReleasePoint(index); |
265 } | 268 } |
266 | 269 |
267 void CancelTouchPoint(int index) { | 270 void CancelTouchPoint(int index) { |
268 touch_event_.CancelPoint(index); | 271 touch_event_.CancelPoint(index); |
269 } | 272 } |
270 | 273 |
271 void SendInputEventACK(blink::WebInputEvent::Type type, | 274 void SendInputEventACK(blink::WebInputEvent::Type type, |
272 InputEventAckState ack_result) { | 275 InputEventAckState ack_result) { |
273 InputHostMsg_HandleInputEvent_ACK_Params ack; | 276 InputHostMsg_HandleInputEvent_ACK_Params ack; |
274 ack.type = type; | 277 ack.type = type; |
275 ack.state = ack_result; | 278 ack.state = ack_result; |
| 279 if (WebInputEvent::isTouchEventType(type)) { |
| 280 DCHECK(!sent_events_ids_.empty()); |
| 281 ack.unique_touch_event_id = sent_events_ids_.front(); |
| 282 sent_events_ids_.pop_front(); |
| 283 } |
276 input_router_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack)); | 284 input_router_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack)); |
| 285 SetLastEventID(); |
277 } | 286 } |
278 | 287 |
279 void NotifyDidStopFlinging() { | 288 void NotifyDidStopFlinging() { |
280 input_router_->OnMessageReceived(InputHostMsg_DidStopFlinging(0)); | 289 input_router_->OnMessageReceived(InputHostMsg_DidStopFlinging(0)); |
281 } | 290 } |
282 | 291 |
283 InputRouterImpl* input_router() const { | 292 InputRouterImpl* input_router() const { |
284 return input_router_.get(); | 293 return input_router_.get(); |
285 } | 294 } |
286 | 295 |
(...skipping 26 matching lines...) Expand all Loading... |
313 input_router_->OnMessageReceived( | 322 input_router_->OnMessageReceived( |
314 InputHostMsg_SetTouchAction(0, touch_action)); | 323 InputHostMsg_SetTouchAction(0, touch_action)); |
315 } | 324 } |
316 | 325 |
317 size_t GetSentMessageCountAndResetSink() { | 326 size_t GetSentMessageCountAndResetSink() { |
318 size_t count = process_->sink().message_count(); | 327 size_t count = process_->sink().message_count(); |
319 process_->sink().ClearMessages(); | 328 process_->sink().ClearMessages(); |
320 return count; | 329 return count; |
321 } | 330 } |
322 | 331 |
| 332 bool TouchEventCancelable() { return touch_event_.cancelable; } |
| 333 |
| 334 void SetLastEventID() { |
| 335 size_t count = process_->sink().message_count(); |
| 336 for (size_t i = 0; i < count; ++i) { |
| 337 const WebInputEvent* input_event = |
| 338 GetInputEventFromMessage(*process_->sink().GetMessageAt(i)); |
| 339 uint32 id = WebInputEventTraits::GetUniqueTouchEventId(*input_event); |
| 340 if (id != 0 && |
| 341 all_sent_events_ids_.find(id) == all_sent_events_ids_.end()) { |
| 342 sent_events_ids_.push_back(id); |
| 343 all_sent_events_ids_.insert(id); |
| 344 } |
| 345 } |
| 346 } |
| 347 |
323 static void RunTasksAndWait(base::TimeDelta delay) { | 348 static void RunTasksAndWait(base::TimeDelta delay) { |
324 base::MessageLoop::current()->PostDelayedTask( | 349 base::MessageLoop::current()->PostDelayedTask( |
325 FROM_HERE, base::MessageLoop::QuitClosure(), delay); | 350 FROM_HERE, base::MessageLoop::QuitClosure(), delay); |
326 base::MessageLoop::current()->Run(); | 351 base::MessageLoop::current()->Run(); |
327 } | 352 } |
328 | 353 |
329 InputRouterImpl::Config config_; | 354 InputRouterImpl::Config config_; |
330 scoped_ptr<MockRenderProcessHost> process_; | 355 scoped_ptr<MockRenderProcessHost> process_; |
331 scoped_ptr<MockInputRouterClient> client_; | 356 scoped_ptr<MockInputRouterClient> client_; |
332 scoped_ptr<MockInputAckHandler> ack_handler_; | 357 scoped_ptr<MockInputAckHandler> ack_handler_; |
333 scoped_ptr<InputRouterImpl> input_router_; | 358 scoped_ptr<InputRouterImpl> input_router_; |
334 | 359 |
335 private: | 360 private: |
336 base::MessageLoopForUI message_loop_; | 361 base::MessageLoopForUI message_loop_; |
337 SyntheticWebTouchEvent touch_event_; | 362 SyntheticWebTouchEvent touch_event_; |
338 | 363 |
339 scoped_ptr<TestBrowserContext> browser_context_; | 364 scoped_ptr<TestBrowserContext> browser_context_; |
| 365 std::deque<uint32> sent_events_ids_; |
| 366 std::set<uint32> all_sent_events_ids_; |
340 }; | 367 }; |
341 | 368 |
342 TEST_F(InputRouterImplTest, CoalescesRangeSelection) { | 369 TEST_F(InputRouterImplTest, CoalescesRangeSelection) { |
343 input_router_->SendInput(scoped_ptr<IPC::Message>( | 370 input_router_->SendInput(scoped_ptr<IPC::Message>( |
344 new InputMsg_SelectRange(0, gfx::Point(1, 2), gfx::Point(3, 4)))); | 371 new InputMsg_SelectRange(0, gfx::Point(1, 2), gfx::Point(3, 4)))); |
345 ExpectIPCMessageWithArg2<InputMsg_SelectRange>( | 372 ExpectIPCMessageWithArg2<InputMsg_SelectRange>( |
346 process_->sink().GetMessageAt(0), | 373 process_->sink().GetMessageAt(0), |
347 gfx::Point(1, 2), | 374 gfx::Point(1, 2), |
348 gfx::Point(3, 4)); | 375 gfx::Point(3, 4)); |
349 EXPECT_EQ(1u, GetSentMessageCountAndResetSink()); | 376 EXPECT_EQ(1u, GetSentMessageCountAndResetSink()); |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 InputMsg_HandleInputEvent::ID)); | 981 InputMsg_HandleInputEvent::ID)); |
955 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 982 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
956 | 983 |
957 // Check that the correct unhandled wheel event was received. | 984 // Check that the correct unhandled wheel event was received. |
958 EXPECT_EQ(ack_handler_->acked_wheel_event().deltaY, -5); | 985 EXPECT_EQ(ack_handler_->acked_wheel_event().deltaY, -5); |
959 } | 986 } |
960 | 987 |
961 TEST_F(InputRouterImplTest, TouchTypesIgnoringAck) { | 988 TEST_F(InputRouterImplTest, TouchTypesIgnoringAck) { |
962 OnHasTouchEventHandlers(true); | 989 OnHasTouchEventHandlers(true); |
963 // Only acks for TouchCancel should always be ignored. | 990 // Only acks for TouchCancel should always be ignored. |
964 ASSERT_FALSE(WebInputEventTraits::IgnoresAckDisposition( | 991 ASSERT_TRUE(WebInputEventTraits::WillReceiveAckFromRenderer( |
965 GetEventWithType(WebInputEvent::TouchStart))); | 992 GetEventWithType(WebInputEvent::TouchStart))); |
966 ASSERT_FALSE(WebInputEventTraits::IgnoresAckDisposition( | 993 ASSERT_TRUE(WebInputEventTraits::WillReceiveAckFromRenderer( |
967 GetEventWithType(WebInputEvent::TouchMove))); | 994 GetEventWithType(WebInputEvent::TouchMove))); |
968 ASSERT_FALSE(WebInputEventTraits::IgnoresAckDisposition( | 995 ASSERT_TRUE(WebInputEventTraits::WillReceiveAckFromRenderer( |
969 GetEventWithType(WebInputEvent::TouchEnd))); | 996 GetEventWithType(WebInputEvent::TouchEnd))); |
970 | 997 |
971 // Precede the TouchCancel with an appropriate TouchStart; | 998 // Precede the TouchCancel with an appropriate TouchStart; |
972 PressTouchPoint(1, 1); | 999 PressTouchPoint(1, 1); |
973 SendTouchEvent(); | 1000 SendTouchEvent(); |
974 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); | 1001 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); |
975 ASSERT_EQ(1U, GetSentMessageCountAndResetSink()); | 1002 ASSERT_EQ(1U, GetSentMessageCountAndResetSink()); |
976 ASSERT_EQ(1U, ack_handler_->GetAndResetAckCount()); | 1003 ASSERT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
977 ASSERT_EQ(0, client_->in_flight_event_count()); | 1004 ASSERT_EQ(0, client_->in_flight_event_count()); |
978 | 1005 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 WebInputEvent::GestureTapCancel, | 1044 WebInputEvent::GestureTapCancel, |
1018 WebInputEvent::GestureScrollBegin, | 1045 WebInputEvent::GestureScrollBegin, |
1019 WebInputEvent::GestureScrollUpdate, | 1046 WebInputEvent::GestureScrollUpdate, |
1020 WebInputEvent::GesturePinchBegin, | 1047 WebInputEvent::GesturePinchBegin, |
1021 WebInputEvent::GesturePinchUpdate, | 1048 WebInputEvent::GesturePinchUpdate, |
1022 WebInputEvent::GesturePinchEnd, | 1049 WebInputEvent::GesturePinchEnd, |
1023 WebInputEvent::GestureScrollEnd}; | 1050 WebInputEvent::GestureScrollEnd}; |
1024 for (size_t i = 0; i < arraysize(eventTypes); ++i) { | 1051 for (size_t i = 0; i < arraysize(eventTypes); ++i) { |
1025 WebInputEvent::Type type = eventTypes[i]; | 1052 WebInputEvent::Type type = eventTypes[i]; |
1026 SCOPED_TRACE(WebInputEventTraits::GetName(type)); | 1053 SCOPED_TRACE(WebInputEventTraits::GetName(type)); |
1027 if (!WebInputEventTraits::IgnoresAckDisposition(GetEventWithType(type))) { | 1054 if (WebInputEventTraits::WillReceiveAckFromRenderer( |
| 1055 GetEventWithType(type))) { |
1028 SimulateGestureEvent(type, blink::WebGestureDeviceTouchscreen); | 1056 SimulateGestureEvent(type, blink::WebGestureDeviceTouchscreen); |
1029 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1057 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
1030 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); | 1058 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
1031 EXPECT_EQ(1, client_->in_flight_event_count()); | 1059 EXPECT_EQ(1, client_->in_flight_event_count()); |
1032 EXPECT_TRUE(HasPendingEvents()); | 1060 EXPECT_TRUE(HasPendingEvents()); |
1033 | 1061 |
1034 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_CONSUMED); | 1062 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_CONSUMED); |
1035 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 1063 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
1036 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); | 1064 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
1037 EXPECT_EQ(0, client_->in_flight_event_count()); | 1065 EXPECT_EQ(0, client_->in_flight_event_count()); |
(...skipping 18 matching lines...) Expand all Loading... |
1056 } | 1084 } |
1057 } | 1085 } |
1058 | 1086 |
1059 TEST_F(InputRouterImplTest, MouseTypesIgnoringAck) { | 1087 TEST_F(InputRouterImplTest, MouseTypesIgnoringAck) { |
1060 int start_type = static_cast<int>(WebInputEvent::MouseDown); | 1088 int start_type = static_cast<int>(WebInputEvent::MouseDown); |
1061 int end_type = static_cast<int>(WebInputEvent::ContextMenu); | 1089 int end_type = static_cast<int>(WebInputEvent::ContextMenu); |
1062 ASSERT_LT(start_type, end_type); | 1090 ASSERT_LT(start_type, end_type); |
1063 for (int i = start_type; i <= end_type; ++i) { | 1091 for (int i = start_type; i <= end_type; ++i) { |
1064 WebInputEvent::Type type = static_cast<WebInputEvent::Type>(i); | 1092 WebInputEvent::Type type = static_cast<WebInputEvent::Type>(i); |
1065 int expected_in_flight_event_count = | 1093 int expected_in_flight_event_count = |
1066 WebInputEventTraits::IgnoresAckDisposition(GetEventWithType(type)) ? 0 | 1094 !WebInputEventTraits::WillReceiveAckFromRenderer(GetEventWithType(type)) |
1067 : 1; | 1095 ? 0 |
| 1096 : 1; |
1068 | 1097 |
1069 // Note: Mouse event acks are never forwarded to the ack handler, so the key | 1098 // Note: Mouse event acks are never forwarded to the ack handler, so the key |
1070 // result here is that ignored ack types don't affect the in-flight count. | 1099 // result here is that ignored ack types don't affect the in-flight count. |
1071 SimulateMouseEvent(type, 0, 0); | 1100 SimulateMouseEvent(type, 0, 0); |
1072 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1101 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
1073 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); | 1102 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
1074 EXPECT_EQ(expected_in_flight_event_count, client_->in_flight_event_count()); | 1103 EXPECT_EQ(expected_in_flight_event_count, client_->in_flight_event_count()); |
1075 if (expected_in_flight_event_count) { | 1104 if (expected_in_flight_event_count) { |
1076 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1105 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1077 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 1106 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
1078 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); | 1107 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
1079 EXPECT_EQ(0, client_->in_flight_event_count()); | 1108 EXPECT_EQ(0, client_->in_flight_event_count()); |
1080 } | 1109 } |
1081 } | 1110 } |
1082 } | 1111 } |
1083 | 1112 |
1084 // Guard against breaking changes to the list of ignored event ack types in | 1113 // Guard against breaking changes to the list of ignored event ack types in |
1085 // |WebInputEventTraits::IgnoresAckDisposition|. | 1114 // |WebInputEventTraits::WillReceiveAckFromRenderer|. |
1086 TEST_F(InputRouterImplTest, RequiredEventAckTypes) { | 1115 TEST_F(InputRouterImplTest, RequiredEventAckTypes) { |
1087 const WebInputEvent::Type kRequiredEventAckTypes[] = { | 1116 const WebInputEvent::Type kRequiredEventAckTypes[] = { |
1088 WebInputEvent::MouseMove, | 1117 WebInputEvent::MouseMove, |
1089 WebInputEvent::MouseWheel, | 1118 WebInputEvent::MouseWheel, |
1090 WebInputEvent::RawKeyDown, | 1119 WebInputEvent::RawKeyDown, |
1091 WebInputEvent::KeyDown, | 1120 WebInputEvent::KeyDown, |
1092 WebInputEvent::KeyUp, | 1121 WebInputEvent::KeyUp, |
1093 WebInputEvent::Char, | 1122 WebInputEvent::Char, |
1094 WebInputEvent::GestureScrollUpdate, | 1123 WebInputEvent::GestureScrollUpdate, |
1095 WebInputEvent::GestureFlingStart, | 1124 WebInputEvent::GestureFlingStart, |
1096 WebInputEvent::GestureFlingCancel, | 1125 WebInputEvent::GestureFlingCancel, |
1097 WebInputEvent::GesturePinchUpdate, | 1126 WebInputEvent::GesturePinchUpdate, |
1098 WebInputEvent::TouchStart, | 1127 WebInputEvent::TouchStart, |
1099 WebInputEvent::TouchMove | 1128 WebInputEvent::TouchMove |
1100 }; | 1129 }; |
1101 for (size_t i = 0; i < arraysize(kRequiredEventAckTypes); ++i) { | 1130 for (size_t i = 0; i < arraysize(kRequiredEventAckTypes); ++i) { |
1102 const WebInputEvent::Type required_ack_type = kRequiredEventAckTypes[i]; | 1131 const WebInputEvent::Type required_ack_type = kRequiredEventAckTypes[i]; |
1103 EXPECT_FALSE(WebInputEventTraits::IgnoresAckDisposition( | 1132 ASSERT_TRUE(WebInputEventTraits::WillReceiveAckFromRenderer( |
1104 GetEventWithType(required_ack_type))); | 1133 GetEventWithType(required_ack_type))); |
1105 } | 1134 } |
1106 } | 1135 } |
1107 | 1136 |
1108 // Test that GestureShowPress, GestureTapDown and GestureTapCancel events don't | 1137 // Test that GestureShowPress, GestureTapDown and GestureTapCancel events don't |
1109 // wait for ACKs. | 1138 // wait for ACKs. |
1110 TEST_F(InputRouterImplTest, GestureTypesIgnoringAckInterleaved) { | 1139 TEST_F(InputRouterImplTest, GestureTypesIgnoringAckInterleaved) { |
1111 // Interleave a few events that do and do not ignore acks, ensuring that | 1140 // Interleave a few events that do and do not ignore acks, ensuring that |
1112 // ack-ignoring events aren't dispatched until all prior events which observe | 1141 // ack-ignoring events aren't dispatched until all prior events which observe |
1113 // their ack disposition have been dispatched. | 1142 // their ack disposition have been dispatched. |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1511 SimulateGestureEvent(WebInputEvent::GestureTapDown, | 1540 SimulateGestureEvent(WebInputEvent::GestureTapDown, |
1512 blink::WebGestureDeviceTouchscreen); | 1541 blink::WebGestureDeviceTouchscreen); |
1513 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1542 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
1514 | 1543 |
1515 // The GestureTapUnconfirmed is converted into a tap, as the touch action is | 1544 // The GestureTapUnconfirmed is converted into a tap, as the touch action is |
1516 // none. | 1545 // none. |
1517 SimulateGestureEvent(WebInputEvent::GestureTapUnconfirmed, | 1546 SimulateGestureEvent(WebInputEvent::GestureTapUnconfirmed, |
1518 blink::WebGestureDeviceTouchscreen); | 1547 blink::WebGestureDeviceTouchscreen); |
1519 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1548 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
1520 // This test will become invalid if GestureTap stops requiring an ack. | 1549 // This test will become invalid if GestureTap stops requiring an ack. |
1521 ASSERT_FALSE(WebInputEventTraits::IgnoresAckDisposition( | 1550 ASSERT_TRUE(WebInputEventTraits::WillReceiveAckFromRenderer( |
1522 GetEventWithType(WebInputEvent::GestureTap))); | 1551 GetEventWithType(WebInputEvent::GestureTap))); |
1523 EXPECT_EQ(2, client_->in_flight_event_count()); | 1552 EXPECT_EQ(2, client_->in_flight_event_count()); |
1524 SendInputEventACK(WebInputEvent::GestureTap, | 1553 SendInputEventACK(WebInputEvent::GestureTap, |
1525 INPUT_EVENT_ACK_STATE_CONSUMED); | 1554 INPUT_EVENT_ACK_STATE_CONSUMED); |
1526 EXPECT_EQ(1, client_->in_flight_event_count()); | 1555 EXPECT_EQ(1, client_->in_flight_event_count()); |
1527 | 1556 |
1528 // This tap gesture is dropped, since the GestureTapUnconfirmed was turned | 1557 // This tap gesture is dropped, since the GestureTapUnconfirmed was turned |
1529 // into a tap. | 1558 // into a tap. |
1530 SimulateGestureEvent(WebInputEvent::GestureTap, | 1559 SimulateGestureEvent(WebInputEvent::GestureTap, |
1531 blink::WebGestureDeviceTouchscreen); | 1560 blink::WebGestureDeviceTouchscreen); |
1532 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 1561 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
1533 | 1562 |
1534 SendInputEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED); | 1563 SendInputEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED); |
1535 SendInputEventACK(WebInputEvent::TouchStart, | 1564 SendInputEventACK(WebInputEvent::TouchStart, |
1536 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); | 1565 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); |
1537 | 1566 |
1538 // Second Tap. | 1567 // Second Tap. |
1539 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1568 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
1540 SimulateGestureEvent(WebInputEvent::GestureTapDown, | 1569 SimulateGestureEvent(WebInputEvent::GestureTapDown, |
1541 blink::WebGestureDeviceTouchscreen); | 1570 blink::WebGestureDeviceTouchscreen); |
1542 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1571 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
1543 | 1572 |
1544 // Although the touch-action is now auto, the double tap still won't be | 1573 // Although the touch-action is now auto, the double tap still won't be |
1545 // dispatched, because the first tap occured when the touch-action was none. | 1574 // dispatched, because the first tap occured when the touch-action was none. |
1546 SimulateGestureEvent(WebInputEvent::GestureDoubleTap, | 1575 SimulateGestureEvent(WebInputEvent::GestureDoubleTap, |
1547 blink::WebGestureDeviceTouchscreen); | 1576 blink::WebGestureDeviceTouchscreen); |
1548 // This test will become invalid if GestureDoubleTap stops requiring an ack. | 1577 // This test will become invalid if GestureDoubleTap stops requiring an ack. |
1549 ASSERT_FALSE(WebInputEventTraits::IgnoresAckDisposition( | 1578 ASSERT_TRUE(WebInputEventTraits::WillReceiveAckFromRenderer( |
1550 GetEventWithType(WebInputEvent::GestureDoubleTap))); | 1579 GetEventWithType(WebInputEvent::GestureDoubleTap))); |
1551 EXPECT_EQ(1, client_->in_flight_event_count()); | 1580 EXPECT_EQ(1, client_->in_flight_event_count()); |
1552 SendInputEventACK(WebInputEvent::GestureTap, INPUT_EVENT_ACK_STATE_CONSUMED); | 1581 SendInputEventACK(WebInputEvent::GestureTap, INPUT_EVENT_ACK_STATE_CONSUMED); |
1553 EXPECT_EQ(0, client_->in_flight_event_count()); | 1582 EXPECT_EQ(0, client_->in_flight_event_count()); |
1554 } | 1583 } |
1555 | 1584 |
1556 // Test that the router will call the client's |DidFlush| after all events have | 1585 // Test that the router will call the client's |DidFlush| after all events have |
1557 // been dispatched following a call to |Flush|. | 1586 // been dispatched following a call to |Flush|. |
1558 TEST_F(InputRouterImplTest, InputFlush) { | 1587 TEST_F(InputRouterImplTest, InputFlush) { |
1559 EXPECT_FALSE(HasPendingEvents()); | 1588 EXPECT_FALSE(HasPendingEvents()); |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1794 client_overscroll = client_->GetAndResetOverscroll(); | 1823 client_overscroll = client_->GetAndResetOverscroll(); |
1795 EXPECT_EQ(wheel_overscroll.accumulated_overscroll, | 1824 EXPECT_EQ(wheel_overscroll.accumulated_overscroll, |
1796 client_overscroll.accumulated_overscroll); | 1825 client_overscroll.accumulated_overscroll); |
1797 EXPECT_EQ(wheel_overscroll.latest_overscroll_delta, | 1826 EXPECT_EQ(wheel_overscroll.latest_overscroll_delta, |
1798 client_overscroll.latest_overscroll_delta); | 1827 client_overscroll.latest_overscroll_delta); |
1799 EXPECT_EQ(wheel_overscroll.current_fling_velocity, | 1828 EXPECT_EQ(wheel_overscroll.current_fling_velocity, |
1800 client_overscroll.current_fling_velocity); | 1829 client_overscroll.current_fling_velocity); |
1801 } | 1830 } |
1802 | 1831 |
1803 } // namespace content | 1832 } // namespace content |
OLD | NEW |