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

Side by Side Diff: ui/aura/gestures/gesture_recognizer_unittest.cc

Issue 489213003: Prevent double acking of ignored touches (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Switch to calling StopPropagation on ignored events. Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/aura/window_event_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/memory/scoped_vector.h" 6 #include "base/memory/scoped_vector.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/timer/timer.h" 9 #include "base/timer/timer.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 4196 matching lines...) Expand 10 before | Expand all | Expand 10 after
4207 delegate->Reset(); 4207 delegate->Reset();
4208 // Wait until the long press event would fire (if we weren't eager). 4208 // Wait until the long press event would fire (if we weren't eager).
4209 DelayByLongPressTimeout(); 4209 DelayByLongPressTimeout();
4210 4210
4211 // Ack the touch release. 4211 // Ack the touch release.
4212 delegate->ReceivedAck(); 4212 delegate->ReceivedAck();
4213 EXPECT_TRUE(delegate->tap()); 4213 EXPECT_TRUE(delegate->tap());
4214 EXPECT_FALSE(delegate->long_press()); 4214 EXPECT_FALSE(delegate->long_press());
4215 } 4215 }
4216 4216
4217 // This tests crbug.com/405519, in which events which the gesture detector
4218 // ignores cause future events to also be thrown away.
4219 TEST_F(GestureRecognizerTest, IgnoredEventsDontPreventFutureEvents) {
4220 scoped_ptr<QueueTouchEventDelegate> delegate(
4221 new QueueTouchEventDelegate(host()->dispatcher()));
4222 TimedEvents tes;
4223 const int kWindowWidth = 300;
4224 const int kWindowHeight = 400;
4225 const int kTouchId1 = 3;
4226 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight);
4227 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
4228 delegate.get(), -1234, bounds, root_window()));
4229 delegate->set_window(window.get());
4230
4231 ui::TouchEvent press1(
4232 ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), kTouchId1, tes.Now());
4233 DispatchEventUsingWindowDispatcher(&press1);
4234 delegate->ReceivedAck();
4235
4236 EXPECT_2_EVENTS(
4237 delegate->events(), ui::ET_GESTURE_BEGIN, ui::ET_GESTURE_TAP_DOWN);
4238
4239 // Move the first finger.
4240 delegate->Reset();
4241 ui::TouchEvent move1(
4242 ui::ET_TOUCH_MOVED, gfx::Point(65, 201), kTouchId1, tes.Now());
4243 DispatchEventUsingWindowDispatcher(&move1);
4244 delegate->ReceivedAck();
4245
4246 EXPECT_3_EVENTS(delegate->events(),
4247 ui::ET_GESTURE_TAP_CANCEL,
4248 ui::ET_GESTURE_SCROLL_BEGIN,
4249 ui::ET_GESTURE_SCROLL_UPDATE);
4250
4251 delegate->Reset();
4252 ui::TouchEvent move2(
4253 ui::ET_TOUCH_MOVED, gfx::Point(65, 202), kTouchId1, tes.Now());
4254 DispatchEventUsingWindowDispatcher(&move2);
4255
4256 // Send a touchmove event at the same location as the previous touchmove
4257 // event. This shouldn't do anything.
4258 ui::TouchEvent move3(
4259 ui::ET_TOUCH_MOVED, gfx::Point(65, 202), kTouchId1, tes.Now());
4260 DispatchEventUsingWindowDispatcher(&move3);
4261
4262 delegate->ReceivedAck();
4263 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE);
4264 }
4265
4217 } // namespace test 4266 } // namespace test
4218 } // namespace aura 4267 } // namespace aura
OLDNEW
« no previous file with comments | « no previous file | ui/aura/window_event_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698