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

Commit c06ea6e3 authored by Josh Yang's avatar Josh Yang Committed by Android (Google) Code Review
Browse files

Merge "Fix failing tests in FullScreenMagnificationGestureHandlerTest" into main

parents 0bb52fc9 9e11b523
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(),