Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9e11b523 authored by Josh Yang's avatar Josh Yang
Browse files

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
parent a2246e9c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -523,6 +523,7 @@ public class FullScreenMagnificationGestureHandler extends MagnificationGestureH
            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 @@ public class FullScreenMagnificationGestureHandler extends MagnificationGestureH
        private MotionEventInfo mEvent;
        SinglePanningState(Context context) {
            mScrollGestureDetector = new GestureDetector(context, this, Handler.getMain());
            mScrollGestureDetector.setIsLongpressEnabled(false);
        }

        @Override
+25 −8
Original line number Diff line number Diff line
@@ -620,7 +620,7 @@ public class FullScreenMagnificationGestureHandlerTest {

    @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 @@ public class FullScreenMagnificationGestureHandlerTest {
        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 @@ public class FullScreenMagnificationGestureHandlerTest {
        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 @@ public class FullScreenMagnificationGestureHandlerTest {
        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);
        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);
        swipe(DEFAULT_POINT, new PointF(DEFAULT_X * 2, DEFAULT_Y * 2), /* durationMs= */ 20);
        send(upEvent(pointer.x, pointer.y));

        verify(mMockScroller).fling(
                /* startX= */ anyInt(),