Commit 21e657e7 authored by tdresser@chromium.org's avatar tdresser@chromium.org

Previously our handling of ignored touches would put the gesture recognizer...

Previously our handling of ignored touches would put the gesture recognizer into a very confused state.

BUG=405519
TEST=GestureRecognizerTest.IgnoredEventsDontPreventFutureEvents

Review URL: https://codereview.chromium.org/489213003

Cr-Commit-Position: refs/heads/master@{#291255}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@291255 0039d316-1c4b-4281-b951-d872f2087c98
parent 074e9858
...@@ -4214,5 +4214,54 @@ TEST_F(GestureRecognizerTest, EagerGestureDetection) { ...@@ -4214,5 +4214,54 @@ TEST_F(GestureRecognizerTest, EagerGestureDetection) {
EXPECT_FALSE(delegate->long_press()); EXPECT_FALSE(delegate->long_press());
} }
// This tests crbug.com/405519, in which events which the gesture detector
// ignores cause future events to also be thrown away.
TEST_F(GestureRecognizerTest, IgnoredEventsDontPreventFutureEvents) {
scoped_ptr<QueueTouchEventDelegate> delegate(
new QueueTouchEventDelegate(host()->dispatcher()));
TimedEvents tes;
const int kWindowWidth = 300;
const int kWindowHeight = 400;
const int kTouchId1 = 3;
gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight);
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
delegate.get(), -1234, bounds, root_window()));
delegate->set_window(window.get());
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), kTouchId1, tes.Now());
DispatchEventUsingWindowDispatcher(&press1);
delegate->ReceivedAck();
EXPECT_2_EVENTS(
delegate->events(), ui::ET_GESTURE_BEGIN, ui::ET_GESTURE_TAP_DOWN);
// Move the first finger.
delegate->Reset();
ui::TouchEvent move1(
ui::ET_TOUCH_MOVED, gfx::Point(65, 201), kTouchId1, tes.Now());
DispatchEventUsingWindowDispatcher(&move1);
delegate->ReceivedAck();
EXPECT_3_EVENTS(delegate->events(),
ui::ET_GESTURE_TAP_CANCEL,
ui::ET_GESTURE_SCROLL_BEGIN,
ui::ET_GESTURE_SCROLL_UPDATE);
delegate->Reset();
ui::TouchEvent move2(
ui::ET_TOUCH_MOVED, gfx::Point(65, 202), kTouchId1, tes.Now());
DispatchEventUsingWindowDispatcher(&move2);
// Send a touchmove event at the same location as the previous touchmove
// event. This shouldn't do anything.
ui::TouchEvent move3(
ui::ET_TOUCH_MOVED, gfx::Point(65, 202), kTouchId1, tes.Now());
DispatchEventUsingWindowDispatcher(&move3);
delegate->ReceivedAck();
EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE);
}
} // namespace test } // namespace test
} // namespace aura } // namespace aura
...@@ -893,11 +893,11 @@ void WindowEventDispatcher::PreDispatchTouchEvent(Window* target, ...@@ -893,11 +893,11 @@ void WindowEventDispatcher::PreDispatchTouchEvent(Window* target,
ui::TouchEvent orig_event(*event, target, window()); ui::TouchEvent orig_event(*event, target, window());
// If the touch event is invalid in some way, the gesture recognizer will // If the touch event is invalid in some way, the gesture recognizer will
// reject it. In this case, stop the touch from reaching the next event // reject it. This must call |StopPropagation()|, in order to prevent the
// phase. // touch from being acked in |PostDispatchEvent|.
if (!ui::GestureRecognizer::Get()->ProcessTouchEventPreDispatch(orig_event, if (!ui::GestureRecognizer::Get()->ProcessTouchEventPreDispatch(orig_event,
target)) { target)) {
event->SetHandled(); event->StopPropagation();
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment