Fix failing tests in FullScreenMagnificationGestureHandlerTest
1. testSingleFingerScrollAfterMagnified_startsFling: this test fails
because the long-press detection interferes with scroll detection
during test. Moreover, the current fake motion events in test is
not recognized as scroll event on watches.
2. testTwoFingerDoubleTap_StateIsIdle_shouldInActivated() and
testTwoFingerDoubleTap_StateIsActivated_shouldInIdle(): these 2 tests
are failing because 1) the test uses the wrong delay and 2) the
queued motion events will immediately change the state to detecting
state from the expected state.
Flag: EXEMPT test fix only
Bug: 353772906
Fix: 353772906
Test: plug a watch and run "atest FullScreenMagnificationGestureHandlerTest"
Change-Id: I7d1efb6400fe4261df5bb191f284cc7cf7250924
diff --git a/services/accessibility/java/com/android/server/accessibility/magnification/FullScreenMagnificationGestureHandler.java b/services/accessibility/java/com/android/server/accessibility/magnification/FullScreenMagnificationGestureHandler.java
index e9c3fbd..2a24e34 100644
--- a/services/accessibility/java/com/android/server/accessibility/magnification/FullScreenMagnificationGestureHandler.java
+++ b/services/accessibility/java/com/android/server/accessibility/magnification/FullScreenMagnificationGestureHandler.java
@@ -523,6 +523,7 @@
mScaleGestureDetector = new ScaleGestureDetector(context, this, Handler.getMain());
mScaleGestureDetector.setQuickScaleEnabled(false);
mScrollGestureDetector = new GestureDetector(context, this, Handler.getMain());
+ mScrollGestureDetector.setIsLongpressEnabled(false);
}
@Override
@@ -1876,6 +1877,7 @@
private MotionEventInfo mEvent;
SinglePanningState(Context context) {
mScrollGestureDetector = new GestureDetector(context, this, Handler.getMain());
+ mScrollGestureDetector.setIsLongpressEnabled(false);
}
@Override
diff --git a/services/tests/servicestests/src/com/android/server/accessibility/magnification/FullScreenMagnificationGestureHandlerTest.java b/services/tests/servicestests/src/com/android/server/accessibility/magnification/FullScreenMagnificationGestureHandlerTest.java
index 3ef81fd..f428aae 100644
--- a/services/tests/servicestests/src/com/android/server/accessibility/magnification/FullScreenMagnificationGestureHandlerTest.java
+++ b/services/tests/servicestests/src/com/android/server/accessibility/magnification/FullScreenMagnificationGestureHandlerTest.java
@@ -620,7 +620,7 @@
@Test
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
- public void testTwoFingerTap_StateIsActivated_shouldInDelegating() {
+ public void testTwoFingerTap_StateIsActivated_shouldInDetecting() {
assumeTrue(isWatch());
enableOneFingerPanning(false);
goFromStateIdleTo(STATE_ACTIVATED);
@@ -629,14 +629,15 @@
send(downEvent());
send(pointerEvent(ACTION_POINTER_DOWN, DEFAULT_X * 2, DEFAULT_Y));
send(upEvent());
- fastForward(ViewConfiguration.getDoubleTapTimeout());
+ fastForward(mMgh.mDetectingState.mMultiTapMaxDelay);
- assertTrue(mMgh.mCurrentState == mMgh.mDelegatingState);
+ verify(mMgh.getNext(), times(3)).onMotionEvent(any(), any(), anyInt());
+ assertTrue(mMgh.mCurrentState == mMgh.mDetectingState);
}
@Test
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
- public void testTwoFingerTap_StateIsIdle_shouldInDelegating() {
+ public void testTwoFingerTap_StateIsIdle_shouldInDetecting() {
assumeTrue(isWatch());
enableOneFingerPanning(false);
goFromStateIdleTo(STATE_IDLE);
@@ -645,9 +646,10 @@
send(downEvent());
send(pointerEvent(ACTION_POINTER_DOWN, DEFAULT_X * 2, DEFAULT_Y));
send(upEvent());
- fastForward(ViewConfiguration.getDoubleTapTimeout());
+ fastForward(mMgh.mDetectingState.mMultiTapMaxDelay);
- assertTrue(mMgh.mCurrentState == mMgh.mDelegatingState);
+ verify(mMgh.getNext(), times(3)).onMotionEvent(any(), any(), anyInt());
+ assertTrue(mMgh.mCurrentState == mMgh.mDetectingState);
}
@Test
@@ -1057,9 +1059,24 @@
assumeTrue(isWatch());
goFromStateIdleTo(STATE_ACTIVATED);
- swipeAndHold();
+ PointF pointer = DEFAULT_POINT;
+ send(downEvent(pointer.x, pointer.y));
+
+ // first move triggers the panning state
+ pointer.offset(100, 100);
fastForward(20);
- swipe(DEFAULT_POINT, new PointF(DEFAULT_X * 2, DEFAULT_Y * 2), /* durationMs= */ 20);
+ send(moveEvent(pointer.x, pointer.y));
+
+ // second move actually pans
+ pointer.offset(100, 100);
+ fastForward(20);
+ send(moveEvent(pointer.x, pointer.y));
+ pointer.offset(100, 100);
+ fastForward(20);
+ send(moveEvent(pointer.x, pointer.y));
+
+ fastForward(20);
+ send(upEvent(pointer.x, pointer.y));
verify(mMockScroller).fling(
/* startX= */ anyInt(),