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

Commit 1765744f authored by Johannes Gallmann's avatar Johannes Gallmann Committed by Android (Google) Code Review
Browse files

Merge "Fix flaky predictive back test" into main

parents 00f85ade 570d6df8
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
@@ -103,15 +103,7 @@ public class WindowOnBackInvokedDispatcherTest {

    private int mCallbackInfoCalls = 0;

    private final BackMotionEvent mBackEvent = new BackMotionEvent(
            /* touchX = */ 0,
            /* touchY = */ 0,
            /* progress = */ 0,
            /* velocityX = */ 0,
            /* velocityY = */ 0,
            /* triggerBack = */ false,
            /* swipeEdge = */ BackEvent.EDGE_LEFT,
            /* departingAnimationTarget = */ null);
    private final BackMotionEvent mBackEvent = backMotionEventFrom(/* progress */ 0f);
    private final MotionEvent mMotionEvent =
            MotionEvent.obtain(0, 0, MotionEvent.ACTION_MOVE, 100, 100, 0);

@@ -558,6 +550,7 @@ public class WindowOnBackInvokedDispatcherTest {
        OnBackInvokedCallbackInfo callbackInfo = assertSetCallbackInfo();

        callbackInfo.getCallback().onBackStarted(mBackEvent);
        callbackInfo.getCallback().onBackProgressed(backMotionEventFrom(/* progress */ 0.5f));
        waitForIdle();
        assertTrue(mDispatcher.mProgressAnimator.isBackAnimationInProgress());

@@ -575,6 +568,18 @@ public class WindowOnBackInvokedDispatcherTest {
        assertFalse(mDispatcher.mProgressAnimator.isBackAnimationInProgress());
    }

    private BackMotionEvent backMotionEventFrom(float progress) {
        return new BackMotionEvent(
                /* touchX = */ 0,
                /* touchY = */ 0,
                /* progress = */ progress,
                /* velocityX = */ 0,
                /* velocityY = */ 0,
                /* triggerBack = */ false,
                /* swipeEdge = */ BackEvent.EDGE_LEFT,
                /* departingAnimationTarget = */ null);
    }

    private void verifyImeCallackRegistrations() throws RemoteException {
        // verify default callback is replaced with ImeBackAnimationController
        mDispatcher.registerOnBackInvokedCallbackUnchecked(mDefaultImeCallback, PRIORITY_DEFAULT);