| 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 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 EXPECT_TRUE(delegate->end()); | 564 EXPECT_TRUE(delegate->end()); |
| 565 EXPECT_FALSE(delegate->double_tap()); | 565 EXPECT_FALSE(delegate->double_tap()); |
| 566 EXPECT_FALSE(delegate->scroll_begin()); | 566 EXPECT_FALSE(delegate->scroll_begin()); |
| 567 EXPECT_FALSE(delegate->scroll_update()); | 567 EXPECT_FALSE(delegate->scroll_update()); |
| 568 EXPECT_FALSE(delegate->scroll_end()); | 568 EXPECT_FALSE(delegate->scroll_end()); |
| 569 | 569 |
| 570 EXPECT_EQ(1, delegate->tap_count()); | 570 EXPECT_EQ(1, delegate->tap_count()); |
| 571 gfx::Point actual_point(delegate->tap_location()); | 571 gfx::Point actual_point(delegate->tap_location()); |
| 572 EXPECT_EQ(24, delegate->bounding_box().width()); | 572 EXPECT_EQ(24, delegate->bounding_box().width()); |
| 573 EXPECT_EQ(24, delegate->bounding_box().height()); | 573 EXPECT_EQ(24, delegate->bounding_box().height()); |
| 574 EXPECT_EQ(101, actual_point.x()); | 574 EXPECT_EQ(100, actual_point.x()); |
| 575 EXPECT_EQ(201, actual_point.y()); | 575 EXPECT_EQ(200, actual_point.y()); |
| 576 } | 576 } |
| 577 | 577 |
| 578 // Test with no ET_TOUCH_MOVED events but different touch points and radii. | 578 // Test with no ET_TOUCH_MOVED events but different touch points and radii. |
| 579 { | 579 { |
| 580 delegate->Reset(); | 580 delegate->Reset(); |
| 581 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(365, 290), | 581 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(365, 290), |
| 582 kTouchId, GetTime()); | 582 kTouchId, GetTime()); |
| 583 press.set_radius_x(8); | 583 press.set_radius_x(8); |
| 584 press.set_radius_y(14); | 584 press.set_radius_y(14); |
| 585 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); | 585 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 608 EXPECT_TRUE(delegate->end()); | 608 EXPECT_TRUE(delegate->end()); |
| 609 EXPECT_FALSE(delegate->double_tap()); | 609 EXPECT_FALSE(delegate->double_tap()); |
| 610 EXPECT_FALSE(delegate->scroll_begin()); | 610 EXPECT_FALSE(delegate->scroll_begin()); |
| 611 EXPECT_FALSE(delegate->scroll_update()); | 611 EXPECT_FALSE(delegate->scroll_update()); |
| 612 EXPECT_FALSE(delegate->scroll_end()); | 612 EXPECT_FALSE(delegate->scroll_end()); |
| 613 | 613 |
| 614 EXPECT_EQ(1, delegate->tap_count()); | 614 EXPECT_EQ(1, delegate->tap_count()); |
| 615 gfx::Point actual_point(delegate->tap_location()); | 615 gfx::Point actual_point(delegate->tap_location()); |
| 616 EXPECT_EQ(40, delegate->bounding_box().width()); | 616 EXPECT_EQ(40, delegate->bounding_box().width()); |
| 617 EXPECT_EQ(40, delegate->bounding_box().height()); | 617 EXPECT_EQ(40, delegate->bounding_box().height()); |
| 618 EXPECT_EQ(367, actual_point.x()); | 618 EXPECT_EQ(366, actual_point.x()); |
| 619 EXPECT_EQ(291, actual_point.y()); | 619 EXPECT_EQ(290, actual_point.y()); |
| 620 } | 620 } |
| 621 | 621 |
| 622 // Test with a single ET_TOUCH_MOVED event. | 622 // Test with a single ET_TOUCH_MOVED event. |
| 623 { | 623 { |
| 624 delegate->Reset(); | 624 delegate->Reset(); |
| 625 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(46, 205), | 625 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(46, 205), |
| 626 kTouchId, GetTime()); | 626 kTouchId, GetTime()); |
| 627 press.set_radius_x(6); | 627 press.set_radius_x(6); |
| 628 press.set_radius_y(10); | 628 press.set_radius_y(10); |
| 629 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); | 629 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 EXPECT_FALSE(delegate->double_tap()); | 671 EXPECT_FALSE(delegate->double_tap()); |
| 672 EXPECT_FALSE(delegate->scroll_begin()); | 672 EXPECT_FALSE(delegate->scroll_begin()); |
| 673 EXPECT_FALSE(delegate->scroll_update()); | 673 EXPECT_FALSE(delegate->scroll_update()); |
| 674 EXPECT_FALSE(delegate->scroll_end()); | 674 EXPECT_FALSE(delegate->scroll_end()); |
| 675 | 675 |
| 676 EXPECT_EQ(1, delegate->tap_count()); | 676 EXPECT_EQ(1, delegate->tap_count()); |
| 677 gfx::Point actual_point(delegate->tap_location()); | 677 gfx::Point actual_point(delegate->tap_location()); |
| 678 EXPECT_EQ(25, delegate->bounding_box().width()); | 678 EXPECT_EQ(25, delegate->bounding_box().width()); |
| 679 EXPECT_EQ(24, delegate->bounding_box().height()); | 679 EXPECT_EQ(24, delegate->bounding_box().height()); |
| 680 EXPECT_EQ(48, actual_point.x()); | 680 EXPECT_EQ(48, actual_point.x()); |
| 681 EXPECT_EQ(204, actual_point.y()); | 681 EXPECT_EQ(203, actual_point.y()); |
| 682 } | 682 } |
| 683 | 683 |
| 684 // Test with a few ET_TOUCH_MOVED events. | 684 // Test with a few ET_TOUCH_MOVED events. |
| 685 { | 685 { |
| 686 delegate->Reset(); | 686 delegate->Reset(); |
| 687 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(400, 150), | 687 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(400, 150), |
| 688 kTouchId, GetTime()); | 688 kTouchId, GetTime()); |
| 689 press.set_radius_x(7); | 689 press.set_radius_x(7); |
| 690 press.set_radius_y(10); | 690 press.set_radius_y(10); |
| 691 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); | 691 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 EXPECT_FALSE(delegate->double_tap()); | 766 EXPECT_FALSE(delegate->double_tap()); |
| 767 EXPECT_FALSE(delegate->scroll_begin()); | 767 EXPECT_FALSE(delegate->scroll_begin()); |
| 768 EXPECT_FALSE(delegate->scroll_update()); | 768 EXPECT_FALSE(delegate->scroll_update()); |
| 769 EXPECT_FALSE(delegate->scroll_end()); | 769 EXPECT_FALSE(delegate->scroll_end()); |
| 770 | 770 |
| 771 EXPECT_EQ(1, delegate->tap_count()); | 771 EXPECT_EQ(1, delegate->tap_count()); |
| 772 gfx::Point actual_point(delegate->tap_location()); | 772 gfx::Point actual_point(delegate->tap_location()); |
| 773 EXPECT_EQ(33, delegate->bounding_box().width()); | 773 EXPECT_EQ(33, delegate->bounding_box().width()); |
| 774 EXPECT_EQ(32, delegate->bounding_box().height()); | 774 EXPECT_EQ(32, delegate->bounding_box().height()); |
| 775 EXPECT_EQ(397, actual_point.x()); | 775 EXPECT_EQ(397, actual_point.x()); |
| 776 EXPECT_EQ(149, actual_point.y()); | 776 EXPECT_EQ(148, actual_point.y()); |
| 777 } | 777 } |
| 778 } | 778 } |
| 779 | 779 |
| 780 // Check that appropriate touch events generate scroll gesture events. | 780 // Check that appropriate touch events generate scroll gesture events. |
| 781 TEST_F(GestureRecognizerTest, GestureEventScroll) { | 781 TEST_F(GestureRecognizerTest, GestureEventScroll) { |
| 782 scoped_ptr<GestureEventConsumeDelegate> delegate( | 782 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 783 new GestureEventConsumeDelegate()); | 783 new GestureEventConsumeDelegate()); |
| 784 const int kWindowWidth = 123; | 784 const int kWindowWidth = 123; |
| 785 const int kWindowHeight = 45; | 785 const int kWindowHeight = 45; |
| 786 const int kTouchId = 5; | 786 const int kTouchId = 5; |
| (...skipping 2115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2902 press1.time_stamp() + base::TimeDelta::FromMilliseconds(40)); | 2902 press1.time_stamp() + base::TimeDelta::FromMilliseconds(40)); |
| 2903 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move4); | 2903 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move4); |
| 2904 EXPECT_TRUE(delegate->scroll_update()); | 2904 EXPECT_TRUE(delegate->scroll_update()); |
| 2905 EXPECT_EQ(-1, delegate->scroll_y()); | 2905 EXPECT_EQ(-1, delegate->scroll_y()); |
| 2906 | 2906 |
| 2907 delegate->Reset(); | 2907 delegate->Reset(); |
| 2908 } | 2908 } |
| 2909 | 2909 |
| 2910 } // namespace test | 2910 } // namespace test |
| 2911 } // namespace aura | 2911 } // namespace aura |
| OLD | NEW |