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

This commit is contained in:
Arthur Hung
2023-03-17 16:26:54 +00:00
committed by Android (Google) Code Review
4 changed files with 82 additions and 1 deletions

View File

@@ -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);

View File

@@ -0,0 +1,32 @@
{
"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"
}
]
}
]
}

View File

@@ -69,6 +69,8 @@ android_test {
enabled: false,
},
test_suites: ["device-tests"],
platform_apis: true,
certificate: "platform",

View File

@@ -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,