OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "content/browser/renderer_host/input/gesture_event_queue.h" | 7 #include "content/browser/renderer_host/input/gesture_event_queue.h" |
8 #include "content/common/input/synthetic_web_input_event_builders.h" | 8 #include "content/common/input/synthetic_web_input_event_builders.h" |
9 #include "content/common/input/web_input_event_traits.h" | 9 #include "content/common/input/web_input_event_traits.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 PushGesture(WebInputEvent::GestureScrollBegin); | 191 PushGesture(WebInputEvent::GestureScrollBegin); |
192 PressTouchPoint(1, 1); | 192 PressTouchPoint(1, 1); |
193 EXPECT_FALSE(GesturesSent()); | 193 EXPECT_FALSE(GesturesSent()); |
194 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 194 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
195 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollBegin), | 195 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollBegin), |
196 GetAndResetSentGestures())); | 196 GetAndResetSentGestures())); |
197 | 197 |
198 // Multiple gestures can be queued for a single event. | 198 // Multiple gestures can be queued for a single event. |
199 PushGesture(WebInputEvent::GestureFlingStart); | 199 PushGesture(WebInputEvent::GestureFlingStart); |
200 PushGesture(WebInputEvent::GestureFlingCancel); | 200 PushGesture(WebInputEvent::GestureFlingCancel); |
201 MoveTouchPoint(0, 1, 1); | 201 ReleaseTouchPoint(0); |
202 EXPECT_FALSE(GesturesSent()); | 202 EXPECT_FALSE(GesturesSent()); |
203 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 203 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
204 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureFlingStart, | 204 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureFlingStart, |
205 WebInputEvent::GestureFlingCancel), | 205 WebInputEvent::GestureFlingCancel), |
206 GetAndResetSentGestures())); | 206 GetAndResetSentGestures())); |
207 } | |
207 | 208 |
208 // A consumed touch's gesture should not be sent. | 209 TEST_F(GestureEventQueueTest, BasicGesturesConsumed) { |
210 // An consumed touch's gesture should be sent. | |
tdresser
2014/02/03 15:52:58
I'm not clear on the purpose of this comment modif
tdresser
2014/02/03 18:55:14
Done.
| |
211 PushGesture(WebInputEvent::GestureScrollBegin); | |
212 PressTouchPoint(1, 1); | |
213 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); | |
214 EXPECT_FALSE(GesturesSent()); | |
215 | |
209 PushGesture(WebInputEvent::GestureFlingStart); | 216 PushGesture(WebInputEvent::GestureFlingStart); |
210 PushGesture(WebInputEvent::GestureFlingCancel); | 217 PushGesture(WebInputEvent::GestureFlingCancel); |
211 ReleaseTouchPoint(0); | 218 ReleaseTouchPoint(0); |
212 EXPECT_FALSE(GesturesSent()); | |
213 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); | 219 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); |
214 EXPECT_FALSE(GesturesSent()); | 220 EXPECT_FALSE(GesturesSent()); |
215 } | 221 } |
216 | 222 |
217 TEST_F(GestureEventQueueTest, ConsumedThenNotConsumed) { | 223 TEST_F(GestureEventQueueTest, ConsumedThenNotConsumed) { |
218 // A consumed touch's gesture should not be sent. | 224 // A consumed touch's gesture should not be sent. |
219 PushGesture(WebInputEvent::GestureScrollBegin); | 225 PushGesture(WebInputEvent::GestureScrollBegin); |
220 PressTouchPoint(1, 1); | 226 PressTouchPoint(1, 1); |
221 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); | 227 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); |
222 EXPECT_FALSE(GesturesSent()); | 228 EXPECT_FALSE(GesturesSent()); |
223 | 229 |
224 // Even if the subsequent touch is not consumed, continue dropping gestures. | 230 // Even if the subsequent touch is not consumed, continue dropping gestures. |
225 PushGesture(WebInputEvent::GestureScrollUpdate); | 231 PushGesture(WebInputEvent::GestureScrollUpdate); |
226 MoveTouchPoint(0, 2, 2); | 232 MoveTouchPoint(0, 2, 2); |
227 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 233 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
228 EXPECT_FALSE(GesturesSent()); | 234 EXPECT_FALSE(GesturesSent()); |
229 | 235 |
230 // Even if the subsequent touch had no consumer, continue dropping gestures. | 236 // Even if the subsequent touch had no consumer, continue dropping gestures. |
231 PushGesture(WebInputEvent::GestureFlingStart); | 237 PushGesture(WebInputEvent::GestureFlingStart); |
232 ReleaseTouchPoint(0); | 238 ReleaseTouchPoint(0); |
233 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 239 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); |
234 EXPECT_FALSE(GesturesSent()); | 240 EXPECT_FALSE(GesturesSent()); |
235 } | 241 } |
236 | 242 |
243 | |
244 TEST_F(GestureEventQueueTest, NotConsumedThenConsumed) { | |
245 // A not consumed touch's gesture should be sent. | |
246 PushGesture(WebInputEvent::GestureScrollBegin); | |
247 PressTouchPoint(1, 1); | |
248 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
249 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollBegin), | |
250 GetAndResetSentGestures())); | |
251 | |
252 // A newly consumed gesture should not be sent. | |
253 PushGesture(WebInputEvent::GesturePinchBegin); | |
254 PressTouchPoint(10, 10); | |
255 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); | |
256 EXPECT_FALSE(GesturesSent()); | |
257 | |
258 // And subsequent non-consumed updates should not be sent. | |
259 PushGesture(WebInputEvent::GestureScrollUpdate); | |
260 PushGesture(WebInputEvent::GesturePinchUpdate); | |
261 MoveTouchPoint(0, 2, 2); | |
262 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
263 EXPECT_FALSE(GesturesSent()); | |
264 | |
265 // End events dispatched only when their start events were. | |
266 PushGesture(WebInputEvent::GesturePinchEnd); | |
267 ReleaseTouchPoint(1); | |
268 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
269 EXPECT_FALSE(GesturesSent()); | |
270 | |
271 PushGesture(WebInputEvent::GestureScrollEnd); | |
272 ReleaseTouchPoint(0); | |
273 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); | |
274 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollEnd), | |
275 GetAndResetSentGestures())); | |
276 } | |
277 | |
237 TEST_F(GestureEventQueueTest, NotConsumedThenNoConsumer) { | 278 TEST_F(GestureEventQueueTest, NotConsumedThenNoConsumer) { |
238 // An unconsumed touch's gesture should be sent. | 279 // An unconsumed touch's gesture should be sent. |
239 PushGesture(WebInputEvent::GestureScrollBegin); | 280 PushGesture(WebInputEvent::GestureScrollBegin); |
240 PressTouchPoint(1, 1); | 281 PressTouchPoint(1, 1); |
241 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 282 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
242 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollBegin), | 283 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollBegin), |
243 GetAndResetSentGestures())); | 284 GetAndResetSentGestures())); |
244 | 285 |
245 // If the subsequent touch has no consumer (e.g., a secondary pointer is | 286 // If the subsequent touch has no consumer (e.g., a secondary pointer is |
246 // pressed but not on a touch handling rect), send the gesture. | 287 // pressed but not on a touch handling rect), send the gesture. |
247 PushGesture(WebInputEvent::GesturePinchBegin); | 288 PushGesture(WebInputEvent::GesturePinchBegin); |
248 PressTouchPoint(2, 2); | 289 PressTouchPoint(2, 2); |
249 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); | 290 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); |
250 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GesturePinchBegin), | 291 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GesturePinchBegin), |
251 GetAndResetSentGestures())); | 292 GetAndResetSentGestures())); |
252 | 293 |
253 // If the subsequent touch is consumed, then the remaining gesture sequence | 294 // End events dispatched when their start events were independent |
tdresser
2014/02/03 15:52:58
"when their start events were" -> "when their star
tdresser
2014/02/03 18:55:14
Done.
| |
254 // should be dropped, regardless of subsequent touch ack disposition. | 295 // of the ack state. |
296 PushGesture(WebInputEvent::GesturePinchEnd); | |
297 ReleaseTouchPoint(1); | |
298 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); | |
299 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GesturePinchEnd), | |
300 GetAndResetSentGestures())); | |
301 | |
302 PushGesture(WebInputEvent::GestureScrollEnd); | |
303 ReleaseTouchPoint(0); | |
304 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); | |
305 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollEnd), | |
306 GetAndResetSentGestures())); | |
307 } | |
308 | |
309 TEST_F(GestureEventQueueTest, EndingEventsSent) { | |
310 PushGesture(WebInputEvent::GestureScrollBegin); | |
311 PressTouchPoint(1, 1); | |
312 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
313 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollBegin), | |
314 GetAndResetSentGestures())); | |
315 | |
316 PushGesture(WebInputEvent::GesturePinchBegin); | |
317 PressTouchPoint(2, 2); | |
318 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
319 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GesturePinchBegin), | |
320 GetAndResetSentGestures())); | |
321 | |
322 // Consuming the touchend event can't suppress the match end gesture. | |
323 PushGesture(WebInputEvent::GesturePinchEnd); | |
324 ReleaseTouchPoint(1); | |
325 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); | |
326 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GesturePinchEnd), | |
327 GetAndResetSentGestures())); | |
328 | |
329 // But other events in the same packet are still suppressed. | |
255 PushGesture(WebInputEvent::GestureScrollUpdate); | 330 PushGesture(WebInputEvent::GestureScrollUpdate); |
256 PushGesture(WebInputEvent::GesturePinchUpdate); | 331 PushGesture(WebInputEvent::GestureScrollEnd); |
332 ReleaseTouchPoint(0); | |
333 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); | |
334 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollEnd), | |
335 GetAndResetSentGestures())); | |
336 | |
337 // GestureScrollEnd and GestureFlingStart behave the same in this regard. | |
338 PushGesture(WebInputEvent::GestureScrollBegin); | |
339 PressTouchPoint(1, 1); | |
340 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
341 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollBegin), | |
342 GetAndResetSentGestures())); | |
343 | |
344 PushGesture(WebInputEvent::GestureFlingStart); | |
345 ReleaseTouchPoint(0); | |
346 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); | |
347 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureFlingStart), | |
348 GetAndResetSentGestures())); | |
349 } | |
350 | |
351 TEST_F(GestureEventQueueTest, EndingEventsNotSent) { | |
352 // Consuming a begin event ensures no end events are sent. | |
353 PushGesture(WebInputEvent::GestureScrollBegin); | |
354 PressTouchPoint(1, 1); | |
355 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); | |
356 EXPECT_FALSE(GesturesSent()); | |
357 | |
358 PushGesture(WebInputEvent::GesturePinchBegin); | |
359 PressTouchPoint(2, 2); | |
360 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
361 EXPECT_FALSE(GesturesSent()); | |
362 | |
363 PushGesture(WebInputEvent::GesturePinchEnd); | |
364 ReleaseTouchPoint(1); | |
365 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
366 EXPECT_FALSE(GesturesSent()); | |
367 | |
368 PushGesture(WebInputEvent::GestureScrollEnd); | |
369 ReleaseTouchPoint(0); | |
370 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
371 EXPECT_FALSE(GesturesSent()); | |
372 } | |
373 | |
374 TEST_F(GestureEventQueueTest, IndependentPacketsAllowed) { | |
375 PushGesture(WebInputEvent::GestureScrollBegin); | |
376 PressTouchPoint(1, 1); | |
377 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
378 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollBegin), | |
379 GetAndResetSentGestures())); | |
380 | |
381 // Consuming a single scroll or pinch update should suppress only that event. | |
382 PushGesture(WebInputEvent::GestureScrollUpdate); | |
257 MoveTouchPoint(0, 2, 2); | 383 MoveTouchPoint(0, 2, 2); |
258 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); | 384 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); |
259 EXPECT_FALSE(GesturesSent()); | 385 EXPECT_FALSE(GesturesSent()); |
260 | 386 |
387 PushGesture(WebInputEvent::GesturePinchBegin); | |
388 PressTouchPoint(2, 2); | |
389 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
390 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GesturePinchBegin), | |
391 GetAndResetSentGestures())); | |
392 | |
393 PushGesture(WebInputEvent::GesturePinchUpdate); | |
394 MoveTouchPoint(1, 2, 3); | |
395 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); | |
396 EXPECT_FALSE(GesturesSent()); | |
397 | |
398 // Subsequent updates should not be affected. | |
399 PushGesture(WebInputEvent::GestureScrollUpdate); | |
400 MoveTouchPoint(0, 4, 4); | |
401 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
402 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollUpdate), | |
403 GetAndResetSentGestures())); | |
404 | |
405 PushGesture(WebInputEvent::GesturePinchUpdate); | |
406 MoveTouchPoint(0, 4, 5); | |
407 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
408 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GesturePinchUpdate), | |
409 GetAndResetSentGestures())); | |
410 | |
411 PushGesture(WebInputEvent::GesturePinchEnd); | |
412 ReleaseTouchPoint(1); | |
413 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); | |
414 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GesturePinchEnd), | |
415 GetAndResetSentGestures())); | |
416 | |
417 PushGesture(WebInputEvent::GestureScrollEnd); | |
418 ReleaseTouchPoint(0); | |
419 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); | |
420 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollEnd), | |
421 GetAndResetSentGestures())); | |
422 } | |
423 | |
424 TEST_F(GestureEventQueueTest, IndependentPacketsNotAllowed) { | |
425 PushGesture(WebInputEvent::GestureScrollBegin); | |
426 PressTouchPoint(1, 1); | |
427 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); | |
428 EXPECT_FALSE(GesturesSent()); | |
429 | |
430 // Independent packets are never sent when the global state is to drop. | |
431 PushGesture(WebInputEvent::GestureScrollUpdate); | |
432 MoveTouchPoint(0, 2, 2); | |
433 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
434 EXPECT_FALSE(GesturesSent()); | |
435 | |
436 PushGesture(WebInputEvent::GesturePinchBegin); | |
437 PressTouchPoint(2, 2); | |
438 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
439 EXPECT_FALSE(GesturesSent()); | |
440 | |
441 PushGesture(WebInputEvent::GesturePinchUpdate); | |
442 MoveTouchPoint(1, 2, 3); | |
443 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); | |
444 EXPECT_FALSE(GesturesSent()); | |
445 | |
261 PushGesture(WebInputEvent::GesturePinchEnd); | 446 PushGesture(WebInputEvent::GesturePinchEnd); |
262 ReleaseTouchPoint(1); | 447 ReleaseTouchPoint(1); |
263 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 448 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
264 EXPECT_FALSE(GesturesSent()); | 449 EXPECT_FALSE(GesturesSent()); |
265 | 450 |
266 PushGesture(WebInputEvent::GestureScrollEnd); | 451 PushGesture(WebInputEvent::GestureScrollEnd); |
267 ReleaseTouchPoint(0); | 452 ReleaseTouchPoint(0); |
268 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); | 453 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
269 EXPECT_FALSE(GesturesSent()); | 454 EXPECT_FALSE(GesturesSent()); |
270 } | 455 } |
271 | 456 |
272 TEST_F(GestureEventQueueTest, MultipleTouchSequences) { | 457 TEST_F(GestureEventQueueTest, MultipleTouchSequences) { |
273 // Queue two touch-to-gestures sequences. | 458 // Queue two touch-to-gestures sequences. |
274 PushGesture(WebInputEvent::GestureFlingStart); | 459 PushGesture(WebInputEvent::GestureTapDown); |
275 PressTouchPoint(1, 1); | 460 PressTouchPoint(1, 1); |
276 PushGesture(WebInputEvent::GestureFlingCancel); | 461 PushGesture(WebInputEvent::GestureTap); |
277 ReleaseTouchPoint(0); | 462 ReleaseTouchPoint(0); |
278 PushGesture(WebInputEvent::GestureFlingStart); | 463 PushGesture(WebInputEvent::GestureScrollBegin); |
279 PressTouchPoint(1, 1); | 464 PressTouchPoint(1, 1); |
280 PushGesture(WebInputEvent::GestureFlingCancel); | 465 PushGesture(WebInputEvent::GestureScrollEnd); |
281 ReleaseTouchPoint(0); | 466 ReleaseTouchPoint(0); |
282 | 467 |
283 // The first gesture sequence should not be allowed. | 468 // The first gesture sequence should not be allowed. |
284 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); | 469 SendTouchEventACK(INPUT_EVENT_ACK_STATE_CONSUMED); |
285 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 470 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
286 EXPECT_FALSE(GesturesSent()); | 471 EXPECT_FALSE(GesturesSent()); |
287 | 472 |
288 // The subsequent sequence should "reset" allowance. | 473 // The subsequent sequence should "reset" allowance. |
289 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 474 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
290 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 475 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
291 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureFlingStart, | 476 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollBegin, |
292 WebInputEvent::GestureFlingCancel), | 477 WebInputEvent::GestureScrollEnd), |
293 GetAndResetSentGestures())); | 478 GetAndResetSentGestures())); |
294 } | 479 } |
295 | 480 |
296 TEST_F(GestureEventQueueTest, FlingCancelledOnNewTouchSequence) { | 481 TEST_F(GestureEventQueueTest, FlingCancelledOnNewTouchSequence) { |
297 // Simulate a fling. | 482 // Simulate a fling. |
483 PushGesture(WebInputEvent::GestureScrollBegin); | |
298 PressTouchPoint(1, 1); | 484 PressTouchPoint(1, 1); |
299 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); | 485 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); |
486 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollBegin), | |
487 GetAndResetSentGestures())); | |
300 PushGesture(WebInputEvent::GestureFlingStart); | 488 PushGesture(WebInputEvent::GestureFlingStart); |
301 ReleaseTouchPoint(0); | 489 ReleaseTouchPoint(0); |
302 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 490 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
303 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureFlingStart), | 491 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureFlingStart), |
304 GetAndResetSentGestures())); | 492 GetAndResetSentGestures())); |
305 | 493 |
306 // A new touch seqeuence should cancel the outstanding fling. | 494 // A new touch seqeuence should cancel the outstanding fling. |
307 PressTouchPoint(1, 1); | 495 PressTouchPoint(1, 1); |
308 ReleaseTouchPoint(0); | |
309 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); | 496 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); |
310 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureFlingCancel), | 497 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureFlingCancel), |
311 GetAndResetSentGestures())); | 498 GetAndResetSentGestures())); |
499 ReleaseTouchPoint(0); | |
500 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); | |
501 EXPECT_FALSE(GesturesSent()); | |
312 } | 502 } |
313 | 503 |
314 TEST_F(GestureEventQueueTest, FlingCancelledOnScrollBegin) { | 504 TEST_F(GestureEventQueueTest, FlingCancelledOnScrollBegin) { |
315 // Simulate a fling sequence. | 505 // Simulate a fling sequence. |
316 PushGesture(WebInputEvent::GestureScrollBegin); | 506 PushGesture(WebInputEvent::GestureScrollBegin); |
317 PushGesture(WebInputEvent::GestureFlingStart); | 507 PushGesture(WebInputEvent::GestureFlingStart); |
318 PressTouchPoint(1, 1); | 508 PressTouchPoint(1, 1); |
319 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 509 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
320 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollBegin, | 510 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollBegin, |
321 WebInputEvent::GestureFlingStart), | 511 WebInputEvent::GestureFlingStart), |
322 GetAndResetSentGestures())); | 512 GetAndResetSentGestures())); |
323 | 513 |
324 // The new fling should cancel the preceding one. | 514 // The new fling should cancel the preceding one. |
325 PushGesture(WebInputEvent::GestureScrollBegin); | 515 PushGesture(WebInputEvent::GestureScrollBegin); |
326 PushGesture(WebInputEvent::GestureFlingStart); | 516 PushGesture(WebInputEvent::GestureFlingStart); |
327 ReleaseTouchPoint(0); | 517 ReleaseTouchPoint(0); |
328 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 518 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
329 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureFlingCancel, | 519 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureFlingCancel, |
330 WebInputEvent::GestureScrollBegin, | 520 WebInputEvent::GestureScrollBegin, |
331 WebInputEvent::GestureFlingStart), | 521 WebInputEvent::GestureFlingStart), |
332 GetAndResetSentGestures())); | 522 GetAndResetSentGestures())); |
333 } | 523 } |
334 | 524 |
335 TEST_F(GestureEventQueueTest, FlingNotCancelledIfGFCEventReceived) { | 525 TEST_F(GestureEventQueueTest, FlingNotCancelledIfGFCEventReceived) { |
336 // Simulate a fling that is started then cancelled. | 526 // Simulate a fling that is started then cancelled. |
527 PushGesture(WebInputEvent::GestureScrollBegin); | |
528 PressTouchPoint(1, 1); | |
529 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); | |
337 PushGesture(WebInputEvent::GestureFlingStart); | 530 PushGesture(WebInputEvent::GestureFlingStart); |
338 PressTouchPoint(1, 1); | 531 MoveTouchPoint(0, 1, 1); |
339 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); | 532 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); |
340 PushGesture(WebInputEvent::GestureFlingCancel); | 533 PushGesture(WebInputEvent::GestureFlingCancel); |
341 ReleaseTouchPoint(0); | 534 ReleaseTouchPoint(0); |
342 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 535 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
343 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureFlingStart, | 536 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureScrollBegin, |
537 WebInputEvent::GestureFlingStart, | |
344 WebInputEvent::GestureFlingCancel), | 538 WebInputEvent::GestureFlingCancel), |
345 GetAndResetSentGestures())); | 539 GetAndResetSentGestures())); |
346 | 540 |
347 // A new touch sequence will not inject a GestureFlingCancel, as the fling | 541 // A new touch sequence will not inject a GestureFlingCancel, as the fling |
348 // has already been cancelled. | 542 // has already been cancelled. |
349 PressTouchPoint(1, 1); | 543 PressTouchPoint(1, 1); |
544 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); | |
350 ReleaseTouchPoint(0); | 545 ReleaseTouchPoint(0); |
351 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); | 546 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); |
352 EXPECT_FALSE(GesturesSent()); | 547 EXPECT_FALSE(GesturesSent()); |
353 } | 548 } |
354 | 549 |
355 TEST_F(GestureEventQueueTest, TapCancelledWhenScrollBegins) { | 550 TEST_F(GestureEventQueueTest, TapCancelledWhenScrollBegins) { |
356 PushGesture(WebInputEvent::GestureTapDown); | 551 PushGesture(WebInputEvent::GestureTapDown); |
357 PressTouchPoint(1, 1); | 552 PressTouchPoint(1, 1); |
358 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 553 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
359 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureTapDown), | 554 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureTapDown), |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
440 | 635 |
441 SendTimeoutGesture(WebInputEvent::GestureLongPress); | 636 SendTimeoutGesture(WebInputEvent::GestureLongPress); |
442 EXPECT_FALSE(GesturesSent()); | 637 EXPECT_FALSE(GesturesSent()); |
443 | 638 |
444 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 639 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
445 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureLongPress), | 640 EXPECT_TRUE(GesturesMatch(Gestures(WebInputEvent::GestureLongPress), |
446 GetAndResetSentGestures())); | 641 GetAndResetSentGestures())); |
447 } | 642 } |
448 | 643 |
449 } // namespace content | 644 } // namespace content |
OLD | NEW |