Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(495)

Unified Diff: ui/aura/gestures/gesture_recognizer_unittest.cc

Issue 10831295: gesture recognizer: Change the way a processed touch-release event is handled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/base/gestures/gesture_sequence.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 0248672f84301a91477a77ac6c5de5c0fbaa84fb..12a9d2682fc38a054dfaabc92bed9f0d9e6ae51e 100644
--- a/ui/aura/gestures/gesture_recognizer_unittest.cc
+++ b/ui/aura/gestures/gesture_recognizer_unittest.cc
@@ -1883,6 +1883,90 @@ TEST_F(GestureRecognizerTest, NoTapWithPreventDefaultedRelease) {
EXPECT_FALSE(delegate->tap());
}
+TEST_F(GestureRecognizerTest, PinchScrollWithPreventDefaultedRelease) {
+ scoped_ptr<QueueTouchEventDelegate> delegate(
+ new QueueTouchEventDelegate(root_window()));
+ const int kTouchId1 = 7;
+ const int kTouchId2 = 5;
+ gfx::Rect bounds(10, 20, 100, 100);
+ scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
+ delegate.get(), -1234, bounds, NULL));
+ delegate->set_window(window.get());
+
+ delegate->Reset();
+ ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(15, 25), kTouchId1,
+ GetTime());
+ ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(20, 95), kTouchId1,
+ press.time_stamp() + base::TimeDelta::FromMilliseconds(200));
+ ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(15, 25), kTouchId1,
+ move.time_stamp() + base::TimeDelta::FromMilliseconds(50));
+ root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
+ root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move);
+ root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release);
+ delegate->Reset();
+
+ // Ack the press event.
+ delegate->ReceivedAck();
+ EXPECT_TRUE(delegate->tap_down());
+ delegate->Reset();
+
+ // Ack the move event.
+ delegate->ReceivedAck();
+ EXPECT_TRUE(delegate->scroll_begin());
+ delegate->Reset();
+
+ // Ack the release event. Although the release event has been processed, it
+ // should still generate a scroll-end event.
+ delegate->ReceivedAckPreventDefaulted();
+ EXPECT_TRUE(delegate->scroll_end());
+
+ ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(55, 25), kTouchId2,
+ GetTime());
+ ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(45, 85), kTouchId2,
+ press2.time_stamp() + base::TimeDelta::FromMilliseconds(1000));
+ ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(45, 85), kTouchId2,
+ move2.time_stamp() + base::TimeDelta::FromMilliseconds(14));
+
+ // Do a pinch.
+ root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
+ root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move);
+ root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2);
+ root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2);
+ root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release);
+ root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release2);
+
+ // Ack the press and move events.
+ delegate->Reset();
+ delegate->ReceivedAck();
+ EXPECT_TRUE(delegate->begin());
+ EXPECT_TRUE(delegate->tap_down());
+
+ delegate->Reset();
+ delegate->ReceivedAck();
+ EXPECT_TRUE(delegate->scroll_begin());
+
+ delegate->Reset();
+ delegate->ReceivedAck();
+ EXPECT_TRUE(delegate->begin());
+ EXPECT_FALSE(delegate->pinch_begin());
+
+ delegate->Reset();
+ delegate->ReceivedAck();
+ EXPECT_TRUE(delegate->pinch_begin());
+
+ // Ack the first release. Although the release is processed, it should still
+ // generate a pinch-end event.
+ delegate->Reset();
+ delegate->ReceivedAckPreventDefaulted();
+ EXPECT_TRUE(delegate->pinch_end());
+ EXPECT_TRUE(delegate->end());
+
+ delegate->Reset();
+ delegate->ReceivedAckPreventDefaulted();
+ EXPECT_TRUE(delegate->scroll_end());
+ EXPECT_TRUE(delegate->end());
+}
+
TEST_F(GestureRecognizerTest, CaptureSendsGestureEnd) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
« no previous file with comments | « no previous file | ui/base/gestures/gesture_sequence.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698