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

Commit d1ec1be0 authored by Arthur Hung's avatar Arthur Hung
Browse files

Add test mapping for back animation

Add the TEST_MAPPING for back animation.

Add unit tests for CrossTaskBackAnimation and CrossActivityAnimation.

Test: atest --test-mapping
Bug: 262322161
Bug: 262322082
Bug: 262322245
Change-Id: I35c195cfbc1aaeca4989d705e39bdcc0ef9fb5ea
parent 230c90d2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ class BackAnimationRunner {
                };
        mWaitingAnimation = false;
        try {
            mRunner.onAnimationStart(TRANSIT_OLD_UNSET, apps, wallpapers,
            getRunner().onAnimationStart(TRANSIT_OLD_UNSET, apps, wallpapers,
                    nonApps, callback);
        } catch (RemoteException e) {
            Log.w(TAG, "Failed call onAnimationStart", e);
+32 −0
Original line number Diff line number Diff line
{
  "presubmit": [
    {
      "name": "WMShellUnitTests",
      "options": [
        {
          "exclude-annotation": "androidx.test.filters.FlakyTest"
        },
        {
          "include-filter": "com.android.wm.shell.back"
        }
      ]
    },
    {
      "name": "CtsWindowManagerDeviceTestCases",
      "options": [
        {
          "exclude-annotation": "androidx.test.filters.FlakyTest"
        },
        {
          "include-filter": "android.server.wm.BackGestureInvokedTest"
        },
        {
          "include-filter": "android.server.wm.BackNavigationTests"
        },
        {
          "include-filter": "android.server.wm.OnBackInvokedCallbackGestureTest"
        }
      ]
    }
  ]
}
+2 −0
Original line number Diff line number Diff line
@@ -69,6 +69,8 @@ android_test {
        enabled: false,
    },

    test_suites: ["device-tests"],

    platform_apis: true,
    certificate: "platform",

+47 −0
Original line number Diff line number Diff line
@@ -411,6 +411,53 @@ public class BackAnimationControllerTest extends ShellTestCase {
        verify(mAnimatorCallback, never()).onBackInvoked();
    }

    @Test
    public void testBackToActivity() throws RemoteException {
        final CrossActivityAnimation animation = new CrossActivityAnimation(mContext,
                mAnimationBackground);
        verifySystemBackBehavior(
                BackNavigationInfo.TYPE_CROSS_ACTIVITY, animation.mBackAnimationRunner);
    }

    @Test
    public void testBackToTask() throws RemoteException {
        final CrossTaskBackAnimation animation = new CrossTaskBackAnimation(mContext,
                mAnimationBackground);
        verifySystemBackBehavior(
                BackNavigationInfo.TYPE_CROSS_TASK, animation.mBackAnimationRunner);
    }

    private void verifySystemBackBehavior(int type, BackAnimationRunner animation)
            throws RemoteException {
        final BackAnimationRunner animationRunner = spy(animation);
        final IRemoteAnimationRunner runner = spy(animationRunner.getRunner());
        final IOnBackInvokedCallback callback = spy(animationRunner.getCallback());

        // Set up the monitoring objects.
        doNothing().when(runner).onAnimationStart(anyInt(), any(), any(), any(), any());
        doReturn(runner).when(animationRunner).getRunner();
        doReturn(callback).when(animationRunner).getCallback();

        mController.registerAnimation(type, animationRunner);

        createNavigationInfo(type, true);

        doMotionEvent(MotionEvent.ACTION_DOWN, 0);

        // Check that back start and progress is dispatched when first move.
        doMotionEvent(MotionEvent.ACTION_MOVE, 100);

        simulateRemoteAnimationStart(type);

        verify(callback).onBackStarted(any(BackMotionEvent.class));
        verify(animationRunner).startAnimation(any(), any(), any(), any());

        // Check that back invocation is dispatched.
        mController.setTriggerBack(true);   // Fake trigger back
        doMotionEvent(MotionEvent.ACTION_UP, 0);
        verify(callback).onBackInvoked();
    }

    private void doMotionEvent(int actionDown, int coordinate) {
        mController.onMotionEvent(
                coordinate, coordinate,