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

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

Issue 997283002: Coalesce async touch move events until the ack back from render (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 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
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
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 InputEventAck ack(type, ack_result);
274 ack.type = type; 277 if (WebInputEvent::isTouchEventType(type)) {
275 ack.state = ack_result; 278 DCHECK(!sent_events_ids_.empty());
279 ack.unique_touch_event_id = sent_events_ids_.front();
280 sent_events_ids_.pop_front();
281 }
276 input_router_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack)); 282 input_router_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack));
283 SetLastEventID();
277 } 284 }
278 285
279 InputRouterImpl* input_router() const { 286 InputRouterImpl* input_router() const {
280 return input_router_.get(); 287 return input_router_.get();
281 } 288 }
282 289
283 bool TouchEventQueueEmpty() const { 290 bool TouchEventQueueEmpty() const {
284 return input_router()->touch_event_queue_.empty(); 291 return input_router()->touch_event_queue_.empty();
285 } 292 }
286 293
(...skipping 22 matching lines...) Expand all
309 input_router_->OnMessageReceived( 316 input_router_->OnMessageReceived(
310 InputHostMsg_SetTouchAction(0, touch_action)); 317 InputHostMsg_SetTouchAction(0, touch_action));
311 } 318 }
312 319
313 size_t GetSentMessageCountAndResetSink() { 320 size_t GetSentMessageCountAndResetSink() {
314 size_t count = process_->sink().message_count(); 321 size_t count = process_->sink().message_count();
315 process_->sink().ClearMessages(); 322 process_->sink().ClearMessages();
316 return count; 323 return count;
317 } 324 }
318 325
326 bool TouchEventCancelable() { return touch_event_.cancelable; }
327
328 void SetLastEventID() {
329 size_t count = process_->sink().message_count();
jdduke (slow) 2015/05/12 16:07:11 Hmm, this probably works fine, but I wonder if it'
lanwei 2015/05/13 21:01:53 I think you are right, even though we have to add
330 for (size_t i = 0; i < count; ++i) {
331 const WebInputEvent* input_event =
332 GetInputEventFromMessage(*process_->sink().GetMessageAt(i));
333 uint32 id = WebInputEventTraits::GetUniqueTouchEventId(*input_event);
334 if (id != 0 &&
335 all_sent_events_ids_.find(id) == all_sent_events_ids_.end()) {
336 sent_events_ids_.push_back(id);
337 all_sent_events_ids_.insert(id);
338 }
339 }
340 }
341
319 static void RunTasksAndWait(base::TimeDelta delay) { 342 static void RunTasksAndWait(base::TimeDelta delay) {
320 base::MessageLoop::current()->PostDelayedTask( 343 base::MessageLoop::current()->PostDelayedTask(
321 FROM_HERE, base::MessageLoop::QuitClosure(), delay); 344 FROM_HERE, base::MessageLoop::QuitClosure(), delay);
322 base::MessageLoop::current()->Run(); 345 base::MessageLoop::current()->Run();
323 } 346 }
324 347
325 InputRouterImpl::Config config_; 348 InputRouterImpl::Config config_;
326 scoped_ptr<MockRenderProcessHost> process_; 349 scoped_ptr<MockRenderProcessHost> process_;
327 scoped_ptr<MockInputRouterClient> client_; 350 scoped_ptr<MockInputRouterClient> client_;
328 scoped_ptr<MockInputAckHandler> ack_handler_; 351 scoped_ptr<MockInputAckHandler> ack_handler_;
329 scoped_ptr<InputRouterImpl> input_router_; 352 scoped_ptr<InputRouterImpl> input_router_;
330 353
331 private: 354 private:
332 base::MessageLoopForUI message_loop_; 355 base::MessageLoopForUI message_loop_;
333 SyntheticWebTouchEvent touch_event_; 356 SyntheticWebTouchEvent touch_event_;
334 357
335 scoped_ptr<TestBrowserContext> browser_context_; 358 scoped_ptr<TestBrowserContext> browser_context_;
359 std::deque<uint32> sent_events_ids_;
360 std::set<uint32> all_sent_events_ids_;
336 }; 361 };
337 362
338 TEST_F(InputRouterImplTest, CoalescesRangeSelection) { 363 TEST_F(InputRouterImplTest, CoalescesRangeSelection) {
339 input_router_->SendInput(scoped_ptr<IPC::Message>( 364 input_router_->SendInput(scoped_ptr<IPC::Message>(
340 new InputMsg_SelectRange(0, gfx::Point(1, 2), gfx::Point(3, 4)))); 365 new InputMsg_SelectRange(0, gfx::Point(1, 2), gfx::Point(3, 4))));
341 ExpectIPCMessageWithArg2<InputMsg_SelectRange>( 366 ExpectIPCMessageWithArg2<InputMsg_SelectRange>(
342 process_->sink().GetMessageAt(0), 367 process_->sink().GetMessageAt(0),
343 gfx::Point(1, 2), 368 gfx::Point(1, 2),
344 gfx::Point(3, 4)); 369 gfx::Point(3, 4));
345 EXPECT_EQ(1u, GetSentMessageCountAndResetSink()); 370 EXPECT_EQ(1u, GetSentMessageCountAndResetSink());
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 InputMsg_HandleInputEvent::ID)); 975 InputMsg_HandleInputEvent::ID));
951 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 976 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
952 977
953 // Check that the correct unhandled wheel event was received. 978 // Check that the correct unhandled wheel event was received.
954 EXPECT_EQ(ack_handler_->acked_wheel_event().deltaY, -5); 979 EXPECT_EQ(ack_handler_->acked_wheel_event().deltaY, -5);
955 } 980 }
956 981
957 TEST_F(InputRouterImplTest, TouchTypesIgnoringAck) { 982 TEST_F(InputRouterImplTest, TouchTypesIgnoringAck) {
958 OnHasTouchEventHandlers(true); 983 OnHasTouchEventHandlers(true);
959 // Only acks for TouchCancel should always be ignored. 984 // Only acks for TouchCancel should always be ignored.
960 ASSERT_FALSE(WebInputEventTraits::IgnoresAckDisposition( 985 ASSERT_TRUE(WebInputEventTraits::WillReceiveAckFromRenderer(
961 GetEventWithType(WebInputEvent::TouchStart))); 986 GetEventWithType(WebInputEvent::TouchStart)));
962 ASSERT_FALSE(WebInputEventTraits::IgnoresAckDisposition( 987 ASSERT_TRUE(WebInputEventTraits::WillReceiveAckFromRenderer(
963 GetEventWithType(WebInputEvent::TouchMove))); 988 GetEventWithType(WebInputEvent::TouchMove)));
964 ASSERT_FALSE(WebInputEventTraits::IgnoresAckDisposition( 989 ASSERT_TRUE(WebInputEventTraits::WillReceiveAckFromRenderer(
965 GetEventWithType(WebInputEvent::TouchEnd))); 990 GetEventWithType(WebInputEvent::TouchEnd)));
966 991
967 // Precede the TouchCancel with an appropriate TouchStart; 992 // Precede the TouchCancel with an appropriate TouchStart;
968 PressTouchPoint(1, 1); 993 PressTouchPoint(1, 1);
969 SendTouchEvent(); 994 SendTouchEvent();
970 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); 995 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED);
971 ASSERT_EQ(1U, GetSentMessageCountAndResetSink()); 996 ASSERT_EQ(1U, GetSentMessageCountAndResetSink());
972 ASSERT_EQ(1U, ack_handler_->GetAndResetAckCount()); 997 ASSERT_EQ(1U, ack_handler_->GetAndResetAckCount());
973 ASSERT_EQ(0, client_->in_flight_event_count()); 998 ASSERT_EQ(0, client_->in_flight_event_count());
974 999
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 WebInputEvent::GestureTapDown, 1037 WebInputEvent::GestureTapDown,
1013 WebInputEvent::GestureTapCancel, 1038 WebInputEvent::GestureTapCancel,
1014 WebInputEvent::GestureScrollBegin, 1039 WebInputEvent::GestureScrollBegin,
1015 WebInputEvent::GestureScrollUpdate, 1040 WebInputEvent::GestureScrollUpdate,
1016 WebInputEvent::GesturePinchBegin, 1041 WebInputEvent::GesturePinchBegin,
1017 WebInputEvent::GesturePinchUpdate, 1042 WebInputEvent::GesturePinchUpdate,
1018 WebInputEvent::GesturePinchEnd, 1043 WebInputEvent::GesturePinchEnd,
1019 WebInputEvent::GestureScrollEnd}; 1044 WebInputEvent::GestureScrollEnd};
1020 for (size_t i = 0; i < arraysize(eventTypes); ++i) { 1045 for (size_t i = 0; i < arraysize(eventTypes); ++i) {
1021 WebInputEvent::Type type = eventTypes[i]; 1046 WebInputEvent::Type type = eventTypes[i];
1022 if (!WebInputEventTraits::IgnoresAckDisposition(GetEventWithType(type))) { 1047 if (WebInputEventTraits::WillReceiveAckFromRenderer(
1048 GetEventWithType(type))) {
1023 SimulateGestureEvent(type, blink::WebGestureDeviceTouchscreen); 1049 SimulateGestureEvent(type, blink::WebGestureDeviceTouchscreen);
1024 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1050 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1025 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); 1051 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
1026 EXPECT_EQ(1, client_->in_flight_event_count()); 1052 EXPECT_EQ(1, client_->in_flight_event_count());
1027 EXPECT_TRUE(HasPendingEvents()); 1053 EXPECT_TRUE(HasPendingEvents());
1028 1054
1029 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1055 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1030 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); 1056 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
1031 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); 1057 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
1032 EXPECT_EQ(0, client_->in_flight_event_count()); 1058 EXPECT_EQ(0, client_->in_flight_event_count());
1033 EXPECT_FALSE(HasPendingEvents()); 1059 EXPECT_FALSE(HasPendingEvents());
1034 continue; 1060 continue;
1035 } 1061 }
1036 1062
1037 SimulateGestureEvent(type, blink::WebGestureDeviceTouchscreen); 1063 SimulateGestureEvent(type, blink::WebGestureDeviceTouchscreen);
1038 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1064 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1039 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); 1065 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
1040 EXPECT_EQ(0, client_->in_flight_event_count()); 1066 EXPECT_EQ(0, client_->in_flight_event_count());
1041 EXPECT_FALSE(HasPendingEvents()); 1067 EXPECT_FALSE(HasPendingEvents());
1042 } 1068 }
1043 } 1069 }
1044 1070
1045 TEST_F(InputRouterImplTest, MouseTypesIgnoringAck) { 1071 TEST_F(InputRouterImplTest, MouseTypesIgnoringAck) {
1046 int start_type = static_cast<int>(WebInputEvent::MouseDown); 1072 int start_type = static_cast<int>(WebInputEvent::MouseDown);
1047 int end_type = static_cast<int>(WebInputEvent::ContextMenu); 1073 int end_type = static_cast<int>(WebInputEvent::ContextMenu);
1048 ASSERT_LT(start_type, end_type); 1074 ASSERT_LT(start_type, end_type);
1049 for (int i = start_type; i <= end_type; ++i) { 1075 for (int i = start_type; i <= end_type; ++i) {
1050 WebInputEvent::Type type = static_cast<WebInputEvent::Type>(i); 1076 WebInputEvent::Type type = static_cast<WebInputEvent::Type>(i);
1051 int expected_in_flight_event_count = 1077 int expected_in_flight_event_count =
1052 WebInputEventTraits::IgnoresAckDisposition(GetEventWithType(type)) ? 0 1078 !WebInputEventTraits::WillReceiveAckFromRenderer(GetEventWithType(type))
1053 : 1; 1079 ? 0
1080 : 1;
1054 1081
1055 // Note: Mouse event acks are never forwarded to the ack handler, so the key 1082 // Note: Mouse event acks are never forwarded to the ack handler, so the key
1056 // result here is that ignored ack types don't affect the in-flight count. 1083 // result here is that ignored ack types don't affect the in-flight count.
1057 SimulateMouseEvent(type, 0, 0); 1084 SimulateMouseEvent(type, 0, 0);
1058 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1085 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1059 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); 1086 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
1060 EXPECT_EQ(expected_in_flight_event_count, client_->in_flight_event_count()); 1087 EXPECT_EQ(expected_in_flight_event_count, client_->in_flight_event_count());
1061 if (expected_in_flight_event_count) { 1088 if (expected_in_flight_event_count) {
1062 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1089 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1063 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); 1090 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
1064 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); 1091 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
1065 EXPECT_EQ(0, client_->in_flight_event_count()); 1092 EXPECT_EQ(0, client_->in_flight_event_count());
1066 } 1093 }
1067 } 1094 }
1068 } 1095 }
1069 1096
1070 // Guard against breaking changes to the list of ignored event ack types in 1097 // Guard against breaking changes to the list of ignored event ack types in
1071 // |WebInputEventTraits::IgnoresAckDisposition|. 1098 // |WebInputEventTraits::WillReceiveAckFromRenderer|.
1072 TEST_F(InputRouterImplTest, RequiredEventAckTypes) { 1099 TEST_F(InputRouterImplTest, RequiredEventAckTypes) {
1073 const WebInputEvent::Type kRequiredEventAckTypes[] = { 1100 const WebInputEvent::Type kRequiredEventAckTypes[] = {
1074 WebInputEvent::MouseMove, 1101 WebInputEvent::MouseMove,
1075 WebInputEvent::MouseWheel, 1102 WebInputEvent::MouseWheel,
1076 WebInputEvent::RawKeyDown, 1103 WebInputEvent::RawKeyDown,
1077 WebInputEvent::KeyDown, 1104 WebInputEvent::KeyDown,
1078 WebInputEvent::KeyUp, 1105 WebInputEvent::KeyUp,
1079 WebInputEvent::Char, 1106 WebInputEvent::Char,
1080 WebInputEvent::GestureScrollUpdate, 1107 WebInputEvent::GestureScrollUpdate,
1081 WebInputEvent::GestureFlingStart, 1108 WebInputEvent::GestureFlingStart,
1082 WebInputEvent::GestureFlingCancel, 1109 WebInputEvent::GestureFlingCancel,
1083 WebInputEvent::GesturePinchUpdate, 1110 WebInputEvent::GesturePinchUpdate,
1084 WebInputEvent::TouchStart, 1111 WebInputEvent::TouchStart,
1085 WebInputEvent::TouchMove 1112 WebInputEvent::TouchMove
1086 }; 1113 };
1087 for (size_t i = 0; i < arraysize(kRequiredEventAckTypes); ++i) { 1114 for (size_t i = 0; i < arraysize(kRequiredEventAckTypes); ++i) {
1088 const WebInputEvent::Type required_ack_type = kRequiredEventAckTypes[i]; 1115 const WebInputEvent::Type required_ack_type = kRequiredEventAckTypes[i];
1089 EXPECT_FALSE(WebInputEventTraits::IgnoresAckDisposition( 1116 ASSERT_TRUE(WebInputEventTraits::WillReceiveAckFromRenderer(
1090 GetEventWithType(required_ack_type))); 1117 GetEventWithType(required_ack_type)));
1091 } 1118 }
1092 } 1119 }
1093 1120
1094 // Test that GestureShowPress, GestureTapDown and GestureTapCancel events don't 1121 // Test that GestureShowPress, GestureTapDown and GestureTapCancel events don't
1095 // wait for ACKs. 1122 // wait for ACKs.
1096 TEST_F(InputRouterImplTest, GestureTypesIgnoringAckInterleaved) { 1123 TEST_F(InputRouterImplTest, GestureTypesIgnoringAckInterleaved) {
1097 // Interleave a few events that do and do not ignore acks, ensuring that 1124 // Interleave a few events that do and do not ignore acks, ensuring that
1098 // ack-ignoring events aren't dispatched until all prior events which observe 1125 // ack-ignoring events aren't dispatched until all prior events which observe
1099 // their ack disposition have been dispatched. 1126 // their ack disposition have been dispatched.
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 SimulateGestureEvent(WebInputEvent::GestureTapDown, 1524 SimulateGestureEvent(WebInputEvent::GestureTapDown,
1498 blink::WebGestureDeviceTouchscreen); 1525 blink::WebGestureDeviceTouchscreen);
1499 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1526 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1500 1527
1501 // The GestureTapUnconfirmed is converted into a tap, as the touch action is 1528 // The GestureTapUnconfirmed is converted into a tap, as the touch action is
1502 // none. 1529 // none.
1503 SimulateGestureEvent(WebInputEvent::GestureTapUnconfirmed, 1530 SimulateGestureEvent(WebInputEvent::GestureTapUnconfirmed,
1504 blink::WebGestureDeviceTouchscreen); 1531 blink::WebGestureDeviceTouchscreen);
1505 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1532 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1506 // This test will become invalid if GestureTap stops requiring an ack. 1533 // This test will become invalid if GestureTap stops requiring an ack.
1507 ASSERT_FALSE(WebInputEventTraits::IgnoresAckDisposition( 1534 ASSERT_TRUE(WebInputEventTraits::WillReceiveAckFromRenderer(
1508 GetEventWithType(WebInputEvent::GestureTap))); 1535 GetEventWithType(WebInputEvent::GestureTap)));
1509 EXPECT_EQ(2, client_->in_flight_event_count()); 1536 EXPECT_EQ(2, client_->in_flight_event_count());
1510 SendInputEventACK(WebInputEvent::GestureTap, 1537 SendInputEventACK(WebInputEvent::GestureTap,
1511 INPUT_EVENT_ACK_STATE_CONSUMED); 1538 INPUT_EVENT_ACK_STATE_CONSUMED);
1512 EXPECT_EQ(1, client_->in_flight_event_count()); 1539 EXPECT_EQ(1, client_->in_flight_event_count());
1513 1540
1514 // This tap gesture is dropped, since the GestureTapUnconfirmed was turned 1541 // This tap gesture is dropped, since the GestureTapUnconfirmed was turned
1515 // into a tap. 1542 // into a tap.
1516 SimulateGestureEvent(WebInputEvent::GestureTap, 1543 SimulateGestureEvent(WebInputEvent::GestureTap,
1517 blink::WebGestureDeviceTouchscreen); 1544 blink::WebGestureDeviceTouchscreen);
1518 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); 1545 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
1519 1546
1520 SendInputEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED); 1547 SendInputEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED);
1521 SendInputEventACK(WebInputEvent::TouchStart, 1548 SendInputEventACK(WebInputEvent::TouchStart,
1522 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); 1549 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
1523 1550
1524 // Second Tap. 1551 // Second Tap.
1525 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1552 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1526 SimulateGestureEvent(WebInputEvent::GestureTapDown, 1553 SimulateGestureEvent(WebInputEvent::GestureTapDown,
1527 blink::WebGestureDeviceTouchscreen); 1554 blink::WebGestureDeviceTouchscreen);
1528 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1555 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1529 1556
1530 // Although the touch-action is now auto, the double tap still won't be 1557 // Although the touch-action is now auto, the double tap still won't be
1531 // dispatched, because the first tap occured when the touch-action was none. 1558 // dispatched, because the first tap occured when the touch-action was none.
1532 SimulateGestureEvent(WebInputEvent::GestureDoubleTap, 1559 SimulateGestureEvent(WebInputEvent::GestureDoubleTap,
1533 blink::WebGestureDeviceTouchscreen); 1560 blink::WebGestureDeviceTouchscreen);
1534 // This test will become invalid if GestureDoubleTap stops requiring an ack. 1561 // This test will become invalid if GestureDoubleTap stops requiring an ack.
1535 ASSERT_FALSE(WebInputEventTraits::IgnoresAckDisposition( 1562 ASSERT_TRUE(WebInputEventTraits::WillReceiveAckFromRenderer(
1536 GetEventWithType(WebInputEvent::GestureDoubleTap))); 1563 GetEventWithType(WebInputEvent::GestureDoubleTap)));
1537 EXPECT_EQ(1, client_->in_flight_event_count()); 1564 EXPECT_EQ(1, client_->in_flight_event_count());
1538 SendInputEventACK(WebInputEvent::GestureTap, INPUT_EVENT_ACK_STATE_CONSUMED); 1565 SendInputEventACK(WebInputEvent::GestureTap, INPUT_EVENT_ACK_STATE_CONSUMED);
1539 EXPECT_EQ(0, client_->in_flight_event_count()); 1566 EXPECT_EQ(0, client_->in_flight_event_count());
1540 } 1567 }
1541 1568
1542 // Test that the router will call the client's |DidFlush| after all events have 1569 // Test that the router will call the client's |DidFlush| after all events have
1543 // been dispatched following a call to |Flush|. 1570 // been dispatched following a call to |Flush|.
1544 TEST_F(InputRouterImplTest, InputFlush) { 1571 TEST_F(InputRouterImplTest, InputFlush) {
1545 EXPECT_FALSE(HasPendingEvents()); 1572 EXPECT_FALSE(HasPendingEvents());
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1723 client_overscroll.latest_overscroll_delta); 1750 client_overscroll.latest_overscroll_delta);
1724 EXPECT_EQ(overscroll.current_fling_velocity, 1751 EXPECT_EQ(overscroll.current_fling_velocity,
1725 client_overscroll.current_fling_velocity); 1752 client_overscroll.current_fling_velocity);
1726 1753
1727 DidOverscrollParams wheel_overscroll; 1754 DidOverscrollParams wheel_overscroll;
1728 wheel_overscroll.accumulated_overscroll = gfx::Vector2dF(7, -7); 1755 wheel_overscroll.accumulated_overscroll = gfx::Vector2dF(7, -7);
1729 wheel_overscroll.latest_overscroll_delta = gfx::Vector2dF(3, 0); 1756 wheel_overscroll.latest_overscroll_delta = gfx::Vector2dF(3, 0);
1730 wheel_overscroll.current_fling_velocity = gfx::Vector2dF(1, 0); 1757 wheel_overscroll.current_fling_velocity = gfx::Vector2dF(1, 0);
1731 1758
1732 SimulateWheelEvent(3, 0, 0, false); 1759 SimulateWheelEvent(3, 0, 0, false);
1733 InputHostMsg_HandleInputEvent_ACK_Params ack; 1760 InputEventAck ack(WebInputEvent::MouseWheel,
1734 ack.type = WebInputEvent::MouseWheel; 1761 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1735 ack.state = INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
1736 ack.overscroll.reset(new DidOverscrollParams(wheel_overscroll)); 1762 ack.overscroll.reset(new DidOverscrollParams(wheel_overscroll));
1737 input_router_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack)); 1763 input_router_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack));
1738 1764
1739 client_overscroll = client_->GetAndResetOverscroll(); 1765 client_overscroll = client_->GetAndResetOverscroll();
1740 EXPECT_EQ(wheel_overscroll.accumulated_overscroll, 1766 EXPECT_EQ(wheel_overscroll.accumulated_overscroll,
1741 client_overscroll.accumulated_overscroll); 1767 client_overscroll.accumulated_overscroll);
1742 EXPECT_EQ(wheel_overscroll.latest_overscroll_delta, 1768 EXPECT_EQ(wheel_overscroll.latest_overscroll_delta,
1743 client_overscroll.latest_overscroll_delta); 1769 client_overscroll.latest_overscroll_delta);
1744 EXPECT_EQ(wheel_overscroll.current_fling_velocity, 1770 EXPECT_EQ(wheel_overscroll.current_fling_velocity,
1745 client_overscroll.current_fling_velocity); 1771 client_overscroll.current_fling_velocity);
1746 } 1772 }
1747 1773
1748 } // namespace content 1774 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698