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

Side by Side Diff: ui/events/gesture_detection/gesture_provider_unittest.cc

Issue 407313002: Add a MotionEventGeneric implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review Created 6 years, 5 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 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/logging.h" 6 #include "base/logging.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 protected: 269 protected:
270 void CheckScrollEventSequenceForEndActionType( 270 void CheckScrollEventSequenceForEndActionType(
271 MotionEvent::Action end_action_type) { 271 MotionEvent::Action end_action_type) {
272 base::TimeTicks event_time = base::TimeTicks::Now(); 272 base::TimeTicks event_time = base::TimeTicks::Now();
273 const float scroll_to_x = kFakeCoordX + 100; 273 const float scroll_to_x = kFakeCoordX + 100;
274 const float scroll_to_y = kFakeCoordY + 100; 274 const float scroll_to_y = kFakeCoordY + 100;
275 int motion_event_id = 0; 275 int motion_event_id = 0;
276 276
277 MockMotionEvent event = 277 MockMotionEvent event =
278 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); 278 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
279 event.SetId(++motion_event_id); 279 event.set_id(++motion_event_id);
280 280
281 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 281 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
282 282
283 event = ObtainMotionEvent(event_time + kOneSecond, 283 event = ObtainMotionEvent(event_time + kOneSecond,
284 MotionEvent::ACTION_MOVE, 284 MotionEvent::ACTION_MOVE,
285 scroll_to_x, 285 scroll_to_x,
286 scroll_to_y); 286 scroll_to_y);
287 event.SetId(++motion_event_id); 287 event.set_id(++motion_event_id);
288 288
289 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 289 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
290 EXPECT_TRUE(gesture_provider_->IsScrollInProgress()); 290 EXPECT_TRUE(gesture_provider_->IsScrollInProgress());
291 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN)); 291 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN));
292 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 292 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
293 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetMostRecentGestureEventType()); 293 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetMostRecentGestureEventType());
294 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(scroll_to_x, scroll_to_y), 294 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(scroll_to_x, scroll_to_y),
295 GetMostRecentGestureEvent().details.bounding_box()); 295 GetMostRecentGestureEvent().details.bounding_box());
296 ASSERT_EQ(3U, GetReceivedGestureCount()) << "Only TapDown, " 296 ASSERT_EQ(3U, GetReceivedGestureCount()) << "Only TapDown, "
297 "ScrollBegin and ScrollBy " 297 "ScrollBegin and ScrollBy "
298 "should have been sent"; 298 "should have been sent";
299 299
300 EXPECT_EQ(ET_GESTURE_SCROLL_BEGIN, GetReceivedGesture(1).type()); 300 EXPECT_EQ(ET_GESTURE_SCROLL_BEGIN, GetReceivedGesture(1).type());
301 EXPECT_EQ(motion_event_id, GetReceivedGesture(1).motion_event_id); 301 EXPECT_EQ(motion_event_id, GetReceivedGesture(1).motion_event_id);
302 EXPECT_EQ(event_time + kOneSecond, GetReceivedGesture(1).time) 302 EXPECT_EQ(event_time + kOneSecond, GetReceivedGesture(1).time)
303 << "ScrollBegin should have the time of the ACTION_MOVE"; 303 << "ScrollBegin should have the time of the ACTION_MOVE";
304 304
305 event = ObtainMotionEvent( 305 event = ObtainMotionEvent(
306 event_time + kOneSecond, end_action_type, scroll_to_x, scroll_to_y); 306 event_time + kOneSecond, end_action_type, scroll_to_x, scroll_to_y);
307 event.SetId(++motion_event_id); 307 event.set_id(++motion_event_id);
308 308
309 gesture_provider_->OnTouchEvent(event); 309 gesture_provider_->OnTouchEvent(event);
310 EXPECT_FALSE(gesture_provider_->IsScrollInProgress()); 310 EXPECT_FALSE(gesture_provider_->IsScrollInProgress());
311 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_END)); 311 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_END));
312 EXPECT_EQ(ET_GESTURE_SCROLL_END, GetMostRecentGestureEventType()); 312 EXPECT_EQ(ET_GESTURE_SCROLL_END, GetMostRecentGestureEventType());
313 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 313 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
314 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 314 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
315 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(scroll_to_x, scroll_to_y), 315 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(scroll_to_x, scroll_to_y),
316 GetMostRecentGestureEvent().details.bounding_box()); 316 GetMostRecentGestureEvent().details.bounding_box());
317 } 317 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 402
403 // Verify that a DOWN followed shortly by an UP will trigger a single tap. 403 // Verify that a DOWN followed shortly by an UP will trigger a single tap.
404 TEST_F(GestureProviderTest, GestureTap) { 404 TEST_F(GestureProviderTest, GestureTap) {
405 base::TimeTicks event_time = base::TimeTicks::Now(); 405 base::TimeTicks event_time = base::TimeTicks::Now();
406 int motion_event_id = 0; 406 int motion_event_id = 0;
407 407
408 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(false); 408 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(false);
409 409
410 MockMotionEvent event = 410 MockMotionEvent event =
411 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); 411 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
412 event.SetId(++motion_event_id); 412 event.set_id(++motion_event_id);
413 413
414 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 414 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
415 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); 415 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
416 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 416 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
417 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY), 417 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY),
418 GetMostRecentGestureEvent().details.bounding_box()); 418 GetMostRecentGestureEvent().details.bounding_box());
419 419
420 event = ObtainMotionEvent(event_time + kOneMicrosecond, 420 event = ObtainMotionEvent(event_time + kOneMicrosecond,
421 MotionEvent::ACTION_UP); 421 MotionEvent::ACTION_UP);
422 event.SetId(++motion_event_id); 422 event.set_id(++motion_event_id);
423 423
424 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 424 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
425 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType()); 425 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType());
426 // Ensure tap details have been set. 426 // Ensure tap details have been set.
427 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count()); 427 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count());
428 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 428 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
429 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 429 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
430 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY), 430 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY),
431 GetMostRecentGestureEvent().details.bounding_box()); 431 GetMostRecentGestureEvent().details.bounding_box());
432 } 432 }
433 433
434 // Verify that a DOWN followed shortly by an UP will trigger 434 // Verify that a DOWN followed shortly by an UP will trigger
435 // a ET_GESTURE_TAP_UNCONFIRMED event if double-tap is enabled. 435 // a ET_GESTURE_TAP_UNCONFIRMED event if double-tap is enabled.
436 TEST_F(GestureProviderTest, GestureTapWithDelay) { 436 TEST_F(GestureProviderTest, GestureTapWithDelay) {
437 base::TimeTicks event_time = base::TimeTicks::Now(); 437 base::TimeTicks event_time = base::TimeTicks::Now();
438 int motion_event_id = 0; 438 int motion_event_id = 0;
439 439
440 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(true); 440 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(true);
441 441
442 MockMotionEvent event = 442 MockMotionEvent event =
443 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); 443 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
444 event.SetId(++motion_event_id); 444 event.set_id(++motion_event_id);
445 445
446 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 446 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
447 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); 447 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
448 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 448 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
449 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 449 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
450 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY), 450 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY),
451 GetMostRecentGestureEvent().details.bounding_box()); 451 GetMostRecentGestureEvent().details.bounding_box());
452 452
453 event = ObtainMotionEvent(event_time + kOneMicrosecond, 453 event = ObtainMotionEvent(event_time + kOneMicrosecond,
454 MotionEvent::ACTION_UP); 454 MotionEvent::ACTION_UP);
455 event.SetId(++motion_event_id); 455 event.set_id(++motion_event_id);
456 456
457 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 457 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
458 EXPECT_EQ(ET_GESTURE_TAP_UNCONFIRMED, GetMostRecentGestureEventType()); 458 EXPECT_EQ(ET_GESTURE_TAP_UNCONFIRMED, GetMostRecentGestureEventType());
459 // Ensure tap details have been set. 459 // Ensure tap details have been set.
460 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count()); 460 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count());
461 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 461 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
462 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 462 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
463 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY), 463 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY),
464 GetMostRecentGestureEvent().details.bounding_box()); 464 GetMostRecentGestureEvent().details.bounding_box());
465 465
466 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_TAP)); 466 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_TAP));
467 RunTasksAndWait(GetDoubleTapTimeout()); 467 RunTasksAndWait(GetDoubleTapTimeout());
468 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_TAP)); 468 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_TAP));
469 } 469 }
470 470
471 // Verify that a DOWN followed by a MOVE will trigger fling (but not LONG). 471 // Verify that a DOWN followed by a MOVE will trigger fling (but not LONG).
472 TEST_F(GestureProviderTest, GestureFlingAndCancelLongPress) { 472 TEST_F(GestureProviderTest, GestureFlingAndCancelLongPress) {
473 base::TimeTicks event_time = TimeTicks::Now(); 473 base::TimeTicks event_time = TimeTicks::Now();
474 base::TimeDelta delta_time = kDeltaTimeForFlingSequences; 474 base::TimeDelta delta_time = kDeltaTimeForFlingSequences;
475 int motion_event_id = 0; 475 int motion_event_id = 0;
476 476
477 MockMotionEvent event = 477 MockMotionEvent event =
478 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); 478 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
479 event.SetId(++motion_event_id); 479 event.set_id(++motion_event_id);
480 480
481 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 481 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
482 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); 482 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
483 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 483 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
484 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 484 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
485 485
486 event = ObtainMotionEvent(event_time + delta_time, 486 event = ObtainMotionEvent(event_time + delta_time,
487 MotionEvent::ACTION_MOVE, 487 MotionEvent::ACTION_MOVE,
488 kFakeCoordX * 10, 488 kFakeCoordX * 10,
489 kFakeCoordY * 10); 489 kFakeCoordY * 10);
490 event.SetId(++motion_event_id); 490 event.set_id(++motion_event_id);
491 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 491 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
492 492
493 event = ObtainMotionEvent(event_time + delta_time * 2, 493 event = ObtainMotionEvent(event_time + delta_time * 2,
494 MotionEvent::ACTION_UP, 494 MotionEvent::ACTION_UP,
495 kFakeCoordX * 10, 495 kFakeCoordX * 10,
496 kFakeCoordY * 10); 496 kFakeCoordY * 10);
497 event.SetId(++motion_event_id); 497 event.set_id(++motion_event_id);
498 498
499 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 499 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
500 EXPECT_EQ(ET_SCROLL_FLING_START, GetMostRecentGestureEventType()); 500 EXPECT_EQ(ET_SCROLL_FLING_START, GetMostRecentGestureEventType());
501 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 501 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
502 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 502 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
503 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_LONG_PRESS)); 503 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_LONG_PRESS));
504 EXPECT_EQ( 504 EXPECT_EQ(
505 BoundsForSingleMockTouchAtLocation(kFakeCoordX * 10, kFakeCoordY * 10), 505 BoundsForSingleMockTouchAtLocation(kFakeCoordX * 10, kFakeCoordY * 10),
506 GetMostRecentGestureEvent().details.bounding_box()); 506 GetMostRecentGestureEvent().details.bounding_box());
507 } 507 }
(...skipping 18 matching lines...) Expand all
526 // sent: 526 // sent:
527 // - ET_GESTURE_SCROLL_BEGIN 527 // - ET_GESTURE_SCROLL_BEGIN
528 // - ET_SCROLL_FLING_START 528 // - ET_SCROLL_FLING_START
529 TEST_F(GestureProviderTest, FlingEventSequence) { 529 TEST_F(GestureProviderTest, FlingEventSequence) {
530 base::TimeTicks event_time = base::TimeTicks::Now(); 530 base::TimeTicks event_time = base::TimeTicks::Now();
531 base::TimeDelta delta_time = kDeltaTimeForFlingSequences; 531 base::TimeDelta delta_time = kDeltaTimeForFlingSequences;
532 int motion_event_id = 0; 532 int motion_event_id = 0;
533 533
534 MockMotionEvent event = 534 MockMotionEvent event =
535 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); 535 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
536 event.SetId(++motion_event_id); 536 event.set_id(++motion_event_id);
537 537
538 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 538 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
539 539
540 event = ObtainMotionEvent(event_time + delta_time, 540 event = ObtainMotionEvent(event_time + delta_time,
541 MotionEvent::ACTION_MOVE, 541 MotionEvent::ACTION_MOVE,
542 kFakeCoordX * 5, 542 kFakeCoordX * 5,
543 kFakeCoordY * 5); 543 kFakeCoordY * 5);
544 event.SetId(++motion_event_id); 544 event.set_id(++motion_event_id);
545 545
546 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 546 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
547 EXPECT_TRUE(gesture_provider_->IsScrollInProgress()); 547 EXPECT_TRUE(gesture_provider_->IsScrollInProgress());
548 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN)); 548 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN));
549 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetMostRecentGestureEventType()); 549 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetMostRecentGestureEventType());
550 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 550 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
551 ASSERT_EQ(3U, GetReceivedGestureCount()); 551 ASSERT_EQ(3U, GetReceivedGestureCount());
552 ASSERT_EQ(ET_GESTURE_SCROLL_BEGIN, GetReceivedGesture(1).type()); 552 ASSERT_EQ(ET_GESTURE_SCROLL_BEGIN, GetReceivedGesture(1).type());
553 EXPECT_EQ(motion_event_id, GetReceivedGesture(1).motion_event_id); 553 EXPECT_EQ(motion_event_id, GetReceivedGesture(1).motion_event_id);
554 554
555 // We don't want to take a dependency here on exactly how hints are calculated 555 // We don't want to take a dependency here on exactly how hints are calculated
556 // for a fling (eg. may depend on velocity), so just validate the direction. 556 // for a fling (eg. may depend on velocity), so just validate the direction.
557 int hint_x = GetReceivedGesture(1).details.scroll_x_hint(); 557 int hint_x = GetReceivedGesture(1).details.scroll_x_hint();
558 int hint_y = GetReceivedGesture(1).details.scroll_y_hint(); 558 int hint_y = GetReceivedGesture(1).details.scroll_y_hint();
559 EXPECT_TRUE(hint_x > 0 && hint_y > 0 && hint_x > hint_y) 559 EXPECT_TRUE(hint_x > 0 && hint_y > 0 && hint_x > hint_y)
560 << "ScrollBegin hint should be in positive X axis"; 560 << "ScrollBegin hint should be in positive X axis";
561 561
562 event = ObtainMotionEvent(event_time + delta_time * 2, 562 event = ObtainMotionEvent(event_time + delta_time * 2,
563 MotionEvent::ACTION_UP, 563 MotionEvent::ACTION_UP,
564 kFakeCoordX * 10, 564 kFakeCoordX * 10,
565 kFakeCoordY * 10); 565 kFakeCoordY * 10);
566 event.SetId(++motion_event_id); 566 event.set_id(++motion_event_id);
567 567
568 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 568 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
569 EXPECT_FALSE(gesture_provider_->IsScrollInProgress()); 569 EXPECT_FALSE(gesture_provider_->IsScrollInProgress());
570 EXPECT_EQ(ET_SCROLL_FLING_START, GetMostRecentGestureEventType()); 570 EXPECT_EQ(ET_SCROLL_FLING_START, GetMostRecentGestureEventType());
571 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 571 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
572 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 572 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
573 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_SCROLL_END)); 573 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_SCROLL_END));
574 EXPECT_EQ(event_time + delta_time * 2, GetMostRecentGestureEvent().time) 574 EXPECT_EQ(event_time + delta_time * 2, GetMostRecentGestureEvent().time)
575 << "FlingStart should have the time of the ACTION_UP"; 575 << "FlingStart should have the time of the ACTION_UP";
576 } 576 }
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 977
978 const base::TimeDelta long_press_timeout = 978 const base::TimeDelta long_press_timeout =
979 GetLongPressTimeout() + GetShowPressTimeout() + kOneMicrosecond; 979 GetLongPressTimeout() + GetShowPressTimeout() + kOneMicrosecond;
980 RunTasksAndWait(long_press_timeout); 980 RunTasksAndWait(long_press_timeout);
981 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_LONG_PRESS)); 981 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_LONG_PRESS));
982 982
983 event = ObtainMotionEvent(event_time + long_press_timeout, 983 event = ObtainMotionEvent(event_time + long_press_timeout,
984 MotionEvent::ACTION_MOVE, 984 MotionEvent::ACTION_MOVE,
985 kFakeCoordX + 20, 985 kFakeCoordX + 20,
986 kFakeCoordY + 20); 986 kFakeCoordY + 20);
987 event.SetId(++motion_event_id); 987 event.set_id(++motion_event_id);
988 988
989 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 989 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
990 EXPECT_EQ(ET_GESTURE_PINCH_BEGIN, GetMostRecentGestureEventType()); 990 EXPECT_EQ(ET_GESTURE_PINCH_BEGIN, GetMostRecentGestureEventType());
991 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 991 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
992 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 992 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
993 EXPECT_TRUE(gesture_provider_->IsDoubleTapInProgress()); 993 EXPECT_TRUE(gesture_provider_->IsDoubleTapInProgress());
994 994
995 event = ObtainMotionEvent(event_time + long_press_timeout + kOneMicrosecond, 995 event = ObtainMotionEvent(event_time + long_press_timeout + kOneMicrosecond,
996 MotionEvent::ACTION_UP, 996 MotionEvent::ACTION_UP,
997 kFakeCoordX, 997 kFakeCoordX,
998 kFakeCoordY + 1); 998 kFakeCoordY + 1);
999 event.SetId(++motion_event_id); 999 event.set_id(++motion_event_id);
1000 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1000 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1001 EXPECT_EQ(ET_GESTURE_SCROLL_END, GetMostRecentGestureEventType()); 1001 EXPECT_EQ(ET_GESTURE_SCROLL_END, GetMostRecentGestureEventType());
1002 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 1002 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
1003 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 1003 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
1004 EXPECT_FALSE(gesture_provider_->IsDoubleTapInProgress()); 1004 EXPECT_FALSE(gesture_provider_->IsDoubleTapInProgress());
1005 } 1005 }
1006 1006
1007 // Verify that the touch slop region is removed from the first scroll delta to 1007 // Verify that the touch slop region is removed from the first scroll delta to
1008 // avoid a jump when starting to scroll. 1008 // avoid a jump when starting to scroll.
1009 TEST_F(GestureProviderTest, TouchSlopRemovedFromScroll) { 1009 TEST_F(GestureProviderTest, TouchSlopRemovedFromScroll) {
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
1434 1434
1435 gesture_provider_->SetDoubleTapSupportForPageEnabled(false); 1435 gesture_provider_->SetDoubleTapSupportForPageEnabled(false);
1436 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(true); 1436 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(true);
1437 gesture_provider_->SetMultiTouchZoomSupportEnabled(true); 1437 gesture_provider_->SetMultiTouchZoomSupportEnabled(true);
1438 1438
1439 int secondary_coord_x = kFakeCoordX + 20 * touch_slop; 1439 int secondary_coord_x = kFakeCoordX + 20 * touch_slop;
1440 int secondary_coord_y = kFakeCoordY + 20 * touch_slop; 1440 int secondary_coord_y = kFakeCoordY + 20 * touch_slop;
1441 1441
1442 MockMotionEvent event = 1442 MockMotionEvent event =
1443 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); 1443 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
1444 event.SetId(++motion_event_id); 1444 event.set_id(++motion_event_id);
1445 event.SetRawOffset(raw_offset_x, raw_offset_y); 1445 event.SetRawOffset(raw_offset_x, raw_offset_y);
1446 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1446 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1447 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); 1447 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
1448 EXPECT_EQ(kFakeCoordX, GetMostRecentGestureEvent().x); 1448 EXPECT_EQ(kFakeCoordX, GetMostRecentGestureEvent().x);
1449 EXPECT_EQ(kFakeCoordY, GetMostRecentGestureEvent().y); 1449 EXPECT_EQ(kFakeCoordY, GetMostRecentGestureEvent().y);
1450 EXPECT_EQ(kFakeCoordX + raw_offset_x, GetMostRecentGestureEvent().raw_x); 1450 EXPECT_EQ(kFakeCoordX + raw_offset_x, GetMostRecentGestureEvent().raw_x);
1451 EXPECT_EQ(kFakeCoordY + raw_offset_y, GetMostRecentGestureEvent().raw_y); 1451 EXPECT_EQ(kFakeCoordY + raw_offset_y, GetMostRecentGestureEvent().raw_y);
1452 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 1452 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
1453 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY), 1453 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY),
1454 GetMostRecentGestureEvent().details.bounding_box()); 1454 GetMostRecentGestureEvent().details.bounding_box());
1455 1455
1456 // Toggling double-tap support should not take effect until the next sequence. 1456 // Toggling double-tap support should not take effect until the next sequence.
1457 gesture_provider_->SetDoubleTapSupportForPageEnabled(true); 1457 gesture_provider_->SetDoubleTapSupportForPageEnabled(true);
1458 1458
1459 event = ObtainMotionEvent(event_time, 1459 event = ObtainMotionEvent(event_time,
1460 MotionEvent::ACTION_POINTER_DOWN, 1460 MotionEvent::ACTION_POINTER_DOWN,
1461 kFakeCoordX, 1461 kFakeCoordX,
1462 kFakeCoordY, 1462 kFakeCoordY,
1463 secondary_coord_x, 1463 secondary_coord_x,
1464 secondary_coord_y); 1464 secondary_coord_y);
1465 event.SetId(++motion_event_id); 1465 event.set_id(++motion_event_id);
1466 event.SetRawOffset(raw_offset_x, raw_offset_y); 1466 event.SetRawOffset(raw_offset_x, raw_offset_y);
1467 1467
1468 gesture_provider_->OnTouchEvent(event); 1468 gesture_provider_->OnTouchEvent(event);
1469 EXPECT_EQ(1U, GetReceivedGestureCount()); 1469 EXPECT_EQ(1U, GetReceivedGestureCount());
1470 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 1470 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
1471 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY), 1471 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY),
1472 GetMostRecentGestureEvent().details.bounding_box()); 1472 GetMostRecentGestureEvent().details.bounding_box());
1473 1473
1474 secondary_coord_x += 5 * touch_slop; 1474 secondary_coord_x += 5 * touch_slop;
1475 secondary_coord_y += 5 * touch_slop; 1475 secondary_coord_y += 5 * touch_slop;
1476 event = ObtainMotionEvent(event_time, 1476 event = ObtainMotionEvent(event_time,
1477 MotionEvent::ACTION_MOVE, 1477 MotionEvent::ACTION_MOVE,
1478 kFakeCoordX, 1478 kFakeCoordX,
1479 kFakeCoordY, 1479 kFakeCoordY,
1480 secondary_coord_x, 1480 secondary_coord_x,
1481 secondary_coord_y); 1481 secondary_coord_y);
1482 event.SetId(++motion_event_id); 1482 event.set_id(++motion_event_id);
1483 event.SetRawOffset(raw_offset_x, raw_offset_y); 1483 event.SetRawOffset(raw_offset_x, raw_offset_y);
1484 1484
1485 // Toggling double-tap support should not take effect until the next sequence. 1485 // Toggling double-tap support should not take effect until the next sequence.
1486 gesture_provider_->SetDoubleTapSupportForPageEnabled(false); 1486 gesture_provider_->SetDoubleTapSupportForPageEnabled(false);
1487 1487
1488 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1488 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1489 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 1489 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
1490 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); 1490 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points());
1491 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_PINCH_BEGIN)); 1491 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_PINCH_BEGIN));
1492 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN)); 1492 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN));
(...skipping 14 matching lines...) Expand all
1507 GetMostRecentGestureEvent().details.bounding_box()); 1507 GetMostRecentGestureEvent().details.bounding_box());
1508 1508
1509 secondary_coord_x += 2 * touch_slop; 1509 secondary_coord_x += 2 * touch_slop;
1510 secondary_coord_y += 2 * touch_slop; 1510 secondary_coord_y += 2 * touch_slop;
1511 event = ObtainMotionEvent(event_time, 1511 event = ObtainMotionEvent(event_time,
1512 MotionEvent::ACTION_MOVE, 1512 MotionEvent::ACTION_MOVE,
1513 kFakeCoordX, 1513 kFakeCoordX,
1514 kFakeCoordY, 1514 kFakeCoordY,
1515 secondary_coord_x, 1515 secondary_coord_x,
1516 secondary_coord_y); 1516 secondary_coord_y);
1517 event.SetId(++motion_event_id); 1517 event.set_id(++motion_event_id);
1518 1518
1519 // Toggling double-tap support should not take effect until the next sequence. 1519 // Toggling double-tap support should not take effect until the next sequence.
1520 gesture_provider_->SetDoubleTapSupportForPageEnabled(true); 1520 gesture_provider_->SetDoubleTapSupportForPageEnabled(true);
1521 1521
1522 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1522 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1523 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 1523 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
1524 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_UPDATE)); 1524 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_UPDATE));
1525 EXPECT_EQ(ET_GESTURE_PINCH_UPDATE, GetMostRecentGestureEventType()); 1525 EXPECT_EQ(ET_GESTURE_PINCH_UPDATE, GetMostRecentGestureEventType());
1526 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); 1526 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points());
1527 EXPECT_LT(1.f, GetMostRecentGestureEvent().details.scale()); 1527 EXPECT_LT(1.f, GetMostRecentGestureEvent().details.scale());
1528 EXPECT_EQ( 1528 EXPECT_EQ(
1529 gfx::RectF(kFakeCoordX - kMockTouchRadius, 1529 gfx::RectF(kFakeCoordX - kMockTouchRadius,
1530 kFakeCoordY - kMockTouchRadius, 1530 kFakeCoordY - kMockTouchRadius,
1531 secondary_coord_x - kFakeCoordX + kMockTouchRadius * 2, 1531 secondary_coord_x - kFakeCoordX + kMockTouchRadius * 2,
1532 secondary_coord_y - kFakeCoordY + kMockTouchRadius * 2), 1532 secondary_coord_y - kFakeCoordY + kMockTouchRadius * 2),
1533 GetMostRecentGestureEvent().details.bounding_box()); 1533 GetMostRecentGestureEvent().details.bounding_box());
1534 1534
1535 event = ObtainMotionEvent(event_time, 1535 event = ObtainMotionEvent(event_time,
1536 MotionEvent::ACTION_POINTER_UP, 1536 MotionEvent::ACTION_POINTER_UP,
1537 kFakeCoordX, 1537 kFakeCoordX,
1538 kFakeCoordY, 1538 kFakeCoordY,
1539 secondary_coord_x, 1539 secondary_coord_x,
1540 secondary_coord_y); 1540 secondary_coord_y);
1541 event.SetId(++motion_event_id); 1541 event.set_id(++motion_event_id);
1542 1542
1543 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1543 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1544 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 1544 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
1545 EXPECT_EQ(ET_GESTURE_PINCH_END, GetMostRecentGestureEventType()); 1545 EXPECT_EQ(ET_GESTURE_PINCH_END, GetMostRecentGestureEventType());
1546 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); 1546 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points());
1547 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_SCROLL_END)); 1547 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_SCROLL_END));
1548 EXPECT_EQ( 1548 EXPECT_EQ(
1549 gfx::RectF(kFakeCoordX - kMockTouchRadius, 1549 gfx::RectF(kFakeCoordX - kMockTouchRadius,
1550 kFakeCoordY - kMockTouchRadius, 1550 kFakeCoordY - kMockTouchRadius,
1551 secondary_coord_x - kFakeCoordX + kMockTouchRadius * 2, 1551 secondary_coord_x - kFakeCoordX + kMockTouchRadius * 2,
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 // gesture sequence cancellation. 1777 // gesture sequence cancellation.
1778 TEST_F(GestureProviderTest, CancelActiveTouchSequence) { 1778 TEST_F(GestureProviderTest, CancelActiveTouchSequence) {
1779 base::TimeTicks event_time = base::TimeTicks::Now(); 1779 base::TimeTicks event_time = base::TimeTicks::Now();
1780 int motion_event_id = 0; 1780 int motion_event_id = 0;
1781 1781
1782 EXPECT_FALSE(CancelActiveTouchSequence()); 1782 EXPECT_FALSE(CancelActiveTouchSequence());
1783 EXPECT_EQ(0U, GetReceivedGestureCount()); 1783 EXPECT_EQ(0U, GetReceivedGestureCount());
1784 1784
1785 MockMotionEvent event = 1785 MockMotionEvent event =
1786 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); 1786 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
1787 event.SetId(++motion_event_id); 1787 event.set_id(++motion_event_id);
1788 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1788 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1789 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); 1789 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
1790 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 1790 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
1791 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 1791 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
1792 1792
1793 ASSERT_TRUE(CancelActiveTouchSequence()); 1793 ASSERT_TRUE(CancelActiveTouchSequence());
1794 EXPECT_FALSE(HasDownEvent()); 1794 EXPECT_FALSE(HasDownEvent());
1795 1795
1796 // Subsequent MotionEvent's are dropped until ACTION_DOWN. 1796 // Subsequent MotionEvent's are dropped until ACTION_DOWN.
1797 event = ObtainMotionEvent(event_time + kOneMicrosecond, 1797 event = ObtainMotionEvent(event_time + kOneMicrosecond,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1872 // Verify that gesture begin and gesture end events are dispatched correctly. 1872 // Verify that gesture begin and gesture end events are dispatched correctly.
1873 TEST_F(GestureProviderTest, GestureBeginAndEnd) { 1873 TEST_F(GestureProviderTest, GestureBeginAndEnd) {
1874 EnableBeginEndTypes(); 1874 EnableBeginEndTypes();
1875 base::TimeTicks event_time = base::TimeTicks::Now(); 1875 base::TimeTicks event_time = base::TimeTicks::Now();
1876 const float raw_offset_x = 7.5f; 1876 const float raw_offset_x = 7.5f;
1877 const float raw_offset_y = 5.7f; 1877 const float raw_offset_y = 5.7f;
1878 1878
1879 EXPECT_EQ(0U, GetReceivedGestureCount()); 1879 EXPECT_EQ(0U, GetReceivedGestureCount());
1880 MockMotionEvent event = 1880 MockMotionEvent event =
1881 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN, 1, 1); 1881 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN, 1, 1);
1882 event.pointer_count = 1;
1883 event.SetRawOffset(raw_offset_x, raw_offset_y); 1882 event.SetRawOffset(raw_offset_x, raw_offset_y);
1884 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1883 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1885 EXPECT_EQ(ET_GESTURE_BEGIN, GetReceivedGesture(0).type()); 1884 EXPECT_EQ(ET_GESTURE_BEGIN, GetReceivedGesture(0).type());
1886 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); 1885 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
1887 EXPECT_EQ(2U, GetReceivedGestureCount()); 1886 EXPECT_EQ(2U, GetReceivedGestureCount());
1888 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 1887 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
1889 EXPECT_EQ(1, GetMostRecentGestureEvent().x); 1888 EXPECT_EQ(1, GetMostRecentGestureEvent().x);
1890 EXPECT_EQ(1, GetMostRecentGestureEvent().y); 1889 EXPECT_EQ(1, GetMostRecentGestureEvent().y);
1891 EXPECT_EQ(1 + raw_offset_x, GetMostRecentGestureEvent().raw_x); 1890 EXPECT_EQ(1 + raw_offset_x, GetMostRecentGestureEvent().raw_x);
1892 EXPECT_EQ(1 + raw_offset_y, GetMostRecentGestureEvent().raw_y); 1891 EXPECT_EQ(1 + raw_offset_y, GetMostRecentGestureEvent().raw_y);
1893 EXPECT_EQ(gfx::RectF(1 - kMockTouchRadius, 1892 EXPECT_EQ(gfx::RectF(1 - kMockTouchRadius,
1894 1 - kMockTouchRadius, 1893 1 - kMockTouchRadius,
1895 kMockTouchRadius * 2, 1894 kMockTouchRadius * 2,
1896 kMockTouchRadius * 2), 1895 kMockTouchRadius * 2),
1897 GetMostRecentGestureEvent().details.bounding_box()); 1896 GetMostRecentGestureEvent().details.bounding_box());
1898 1897
1899 event = ObtainMotionEvent( 1898 event = ObtainMotionEvent(
1900 event_time, MotionEvent::ACTION_POINTER_DOWN, 1, 1, 2, 2); 1899 event_time, MotionEvent::ACTION_POINTER_DOWN, 1, 1, 2, 2);
1901 event.pointer_count = 2;
1902 event.SetRawOffset(raw_offset_x, raw_offset_y); 1900 event.SetRawOffset(raw_offset_x, raw_offset_y);
1903 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1901 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1904 EXPECT_EQ(ET_GESTURE_BEGIN, GetMostRecentGestureEventType()); 1902 EXPECT_EQ(ET_GESTURE_BEGIN, GetMostRecentGestureEventType());
1905 EXPECT_EQ(3U, GetReceivedGestureCount()); 1903 EXPECT_EQ(3U, GetReceivedGestureCount());
1906 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); 1904 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points());
1907 EXPECT_EQ(2, GetMostRecentGestureEvent().x); 1905 EXPECT_EQ(2, GetMostRecentGestureEvent().x);
1908 EXPECT_EQ(2, GetMostRecentGestureEvent().y); 1906 EXPECT_EQ(2, GetMostRecentGestureEvent().y);
1909 EXPECT_EQ(2 + raw_offset_x, GetMostRecentGestureEvent().raw_x); 1907 EXPECT_EQ(2 + raw_offset_x, GetMostRecentGestureEvent().raw_x);
1910 EXPECT_EQ(2 + raw_offset_y, GetMostRecentGestureEvent().raw_y); 1908 EXPECT_EQ(2 + raw_offset_y, GetMostRecentGestureEvent().raw_y);
1911 1909
1912 event = ObtainMotionEvent( 1910 event = ObtainMotionEvent(
1913 event_time, MotionEvent::ACTION_POINTER_DOWN, 1, 1, 2, 2, 3, 3); 1911 event_time, MotionEvent::ACTION_POINTER_DOWN, 1, 1, 2, 2, 3, 3);
1914 event.pointer_count = 3;
1915 event.SetRawOffset(raw_offset_x, raw_offset_y); 1912 event.SetRawOffset(raw_offset_x, raw_offset_y);
1916 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1913 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1917 EXPECT_EQ(ET_GESTURE_BEGIN, GetMostRecentGestureEventType()); 1914 EXPECT_EQ(ET_GESTURE_BEGIN, GetMostRecentGestureEventType());
1918 EXPECT_EQ(4U, GetReceivedGestureCount()); 1915 EXPECT_EQ(4U, GetReceivedGestureCount());
1919 EXPECT_EQ(3, GetMostRecentGestureEvent().details.touch_points()); 1916 EXPECT_EQ(3, GetMostRecentGestureEvent().details.touch_points());
1920 EXPECT_EQ(3, GetMostRecentGestureEvent().x); 1917 EXPECT_EQ(3, GetMostRecentGestureEvent().x);
1921 EXPECT_EQ(3, GetMostRecentGestureEvent().y); 1918 EXPECT_EQ(3, GetMostRecentGestureEvent().y);
1922 EXPECT_EQ(3 + raw_offset_x, GetMostRecentGestureEvent().raw_x); 1919 EXPECT_EQ(3 + raw_offset_x, GetMostRecentGestureEvent().raw_x);
1923 EXPECT_EQ(3 + raw_offset_y, GetMostRecentGestureEvent().raw_y); 1920 EXPECT_EQ(3 + raw_offset_y, GetMostRecentGestureEvent().raw_y);
1924 1921
1925 event = ObtainMotionEvent( 1922 event = ObtainMotionEvent(
1926 event_time, MotionEvent::ACTION_POINTER_UP, 1, 1, 2, 2, 3, 3); 1923 event_time, MotionEvent::ACTION_POINTER_UP, 1, 1, 2, 2, 3, 3);
1927 event.pointer_count = 2;
1928 event.SetRawOffset(raw_offset_x, raw_offset_y); 1924 event.SetRawOffset(raw_offset_x, raw_offset_y);
1929 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1925 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1930 EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType()); 1926 EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType());
1931 EXPECT_EQ(5U, GetReceivedGestureCount()); 1927 EXPECT_EQ(5U, GetReceivedGestureCount());
1932 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); 1928 EXPECT_EQ(3, GetMostRecentGestureEvent().details.touch_points());
1933 EXPECT_EQ(1, GetMostRecentGestureEvent().x); 1929 EXPECT_EQ(1, GetMostRecentGestureEvent().x);
1934 EXPECT_EQ(1, GetMostRecentGestureEvent().y); 1930 EXPECT_EQ(1, GetMostRecentGestureEvent().y);
1935 EXPECT_EQ(1 + raw_offset_x, GetMostRecentGestureEvent().raw_x); 1931 EXPECT_EQ(1 + raw_offset_x, GetMostRecentGestureEvent().raw_x);
1936 EXPECT_EQ(1 + raw_offset_y, GetMostRecentGestureEvent().raw_y); 1932 EXPECT_EQ(1 + raw_offset_y, GetMostRecentGestureEvent().raw_y);
1937 1933
1938 event = ObtainMotionEvent( 1934 event = ObtainMotionEvent(
1939 event_time, MotionEvent::ACTION_POINTER_DOWN, 2, 2, 3, 3, 4, 4); 1935 event_time, MotionEvent::ACTION_POINTER_DOWN, 2, 2, 3, 3, 4, 4);
1940 event.SetRawOffset(raw_offset_x, raw_offset_y); 1936 event.SetRawOffset(raw_offset_x, raw_offset_y);
1941 event.pointer_count = 3;
1942 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1937 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1943 EXPECT_EQ(ET_GESTURE_BEGIN, GetMostRecentGestureEventType()); 1938 EXPECT_EQ(ET_GESTURE_BEGIN, GetMostRecentGestureEventType());
1944 EXPECT_EQ(6U, GetReceivedGestureCount()); 1939 EXPECT_EQ(6U, GetReceivedGestureCount());
1945 EXPECT_EQ(3, GetMostRecentGestureEvent().details.touch_points()); 1940 EXPECT_EQ(3, GetMostRecentGestureEvent().details.touch_points());
1946 EXPECT_EQ(4, GetMostRecentGestureEvent().x); 1941 EXPECT_EQ(4, GetMostRecentGestureEvent().x);
1947 EXPECT_EQ(4, GetMostRecentGestureEvent().y); 1942 EXPECT_EQ(4, GetMostRecentGestureEvent().y);
1948 EXPECT_EQ(4 + raw_offset_x, GetMostRecentGestureEvent().raw_x); 1943 EXPECT_EQ(4 + raw_offset_x, GetMostRecentGestureEvent().raw_x);
1949 EXPECT_EQ(4 + raw_offset_y, GetMostRecentGestureEvent().raw_y); 1944 EXPECT_EQ(4 + raw_offset_y, GetMostRecentGestureEvent().raw_y);
1950 1945
1951 event = ObtainMotionEvent( 1946 event = ObtainMotionEvent(
1952 event_time, MotionEvent::ACTION_POINTER_UP, 2, 2, 3, 3, 4, 4); 1947 event_time, MotionEvent::ACTION_POINTER_UP, 2, 2, 3, 3, 4, 4);
1953 event.pointer_count = 2;
1954 event.SetRawOffset(raw_offset_x, raw_offset_y); 1948 event.SetRawOffset(raw_offset_x, raw_offset_y);
1955 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1949 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1956 EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType()); 1950 EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType());
1957 EXPECT_EQ(7U, GetReceivedGestureCount()); 1951 EXPECT_EQ(7U, GetReceivedGestureCount());
1958 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); 1952 EXPECT_EQ(3, GetMostRecentGestureEvent().details.touch_points());
1959 EXPECT_EQ(2, GetMostRecentGestureEvent().x); 1953 EXPECT_EQ(2, GetMostRecentGestureEvent().x);
1960 EXPECT_EQ(2, GetMostRecentGestureEvent().y); 1954 EXPECT_EQ(2, GetMostRecentGestureEvent().y);
1961 EXPECT_EQ(2 + raw_offset_x, GetMostRecentGestureEvent().raw_x); 1955 EXPECT_EQ(2 + raw_offset_x, GetMostRecentGestureEvent().raw_x);
1962 EXPECT_EQ(2 + raw_offset_y, GetMostRecentGestureEvent().raw_y); 1956 EXPECT_EQ(2 + raw_offset_y, GetMostRecentGestureEvent().raw_y);
1963 1957
1964 event = 1958 event =
1965 ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_UP, 3, 3, 4, 4); 1959 ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_UP, 3, 3, 4, 4);
1966 event.pointer_count = 1;
1967 event.SetRawOffset(raw_offset_x, raw_offset_y); 1960 event.SetRawOffset(raw_offset_x, raw_offset_y);
1968 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1961 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1969 EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType()); 1962 EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType());
1970 EXPECT_EQ(8U, GetReceivedGestureCount()); 1963 EXPECT_EQ(8U, GetReceivedGestureCount());
1971 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 1964 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points());
1972 EXPECT_EQ(3, GetMostRecentGestureEvent().x); 1965 EXPECT_EQ(3, GetMostRecentGestureEvent().x);
1973 EXPECT_EQ(3, GetMostRecentGestureEvent().y); 1966 EXPECT_EQ(3, GetMostRecentGestureEvent().y);
1974 EXPECT_EQ(3 + raw_offset_x, GetMostRecentGestureEvent().raw_x); 1967 EXPECT_EQ(3 + raw_offset_x, GetMostRecentGestureEvent().raw_x);
1975 EXPECT_EQ(3 + raw_offset_y, GetMostRecentGestureEvent().raw_y); 1968 EXPECT_EQ(3 + raw_offset_y, GetMostRecentGestureEvent().raw_y);
1976 1969
1977 1970
1978 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_UP, 4, 4); 1971 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_UP, 4, 4);
1979 event.pointer_count = 1;
1980 event.SetRawOffset(raw_offset_x, raw_offset_y); 1972 event.SetRawOffset(raw_offset_x, raw_offset_y);
1981 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1973 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1982 EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType()); 1974 EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType());
1983 EXPECT_EQ(9U, GetReceivedGestureCount()); 1975 EXPECT_EQ(9U, GetReceivedGestureCount());
1984 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 1976 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
1985 EXPECT_EQ(4, GetMostRecentGestureEvent().x); 1977 EXPECT_EQ(4, GetMostRecentGestureEvent().x);
1986 EXPECT_EQ(4, GetMostRecentGestureEvent().y); 1978 EXPECT_EQ(4, GetMostRecentGestureEvent().y);
1987 EXPECT_EQ(4 + raw_offset_x, GetMostRecentGestureEvent().raw_x); 1979 EXPECT_EQ(4 + raw_offset_x, GetMostRecentGestureEvent().raw_x);
1988 EXPECT_EQ(4 + raw_offset_y, GetMostRecentGestureEvent().raw_y); 1980 EXPECT_EQ(4 + raw_offset_y, GetMostRecentGestureEvent().raw_y);
1989 } 1981 }
1990 1982
1991 // Verify that gesture begin and gesture end events are dispatched correctly 1983 // Verify that gesture begin and gesture end events are dispatched correctly
1992 // when an ACTION_CANCEL is received. 1984 // when an ACTION_CANCEL is received.
1993 TEST_F(GestureProviderTest, GestureBeginAndEndOnCancel) { 1985 TEST_F(GestureProviderTest, GestureBeginAndEndOnCancel) {
1994 EnableBeginEndTypes(); 1986 EnableBeginEndTypes();
1995 base::TimeTicks event_time = base::TimeTicks::Now(); 1987 base::TimeTicks event_time = base::TimeTicks::Now();
1996 1988
1997 EXPECT_EQ(0U, GetReceivedGestureCount()); 1989 EXPECT_EQ(0U, GetReceivedGestureCount());
1998 MockMotionEvent event = 1990 MockMotionEvent event =
1999 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN, 1, 1); 1991 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN, 1, 1);
2000 event.pointer_count = 1;
2001 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1992 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
2002 EXPECT_EQ(ET_GESTURE_BEGIN, GetReceivedGesture(0).type()); 1993 EXPECT_EQ(ET_GESTURE_BEGIN, GetReceivedGesture(0).type());
2003 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); 1994 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
2004 EXPECT_EQ(2U, GetReceivedGestureCount()); 1995 EXPECT_EQ(2U, GetReceivedGestureCount());
2005 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 1996 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
2006 EXPECT_EQ(gfx::RectF(1 - kMockTouchRadius, 1997 EXPECT_EQ(gfx::RectF(1 - kMockTouchRadius,
2007 1 - kMockTouchRadius, 1998 1 - kMockTouchRadius,
2008 kMockTouchRadius * 2, 1999 kMockTouchRadius * 2,
2009 kMockTouchRadius * 2), 2000 kMockTouchRadius * 2),
2010 GetMostRecentGestureEvent().details.bounding_box()); 2001 GetMostRecentGestureEvent().details.bounding_box());
2011 EXPECT_EQ(1, GetMostRecentGestureEvent().x); 2002 EXPECT_EQ(1, GetMostRecentGestureEvent().x);
2012 EXPECT_EQ(1, GetMostRecentGestureEvent().y); 2003 EXPECT_EQ(1, GetMostRecentGestureEvent().y);
2013 2004
2014 event = ObtainMotionEvent( 2005 event = ObtainMotionEvent(
2015 event_time, MotionEvent::ACTION_POINTER_DOWN, 1, 1, 2, 2); 2006 event_time, MotionEvent::ACTION_POINTER_DOWN, 1, 1, 2, 2);
2016 event.pointer_count = 2;
2017 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 2007 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
2018 EXPECT_EQ(ET_GESTURE_BEGIN, GetMostRecentGestureEventType()); 2008 EXPECT_EQ(ET_GESTURE_BEGIN, GetMostRecentGestureEventType());
2019 EXPECT_EQ(3U, GetReceivedGestureCount()); 2009 EXPECT_EQ(3U, GetReceivedGestureCount());
2020 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); 2010 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points());
2021 EXPECT_EQ(2, GetMostRecentGestureEvent().x); 2011 EXPECT_EQ(2, GetMostRecentGestureEvent().x);
2022 EXPECT_EQ(2, GetMostRecentGestureEvent().y); 2012 EXPECT_EQ(2, GetMostRecentGestureEvent().y);
2023 2013
2024 2014
2025 event = ObtainMotionEvent( 2015 event = ObtainMotionEvent(
2026 event_time, MotionEvent::ACTION_POINTER_DOWN, 1, 1, 2, 2, 3, 3); 2016 event_time, MotionEvent::ACTION_POINTER_DOWN, 1, 1, 2, 2, 3, 3);
2027 event.pointer_count = 3;
2028 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 2017 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
2029 EXPECT_EQ(ET_GESTURE_BEGIN, GetMostRecentGestureEventType()); 2018 EXPECT_EQ(ET_GESTURE_BEGIN, GetMostRecentGestureEventType());
2030 EXPECT_EQ(4U, GetReceivedGestureCount()); 2019 EXPECT_EQ(4U, GetReceivedGestureCount());
2031 EXPECT_EQ(3, GetMostRecentGestureEvent().details.touch_points()); 2020 EXPECT_EQ(3, GetMostRecentGestureEvent().details.touch_points());
2032 EXPECT_EQ(3, GetMostRecentGestureEvent().x); 2021 EXPECT_EQ(3, GetMostRecentGestureEvent().x);
2033 EXPECT_EQ(3, GetMostRecentGestureEvent().y); 2022 EXPECT_EQ(3, GetMostRecentGestureEvent().y);
2034 2023
2035 event = ObtainMotionEvent( 2024 event = ObtainMotionEvent(
2036 event_time, MotionEvent::ACTION_CANCEL, 1, 1, 2, 2, 3, 3); 2025 event_time, MotionEvent::ACTION_CANCEL, 1, 1, 2, 2, 3, 3);
2037 event.pointer_count = 3;
2038 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 2026 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
2039 EXPECT_EQ(7U, GetReceivedGestureCount()); 2027 EXPECT_EQ(7U, GetReceivedGestureCount());
2040 EXPECT_EQ(3, GetReceivedGesture(4).details.touch_points()); 2028 EXPECT_EQ(3, GetReceivedGesture(4).details.touch_points());
2041 EXPECT_EQ(ET_GESTURE_END, GetReceivedGesture(4).type()); 2029 EXPECT_EQ(ET_GESTURE_END, GetReceivedGesture(4).type());
2042 EXPECT_EQ(2, GetReceivedGesture(5).details.touch_points()); 2030 EXPECT_EQ(2, GetReceivedGesture(5).details.touch_points());
2043 EXPECT_EQ(ET_GESTURE_END, GetReceivedGesture(5).type()); 2031 EXPECT_EQ(ET_GESTURE_END, GetReceivedGesture(5).type());
2044 EXPECT_EQ(1, GetReceivedGesture(6).details.touch_points()); 2032 EXPECT_EQ(1, GetReceivedGesture(6).details.touch_points());
2045 EXPECT_EQ(ET_GESTURE_END, GetReceivedGesture(6).type()); 2033 EXPECT_EQ(ET_GESTURE_END, GetReceivedGesture(6).type());
2046 EXPECT_EQ(1, GetReceivedGesture(4).x); 2034 EXPECT_EQ(1, GetReceivedGesture(4).x);
2047 EXPECT_EQ(1, GetReceivedGesture(4).y); 2035 EXPECT_EQ(1, GetReceivedGesture(4).y);
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
2338 ObtainMotionEvent(event_time + kOneMicrosecond, MotionEvent::ACTION_UP); 2326 ObtainMotionEvent(event_time + kOneMicrosecond, MotionEvent::ACTION_UP);
2339 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 2327 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
2340 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType()); 2328 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType());
2341 EXPECT_EQ(kMaxGestureBoundsLength, 2329 EXPECT_EQ(kMaxGestureBoundsLength,
2342 GetMostRecentGestureEvent().details.bounding_box_f().width()); 2330 GetMostRecentGestureEvent().details.bounding_box_f().width());
2343 EXPECT_EQ(kMaxGestureBoundsLength, 2331 EXPECT_EQ(kMaxGestureBoundsLength,
2344 GetMostRecentGestureEvent().details.bounding_box_f().height()); 2332 GetMostRecentGestureEvent().details.bounding_box_f().height());
2345 } 2333 }
2346 2334
2347 } // namespace ui 2335 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698