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

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

Powered by Google App Engine
This is Rietveld 408576698