summaryrefslogtreecommitdiffstats
path: root/ui/aura
diff options
context:
space:
mode:
authorrbyers@chromium.org <rbyers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-17 21:07:20 +0000
committerrbyers@chromium.org <rbyers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-17 21:07:20 +0000
commit41f79692680de91ba6e9e43c2ddd2184ffd3619c (patch)
tree98dcff853fe6a513bce3011efb1b31e97951d276 /ui/aura
parent60ccc243dfbfc86001cf1c0a4b44131a39d7d28d (diff)
downloadchromium_src-41f79692680de91ba6e9e43c2ddd2184ffd3619c.zip
chromium_src-41f79692680de91ba6e9e43c2ddd2184ffd3619c.tar.gz
chromium_src-41f79692680de91ba6e9e43c2ddd2184ffd3619c.tar.bz2
Fix getting tap events on scroll gestures when touchmove is consumed
Regression introduced in r158592. The GesturePoint::UpdateForScroll call was having the side-effect of making the InInsideManhattanSquare check for a click always return true. This is a quick fix designed to be easily merged back to M23 - just don't update the notion of the starting position of a scroll on consumed touchmove events. BUG=154844 Review URL: https://chromiumcodereview.appspot.com/11147015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162521 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura')
-rw-r--r--ui/aura/gestures/gesture_recognizer_unittest.cc74
1 files changed, 67 insertions, 7 deletions
diff --git a/ui/aura/gestures/gesture_recognizer_unittest.cc b/ui/aura/gestures/gesture_recognizer_unittest.cc
index 2405df9..adc6419 100644
--- a/ui/aura/gestures/gesture_recognizer_unittest.cc
+++ b/ui/aura/gestures/gesture_recognizer_unittest.cc
@@ -2530,8 +2530,8 @@ class ConsumesTouchMovesDelegate : public GestureEventConsumeDelegate {
DISALLOW_COPY_AND_ASSIGN(ConsumesTouchMovesDelegate);
};
-// Same as GestureEventScroll, but tests the different behaviour for consumed
-// touch-move events before and after scroll has started.
+// Same as GestureEventScroll, but tests that the behavior is the same
+// even if all the touch-move events are consumed.
TEST_F(GestureRecognizerTest, GestureEventScrollTouchMoveConsumed) {
scoped_ptr<ConsumesTouchMovesDelegate> delegate(
new ConsumesTouchMovesDelegate());
@@ -2557,8 +2557,66 @@ TEST_F(GestureRecognizerTest, GestureEventScrollTouchMoveConsumed) {
// Move the touch-point enough so that it would normally be considered a
// scroll. But since the touch-moves will be consumed, the scroll should not
- // start. We should, however, get the TAP_CANCEL event now (since it's now
- // impossible for the gesture to become a tap).
+ // start.
+ SendScrollEvent(root_window(), 130, 230, kTouchId, delegate.get());
+ EXPECT_FALSE(delegate->tap());
+ EXPECT_FALSE(delegate->tap_down());
+ // TODO(rbyers): Really we should get the TapCancel here instead of below,
+ // but this is a symptom of a larger issue: crbug.com/146397.
+ EXPECT_FALSE(delegate->tap_cancel());
+ EXPECT_FALSE(delegate->begin());
+ EXPECT_FALSE(delegate->double_tap());
+ EXPECT_FALSE(delegate->scroll_begin());
+ EXPECT_FALSE(delegate->scroll_update());
+ EXPECT_FALSE(delegate->scroll_end());
+
+ // Release the touch back at the start point. This should end without causing
+ // a tap.
+ delegate->Reset();
+ ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(130, 230),
+ kTouchId, press.time_stamp() +
+ base::TimeDelta::FromMilliseconds(50));
+ root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release);
+ EXPECT_FALSE(delegate->tap());
+ EXPECT_FALSE(delegate->tap_down());
+ EXPECT_TRUE(delegate->tap_cancel());
+ EXPECT_FALSE(delegate->begin());
+ EXPECT_TRUE(delegate->end());
+ EXPECT_FALSE(delegate->double_tap());
+ EXPECT_FALSE(delegate->scroll_begin());
+ EXPECT_FALSE(delegate->scroll_update());
+ EXPECT_FALSE(delegate->scroll_end());
+}
+
+// Like as GestureEventTouchMoveConsumed but tests the different behavior
+// depending on whether the events were consumed before or after the scroll
+// started.
+TEST_F(GestureRecognizerTest, GestureEventScrollTouchMovePartialConsumed) {
+ scoped_ptr<ConsumesTouchMovesDelegate> delegate(
+ new ConsumesTouchMovesDelegate());
+ const int kWindowWidth = 123;
+ const int kWindowHeight = 45;
+ const int kTouchId = 5;
+ gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
+ scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
+ delegate.get(), -1234, bounds, NULL));
+
+ delegate->Reset();
+ ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
+ kTouchId, GetTime());
+ root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
+ EXPECT_FALSE(delegate->tap());
+ EXPECT_TRUE(delegate->tap_down());
+ EXPECT_FALSE(delegate->tap_cancel());
+ EXPECT_TRUE(delegate->begin());
+ EXPECT_FALSE(delegate->double_tap());
+ EXPECT_FALSE(delegate->scroll_begin());
+ EXPECT_FALSE(delegate->scroll_update());
+ EXPECT_FALSE(delegate->scroll_end());
+
+ // Move the touch-point enough so that it would normally be considered a
+ // scroll. But since the touch-moves will be consumed, the scroll should not
+ // start.
SendScrollEvent(root_window(), 130, 230, kTouchId, delegate.get());
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -2582,9 +2640,11 @@ TEST_F(GestureRecognizerTest, GestureEventScrollTouchMoveConsumed) {
EXPECT_TRUE(delegate->scroll_begin());
EXPECT_TRUE(delegate->scroll_update());
EXPECT_FALSE(delegate->scroll_end());
- EXPECT_EQ(29, delegate->scroll_x());
- EXPECT_EQ(29, delegate->scroll_y());
- EXPECT_EQ(gfx::Point(30, 30).ToString(),
+ // Consuming move events doesn't effect what the ultimate scroll position
+ // will be if scrolling is later allowed to happen.
+ EXPECT_EQ(58, delegate->scroll_x());
+ EXPECT_EQ(58, delegate->scroll_y());
+ EXPECT_EQ(gfx::Point(1, 1).ToString(),
delegate->scroll_begin_position().ToString());
// Start consuming touch-move events again. However, since gesture-scroll has