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

Commit 4b90a438 authored by Marzia Favaro's avatar Marzia Favaro
Browse files

TransitionDispatchState for DefaultTransitionHandler

Bug: 402454136
Test: DefaultTransitionHandlerTest
Flag: EXEMPT code is not yet called
Change-Id: Ic3b67a192e6d5eee6e5273e9a1d2df897c5f14e9
parent 56fb3d89
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -320,6 +320,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;
    }
}