OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/memory/scoped_vector.h" | 5 #include "base/memory/scoped_vector.h" |
6 #include "base/string_number_conversions.h" | 6 #include "base/string_number_conversions.h" |
7 #include "base/timer.h" | 7 #include "base/timer.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "ui/aura/root_window.h" | 9 #include "ui/aura/root_window.h" |
10 #include "ui/aura/test/aura_test_base.h" | 10 #include "ui/aura/test/aura_test_base.h" |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 EXPECT_FALSE(delegate->tap()); | 525 EXPECT_FALSE(delegate->tap()); |
526 EXPECT_TRUE(delegate->tap_down()); | 526 EXPECT_TRUE(delegate->tap_down()); |
527 EXPECT_TRUE(delegate->begin()); | 527 EXPECT_TRUE(delegate->begin()); |
528 EXPECT_FALSE(delegate->double_tap()); | 528 EXPECT_FALSE(delegate->double_tap()); |
529 EXPECT_FALSE(delegate->scroll_begin()); | 529 EXPECT_FALSE(delegate->scroll_begin()); |
530 EXPECT_FALSE(delegate->scroll_update()); | 530 EXPECT_FALSE(delegate->scroll_update()); |
531 EXPECT_FALSE(delegate->scroll_end()); | 531 EXPECT_FALSE(delegate->scroll_end()); |
532 EXPECT_FALSE(delegate->long_press()); | 532 EXPECT_FALSE(delegate->long_press()); |
533 | 533 |
534 delegate->Reset(); | 534 delegate->Reset(); |
535 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(377, 291), | 535 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(367, 291), |
536 kTouchId, press.time_stamp() + | 536 kTouchId, press.time_stamp() + |
537 base::TimeDelta::FromMilliseconds(50)); | 537 base::TimeDelta::FromMilliseconds(50)); |
538 release.set_radius_x(20); | 538 release.set_radius_x(20); |
539 release.set_radius_y(13); | 539 release.set_radius_y(13); |
540 | 540 |
541 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); | 541 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); |
542 EXPECT_TRUE(delegate->tap()); | 542 EXPECT_TRUE(delegate->tap()); |
543 EXPECT_FALSE(delegate->tap_down()); | 543 EXPECT_FALSE(delegate->tap_down()); |
544 EXPECT_FALSE(delegate->begin()); | 544 EXPECT_FALSE(delegate->begin()); |
545 EXPECT_TRUE(delegate->end()); | 545 EXPECT_TRUE(delegate->end()); |
546 EXPECT_FALSE(delegate->double_tap()); | 546 EXPECT_FALSE(delegate->double_tap()); |
547 EXPECT_FALSE(delegate->scroll_begin()); | 547 EXPECT_FALSE(delegate->scroll_begin()); |
548 EXPECT_FALSE(delegate->scroll_update()); | 548 EXPECT_FALSE(delegate->scroll_update()); |
549 EXPECT_FALSE(delegate->scroll_end()); | 549 EXPECT_FALSE(delegate->scroll_end()); |
550 | 550 |
551 EXPECT_EQ(1, delegate->tap_count()); | 551 EXPECT_EQ(1, delegate->tap_count()); |
552 gfx::Point actual_point(delegate->tap_location()); | 552 gfx::Point actual_point(delegate->tap_location()); |
553 EXPECT_EQ(46, delegate->bounding_box().width()); | 553 EXPECT_EQ(40, delegate->bounding_box().width()); |
554 EXPECT_EQ(40, delegate->bounding_box().height()); | 554 EXPECT_EQ(40, delegate->bounding_box().height()); |
555 EXPECT_EQ(373, actual_point.x()); | 555 EXPECT_EQ(366, actual_point.x()); |
556 EXPECT_EQ(290, actual_point.y()); | 556 EXPECT_EQ(290, actual_point.y()); |
557 } | 557 } |
558 | 558 |
559 // Test with a single ET_TOUCH_MOVED event. | 559 // Test with a single ET_TOUCH_MOVED event. |
560 { | 560 { |
561 delegate->Reset(); | 561 delegate->Reset(); |
562 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(46, 205), | 562 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(46, 205), |
563 kTouchId, GetTime()); | 563 kTouchId, GetTime()); |
564 press.set_radius_x(6); | 564 press.set_radius_x(6); |
565 press.set_radius_y(10); | 565 press.set_radius_y(10); |
566 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); | 566 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); |
567 EXPECT_FALSE(delegate->tap()); | 567 EXPECT_FALSE(delegate->tap()); |
568 EXPECT_TRUE(delegate->tap_down()); | 568 EXPECT_TRUE(delegate->tap_down()); |
569 EXPECT_TRUE(delegate->begin()); | 569 EXPECT_TRUE(delegate->begin()); |
570 EXPECT_FALSE(delegate->double_tap()); | 570 EXPECT_FALSE(delegate->double_tap()); |
571 EXPECT_FALSE(delegate->scroll_begin()); | 571 EXPECT_FALSE(delegate->scroll_begin()); |
572 EXPECT_FALSE(delegate->scroll_update()); | 572 EXPECT_FALSE(delegate->scroll_update()); |
573 EXPECT_FALSE(delegate->scroll_end()); | 573 EXPECT_FALSE(delegate->scroll_end()); |
574 EXPECT_FALSE(delegate->long_press()); | 574 EXPECT_FALSE(delegate->long_press()); |
575 | 575 |
576 delegate->Reset(); | 576 delegate->Reset(); |
577 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(52, 200), | 577 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(49, 204), |
578 kTouchId, press.time_stamp() + | 578 kTouchId, press.time_stamp() + |
579 base::TimeDelta::FromMilliseconds(50)); | 579 base::TimeDelta::FromMilliseconds(50)); |
580 move.set_radius_x(8); | 580 move.set_radius_x(8); |
581 move.set_radius_y(12); | 581 move.set_radius_y(12); |
582 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move); | 582 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move); |
583 EXPECT_FALSE(delegate->tap()); | 583 EXPECT_FALSE(delegate->tap()); |
584 EXPECT_FALSE(delegate->tap_down()); | 584 EXPECT_FALSE(delegate->tap_down()); |
585 EXPECT_FALSE(delegate->begin()); | 585 EXPECT_FALSE(delegate->begin()); |
586 EXPECT_FALSE(delegate->double_tap()); | 586 EXPECT_FALSE(delegate->double_tap()); |
587 EXPECT_FALSE(delegate->scroll_begin()); | 587 EXPECT_FALSE(delegate->scroll_begin()); |
588 EXPECT_FALSE(delegate->scroll_update()); | 588 EXPECT_FALSE(delegate->scroll_update()); |
589 EXPECT_FALSE(delegate->scroll_end()); | 589 EXPECT_FALSE(delegate->scroll_end()); |
590 EXPECT_FALSE(delegate->long_press()); | 590 EXPECT_FALSE(delegate->long_press()); |
591 | 591 |
592 delegate->Reset(); | 592 delegate->Reset(); |
593 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(50, 195), | 593 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(49, 204), |
594 kTouchId, press.time_stamp() + | 594 kTouchId, press.time_stamp() + |
595 base::TimeDelta::FromMilliseconds(50)); | 595 base::TimeDelta::FromMilliseconds(50)); |
596 release.set_radius_x(4); | 596 release.set_radius_x(4); |
597 release.set_radius_y(8); | 597 release.set_radius_y(8); |
598 | 598 |
599 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); | 599 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); |
600 EXPECT_TRUE(delegate->tap()); | 600 EXPECT_TRUE(delegate->tap()); |
601 EXPECT_FALSE(delegate->tap_down()); | 601 EXPECT_FALSE(delegate->tap_down()); |
602 EXPECT_FALSE(delegate->begin()); | 602 EXPECT_FALSE(delegate->begin()); |
603 EXPECT_TRUE(delegate->end()); | 603 EXPECT_TRUE(delegate->end()); |
604 EXPECT_FALSE(delegate->double_tap()); | 604 EXPECT_FALSE(delegate->double_tap()); |
605 EXPECT_FALSE(delegate->scroll_begin()); | 605 EXPECT_FALSE(delegate->scroll_begin()); |
606 EXPECT_FALSE(delegate->scroll_update()); | 606 EXPECT_FALSE(delegate->scroll_update()); |
607 EXPECT_FALSE(delegate->scroll_end()); | 607 EXPECT_FALSE(delegate->scroll_end()); |
608 | 608 |
609 EXPECT_EQ(1, delegate->tap_count()); | 609 EXPECT_EQ(1, delegate->tap_count()); |
610 gfx::Point actual_point(delegate->tap_location()); | 610 gfx::Point actual_point(delegate->tap_location()); |
611 EXPECT_EQ(28, delegate->bounding_box().width()); | 611 EXPECT_EQ(25, delegate->bounding_box().width()); |
612 EXPECT_EQ(28, delegate->bounding_box().height()); | 612 EXPECT_EQ(24, delegate->bounding_box().height()); |
613 EXPECT_EQ(49, actual_point.x()); | 613 EXPECT_EQ(48, actual_point.x()); |
614 EXPECT_EQ(200, actual_point.y()); | 614 EXPECT_EQ(203, actual_point.y()); |
615 } | 615 } |
616 | 616 |
617 // Test with a few ET_TOUCH_MOVED events. | 617 // Test with a few ET_TOUCH_MOVED events. |
618 { | 618 { |
619 delegate->Reset(); | 619 delegate->Reset(); |
620 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(400, 150), | 620 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(400, 150), |
621 kTouchId, GetTime()); | 621 kTouchId, GetTime()); |
622 press.set_radius_x(7); | 622 press.set_radius_x(7); |
623 press.set_radius_y(10); | 623 press.set_radius_y(10); |
624 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); | 624 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); |
625 EXPECT_FALSE(delegate->tap()); | 625 EXPECT_FALSE(delegate->tap()); |
626 EXPECT_TRUE(delegate->tap_down()); | 626 EXPECT_TRUE(delegate->tap_down()); |
627 EXPECT_TRUE(delegate->begin()); | 627 EXPECT_TRUE(delegate->begin()); |
628 EXPECT_FALSE(delegate->double_tap()); | 628 EXPECT_FALSE(delegate->double_tap()); |
629 EXPECT_FALSE(delegate->scroll_begin()); | 629 EXPECT_FALSE(delegate->scroll_begin()); |
630 EXPECT_FALSE(delegate->scroll_update()); | 630 EXPECT_FALSE(delegate->scroll_update()); |
631 EXPECT_FALSE(delegate->scroll_end()); | 631 EXPECT_FALSE(delegate->scroll_end()); |
632 EXPECT_FALSE(delegate->long_press()); | 632 EXPECT_FALSE(delegate->long_press()); |
633 | 633 |
634 delegate->Reset(); | 634 delegate->Reset(); |
635 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(397, 155), | 635 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(397, 151), |
636 kTouchId, press.time_stamp() + | 636 kTouchId, press.time_stamp() + |
637 base::TimeDelta::FromMilliseconds(50)); | 637 base::TimeDelta::FromMilliseconds(50)); |
638 move.set_radius_x(13); | 638 move.set_radius_x(13); |
639 move.set_radius_y(12); | 639 move.set_radius_y(12); |
640 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move); | 640 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move); |
641 EXPECT_FALSE(delegate->tap()); | 641 EXPECT_FALSE(delegate->tap()); |
642 EXPECT_FALSE(delegate->tap_down()); | 642 EXPECT_FALSE(delegate->tap_down()); |
643 EXPECT_FALSE(delegate->begin()); | 643 EXPECT_FALSE(delegate->begin()); |
644 EXPECT_FALSE(delegate->double_tap()); | 644 EXPECT_FALSE(delegate->double_tap()); |
645 EXPECT_FALSE(delegate->scroll_begin()); | 645 EXPECT_FALSE(delegate->scroll_begin()); |
646 EXPECT_FALSE(delegate->scroll_update()); | 646 EXPECT_FALSE(delegate->scroll_update()); |
647 EXPECT_FALSE(delegate->scroll_end()); | 647 EXPECT_FALSE(delegate->scroll_end()); |
648 EXPECT_FALSE(delegate->long_press()); | 648 EXPECT_FALSE(delegate->long_press()); |
649 | 649 |
650 delegate->Reset(); | 650 delegate->Reset(); |
651 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(395, 148), | 651 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(397, 149), |
652 kTouchId, move.time_stamp() + | 652 kTouchId, move.time_stamp() + |
653 base::TimeDelta::FromMilliseconds(50)); | 653 base::TimeDelta::FromMilliseconds(50)); |
654 move1.set_radius_x(16); | 654 move1.set_radius_x(16); |
655 move1.set_radius_y(16); | 655 move1.set_radius_y(16); |
656 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move1); | 656 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move1); |
657 EXPECT_FALSE(delegate->tap()); | 657 EXPECT_FALSE(delegate->tap()); |
658 EXPECT_FALSE(delegate->tap_down()); | 658 EXPECT_FALSE(delegate->tap_down()); |
659 EXPECT_FALSE(delegate->begin()); | 659 EXPECT_FALSE(delegate->begin()); |
660 EXPECT_FALSE(delegate->double_tap()); | 660 EXPECT_FALSE(delegate->double_tap()); |
661 EXPECT_FALSE(delegate->scroll_begin()); | 661 EXPECT_FALSE(delegate->scroll_begin()); |
(...skipping 29 matching lines...) Expand all Loading... |
691 EXPECT_FALSE(delegate->tap_down()); | 691 EXPECT_FALSE(delegate->tap_down()); |
692 EXPECT_FALSE(delegate->begin()); | 692 EXPECT_FALSE(delegate->begin()); |
693 EXPECT_TRUE(delegate->end()); | 693 EXPECT_TRUE(delegate->end()); |
694 EXPECT_FALSE(delegate->double_tap()); | 694 EXPECT_FALSE(delegate->double_tap()); |
695 EXPECT_FALSE(delegate->scroll_begin()); | 695 EXPECT_FALSE(delegate->scroll_begin()); |
696 EXPECT_FALSE(delegate->scroll_update()); | 696 EXPECT_FALSE(delegate->scroll_update()); |
697 EXPECT_FALSE(delegate->scroll_end()); | 697 EXPECT_FALSE(delegate->scroll_end()); |
698 | 698 |
699 EXPECT_EQ(1, delegate->tap_count()); | 699 EXPECT_EQ(1, delegate->tap_count()); |
700 gfx::Point actual_point(delegate->tap_location()); | 700 gfx::Point actual_point(delegate->tap_location()); |
701 EXPECT_EQ(35, delegate->bounding_box().width()); | 701 EXPECT_EQ(33, delegate->bounding_box().width()); |
702 EXPECT_EQ(36, delegate->bounding_box().height()); | 702 EXPECT_EQ(32, delegate->bounding_box().height()); |
703 EXPECT_EQ(396, actual_point.x()); | 703 EXPECT_EQ(397, actual_point.x()); |
704 EXPECT_EQ(149, actual_point.y()); | 704 EXPECT_EQ(148, actual_point.y()); |
705 } | 705 } |
706 } | 706 } |
707 | 707 |
708 // Check that appropriate touch events generate scroll gesture events. | 708 // Check that appropriate touch events generate scroll gesture events. |
709 TEST_F(GestureRecognizerTest, GestureEventScroll) { | 709 TEST_F(GestureRecognizerTest, GestureEventScroll) { |
710 scoped_ptr<GestureEventConsumeDelegate> delegate( | 710 scoped_ptr<GestureEventConsumeDelegate> delegate( |
711 new GestureEventConsumeDelegate()); | 711 new GestureEventConsumeDelegate()); |
712 const int kWindowWidth = 123; | 712 const int kWindowWidth = 123; |
713 const int kWindowHeight = 45; | 713 const int kWindowHeight = 45; |
714 const int kTouchId = 5; | 714 const int kTouchId = 5; |
(...skipping 2048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2763 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2); | 2763 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2); |
2764 EXPECT_FALSE(delegate->tap()); | 2764 EXPECT_FALSE(delegate->tap()); |
2765 EXPECT_FALSE(delegate->scroll_update()); | 2765 EXPECT_FALSE(delegate->scroll_update()); |
2766 EXPECT_FALSE(delegate->pinch_update()); | 2766 EXPECT_FALSE(delegate->pinch_update()); |
2767 | 2767 |
2768 delegate->Reset(); | 2768 delegate->Reset(); |
2769 } | 2769 } |
2770 | 2770 |
2771 } // namespace test | 2771 } // namespace test |
2772 } // namespace aura | 2772 } // namespace aura |
OLD | NEW |