OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
8 #include "content/browser/renderer_host/input/synthetic_gesture.h" | 8 #include "content/browser/renderer_host/input/synthetic_gesture.h" |
9 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h" | 9 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h" |
10 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" | 10 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 int num_success_; | 426 int num_success_; |
427 int num_failure_; | 427 int num_failure_; |
428 }; | 428 }; |
429 | 429 |
430 TEST_F(SyntheticGestureControllerTest, SingleGesture) { | 430 TEST_F(SyntheticGestureControllerTest, SingleGesture) { |
431 CreateControllerAndTarget<MockSyntheticGestureTarget>(); | 431 CreateControllerAndTarget<MockSyntheticGestureTarget>(); |
432 | 432 |
433 bool finished = false; | 433 bool finished = false; |
434 scoped_ptr<MockSyntheticGesture> gesture( | 434 scoped_ptr<MockSyntheticGesture> gesture( |
435 new MockSyntheticGesture(&finished, 3)); | 435 new MockSyntheticGesture(&finished, 3)); |
436 QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); | 436 QueueSyntheticGesture(gesture.Pass()); |
437 FlushInputUntilComplete(); | 437 FlushInputUntilComplete(); |
438 | 438 |
439 EXPECT_TRUE(finished); | 439 EXPECT_TRUE(finished); |
440 EXPECT_EQ(1, num_success_); | 440 EXPECT_EQ(1, num_success_); |
441 EXPECT_EQ(0, num_failure_); | 441 EXPECT_EQ(0, num_failure_); |
442 } | 442 } |
443 | 443 |
444 TEST_F(SyntheticGestureControllerTest, GestureFailed) { | 444 TEST_F(SyntheticGestureControllerTest, GestureFailed) { |
445 CreateControllerAndTarget<MockSyntheticGestureTarget>(); | 445 CreateControllerAndTarget<MockSyntheticGestureTarget>(); |
446 | 446 |
447 bool finished = false; | 447 bool finished = false; |
448 scoped_ptr<MockSyntheticGesture> gesture( | 448 scoped_ptr<MockSyntheticGesture> gesture( |
449 new MockSyntheticGesture(&finished, 0)); | 449 new MockSyntheticGesture(&finished, 0)); |
450 QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); | 450 QueueSyntheticGesture(gesture.Pass()); |
451 FlushInputUntilComplete(); | 451 FlushInputUntilComplete(); |
452 | 452 |
453 EXPECT_TRUE(finished); | 453 EXPECT_TRUE(finished); |
454 EXPECT_EQ(1, num_failure_); | 454 EXPECT_EQ(1, num_failure_); |
455 EXPECT_EQ(0, num_success_); | 455 EXPECT_EQ(0, num_success_); |
456 } | 456 } |
457 | 457 |
458 TEST_F(SyntheticGestureControllerTest, SuccessiveGestures) { | 458 TEST_F(SyntheticGestureControllerTest, SuccessiveGestures) { |
459 CreateControllerAndTarget<MockSyntheticGestureTarget>(); | 459 CreateControllerAndTarget<MockSyntheticGestureTarget>(); |
460 | 460 |
461 bool finished_1 = false; | 461 bool finished_1 = false; |
462 scoped_ptr<MockSyntheticGesture> gesture_1( | 462 scoped_ptr<MockSyntheticGesture> gesture_1( |
463 new MockSyntheticGesture(&finished_1, 2)); | 463 new MockSyntheticGesture(&finished_1, 2)); |
464 bool finished_2 = false; | 464 bool finished_2 = false; |
465 scoped_ptr<MockSyntheticGesture> gesture_2( | 465 scoped_ptr<MockSyntheticGesture> gesture_2( |
466 new MockSyntheticGesture(&finished_2, 4)); | 466 new MockSyntheticGesture(&finished_2, 4)); |
467 | 467 |
468 // Queue first gesture and wait for it to finish | 468 // Queue first gesture and wait for it to finish |
469 QueueSyntheticGesture(gesture_1.PassAs<SyntheticGesture>()); | 469 QueueSyntheticGesture(gesture_1.Pass()); |
470 FlushInputUntilComplete(); | 470 FlushInputUntilComplete(); |
471 | 471 |
472 EXPECT_TRUE(finished_1); | 472 EXPECT_TRUE(finished_1); |
473 EXPECT_EQ(1, num_success_); | 473 EXPECT_EQ(1, num_success_); |
474 EXPECT_EQ(0, num_failure_); | 474 EXPECT_EQ(0, num_failure_); |
475 | 475 |
476 // Queue second gesture. | 476 // Queue second gesture. |
477 QueueSyntheticGesture(gesture_2.PassAs<SyntheticGesture>()); | 477 QueueSyntheticGesture(gesture_2.Pass()); |
478 FlushInputUntilComplete(); | 478 FlushInputUntilComplete(); |
479 | 479 |
480 EXPECT_TRUE(finished_2); | 480 EXPECT_TRUE(finished_2); |
481 EXPECT_EQ(2, num_success_); | 481 EXPECT_EQ(2, num_success_); |
482 EXPECT_EQ(0, num_failure_); | 482 EXPECT_EQ(0, num_failure_); |
483 } | 483 } |
484 | 484 |
485 TEST_F(SyntheticGestureControllerTest, TwoGesturesInFlight) { | 485 TEST_F(SyntheticGestureControllerTest, TwoGesturesInFlight) { |
486 CreateControllerAndTarget<MockSyntheticGestureTarget>(); | 486 CreateControllerAndTarget<MockSyntheticGestureTarget>(); |
487 | 487 |
488 bool finished_1 = false; | 488 bool finished_1 = false; |
489 scoped_ptr<MockSyntheticGesture> gesture_1( | 489 scoped_ptr<MockSyntheticGesture> gesture_1( |
490 new MockSyntheticGesture(&finished_1, 2)); | 490 new MockSyntheticGesture(&finished_1, 2)); |
491 bool finished_2 = false; | 491 bool finished_2 = false; |
492 scoped_ptr<MockSyntheticGesture> gesture_2( | 492 scoped_ptr<MockSyntheticGesture> gesture_2( |
493 new MockSyntheticGesture(&finished_2, 4)); | 493 new MockSyntheticGesture(&finished_2, 4)); |
494 | 494 |
495 QueueSyntheticGesture(gesture_1.PassAs<SyntheticGesture>()); | 495 QueueSyntheticGesture(gesture_1.Pass()); |
496 QueueSyntheticGesture(gesture_2.PassAs<SyntheticGesture>()); | 496 QueueSyntheticGesture(gesture_2.Pass()); |
497 FlushInputUntilComplete(); | 497 FlushInputUntilComplete(); |
498 | 498 |
499 EXPECT_TRUE(finished_1); | 499 EXPECT_TRUE(finished_1); |
500 EXPECT_TRUE(finished_2); | 500 EXPECT_TRUE(finished_2); |
501 | 501 |
502 EXPECT_EQ(2, num_success_); | 502 EXPECT_EQ(2, num_success_); |
503 EXPECT_EQ(0, num_failure_); | 503 EXPECT_EQ(0, num_failure_); |
504 } | 504 } |
505 | 505 |
506 TEST_F(SyntheticGestureControllerTest, GestureCompletedOnDidFlushInput) { | 506 TEST_F(SyntheticGestureControllerTest, GestureCompletedOnDidFlushInput) { |
507 CreateControllerAndTarget<MockSyntheticGestureTarget>(); | 507 CreateControllerAndTarget<MockSyntheticGestureTarget>(); |
508 | 508 |
509 bool finished_1, finished_2; | 509 bool finished_1, finished_2; |
510 scoped_ptr<MockSyntheticGesture> gesture_1( | 510 scoped_ptr<MockSyntheticGesture> gesture_1( |
511 new MockSyntheticGesture(&finished_1, 2)); | 511 new MockSyntheticGesture(&finished_1, 2)); |
512 scoped_ptr<MockSyntheticGesture> gesture_2( | 512 scoped_ptr<MockSyntheticGesture> gesture_2( |
513 new MockSyntheticGesture(&finished_2, 4)); | 513 new MockSyntheticGesture(&finished_2, 4)); |
514 | 514 |
515 QueueSyntheticGesture(gesture_1.PassAs<SyntheticGesture>()); | 515 QueueSyntheticGesture(gesture_1.Pass()); |
516 QueueSyntheticGesture(gesture_2.PassAs<SyntheticGesture>()); | 516 QueueSyntheticGesture(gesture_2.Pass()); |
517 | 517 |
518 while (target_->flush_requested()) { | 518 while (target_->flush_requested()) { |
519 target_->ClearFlushRequest(); | 519 target_->ClearFlushRequest(); |
520 time_ += base::TimeDelta::FromMilliseconds(kFlushInputRateInMs); | 520 time_ += base::TimeDelta::FromMilliseconds(kFlushInputRateInMs); |
521 controller_->Flush(time_); | 521 controller_->Flush(time_); |
522 } | 522 } |
523 EXPECT_EQ(0, num_success_); | 523 EXPECT_EQ(0, num_success_); |
524 controller_->OnDidFlushInput(); | 524 controller_->OnDidFlushInput(); |
525 EXPECT_EQ(1, num_success_); | 525 EXPECT_EQ(1, num_success_); |
526 | 526 |
(...skipping 29 matching lines...) Expand all Loading... |
556 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureTouchVertical) { | 556 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureTouchVertical) { |
557 CreateControllerAndTarget<MockScrollTouchTarget>(); | 557 CreateControllerAndTarget<MockScrollTouchTarget>(); |
558 | 558 |
559 SyntheticSmoothScrollGestureParams params; | 559 SyntheticSmoothScrollGestureParams params; |
560 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 560 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
561 params.anchor.SetPoint(89, 32); | 561 params.anchor.SetPoint(89, 32); |
562 params.distances.push_back(gfx::Vector2d(0, 123)); | 562 params.distances.push_back(gfx::Vector2d(0, 123)); |
563 | 563 |
564 scoped_ptr<SyntheticSmoothScrollGesture> gesture( | 564 scoped_ptr<SyntheticSmoothScrollGesture> gesture( |
565 new SyntheticSmoothScrollGesture(params)); | 565 new SyntheticSmoothScrollGesture(params)); |
566 QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); | 566 QueueSyntheticGesture(gesture.Pass()); |
567 FlushInputUntilComplete(); | 567 FlushInputUntilComplete(); |
568 | 568 |
569 MockScrollGestureTarget* scroll_target = | 569 MockScrollGestureTarget* scroll_target = |
570 static_cast<MockScrollGestureTarget*>(target_); | 570 static_cast<MockScrollGestureTarget*>(target_); |
571 EXPECT_EQ(1, num_success_); | 571 EXPECT_EQ(1, num_success_); |
572 EXPECT_EQ(0, num_failure_); | 572 EXPECT_EQ(0, num_failure_); |
573 EXPECT_EQ(AddTouchSlopToVector(params.distances[0], target_), | 573 EXPECT_EQ(AddTouchSlopToVector(params.distances[0], target_), |
574 scroll_target->start_to_end_distance()); | 574 scroll_target->start_to_end_distance()); |
575 } | 575 } |
576 | 576 |
577 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureTouchHorizontal) { | 577 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureTouchHorizontal) { |
578 CreateControllerAndTarget<MockScrollTouchTarget>(); | 578 CreateControllerAndTarget<MockScrollTouchTarget>(); |
579 | 579 |
580 SyntheticSmoothScrollGestureParams params; | 580 SyntheticSmoothScrollGestureParams params; |
581 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 581 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
582 params.anchor.SetPoint(12, -23); | 582 params.anchor.SetPoint(12, -23); |
583 params.distances.push_back(gfx::Vector2d(-234, 0)); | 583 params.distances.push_back(gfx::Vector2d(-234, 0)); |
584 | 584 |
585 scoped_ptr<SyntheticSmoothScrollGesture> gesture( | 585 scoped_ptr<SyntheticSmoothScrollGesture> gesture( |
586 new SyntheticSmoothScrollGesture(params)); | 586 new SyntheticSmoothScrollGesture(params)); |
587 QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); | 587 QueueSyntheticGesture(gesture.Pass()); |
588 FlushInputUntilComplete(); | 588 FlushInputUntilComplete(); |
589 | 589 |
590 MockScrollGestureTarget* scroll_target = | 590 MockScrollGestureTarget* scroll_target = |
591 static_cast<MockScrollGestureTarget*>(target_); | 591 static_cast<MockScrollGestureTarget*>(target_); |
592 EXPECT_EQ(1, num_success_); | 592 EXPECT_EQ(1, num_success_); |
593 EXPECT_EQ(0, num_failure_); | 593 EXPECT_EQ(0, num_failure_); |
594 EXPECT_EQ(AddTouchSlopToVector(params.distances[0], target_), | 594 EXPECT_EQ(AddTouchSlopToVector(params.distances[0], target_), |
595 scroll_target->start_to_end_distance()); | 595 scroll_target->start_to_end_distance()); |
596 } | 596 } |
597 | 597 |
(...skipping 20 matching lines...) Expand all Loading... |
618 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureTouchDiagonal) { | 618 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureTouchDiagonal) { |
619 CreateControllerAndTarget<MockScrollTouchTarget>(); | 619 CreateControllerAndTarget<MockScrollTouchTarget>(); |
620 | 620 |
621 SyntheticSmoothScrollGestureParams params; | 621 SyntheticSmoothScrollGestureParams params; |
622 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 622 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
623 params.anchor.SetPoint(0, 7); | 623 params.anchor.SetPoint(0, 7); |
624 params.distances.push_back(gfx::Vector2d(413, -83)); | 624 params.distances.push_back(gfx::Vector2d(413, -83)); |
625 | 625 |
626 scoped_ptr<SyntheticSmoothScrollGesture> gesture( | 626 scoped_ptr<SyntheticSmoothScrollGesture> gesture( |
627 new SyntheticSmoothScrollGesture(params)); | 627 new SyntheticSmoothScrollGesture(params)); |
628 QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); | 628 QueueSyntheticGesture(gesture.Pass()); |
629 FlushInputUntilComplete(); | 629 FlushInputUntilComplete(); |
630 | 630 |
631 MockScrollGestureTarget* scroll_target = | 631 MockScrollGestureTarget* scroll_target = |
632 static_cast<MockScrollGestureTarget*>(target_); | 632 static_cast<MockScrollGestureTarget*>(target_); |
633 EXPECT_EQ(1, num_success_); | 633 EXPECT_EQ(1, num_success_); |
634 EXPECT_EQ(0, num_failure_); | 634 EXPECT_EQ(0, num_failure_); |
635 CheckSingleScrollDistanceIsWithinRange( | 635 CheckSingleScrollDistanceIsWithinRange( |
636 scroll_target->start_to_end_distance(), params.distances[0], target_); | 636 scroll_target->start_to_end_distance(), params.distances[0], target_); |
637 } | 637 } |
638 | 638 |
639 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureTouchLongStop) { | 639 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureTouchLongStop) { |
640 CreateControllerAndTarget<MockScrollTouchTarget>(); | 640 CreateControllerAndTarget<MockScrollTouchTarget>(); |
641 | 641 |
642 // Create a smooth scroll with a short distance and set the pointer assumed | 642 // Create a smooth scroll with a short distance and set the pointer assumed |
643 // stopped time high, so that the stopping should dominate the time the | 643 // stopped time high, so that the stopping should dominate the time the |
644 // gesture is active. | 644 // gesture is active. |
645 SyntheticSmoothScrollGestureParams params; | 645 SyntheticSmoothScrollGestureParams params; |
646 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 646 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
647 params.anchor.SetPoint(-98, -23); | 647 params.anchor.SetPoint(-98, -23); |
648 params.distances.push_back(gfx::Vector2d(21, -12)); | 648 params.distances.push_back(gfx::Vector2d(21, -12)); |
649 params.prevent_fling = true; | 649 params.prevent_fling = true; |
650 | 650 |
651 target_->set_pointer_assumed_stopped_time_ms(543); | 651 target_->set_pointer_assumed_stopped_time_ms(543); |
652 | 652 |
653 scoped_ptr<SyntheticSmoothScrollGesture> gesture( | 653 scoped_ptr<SyntheticSmoothScrollGesture> gesture( |
654 new SyntheticSmoothScrollGesture(params)); | 654 new SyntheticSmoothScrollGesture(params)); |
655 QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); | 655 QueueSyntheticGesture(gesture.Pass()); |
656 FlushInputUntilComplete(); | 656 FlushInputUntilComplete(); |
657 | 657 |
658 MockScrollGestureTarget* scroll_target = | 658 MockScrollGestureTarget* scroll_target = |
659 static_cast<MockScrollGestureTarget*>(target_); | 659 static_cast<MockScrollGestureTarget*>(target_); |
660 EXPECT_EQ(1, num_success_); | 660 EXPECT_EQ(1, num_success_); |
661 EXPECT_EQ(0, num_failure_); | 661 EXPECT_EQ(0, num_failure_); |
662 CheckSingleScrollDistanceIsWithinRange( | 662 CheckSingleScrollDistanceIsWithinRange( |
663 scroll_target->start_to_end_distance(), params.distances[0], target_); | 663 scroll_target->start_to_end_distance(), params.distances[0], target_); |
664 EXPECT_GE(GetTotalTime(), target_->PointerAssumedStoppedTime()); | 664 EXPECT_GE(GetTotalTime(), target_->PointerAssumedStoppedTime()); |
665 } | 665 } |
666 | 666 |
667 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureTouchFling) { | 667 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureTouchFling) { |
668 CreateControllerAndTarget<MockScrollTouchTarget>(); | 668 CreateControllerAndTarget<MockScrollTouchTarget>(); |
669 | 669 |
670 // Create a smooth scroll with a short distance and set the pointer assumed | 670 // Create a smooth scroll with a short distance and set the pointer assumed |
671 // stopped time high. Disable 'prevent_fling' and check that the gesture | 671 // stopped time high. Disable 'prevent_fling' and check that the gesture |
672 // finishes without waiting before it stops. | 672 // finishes without waiting before it stops. |
673 SyntheticSmoothScrollGestureParams params; | 673 SyntheticSmoothScrollGestureParams params; |
674 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 674 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
675 params.anchor.SetPoint(-89, 78); | 675 params.anchor.SetPoint(-89, 78); |
676 params.distances.push_back(gfx::Vector2d(-43, 19)); | 676 params.distances.push_back(gfx::Vector2d(-43, 19)); |
677 params.prevent_fling = false; | 677 params.prevent_fling = false; |
678 | 678 |
679 target_->set_pointer_assumed_stopped_time_ms(543); | 679 target_->set_pointer_assumed_stopped_time_ms(543); |
680 | 680 |
681 scoped_ptr<SyntheticSmoothScrollGesture> gesture( | 681 scoped_ptr<SyntheticSmoothScrollGesture> gesture( |
682 new SyntheticSmoothScrollGesture(params)); | 682 new SyntheticSmoothScrollGesture(params)); |
683 QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); | 683 QueueSyntheticGesture(gesture.Pass()); |
684 FlushInputUntilComplete(); | 684 FlushInputUntilComplete(); |
685 | 685 |
686 MockScrollGestureTarget* scroll_target = | 686 MockScrollGestureTarget* scroll_target = |
687 static_cast<MockScrollGestureTarget*>(target_); | 687 static_cast<MockScrollGestureTarget*>(target_); |
688 EXPECT_EQ(1, num_success_); | 688 EXPECT_EQ(1, num_success_); |
689 EXPECT_EQ(0, num_failure_); | 689 EXPECT_EQ(0, num_failure_); |
690 CheckSingleScrollDistanceIsWithinRange( | 690 CheckSingleScrollDistanceIsWithinRange( |
691 scroll_target->start_to_end_distance(), params.distances[0], target_); | 691 scroll_target->start_to_end_distance(), params.distances[0], target_); |
692 EXPECT_LE(GetTotalTime(), target_->PointerAssumedStoppedTime()); | 692 EXPECT_LE(GetTotalTime(), target_->PointerAssumedStoppedTime()); |
693 } | 693 } |
694 | 694 |
695 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureTouchZeroDistance) { | 695 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureTouchZeroDistance) { |
696 CreateControllerAndTarget<MockScrollTouchTarget>(); | 696 CreateControllerAndTarget<MockScrollTouchTarget>(); |
697 | 697 |
698 SyntheticSmoothScrollGestureParams params; | 698 SyntheticSmoothScrollGestureParams params; |
699 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 699 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
700 params.anchor.SetPoint(-32, 43); | 700 params.anchor.SetPoint(-32, 43); |
701 params.distances.push_back(gfx::Vector2d(0, 0)); | 701 params.distances.push_back(gfx::Vector2d(0, 0)); |
702 | 702 |
703 scoped_ptr<SyntheticSmoothScrollGesture> gesture( | 703 scoped_ptr<SyntheticSmoothScrollGesture> gesture( |
704 new SyntheticSmoothScrollGesture(params)); | 704 new SyntheticSmoothScrollGesture(params)); |
705 QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); | 705 QueueSyntheticGesture(gesture.Pass()); |
706 FlushInputUntilComplete(); | 706 FlushInputUntilComplete(); |
707 | 707 |
708 MockScrollGestureTarget* scroll_target = | 708 MockScrollGestureTarget* scroll_target = |
709 static_cast<MockScrollGestureTarget*>(target_); | 709 static_cast<MockScrollGestureTarget*>(target_); |
710 EXPECT_EQ(1, num_success_); | 710 EXPECT_EQ(1, num_success_); |
711 EXPECT_EQ(0, num_failure_); | 711 EXPECT_EQ(0, num_failure_); |
712 EXPECT_EQ(gfx::Vector2dF(0, 0), scroll_target->start_to_end_distance()); | 712 EXPECT_EQ(gfx::Vector2dF(0, 0), scroll_target->start_to_end_distance()); |
713 } | 713 } |
714 | 714 |
715 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureMouseVertical) { | 715 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureMouseVertical) { |
716 CreateControllerAndTarget<MockScrollMouseTarget>(); | 716 CreateControllerAndTarget<MockScrollMouseTarget>(); |
717 | 717 |
718 SyntheticSmoothScrollGestureParams params; | 718 SyntheticSmoothScrollGestureParams params; |
719 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; | 719 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; |
720 params.anchor.SetPoint(432, 89); | 720 params.anchor.SetPoint(432, 89); |
721 params.distances.push_back(gfx::Vector2d(0, -234)); | 721 params.distances.push_back(gfx::Vector2d(0, -234)); |
722 | 722 |
723 scoped_ptr<SyntheticSmoothScrollGesture> gesture( | 723 scoped_ptr<SyntheticSmoothScrollGesture> gesture( |
724 new SyntheticSmoothScrollGesture(params)); | 724 new SyntheticSmoothScrollGesture(params)); |
725 QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); | 725 QueueSyntheticGesture(gesture.Pass()); |
726 FlushInputUntilComplete(); | 726 FlushInputUntilComplete(); |
727 | 727 |
728 MockScrollGestureTarget* scroll_target = | 728 MockScrollGestureTarget* scroll_target = |
729 static_cast<MockScrollGestureTarget*>(target_); | 729 static_cast<MockScrollGestureTarget*>(target_); |
730 EXPECT_EQ(1, num_success_); | 730 EXPECT_EQ(1, num_success_); |
731 EXPECT_EQ(0, num_failure_); | 731 EXPECT_EQ(0, num_failure_); |
732 EXPECT_EQ(params.distances[0], scroll_target->start_to_end_distance()); | 732 EXPECT_EQ(params.distances[0], scroll_target->start_to_end_distance()); |
733 } | 733 } |
734 | 734 |
735 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureMouseHorizontal) { | 735 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureMouseHorizontal) { |
736 CreateControllerAndTarget<MockScrollMouseTarget>(); | 736 CreateControllerAndTarget<MockScrollMouseTarget>(); |
737 | 737 |
738 SyntheticSmoothScrollGestureParams params; | 738 SyntheticSmoothScrollGestureParams params; |
739 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; | 739 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; |
740 params.anchor.SetPoint(90, 12); | 740 params.anchor.SetPoint(90, 12); |
741 params.distances.push_back(gfx::Vector2d(345, 0)); | 741 params.distances.push_back(gfx::Vector2d(345, 0)); |
742 | 742 |
743 scoped_ptr<SyntheticSmoothScrollGesture> gesture( | 743 scoped_ptr<SyntheticSmoothScrollGesture> gesture( |
744 new SyntheticSmoothScrollGesture(params)); | 744 new SyntheticSmoothScrollGesture(params)); |
745 QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); | 745 QueueSyntheticGesture(gesture.Pass()); |
746 FlushInputUntilComplete(); | 746 FlushInputUntilComplete(); |
747 | 747 |
748 MockScrollGestureTarget* scroll_target = | 748 MockScrollGestureTarget* scroll_target = |
749 static_cast<MockScrollGestureTarget*>(target_); | 749 static_cast<MockScrollGestureTarget*>(target_); |
750 EXPECT_EQ(1, num_success_); | 750 EXPECT_EQ(1, num_success_); |
751 EXPECT_EQ(0, num_failure_); | 751 EXPECT_EQ(0, num_failure_); |
752 EXPECT_EQ(params.distances[0], scroll_target->start_to_end_distance()); | 752 EXPECT_EQ(params.distances[0], scroll_target->start_to_end_distance()); |
753 } | 753 } |
754 | 754 |
755 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureMouseDiagonal) { | 755 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureMouseDiagonal) { |
756 CreateControllerAndTarget<MockScrollMouseTarget>(); | 756 CreateControllerAndTarget<MockScrollMouseTarget>(); |
757 | 757 |
758 SyntheticSmoothScrollGestureParams params; | 758 SyntheticSmoothScrollGestureParams params; |
759 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; | 759 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; |
760 params.anchor.SetPoint(90, 12); | 760 params.anchor.SetPoint(90, 12); |
761 params.distances.push_back(gfx::Vector2d(-194, 303)); | 761 params.distances.push_back(gfx::Vector2d(-194, 303)); |
762 | 762 |
763 scoped_ptr<SyntheticSmoothScrollGesture> gesture( | 763 scoped_ptr<SyntheticSmoothScrollGesture> gesture( |
764 new SyntheticSmoothScrollGesture(params)); | 764 new SyntheticSmoothScrollGesture(params)); |
765 QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); | 765 QueueSyntheticGesture(gesture.Pass()); |
766 FlushInputUntilComplete(); | 766 FlushInputUntilComplete(); |
767 | 767 |
768 MockScrollGestureTarget* scroll_target = | 768 MockScrollGestureTarget* scroll_target = |
769 static_cast<MockScrollGestureTarget*>(target_); | 769 static_cast<MockScrollGestureTarget*>(target_); |
770 EXPECT_EQ(1, num_success_); | 770 EXPECT_EQ(1, num_success_); |
771 EXPECT_EQ(0, num_failure_); | 771 EXPECT_EQ(0, num_failure_); |
772 EXPECT_EQ(params.distances[0], scroll_target->start_to_end_distance()); | 772 EXPECT_EQ(params.distances[0], scroll_target->start_to_end_distance()); |
773 } | 773 } |
774 | 774 |
775 TEST_F(SyntheticGestureControllerTest, MultiScrollGestureMouse) { | 775 TEST_F(SyntheticGestureControllerTest, MultiScrollGestureMouse) { |
776 CreateControllerAndTarget<MockScrollMouseTarget>(); | 776 CreateControllerAndTarget<MockScrollMouseTarget>(); |
777 | 777 |
778 SyntheticSmoothScrollGestureParams params; | 778 SyntheticSmoothScrollGestureParams params; |
779 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; | 779 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; |
780 params.anchor.SetPoint(90, 12); | 780 params.anchor.SetPoint(90, 12); |
781 params.distances.push_back(gfx::Vector2d(-129, 212)); | 781 params.distances.push_back(gfx::Vector2d(-129, 212)); |
782 params.distances.push_back(gfx::Vector2d(8, -9)); | 782 params.distances.push_back(gfx::Vector2d(8, -9)); |
783 | 783 |
784 scoped_ptr<SyntheticSmoothScrollGesture> gesture( | 784 scoped_ptr<SyntheticSmoothScrollGesture> gesture( |
785 new SyntheticSmoothScrollGesture(params)); | 785 new SyntheticSmoothScrollGesture(params)); |
786 QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); | 786 QueueSyntheticGesture(gesture.Pass()); |
787 FlushInputUntilComplete(); | 787 FlushInputUntilComplete(); |
788 | 788 |
789 MockScrollGestureTarget* scroll_target = | 789 MockScrollGestureTarget* scroll_target = |
790 static_cast<MockScrollGestureTarget*>(target_); | 790 static_cast<MockScrollGestureTarget*>(target_); |
791 EXPECT_EQ(1, num_success_); | 791 EXPECT_EQ(1, num_success_); |
792 EXPECT_EQ(0, num_failure_); | 792 EXPECT_EQ(0, num_failure_); |
793 EXPECT_EQ(params.distances[0] + params.distances[1], | 793 EXPECT_EQ(params.distances[0] + params.distances[1], |
794 scroll_target->start_to_end_distance()); | 794 scroll_target->start_to_end_distance()); |
795 } | 795 } |
796 | 796 |
797 TEST_F(SyntheticGestureControllerTest, MultiScrollGestureMouseHorizontal) { | 797 TEST_F(SyntheticGestureControllerTest, MultiScrollGestureMouseHorizontal) { |
798 CreateControllerAndTarget<MockScrollMouseTarget>(); | 798 CreateControllerAndTarget<MockScrollMouseTarget>(); |
799 | 799 |
800 SyntheticSmoothScrollGestureParams params; | 800 SyntheticSmoothScrollGestureParams params; |
801 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; | 801 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; |
802 params.anchor.SetPoint(90, 12); | 802 params.anchor.SetPoint(90, 12); |
803 params.distances.push_back(gfx::Vector2d(-129, 0)); | 803 params.distances.push_back(gfx::Vector2d(-129, 0)); |
804 params.distances.push_back(gfx::Vector2d(79, 0)); | 804 params.distances.push_back(gfx::Vector2d(79, 0)); |
805 | 805 |
806 scoped_ptr<SyntheticSmoothScrollGesture> gesture( | 806 scoped_ptr<SyntheticSmoothScrollGesture> gesture( |
807 new SyntheticSmoothScrollGesture(params)); | 807 new SyntheticSmoothScrollGesture(params)); |
808 QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); | 808 QueueSyntheticGesture(gesture.Pass()); |
809 FlushInputUntilComplete(); | 809 FlushInputUntilComplete(); |
810 | 810 |
811 MockScrollGestureTarget* scroll_target = | 811 MockScrollGestureTarget* scroll_target = |
812 static_cast<MockScrollGestureTarget*>(target_); | 812 static_cast<MockScrollGestureTarget*>(target_); |
813 EXPECT_EQ(1, num_success_); | 813 EXPECT_EQ(1, num_success_); |
814 EXPECT_EQ(0, num_failure_); | 814 EXPECT_EQ(0, num_failure_); |
815 // This check only works for horizontal or vertical scrolls because of | 815 // This check only works for horizontal or vertical scrolls because of |
816 // floating point precision issues with diagonal scrolls. | 816 // floating point precision issues with diagonal scrolls. |
817 EXPECT_FLOAT_EQ(params.distances[0].Length() + params.distances[1].Length(), | 817 EXPECT_FLOAT_EQ(params.distances[0].Length() + params.distances[1].Length(), |
818 scroll_target->total_abs_scroll_distance_length()); | 818 scroll_target->total_abs_scroll_distance_length()); |
(...skipping 25 matching lines...) Expand all Loading... |
844 CreateControllerAndTarget<MockScrollTouchTarget>(); | 844 CreateControllerAndTarget<MockScrollTouchTarget>(); |
845 | 845 |
846 SyntheticSmoothScrollGestureParams params; | 846 SyntheticSmoothScrollGestureParams params; |
847 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 847 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
848 params.anchor.SetPoint(8, -13); | 848 params.anchor.SetPoint(8, -13); |
849 params.distances.push_back(gfx::Vector2d(234, 133)); | 849 params.distances.push_back(gfx::Vector2d(234, 133)); |
850 params.distances.push_back(gfx::Vector2d(-9, 78)); | 850 params.distances.push_back(gfx::Vector2d(-9, 78)); |
851 | 851 |
852 scoped_ptr<SyntheticSmoothScrollGesture> gesture( | 852 scoped_ptr<SyntheticSmoothScrollGesture> gesture( |
853 new SyntheticSmoothScrollGesture(params)); | 853 new SyntheticSmoothScrollGesture(params)); |
854 QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); | 854 QueueSyntheticGesture(gesture.Pass()); |
855 FlushInputUntilComplete(); | 855 FlushInputUntilComplete(); |
856 | 856 |
857 MockScrollGestureTarget* scroll_target = | 857 MockScrollGestureTarget* scroll_target = |
858 static_cast<MockScrollGestureTarget*>(target_); | 858 static_cast<MockScrollGestureTarget*>(target_); |
859 EXPECT_EQ(1, num_success_); | 859 EXPECT_EQ(1, num_success_); |
860 EXPECT_EQ(0, num_failure_); | 860 EXPECT_EQ(0, num_failure_); |
861 CheckMultiScrollDistanceIsWithinRange( | 861 CheckMultiScrollDistanceIsWithinRange( |
862 scroll_target->start_to_end_distance(), | 862 scroll_target->start_to_end_distance(), |
863 params.distances[0] + params.distances[1], | 863 params.distances[0] + params.distances[1], |
864 target_); | 864 target_); |
865 } | 865 } |
866 | 866 |
867 TEST_F(SyntheticGestureControllerTest, MultiScrollGestureTouchVertical) { | 867 TEST_F(SyntheticGestureControllerTest, MultiScrollGestureTouchVertical) { |
868 CreateControllerAndTarget<MockScrollTouchTarget>(); | 868 CreateControllerAndTarget<MockScrollTouchTarget>(); |
869 | 869 |
870 SyntheticSmoothScrollGestureParams params; | 870 SyntheticSmoothScrollGestureParams params; |
871 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 871 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
872 params.anchor.SetPoint(234, -13); | 872 params.anchor.SetPoint(234, -13); |
873 params.distances.push_back(gfx::Vector2d(0, 133)); | 873 params.distances.push_back(gfx::Vector2d(0, 133)); |
874 params.distances.push_back(gfx::Vector2d(0, 78)); | 874 params.distances.push_back(gfx::Vector2d(0, 78)); |
875 | 875 |
876 scoped_ptr<SyntheticSmoothScrollGesture> gesture( | 876 scoped_ptr<SyntheticSmoothScrollGesture> gesture( |
877 new SyntheticSmoothScrollGesture(params)); | 877 new SyntheticSmoothScrollGesture(params)); |
878 QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); | 878 QueueSyntheticGesture(gesture.Pass()); |
879 FlushInputUntilComplete(); | 879 FlushInputUntilComplete(); |
880 | 880 |
881 MockScrollGestureTarget* scroll_target = | 881 MockScrollGestureTarget* scroll_target = |
882 static_cast<MockScrollGestureTarget*>(target_); | 882 static_cast<MockScrollGestureTarget*>(target_); |
883 EXPECT_EQ(1, num_success_); | 883 EXPECT_EQ(1, num_success_); |
884 EXPECT_EQ(0, num_failure_); | 884 EXPECT_EQ(0, num_failure_); |
885 EXPECT_FLOAT_EQ( | 885 EXPECT_FLOAT_EQ( |
886 params.distances[0].Length() + params.distances[1].Length() + | 886 params.distances[0].Length() + params.distances[1].Length() + |
887 target_->GetTouchSlopInDips(), | 887 target_->GetTouchSlopInDips(), |
888 scroll_target->total_abs_scroll_distance_length()); | 888 scroll_target->total_abs_scroll_distance_length()); |
889 EXPECT_EQ(AddTouchSlopToVector(params.distances[0] + params.distances[1], | 889 EXPECT_EQ(AddTouchSlopToVector(params.distances[0] + params.distances[1], |
890 target_), | 890 target_), |
891 scroll_target->start_to_end_distance()); | 891 scroll_target->start_to_end_distance()); |
892 } | 892 } |
893 | 893 |
894 TEST_F(SyntheticGestureControllerTest, PinchGestureTouchZoomIn) { | 894 TEST_F(SyntheticGestureControllerTest, PinchGestureTouchZoomIn) { |
895 CreateControllerAndTarget<MockSyntheticPinchTouchTarget>(); | 895 CreateControllerAndTarget<MockSyntheticPinchTouchTarget>(); |
896 | 896 |
897 SyntheticPinchGestureParams params; | 897 SyntheticPinchGestureParams params; |
898 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 898 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
899 params.scale_factor = 2.3f; | 899 params.scale_factor = 2.3f; |
900 params.anchor.SetPoint(54, 89); | 900 params.anchor.SetPoint(54, 89); |
901 | 901 |
902 scoped_ptr<SyntheticPinchGesture> gesture(new SyntheticPinchGesture(params)); | 902 scoped_ptr<SyntheticPinchGesture> gesture(new SyntheticPinchGesture(params)); |
903 QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); | 903 QueueSyntheticGesture(gesture.Pass()); |
904 FlushInputUntilComplete(); | 904 FlushInputUntilComplete(); |
905 | 905 |
906 MockSyntheticPinchTouchTarget* pinch_target = | 906 MockSyntheticPinchTouchTarget* pinch_target = |
907 static_cast<MockSyntheticPinchTouchTarget*>(target_); | 907 static_cast<MockSyntheticPinchTouchTarget*>(target_); |
908 EXPECT_EQ(1, num_success_); | 908 EXPECT_EQ(1, num_success_); |
909 EXPECT_EQ(0, num_failure_); | 909 EXPECT_EQ(0, num_failure_); |
910 EXPECT_EQ(pinch_target->zoom_direction(), | 910 EXPECT_EQ(pinch_target->zoom_direction(), |
911 MockSyntheticPinchTouchTarget::ZOOM_IN); | 911 MockSyntheticPinchTouchTarget::ZOOM_IN); |
912 EXPECT_FLOAT_EQ(params.scale_factor, pinch_target->ComputeScaleFactor()); | 912 EXPECT_FLOAT_EQ(params.scale_factor, pinch_target->ComputeScaleFactor()); |
913 } | 913 } |
914 | 914 |
915 TEST_F(SyntheticGestureControllerTest, PinchGestureTouchZoomOut) { | 915 TEST_F(SyntheticGestureControllerTest, PinchGestureTouchZoomOut) { |
916 CreateControllerAndTarget<MockSyntheticPinchTouchTarget>(); | 916 CreateControllerAndTarget<MockSyntheticPinchTouchTarget>(); |
917 | 917 |
918 SyntheticPinchGestureParams params; | 918 SyntheticPinchGestureParams params; |
919 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 919 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
920 params.scale_factor = 0.4f; | 920 params.scale_factor = 0.4f; |
921 params.anchor.SetPoint(-12, 93); | 921 params.anchor.SetPoint(-12, 93); |
922 | 922 |
923 scoped_ptr<SyntheticPinchGesture> gesture(new SyntheticPinchGesture(params)); | 923 scoped_ptr<SyntheticPinchGesture> gesture(new SyntheticPinchGesture(params)); |
924 QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); | 924 QueueSyntheticGesture(gesture.Pass()); |
925 FlushInputUntilComplete(); | 925 FlushInputUntilComplete(); |
926 | 926 |
927 MockSyntheticPinchTouchTarget* pinch_target = | 927 MockSyntheticPinchTouchTarget* pinch_target = |
928 static_cast<MockSyntheticPinchTouchTarget*>(target_); | 928 static_cast<MockSyntheticPinchTouchTarget*>(target_); |
929 EXPECT_EQ(1, num_success_); | 929 EXPECT_EQ(1, num_success_); |
930 EXPECT_EQ(0, num_failure_); | 930 EXPECT_EQ(0, num_failure_); |
931 EXPECT_EQ(pinch_target->zoom_direction(), | 931 EXPECT_EQ(pinch_target->zoom_direction(), |
932 MockSyntheticPinchTouchTarget::ZOOM_OUT); | 932 MockSyntheticPinchTouchTarget::ZOOM_OUT); |
933 EXPECT_FLOAT_EQ(params.scale_factor, pinch_target->ComputeScaleFactor()); | 933 EXPECT_FLOAT_EQ(params.scale_factor, pinch_target->ComputeScaleFactor()); |
934 } | 934 } |
935 | 935 |
936 TEST_F(SyntheticGestureControllerTest, PinchGestureTouchNoScaling) { | 936 TEST_F(SyntheticGestureControllerTest, PinchGestureTouchNoScaling) { |
937 CreateControllerAndTarget<MockSyntheticPinchTouchTarget>(); | 937 CreateControllerAndTarget<MockSyntheticPinchTouchTarget>(); |
938 | 938 |
939 SyntheticPinchGestureParams params; | 939 SyntheticPinchGestureParams params; |
940 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 940 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
941 params.scale_factor = 1.0f; | 941 params.scale_factor = 1.0f; |
942 | 942 |
943 scoped_ptr<SyntheticPinchGesture> gesture(new SyntheticPinchGesture(params)); | 943 scoped_ptr<SyntheticPinchGesture> gesture(new SyntheticPinchGesture(params)); |
944 QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); | 944 QueueSyntheticGesture(gesture.Pass()); |
945 FlushInputUntilComplete(); | 945 FlushInputUntilComplete(); |
946 | 946 |
947 MockSyntheticPinchTouchTarget* pinch_target = | 947 MockSyntheticPinchTouchTarget* pinch_target = |
948 static_cast<MockSyntheticPinchTouchTarget*>(target_); | 948 static_cast<MockSyntheticPinchTouchTarget*>(target_); |
949 EXPECT_EQ(1, num_success_); | 949 EXPECT_EQ(1, num_success_); |
950 EXPECT_EQ(0, num_failure_); | 950 EXPECT_EQ(0, num_failure_); |
951 EXPECT_EQ(pinch_target->zoom_direction(), | 951 EXPECT_EQ(pinch_target->zoom_direction(), |
952 MockSyntheticPinchTouchTarget::ZOOM_DIRECTION_UNKNOWN); | 952 MockSyntheticPinchTouchTarget::ZOOM_DIRECTION_UNKNOWN); |
953 EXPECT_EQ(params.scale_factor, pinch_target->ComputeScaleFactor()); | 953 EXPECT_EQ(params.scale_factor, pinch_target->ComputeScaleFactor()); |
954 } | 954 } |
955 | 955 |
956 TEST_F(SyntheticGestureControllerTest, TapGestureTouch) { | 956 TEST_F(SyntheticGestureControllerTest, TapGestureTouch) { |
957 CreateControllerAndTarget<MockSyntheticTapTouchTarget>(); | 957 CreateControllerAndTarget<MockSyntheticTapTouchTarget>(); |
958 | 958 |
959 SyntheticTapGestureParams params; | 959 SyntheticTapGestureParams params; |
960 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 960 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
961 params.duration_ms = 123; | 961 params.duration_ms = 123; |
962 params.position.SetPoint(87, -124); | 962 params.position.SetPoint(87, -124); |
963 | 963 |
964 scoped_ptr<SyntheticTapGesture> gesture(new SyntheticTapGesture(params)); | 964 scoped_ptr<SyntheticTapGesture> gesture(new SyntheticTapGesture(params)); |
965 QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); | 965 QueueSyntheticGesture(gesture.Pass()); |
966 FlushInputUntilComplete(); | 966 FlushInputUntilComplete(); |
967 | 967 |
968 MockSyntheticTapTouchTarget* tap_target = | 968 MockSyntheticTapTouchTarget* tap_target = |
969 static_cast<MockSyntheticTapTouchTarget*>(target_); | 969 static_cast<MockSyntheticTapTouchTarget*>(target_); |
970 EXPECT_EQ(1, num_success_); | 970 EXPECT_EQ(1, num_success_); |
971 EXPECT_EQ(0, num_failure_); | 971 EXPECT_EQ(0, num_failure_); |
972 EXPECT_TRUE(tap_target->GestureFinished()); | 972 EXPECT_TRUE(tap_target->GestureFinished()); |
973 EXPECT_EQ(tap_target->position(), params.position); | 973 EXPECT_EQ(tap_target->position(), params.position); |
974 EXPECT_EQ(tap_target->GetDuration().InMilliseconds(), params.duration_ms); | 974 EXPECT_EQ(tap_target->GetDuration().InMilliseconds(), params.duration_ms); |
975 EXPECT_GE(GetTotalTime(), | 975 EXPECT_GE(GetTotalTime(), |
976 base::TimeDelta::FromMilliseconds(params.duration_ms)); | 976 base::TimeDelta::FromMilliseconds(params.duration_ms)); |
977 } | 977 } |
978 | 978 |
979 TEST_F(SyntheticGestureControllerTest, TapGestureMouse) { | 979 TEST_F(SyntheticGestureControllerTest, TapGestureMouse) { |
980 CreateControllerAndTarget<MockSyntheticTapMouseTarget>(); | 980 CreateControllerAndTarget<MockSyntheticTapMouseTarget>(); |
981 | 981 |
982 SyntheticTapGestureParams params; | 982 SyntheticTapGestureParams params; |
983 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; | 983 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; |
984 params.duration_ms = 79; | 984 params.duration_ms = 79; |
985 params.position.SetPoint(98, 123); | 985 params.position.SetPoint(98, 123); |
986 | 986 |
987 scoped_ptr<SyntheticTapGesture> gesture(new SyntheticTapGesture(params)); | 987 scoped_ptr<SyntheticTapGesture> gesture(new SyntheticTapGesture(params)); |
988 QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); | 988 QueueSyntheticGesture(gesture.Pass()); |
989 FlushInputUntilComplete(); | 989 FlushInputUntilComplete(); |
990 | 990 |
991 MockSyntheticTapMouseTarget* tap_target = | 991 MockSyntheticTapMouseTarget* tap_target = |
992 static_cast<MockSyntheticTapMouseTarget*>(target_); | 992 static_cast<MockSyntheticTapMouseTarget*>(target_); |
993 EXPECT_EQ(1, num_success_); | 993 EXPECT_EQ(1, num_success_); |
994 EXPECT_EQ(0, num_failure_); | 994 EXPECT_EQ(0, num_failure_); |
995 EXPECT_TRUE(tap_target->GestureFinished()); | 995 EXPECT_TRUE(tap_target->GestureFinished()); |
996 EXPECT_EQ(tap_target->position(), params.position); | 996 EXPECT_EQ(tap_target->position(), params.position); |
997 EXPECT_EQ(tap_target->GetDuration().InMilliseconds(), params.duration_ms); | 997 EXPECT_EQ(tap_target->GetDuration().InMilliseconds(), params.duration_ms); |
998 EXPECT_GE(GetTotalTime(), | 998 EXPECT_GE(GetTotalTime(), |
999 base::TimeDelta::FromMilliseconds(params.duration_ms)); | 999 base::TimeDelta::FromMilliseconds(params.duration_ms)); |
1000 } | 1000 } |
1001 | 1001 |
1002 } // namespace | 1002 } // namespace |
1003 | 1003 |
1004 } // namespace content | 1004 } // namespace content |
OLD | NEW |