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

Commit af2a10bb authored by Marzia Favaro's avatar Marzia Favaro Committed by Android (Google) Code Review
Browse files

Merge "TransitionDispatchState for DefaultTransitionHandler" into main

parents 206f61e7 4b90a438
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -318,6 +318,22 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
        return mRoundedContentBounds.forDisplay(change.getEndDisplayId());
    }

    @Override
    public boolean startAnimation(@NonNull IBinder transition,
                                  @Nullable TransitionInfo info,
                                  @NonNull TransitionDispatchState dispatchState,
                                  @NonNull SurfaceControl.Transaction startTransaction,
                                  @NonNull SurfaceControl.Transaction finishTransaction,
                                  @NonNull Transitions.TransitionFinishCallback finishCallback) {
        if (info == null) {
            // In data collection mode: there can't be errors - nothing to do
            return false;
        }
        // In animation mode: always play everything
        return startAnimation(
                transition, info, startTransaction, finishTransaction, finishCallback);
    }

    @Override
    public boolean startAnimation(@NonNull IBinder transition, @NonNull TransitionInfo info,
            @NonNull SurfaceControl.Transaction startTransaction,
+39 −1
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ import static android.window.TransitionInfo.FLAG_SYNC;
import static android.window.TransitionInfo.FLAG_TRANSLUCENT;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -39,6 +41,7 @@ import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.util.Log;
import android.view.SurfaceControl;
import android.view.animation.AlphaAnimation;
import android.window.TransitionInfo;
@@ -90,6 +93,8 @@ public class DefaultTransitionHandlerTest extends ShellTestCase {
    private RootTaskDisplayAreaOrganizer mRootTaskDisplayAreaOrganizer;
    private DefaultTransitionHandler mTransitionHandler;

    static final String TAG = "DefaultHandlerTest";

    @Before
    public void setUp() {
        mShellInit = new ShellInit(mMainExecutor);
@@ -268,6 +273,40 @@ public class DefaultTransitionHandlerTest extends ShellTestCase {
        verify(startT, never()).reparent(any(), any());
    }

    @Test
    public void startAnimation_neverFindsErrors_animationMode() {
        final TransitionInfo info = mock(TransitionInfo.class);
        final IBinder token = mock(Binder.class);

        TransitionDispatchState dispatchState = new TransitionDispatchState(token, info);

        boolean hasPlayed = mTransitionHandler
                .startAnimation(token, info, dispatchState, MockTransactionPool.create(),
                        MockTransactionPool.create(),
                        mock(Transitions.TransitionFinishCallback.class));

        Log.v(TAG, "dispatchState: \n" + dispatchState.getDebugInfo());
        assertTrue(hasPlayed);
        assertFalse(dispatchState.hasErrors(mTransitionHandler));
    }

    @Test
    public void startAnimation_neverFindsErrors_dataCollectionMode() {
        final TransitionInfo info = mock(TransitionInfo.class);
        final IBinder token = mock(Binder.class);

        TransitionDispatchState dispatchState = new TransitionDispatchState(token, info);

        boolean hasPlayed = mTransitionHandler
                .startAnimation(token, null, dispatchState, MockTransactionPool.create(),
                        MockTransactionPool.create(),
                        mock(Transitions.TransitionFinishCallback.class));

        Log.v(TAG, "dispatchState: \n" + dispatchState.getDebugInfo());
        assertFalse(hasPlayed);
        assertFalse(dispatchState.hasErrors(mTransitionHandler));
    }

    @Test
    public void startAnimation_freeform_minimizeAnimation_reparentsTask() {
        final TransitionInfo.Change openChange = new ChangeBuilder(TRANSIT_OPEN)
@@ -316,4 +355,3 @@ public class DefaultTransitionHandlerTest extends ShellTestCase {
        return taskInfo;
    }
}