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

Commit 38549104 authored by Arthur Hung's avatar Arthur Hung Committed by Android (Google) Code Review
Browse files

Merge "Add test mapping for back animation" into udc-dev

parents 2361fd5c d1ec1be0
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,