Chromium Code Reviews| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/memory/scoped_vector.h" | 6 #include "base/memory/scoped_vector.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 3723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3734 | 3734 |
| 3735 delegate->Reset(); | 3735 delegate->Reset(); |
| 3736 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 3736 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 3737 kTouchId, tes.LeapForward(50)); | 3737 kTouchId, tes.LeapForward(50)); |
| 3738 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1); | 3738 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release1); |
| 3739 EXPECT_TRUE(delegate->show_press()); | 3739 EXPECT_TRUE(delegate->show_press()); |
| 3740 EXPECT_FALSE(delegate->tap_cancel()); | 3740 EXPECT_FALSE(delegate->tap_cancel()); |
| 3741 EXPECT_TRUE(delegate->tap()); | 3741 EXPECT_TRUE(delegate->tap()); |
| 3742 } | 3742 } |
| 3743 | 3743 |
| 3744 // Test that consuming the first move touch event prevents a scroll. | |
| 3745 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveScrollTest) { | |
| 3746 scoped_ptr<QueueTouchEventDelegate> delegate( | |
| 3747 new QueueTouchEventDelegate(dispatcher())); | |
| 3748 TimedEvents tes; | |
| 3749 const int kTouchId = 7; | |
| 3750 gfx::Rect bounds(0, 0, 1000, 1000); | |
| 3751 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | |
| 3752 delegate.get(), -1234, bounds, root_window())); | |
| 3753 | |
| 3754 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), | |
| 3755 kTouchId, tes.Now()); | |
| 3756 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | |
| 3757 delegate->ReceivedAck(); | |
| 3758 | |
| 3759 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(2, 2), | |
| 3760 kTouchId, tes.Now()); | |
| 3761 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move1); | |
| 3762 delegate->ReceivedAckPreventDefaulted(); | |
| 3763 | |
| 3764 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), | |
| 3765 kTouchId, tes.Now()); | |
| 3766 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move2); | |
| 3767 delegate->ReceivedAck(); | |
| 3768 | |
| 3769 EXPECT_FALSE(delegate->scroll_update()); | |
|
sadrul
2014/01/17 17:11:35
EXPECT_FALSE(scroll_begin()) too?
tdresser
2014/01/17 19:48:42
Done.
| |
| 3770 } | |
|
sadrul
2014/01/17 17:11:35
Add a test as above, with the addition of a second
tdresser
2014/01/17 19:48:42
Done.
| |
| 3771 | |
| 3772 // Test that consuming the first move touch doesn't prevent a tap. | |
| 3773 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveTapTest) { | |
| 3774 scoped_ptr<QueueTouchEventDelegate> delegate( | |
| 3775 new QueueTouchEventDelegate(dispatcher())); | |
| 3776 TimedEvents tes; | |
| 3777 const int kTouchId = 7; | |
| 3778 gfx::Rect bounds(0, 0, 1000, 1000); | |
| 3779 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | |
| 3780 delegate.get(), -1234, bounds, root_window())); | |
| 3781 | |
| 3782 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), | |
| 3783 kTouchId, tes.Now()); | |
| 3784 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | |
| 3785 delegate->ReceivedAck(); | |
| 3786 | |
| 3787 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(2, 2), | |
| 3788 kTouchId, tes.Now()); | |
| 3789 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move); | |
| 3790 delegate->ReceivedAckPreventDefaulted(); | |
| 3791 | |
| 3792 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(2, 2), | |
| 3793 kTouchId, tes.LeapForward(50)); | |
| 3794 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | |
| 3795 delegate->ReceivedAck(); | |
| 3796 | |
| 3797 EXPECT_TRUE(delegate->tap()); | |
| 3798 } | |
| 3799 | |
| 3800 // Test that consuming the first move touch doesn't prevent a long press. | |
| 3801 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveLongPressTest) { | |
| 3802 scoped_ptr<QueueTouchEventDelegate> delegate( | |
| 3803 new QueueTouchEventDelegate(dispatcher())); | |
| 3804 TimedEvents tes; | |
| 3805 const int kWindowWidth = 123; | |
| 3806 const int kWindowHeight = 45; | |
| 3807 const int kTouchId = 2; | |
| 3808 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | |
| 3809 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | |
| 3810 delegate.get(), -1234, bounds, root_window())); | |
| 3811 | |
| 3812 delegate->Reset(); | |
| 3813 | |
| 3814 TimerTestGestureRecognizer* gesture_recognizer = | |
| 3815 new TimerTestGestureRecognizer(); | |
| 3816 | |
| 3817 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); | |
| 3818 | |
| 3819 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | |
| 3820 kTouchId, tes.Now()); | |
| 3821 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); | |
| 3822 delegate->ReceivedAck(); | |
| 3823 | |
| 3824 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(103, 203), | |
| 3825 kTouchId, tes.Now()); | |
| 3826 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move); | |
| 3827 delegate->ReceivedAckPreventDefaulted(); | |
| 3828 | |
| 3829 // Wait until the timer runs out | |
| 3830 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS); | |
| 3831 EXPECT_TRUE(delegate->long_press()); | |
| 3832 } | |
| 3833 | |
| 3744 } // namespace test | 3834 } // namespace test |
| 3745 } // namespace aura | 3835 } // namespace aura |
| OLD | NEW |