summaryrefslogtreecommitdiffstats
path: root/ui/aura/gestures
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-09 23:59:19 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-09 23:59:19 +0000
commit9f6fafd7ac3b0c53e8eba4f0ccc98a0d25696ab3 (patch)
tree99e1081f9453e29afd703bb965e1b7e97f2180ce /ui/aura/gestures
parent66030bd55aa2c710f5f2eab35dab1a624e0dea38 (diff)
downloadchromium_src-9f6fafd7ac3b0c53e8eba4f0ccc98a0d25696ab3.zip
chromium_src-9f6fafd7ac3b0c53e8eba4f0ccc98a0d25696ab3.tar.gz
chromium_src-9f6fafd7ac3b0c53e8eba4f0ccc98a0d25696ab3.tar.bz2
aura: Fix setting touch-handler and gesture-handler for asynchronous gestures.
Make sure touch-handler is set when the window queues up touch-events (ie. returns TOUCH_STATUS_QUEUED). Also, set the proper gesture-handler when doing asynchronous gesture processing. BUG=110236 TEST=aura_unittests:GestureRecognizerTest.* Review URL: https://chromiumcodereview.appspot.com/9370032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121340 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura/gestures')
-rw-r--r--ui/aura/gestures/gesture_recognizer_unittest.cc80
1 files changed, 67 insertions, 13 deletions
diff --git a/ui/aura/gestures/gesture_recognizer_unittest.cc b/ui/aura/gestures/gesture_recognizer_unittest.cc
index 1f3bd33..3a3636d 100644
--- a/ui/aura/gestures/gesture_recognizer_unittest.cc
+++ b/ui/aura/gestures/gesture_recognizer_unittest.cc
@@ -124,7 +124,8 @@ class QueueTouchEventDelegate : public GestureEventConsumeDelegate {
virtual ~QueueTouchEventDelegate() {}
virtual ui::TouchStatus OnTouchEvent(TouchEvent* event) OVERRIDE {
- return ui::TOUCH_STATUS_QUEUED;
+ return event->type() == ui::ET_TOUCH_RELEASED ?
+ ui::TOUCH_STATUS_QUEUED_END : ui::TOUCH_STATUS_QUEUED;
}
void ReceivedAck() {
@@ -452,6 +453,21 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
EXPECT_FALSE(queued_delegate->scroll_update());
EXPECT_FALSE(queued_delegate->scroll_end());
+ // Introduce some delay before the touch is released so that it is recognized
+ // as a tap. However, this still should not create any gesture events.
+ queued_delegate->Reset();
+ TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 0);
+ Event::TestApi test_release(&release);
+ test_release.set_time_stamp(press.time_stamp() +
+ base::TimeDelta::FromMilliseconds(50));
+ RootWindow::GetInstance()->DispatchTouchEvent(&release);
+ EXPECT_FALSE(queued_delegate->tap());
+ EXPECT_FALSE(queued_delegate->tap_down());
+ EXPECT_FALSE(queued_delegate->double_tap());
+ EXPECT_FALSE(queued_delegate->scroll_begin());
+ EXPECT_FALSE(queued_delegate->scroll_update());
+ EXPECT_FALSE(queued_delegate->scroll_end());
+
// Create another window, and place a touch-down on it. This should create a
// tap-down gesture.
scoped_ptr<GestureEventConsumeDelegate> delegate(
@@ -468,14 +484,51 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
EXPECT_FALSE(delegate->scroll_update());
EXPECT_FALSE(delegate->scroll_end());
- // Introduce some delay before the touch is released so that it is recognized
- // as a tap. However, this still should not create any gesture events.
+ TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(10, 20), 0);
+ RootWindow::GetInstance()->DispatchTouchEvent(&release2);
+
+ // Process the first queued event.
queued_delegate->Reset();
- TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 0);
- Event::TestApi test_release(&release);
- test_release.set_time_stamp(press.time_stamp() +
- base::TimeDelta::FromMilliseconds(50));
- RootWindow::GetInstance()->DispatchTouchEvent(&release);
+ queued_delegate->ReceivedAck();
+ EXPECT_FALSE(queued_delegate->tap());
+ EXPECT_TRUE(queued_delegate->tap_down());
+ EXPECT_FALSE(queued_delegate->double_tap());
+ EXPECT_FALSE(queued_delegate->scroll_begin());
+ EXPECT_FALSE(queued_delegate->scroll_update());
+ EXPECT_FALSE(queued_delegate->scroll_end());
+
+ // Now, process the second queued event.
+ queued_delegate->Reset();
+ queued_delegate->ReceivedAck();
+ EXPECT_TRUE(queued_delegate->tap());
+ EXPECT_FALSE(queued_delegate->tap_down());
+ EXPECT_FALSE(queued_delegate->double_tap());
+ EXPECT_FALSE(queued_delegate->scroll_begin());
+ EXPECT_FALSE(queued_delegate->scroll_update());
+ EXPECT_FALSE(queued_delegate->scroll_end());
+
+ // Start all over. Press on the first window, then press again on the second
+ // window. The second press should still go to the first window.
+ queued_delegate->Reset();
+ TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 0);
+ RootWindow::GetInstance()->DispatchTouchEvent(&press3);
+ EXPECT_FALSE(queued_delegate->tap());
+ EXPECT_FALSE(queued_delegate->tap_down());
+ EXPECT_FALSE(queued_delegate->double_tap());
+ EXPECT_FALSE(queued_delegate->scroll_begin());
+ EXPECT_FALSE(queued_delegate->scroll_update());
+ EXPECT_FALSE(queued_delegate->scroll_end());
+
+ queued_delegate->Reset();
+ delegate->Reset();
+ TouchEvent press4(ui::ET_TOUCH_PRESSED, gfx::Point(10, 20), 1);
+ RootWindow::GetInstance()->DispatchTouchEvent(&press4);
+ EXPECT_FALSE(delegate->tap());
+ EXPECT_FALSE(delegate->tap_down());
+ EXPECT_FALSE(delegate->double_tap());
+ EXPECT_FALSE(delegate->scroll_begin());
+ EXPECT_FALSE(delegate->scroll_update());
+ EXPECT_FALSE(delegate->scroll_end());
EXPECT_FALSE(queued_delegate->tap());
EXPECT_FALSE(queued_delegate->tap_down());
EXPECT_FALSE(queued_delegate->double_tap());
@@ -483,7 +536,6 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
EXPECT_FALSE(queued_delegate->scroll_update());
EXPECT_FALSE(queued_delegate->scroll_end());
- // Process the first queued event.
queued_delegate->Reset();
queued_delegate->ReceivedAck();
EXPECT_FALSE(queued_delegate->tap());
@@ -493,15 +545,17 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
EXPECT_FALSE(queued_delegate->scroll_update());
EXPECT_FALSE(queued_delegate->scroll_end());
- // Now, process the second queued event.
queued_delegate->Reset();
queued_delegate->ReceivedAck();
- EXPECT_TRUE(queued_delegate->tap());
- EXPECT_FALSE(queued_delegate->tap_down());
+ EXPECT_FALSE(queued_delegate->tap());
+ EXPECT_TRUE(queued_delegate->tap_down());
EXPECT_FALSE(queued_delegate->double_tap());
- EXPECT_FALSE(queued_delegate->scroll_begin());
+ EXPECT_TRUE(queued_delegate->scroll_begin());
EXPECT_FALSE(queued_delegate->scroll_update());
EXPECT_FALSE(queued_delegate->scroll_end());
+ EXPECT_TRUE(queued_delegate->pinch_begin());
+ EXPECT_FALSE(queued_delegate->pinch_update());
+ EXPECT_FALSE(queued_delegate->pinch_end());
}
// Check that appropriate touch events generate pinch gesture events.