Chromium Code Reviews| 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..72c5a52855d84f3e0c1bdd594ce7fed6f16ca4c0 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", |
| + new Integer(ContentViewGestureHandler.GESTURE_LONG_PRESS), |
| + mockDelegate.mGestureTypeList.get(1)); |
|
Ted C
2013/09/13 23:50:26
I would do .intValue() on the get(1) instead of cr
|
| + |
| + // 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", |
| + new Integer(ContentViewGestureHandler.GESTURE_SHOW_PRESS_CANCEL), |
| + mockDelegate.mGestureTypeList.get(2)); |
| + } |
| + |
| + /** |
| * Verify that a recent show pressed state gesture is canceled when scrolling begins. |
| * @throws Exception |
| */ |