diff options
author | boliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-13 18:19:14 +0000 |
---|---|---|
committer | boliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-13 18:19:14 +0000 |
commit | 85c2a3d46dd8cbdee6eb85ca99af062c31ac0cc0 (patch) | |
tree | dff2de8ce5ff1411a3ea35fd00accd3cd40d217e /content | |
parent | 12b6f612c91c63cfeb9c7ef530e3a007b0366802 (diff) | |
download | chromium_src-85c2a3d46dd8cbdee6eb85ca99af062c31ac0cc0.zip chromium_src-85c2a3d46dd8cbdee6eb85ca99af062c31ac0cc0.tar.gz chromium_src-85c2a3d46dd8cbdee6eb85ca99af062c31ac0cc0.tar.bz2 |
[Android] Cancel long press on ACTION_CANCEL as well
Public documentation says CANCEL should be treated similarly to UP
except it should not be peforming any of the actual actions.
BUG=
Android only change. Ran through android trybots.
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/12223101
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182254 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/public/android/java/src/org/chromium/content/browser/LongPressDetector.java | 1 | ||||
-rw-r--r-- | content/public/android/javatests/src/org/chromium/content/browser/LongPressDetectorTest.java | 33 |
2 files changed, 25 insertions, 9 deletions
diff --git a/content/public/android/java/src/org/chromium/content/browser/LongPressDetector.java b/content/public/android/java/src/org/chromium/content/browser/LongPressDetector.java index 0e48db1..5bd73ad0 100644 --- a/content/public/android/java/src/org/chromium/content/browser/LongPressDetector.java +++ b/content/public/android/java/src/org/chromium/content/browser/LongPressDetector.java @@ -109,6 +109,7 @@ class LongPressDetector { } break; case MotionEvent.ACTION_UP: + case MotionEvent.ACTION_CANCEL: if (mCurrentDownEvent.getDownTime() + TAP_TIMEOUT + LONGPRESS_TIMEOUT > ev.getEventTime()) { mInLongPress = false; diff --git a/content/public/android/javatests/src/org/chromium/content/browser/LongPressDetectorTest.java b/content/public/android/javatests/src/org/chromium/content/browser/LongPressDetectorTest.java index 4994ac4..f334817 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/LongPressDetectorTest.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/LongPressDetectorTest.java @@ -51,14 +51,7 @@ public class LongPressDetectorTest extends InstrumentationTestCase { assertTrue("Should have a pending LONG_PRESS", mLongPressDetector.hasPendingMessage()); } - /** - * Verify a DOWN with a corresponding UP will not have a pending Gesture. - * - * @throws Exception - */ - @SmallTest - @Feature({"AndroidWebView"}) - public void testGestureNoLongPress() throws Exception { + private void gestureNoLongPressTestHelper(int cancelActionType) throws Exception { final long downTime = SystemClock.uptimeMillis(); final long eventTime = SystemClock.uptimeMillis(); @@ -67,12 +60,34 @@ public class LongPressDetectorTest extends InstrumentationTestCase { assertTrue("Should have a pending LONG_PRESS", mLongPressDetector.hasPendingMessage()); - event = motionEvent(MotionEvent.ACTION_UP, downTime, eventTime + 10); + event = motionEvent(cancelActionType, downTime, eventTime + 10); mLongPressDetector.cancelLongPressIfNeeded(event); assertTrue("Should not have a pending LONG_PRESS", !mLongPressDetector.hasPendingMessage()); } /** + * Verify a DOWN with a corresponding UP will not have a pending Gesture. + * + * @throws Exception + */ + @SmallTest + @Feature({"AndroidWebView"}) + public void testGestureNoLongPressOnUp() throws Exception { + gestureNoLongPressTestHelper(MotionEvent.ACTION_UP); + } + + /** + * Verify a DOWN with a corresponding CANCEL will not have a pending Gesture. + * + * @throws Exception + */ + @SmallTest + @Feature({"AndroidWebView"}) + public void testGestureNoLongPressOnCancel() throws Exception { + gestureNoLongPressTestHelper(MotionEvent.ACTION_CANCEL); + } + + /** * Verify that a DOWN followed by an UP after the long press timer would * detect a long press (that is, the UP will not trigger a tap or cancel the * long press). |