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

Unified Diff: ui/events/gesture_detection/gesture_provider_unittest.cc

Issue 717573004: [Android] Thoroughly reset gesture detection upon page navigation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment Created 6 years, 1 month 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 | « ui/events/gesture_detection/gesture_provider.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/gesture_detection/gesture_provider_unittest.cc
diff --git a/ui/events/gesture_detection/gesture_provider_unittest.cc b/ui/events/gesture_detection/gesture_provider_unittest.cc
index 4c4dedd0ec95a0e1614932a60718f299894bc581..8f73a4a916b970806581194874949322420294d1 100644
--- a/ui/events/gesture_detection/gesture_provider_unittest.cc
+++ b/ui/events/gesture_detection/gesture_provider_unittest.cc
@@ -143,9 +143,10 @@ class GestureProviderTest : public testing::Test, public GestureProviderClient {
}
void ResetGestureDetection() {
- CancelActiveTouchSequence();
+ gesture_provider_->ResetDetection();
gestures_.clear();
}
+
bool CancelActiveTouchSequence() {
if (!gesture_provider_->current_down_event())
return false;
@@ -609,7 +610,7 @@ TEST_F(GestureProviderTest, FlingEventSequence) {
<< "FlingStart should have the time of the ACTION_UP";
}
-TEST_F(GestureProviderTest, GestureCancelledWhenWindowFocusLost) {
+TEST_F(GestureProviderTest, GestureCancelledOnCancelEvent) {
const base::TimeTicks event_time = TimeTicks::Now();
MockMotionEvent event =
@@ -622,7 +623,8 @@ TEST_F(GestureProviderTest, GestureCancelledWhenWindowFocusLost) {
EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SHOW_PRESS));
EXPECT_EQ(ET_GESTURE_LONG_PRESS, GetMostRecentGestureEventType());
- // The long press triggers window focus loss by opening a context menu.
+ // A cancellation event may be triggered for a number of reasons, e.g.,
+ // from a context-menu-triggering long press resulting in loss of focus.
EXPECT_TRUE(CancelActiveTouchSequence());
EXPECT_FALSE(HasDownEvent());
@@ -632,6 +634,28 @@ TEST_F(GestureProviderTest, GestureCancelledWhenWindowFocusLost) {
EXPECT_FALSE(gesture_provider_->OnTouchEvent(event));
}
+TEST_F(GestureProviderTest, GestureCancelledOnDetectionReset) {
+ const base::TimeTicks event_time = TimeTicks::Now();
+
+ MockMotionEvent event =
+ ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+ EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
+
+ RunTasksAndWait(GetLongPressTimeout() + GetShowPressTimeout() +
+ kOneMicrosecond);
+ EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SHOW_PRESS));
+ EXPECT_EQ(ET_GESTURE_LONG_PRESS, GetMostRecentGestureEventType());
+
+ ResetGestureDetection();
+ EXPECT_FALSE(HasDownEvent());
+
+ // A final ACTION_UP should have no effect.
+ event = ObtainMotionEvent(event_time + kOneMicrosecond * 2,
+ MotionEvent::ACTION_UP);
+ EXPECT_FALSE(gesture_provider_->OnTouchEvent(event));
+}
+
TEST_F(GestureProviderTest, NoTapAfterScrollBegins) {
base::TimeTicks event_time = base::TimeTicks::Now();
« no previous file with comments | « ui/events/gesture_detection/gesture_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698