Index: ui/aura/gestures/gesture_recognizer_unittest.cc |
diff --git a/ui/aura/gestures/gesture_recognizer_unittest.cc b/ui/aura/gestures/gesture_recognizer_unittest.cc |
index 529af63eec609bca004c8ad5f804503b0d14d19e..ee7135bc730d0ac87fea133fdff88bfb2ca8a0e9 100644 |
--- a/ui/aura/gestures/gesture_recognizer_unittest.cc |
+++ b/ui/aura/gestures/gesture_recognizer_unittest.cc |
@@ -3741,5 +3741,95 @@ TEST_F(GestureRecognizerTest, GestureEventShowPressSentOnTap) { |
EXPECT_TRUE(delegate->tap()); |
} |
+// Test that consuming the first move touch event prevents a scroll. |
+TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveScrollTest) { |
+ scoped_ptr<QueueTouchEventDelegate> delegate( |
+ new QueueTouchEventDelegate(dispatcher())); |
+ TimedEvents tes; |
+ const int kTouchId = 7; |
+ gfx::Rect bounds(0, 0, 1000, 1000); |
+ scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
+ delegate.get(), -1234, bounds, root_window())); |
+ |
+ ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), |
+ kTouchId, tes.Now()); |
+ dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); |
+ delegate->ReceivedAck(); |
+ |
+ ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(2, 2), |
+ kTouchId, tes.Now()); |
+ dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move1); |
+ delegate->ReceivedAckPreventDefaulted(); |
+ |
+ ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), |
+ kTouchId, tes.Now()); |
+ dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move2); |
+ delegate->ReceivedAck(); |
+ |
+ 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.
|
+} |
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.
|
+ |
+// Test that consuming the first move touch doesn't prevent a tap. |
+TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveTapTest) { |
+ scoped_ptr<QueueTouchEventDelegate> delegate( |
+ new QueueTouchEventDelegate(dispatcher())); |
+ TimedEvents tes; |
+ const int kTouchId = 7; |
+ gfx::Rect bounds(0, 0, 1000, 1000); |
+ scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
+ delegate.get(), -1234, bounds, root_window())); |
+ |
+ ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), |
+ kTouchId, tes.Now()); |
+ dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); |
+ delegate->ReceivedAck(); |
+ |
+ ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(2, 2), |
+ kTouchId, tes.Now()); |
+ dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move); |
+ delegate->ReceivedAckPreventDefaulted(); |
+ |
+ ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(2, 2), |
+ kTouchId, tes.LeapForward(50)); |
+ dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); |
+ delegate->ReceivedAck(); |
+ |
+ EXPECT_TRUE(delegate->tap()); |
+} |
+ |
+// Test that consuming the first move touch doesn't prevent a long press. |
+TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveLongPressTest) { |
+ scoped_ptr<QueueTouchEventDelegate> delegate( |
+ new QueueTouchEventDelegate(dispatcher())); |
+ TimedEvents tes; |
+ const int kWindowWidth = 123; |
+ const int kWindowHeight = 45; |
+ const int kTouchId = 2; |
+ gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
+ scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
+ delegate.get(), -1234, bounds, root_window())); |
+ |
+ delegate->Reset(); |
+ |
+ TimerTestGestureRecognizer* gesture_recognizer = |
+ new TimerTestGestureRecognizer(); |
+ |
+ ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); |
+ |
+ ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
+ kTouchId, tes.Now()); |
+ dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1); |
+ delegate->ReceivedAck(); |
+ |
+ ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(103, 203), |
+ kTouchId, tes.Now()); |
+ dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move); |
+ delegate->ReceivedAckPreventDefaulted(); |
+ |
+ // Wait until the timer runs out |
+ delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS); |
+ EXPECT_TRUE(delegate->long_press()); |
+} |
+ |
} // namespace test |
} // namespace aura |