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

Unified Diff: content/public/android/javatests/src/org/chromium/content/browser/ContentViewGestureHandlerTest.java

Issue 27220002: [Android] Properly handle cancelled scroll events (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tests detect this as a fling??!? Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/ZoomManager.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/javatests/src/org/chromium/content/browser/ContentViewGestureHandlerTest.java
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/ContentViewGestureHandlerTest.java b/content/public/android/javatests/src/org/chromium/content/browser/ContentViewGestureHandlerTest.java
index a05863fab915ebdce55cbfd55c00b9e47fede5c0..1e2691be1b7a4df8b115aa2055a3b0183fcbb042 100644
--- a/content/public/android/javatests/src/org/chromium/content/browser/ContentViewGestureHandlerTest.java
+++ b/content/public/android/javatests/src/org/chromium/content/browser/ContentViewGestureHandlerTest.java
@@ -596,6 +596,75 @@ public class ContentViewGestureHandlerTest extends InstrumentationTestCase {
}
/**
+ * Verify that for a normal scroll the following events are sent:
+ * - GESTURE_SCROLL_START
+ * - GESTURE_SCROLL_BY
+ * - GESTURE_SCROLL_END
+ * @throws Exception
+ */
+ @SmallTest
+ @Feature({"Gestures"})
+ public void testScrollEventActionUpSequence() throws Exception {
+ checkScrollEventSequenceForEndActionType(MotionEvent.ACTION_UP);
+ }
+
+ /**
+ * Verify that for a cancelled scroll the following events are sent:
+ * - GESTURE_SCROLL_START
+ * - GESTURE_SCROLL_BY
+ * - GESTURE_SCROLL_END
+ * @throws Exception
+ */
+ @SmallTest
+ @Feature({"Gestures"})
+ public void testScrollEventActionCancelSequence() throws Exception {
+ checkScrollEventSequenceForEndActionType(MotionEvent.ACTION_CANCEL);
+ }
+
+ private void checkScrollEventSequenceForEndActionType(int endActionType) throws Exception {
+ final long downTime = SystemClock.uptimeMillis();
+ final long eventTime = SystemClock.uptimeMillis();
+ final int scrollToX = FAKE_COORD_X + 100;
+ final int scrollToY = FAKE_COORD_Y + 100;
+
+ GestureRecordingMotionEventDelegate mockDelegate =
+ new GestureRecordingMotionEventDelegate();
+ mGestureHandler = new ContentViewGestureHandler(
+ getInstrumentation().getTargetContext(), mockDelegate, mMockZoomManager,
+ ContentViewCore.INPUT_EVENTS_DELIVERED_AT_VSYNC);
+
+ MotionEvent event = motionEvent(MotionEvent.ACTION_DOWN, downTime, downTime);
+
+ assertTrue(mGestureHandler.onTouchEvent(event));
+
+ event = MotionEvent.obtain(
+ downTime, eventTime + 1000, MotionEvent.ACTION_MOVE, scrollToX, scrollToY, 0);
+ assertTrue(mGestureHandler.onTouchEvent(event));
+ assertTrue(mGestureHandler.isNativeScrolling());
+ assertTrue("A scrollStart event should have been sent",
+ mockDelegate.mGestureTypeList.contains(
+ ContentViewGestureHandler.GESTURE_SCROLL_START));
+ assertEquals("We should have started scrolling",
+ ContentViewGestureHandler.GESTURE_SCROLL_BY,
+ mockDelegate.mMostRecentGestureEvent.mType);
+ assertEquals("Only scrollBegin and scrollBy should have been sent",
+ 2, mockDelegate.mGestureTypeList.size());
+
+ event = MotionEvent.obtain(
+ downTime, eventTime + 1000, endActionType, scrollToX, scrollToY, 0);
+ mGestureHandler.onTouchEvent(event);
+ assertFalse(mGestureHandler.isNativeScrolling());
+ assertTrue("A scrollEnd event should have been sent",
+ mockDelegate.mGestureTypeList.contains(
+ ContentViewGestureHandler.GESTURE_SCROLL_END));
+ assertEquals("We should have stopped scrolling",
+ ContentViewGestureHandler.GESTURE_SCROLL_END,
+ mockDelegate.mMostRecentGestureEvent.mType);
+ assertEquals("Only scrollBegin and scrollBy and scrollEnd should have been sent",
+ 3, mockDelegate.mGestureTypeList.size());
+ }
+
+ /**
* Verify that for a normal fling (fling after scroll) the following events are sent:
* - GESTURE_SCROLL_BEGIN
* - GESTURE_FLING_START
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/ZoomManager.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698