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

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

Issue 23444068: Fix stuck state when long press on a button is performed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comments Created 7 years, 3 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
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 15e1b25fc332c71e4951e7c1ce169920c91ac631..e05fcb53400bd02fd6df9438a19117254fe10f96 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
@@ -656,6 +656,53 @@ public class ContentViewGestureHandlerTest extends InstrumentationTestCase {
}
/**
+ * Verify that a show pressed state gesture followed by a long press followed by the focus
+ * loss in the window due to context menu cancels show pressed.
+ * @throws Exception
+ */
+ @SmallTest
+ @Feature({"Gestures"})
+ public void testShowPressCancelOnWindowFocusLost() throws Exception {
+ final long time = SystemClock.uptimeMillis();
+ GestureRecordingMotionEventDelegate mockDelegate =
+ new GestureRecordingMotionEventDelegate();
+ mGestureHandler = new ContentViewGestureHandler(
+ getInstrumentation().getTargetContext(), mockDelegate, mMockZoomManager,
+ ContentViewCore.INPUT_EVENTS_DELIVERED_AT_VSYNC);
+ mLongPressDetector = new LongPressDetector(
+ getInstrumentation().getTargetContext(), mGestureHandler);
+ mGestureHandler.setTestDependencies(mLongPressDetector, null, null);
+
+ MotionEvent event = motionEvent(MotionEvent.ACTION_DOWN, time, time);
+ mGestureHandler.onTouchEvent(event);
+
+ mGestureHandler.sendShowPressedStateGestureForTesting();
+ assertEquals("A show pressed state event should have been sent",
+ ContentViewGestureHandler.GESTURE_SHOW_PRESSED_STATE,
+ mockDelegate.mMostRecentGestureEvent.mType);
+ assertEquals("Only showPressedState should have been sent",
+ 1, mockDelegate.mGestureTypeList.size());
+
+ mLongPressDetector.startLongPressTimerIfNeeded(event);
+ mLongPressDetector.sendLongPressGestureForTest();
+
+ assertEquals("Only should have sent only LONG_PRESS event",
+ 2, mockDelegate.mGestureTypeList.size());
+ assertEquals("Should have a long press event next",
+ ContentViewGestureHandler.GESTURE_LONG_PRESS,
+ mockDelegate.mGestureTypeList.get(1).intValue());
+
+ // The long press triggers window focus loss by opening a context menu
+ mGestureHandler.onWindowFocusLost();
+
+ assertEquals("Only should have sent only GESTURE_SHOW_PRESS_CANCEL event",
+ 3, mockDelegate.mGestureTypeList.size());
+ assertEquals("Should have a long press event next",
+ ContentViewGestureHandler.GESTURE_SHOW_PRESS_CANCEL,
+ mockDelegate.mGestureTypeList.get(2).intValue());
+ }
+
+ /**
* Verify that a recent show pressed state gesture is canceled when scrolling begins.
* @throws Exception
*/

Powered by Google App Engine
This is Rietveld 408576698