mFinishedCallback = new FinishedCallback(this);
final RemoteAnimationTarget[] animations = createAnimations();
+ if (animations.length == 0) {
+ onAnimationFinished();
+ return;
+ }
mService.mAnimator.addAfterPrepareSurfacesRunnable(() -> {
try {
mRemoteAnimationAdapter.getRunner().onAnimationStart(animations,
mPendingAnimations.get(i).createRemoteAppAnimation();
if (target != null) {
targets.add(target);
+ } else {
+ mPendingAnimations.remove(i);
}
}
return targets.toArray(new RemoteAnimationTarget[targets.size()]);
RemoteAnimationTarget createRemoteAppAnimation() {
final Task task = mAppWindowToken.getTask();
final WindowState mainWindow = mAppWindowToken.findMainWindow();
- if (task == null) {
- return null;
- }
- if (mainWindow == null) {
+ if (task == null || mainWindow == null || mCapturedFinishCallback == null
+ || mCapturedLeash == null) {
return null;
}
mTarget = new RemoteAnimationTarget(task.mTaskId, getMode(),
super.setUp();
MockitoAnnotations.initMocks(this);
mAdapter = new RemoteAnimationAdapter(mMockRunner, 100, 50);
+ mAdapter.setCallingPid(123);
sWm.mH.runWithScissors(() -> {
mHandler = new TestHandler(null, mClock);
}, 0);
new Point(50, 100), new Rect(50, 100, 150, 150));
adapter.startAnimation(mMockLeash, mMockTransaction, mFinishedCallback);
mController.goodToGo();
-
+ sWm.mAnimator.executeAfterPrepareSurfacesRunnables();
final ArgumentCaptor<RemoteAnimationTarget[]> appsCaptor =
ArgumentCaptor.forClass(RemoteAnimationTarget[].class);
final ArgumentCaptor<IRemoteAnimationFinishedCallback> finishedCaptor =
mController.goodToGo();
verifyZeroInteractions(mMockRunner);
}
+
+ @Test
+ public void testNotReallyStarted() throws Exception {
+ final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin");
+ mController.createAnimationAdapter(win.mAppToken,
+ new Point(50, 100), new Rect(50, 100, 150, 150));
+ mController.goodToGo();
+ verifyZeroInteractions(mMockRunner);
+ }
+
+ @Test
+ public void testOneNotStarted() throws Exception {
+ final WindowState win1 = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin1");
+ final WindowState win2 = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin2");
+ mController.createAnimationAdapter(win1.mAppToken,
+ new Point(50, 100), new Rect(50, 100, 150, 150));
+ final AnimationAdapter adapter = mController.createAnimationAdapter(win2.mAppToken,
+ new Point(50, 100), new Rect(50, 100, 150, 150));
+ adapter.startAnimation(mMockLeash, mMockTransaction, mFinishedCallback);
+ mController.goodToGo();
+ sWm.mAnimator.executeAfterPrepareSurfacesRunnables();
+ final ArgumentCaptor<RemoteAnimationTarget[]> appsCaptor =
+ ArgumentCaptor.forClass(RemoteAnimationTarget[].class);
+ final ArgumentCaptor<IRemoteAnimationFinishedCallback> finishedCaptor =
+ ArgumentCaptor.forClass(IRemoteAnimationFinishedCallback.class);
+ verify(mMockRunner).onAnimationStart(appsCaptor.capture(), finishedCaptor.capture());
+ assertEquals(1, appsCaptor.getValue().length);
+ assertEquals(mMockLeash, appsCaptor.getValue()[0].leash);
+ }
}