Merge "Fix Transition test logic and consolidate some boilerplate"

This commit is contained in:
Evan Rosky
2023-02-10 23:41:11 +00:00
committed by Android (Google) Code Review
9 changed files with 180 additions and 153 deletions

View File

@@ -0,0 +1,78 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.wm.shell;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static org.mockito.Mockito.mock;
import android.app.ActivityManager;
import android.view.SurfaceControl;
import android.view.WindowManager;
import android.window.TransitionInfo;
/**
* Utility for creating/editing synthetic TransitionInfos for tests.
*/
public class TransitionInfoBuilder {
final TransitionInfo mInfo;
public TransitionInfoBuilder(@WindowManager.TransitionType int type) {
this(type, 0 /* flags */);
}
public TransitionInfoBuilder(@WindowManager.TransitionType int type,
@WindowManager.TransitionFlags int flags) {
mInfo = new TransitionInfo(type, flags);
mInfo.setRootLeash(createMockSurface(true /* valid */), 0, 0);
}
public TransitionInfoBuilder addChange(@WindowManager.TransitionType int mode,
@TransitionInfo.ChangeFlags int flags, ActivityManager.RunningTaskInfo taskInfo) {
final TransitionInfo.Change change = new TransitionInfo.Change(
taskInfo != null ? taskInfo.token : null, createMockSurface(true /* valid */));
change.setMode(mode);
change.setFlags(flags);
change.setTaskInfo(taskInfo);
return addChange(change);
}
public TransitionInfoBuilder addChange(@WindowManager.TransitionType int mode,
ActivityManager.RunningTaskInfo taskInfo) {
return addChange(mode, TransitionInfo.FLAG_NONE, taskInfo);
}
public TransitionInfoBuilder addChange(@WindowManager.TransitionType int mode) {
return addChange(mode, TransitionInfo.FLAG_NONE, null /* taskInfo */);
}
public TransitionInfoBuilder addChange(TransitionInfo.Change change) {
mInfo.addChange(change);
return this;
}
public TransitionInfo build() {
return mInfo;
}
private static SurfaceControl createMockSurface(boolean valid) {
SurfaceControl sc = mock(SurfaceControl.class);
doReturn(valid).when(sc).isValid();
doReturn("TestSurface").when(sc).toString();
return sc;
}
}

View File

@@ -35,6 +35,8 @@ import android.window.TransitionInfo;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.wm.shell.TransitionInfoBuilder;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -60,10 +62,9 @@ public class ActivityEmbeddingAnimationRunnerTests extends ActivityEmbeddingAnim
@Test
public void testStartAnimation() {
final TransitionInfo info = new TransitionInfo(TRANSIT_OPEN, 0);
final TransitionInfo.Change embeddingChange = createChange();
embeddingChange.setFlags(FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY);
info.addChange(embeddingChange);
final TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN, 0)
.addChange(createChange(FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY))
.build();
doReturn(mAnimator).when(mAnimRunner).createAnimator(any(), any(), any(), any(), any());
mAnimRunner.startAnimation(mTransition, info, mStartTransaction, mFinishTransaction);
@@ -84,10 +85,9 @@ public class ActivityEmbeddingAnimationRunnerTests extends ActivityEmbeddingAnim
@Test
public void testChangesBehindStartingWindow() {
final TransitionInfo info = new TransitionInfo(TRANSIT_OPEN, 0);
final TransitionInfo.Change embeddingChange = createChange();
embeddingChange.setFlags(FLAG_IS_BEHIND_STARTING_WINDOW);
info.addChange(embeddingChange);
final TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN, 0)
.addChange(createChange(FLAG_IS_BEHIND_STARTING_WINDOW))
.build();
final Animator animator = mAnimRunner.createAnimator(
info, mStartTransaction, mFinishTransaction,
() -> mFinishCallback.onTransitionFinished(null /* wct */, null /* wctCB */),

View File

@@ -82,9 +82,11 @@ abstract class ActivityEmbeddingAnimationTestBase extends ShellTestCase {
}
/** Creates a mock {@link TransitionInfo.Change}. */
static TransitionInfo.Change createChange() {
return new TransitionInfo.Change(mock(WindowContainerToken.class),
static TransitionInfo.Change createChange(@TransitionInfo.ChangeFlags int flags) {
TransitionInfo.Change c = new TransitionInfo.Change(mock(WindowContainerToken.class),
mock(SurfaceControl.class));
c.setFlags(flags);
return c;
}
/**
@@ -93,8 +95,7 @@ abstract class ActivityEmbeddingAnimationTestBase extends ShellTestCase {
*/
static TransitionInfo.Change createEmbeddedChange(@NonNull Rect startBounds,
@NonNull Rect endBounds, @NonNull Rect taskBounds) {
final TransitionInfo.Change change = createChange();
change.setFlags(FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY);
final TransitionInfo.Change change = createChange(FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY);
change.setStartAbsBounds(startBounds);
change.setEndAbsBounds(endBounds);
if (taskBounds.width() == startBounds.width()

View File

@@ -34,6 +34,8 @@ import android.window.TransitionInfo;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.wm.shell.TransitionInfoBuilder;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -80,12 +82,11 @@ public class ActivityEmbeddingControllerTests extends ActivityEmbeddingAnimation
@Test
public void testStartAnimation_containsNonActivityEmbeddingChange() {
final TransitionInfo info = new TransitionInfo(TRANSIT_OPEN, 0);
final TransitionInfo.Change embeddingChange = createEmbeddedChange(EMBEDDED_LEFT_BOUNDS,
EMBEDDED_LEFT_BOUNDS, TASK_BOUNDS);
final TransitionInfo.Change nonEmbeddingChange = createChange();
info.addChange(embeddingChange);
info.addChange(nonEmbeddingChange);
final TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN, 0)
.addChange(createEmbeddedChange(
EMBEDDED_LEFT_BOUNDS, EMBEDDED_LEFT_BOUNDS, TASK_BOUNDS))
.addChange(createChange(0 /* flags */))
.build();
// No-op because it contains non-embedded change.
assertFalse(mController.startAnimation(mTransition, info, mStartTransaction,
@@ -98,10 +99,9 @@ public class ActivityEmbeddingControllerTests extends ActivityEmbeddingAnimation
@Test
public void testStartAnimation_containsOnlyFillTaskActivityEmbeddingChange() {
final TransitionInfo info = new TransitionInfo(TRANSIT_OPEN, 0);
final TransitionInfo.Change embeddingChange = createEmbeddedChange(TASK_BOUNDS, TASK_BOUNDS,
TASK_BOUNDS);
info.addChange(embeddingChange);
final TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN, 0)
.addChange(createEmbeddedChange(TASK_BOUNDS, TASK_BOUNDS, TASK_BOUNDS))
.build();
// No-op because it only contains embedded change that fills the Task. We will let the
// default handler to animate such transition.
@@ -116,10 +116,10 @@ public class ActivityEmbeddingControllerTests extends ActivityEmbeddingAnimation
@Test
public void testStartAnimation_containsActivityEmbeddingSplitChange() {
// Change that occupies only part of the Task.
final TransitionInfo info = new TransitionInfo(TRANSIT_OPEN, 0);
final TransitionInfo.Change embeddingChange = createEmbeddedChange(EMBEDDED_LEFT_BOUNDS,
EMBEDDED_LEFT_BOUNDS, TASK_BOUNDS);
info.addChange(embeddingChange);
final TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN, 0)
.addChange(createEmbeddedChange(
EMBEDDED_LEFT_BOUNDS, EMBEDDED_LEFT_BOUNDS, TASK_BOUNDS))
.build();
// ActivityEmbeddingController will handle such transition.
assertTrue(mController.startAnimation(mTransition, info, mStartTransaction,
@@ -133,10 +133,9 @@ public class ActivityEmbeddingControllerTests extends ActivityEmbeddingAnimation
@Test
public void testStartAnimation_containsChangeEnterActivityEmbeddingSplit() {
// Change that is entering ActivityEmbedding split.
final TransitionInfo info = new TransitionInfo(TRANSIT_OPEN, 0);
final TransitionInfo.Change embeddingChange = createEmbeddedChange(TASK_BOUNDS,
EMBEDDED_LEFT_BOUNDS, TASK_BOUNDS);
info.addChange(embeddingChange);
final TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN, 0)
.addChange(createEmbeddedChange(TASK_BOUNDS, EMBEDDED_LEFT_BOUNDS, TASK_BOUNDS))
.build();
// ActivityEmbeddingController will handle such transition.
assertTrue(mController.startAnimation(mTransition, info, mStartTransaction,
@@ -150,10 +149,9 @@ public class ActivityEmbeddingControllerTests extends ActivityEmbeddingAnimation
@Test
public void testStartAnimation_containsChangeExitActivityEmbeddingSplit() {
// Change that is exiting ActivityEmbedding split.
final TransitionInfo info = new TransitionInfo(TRANSIT_OPEN, 0);
final TransitionInfo.Change embeddingChange = createEmbeddedChange(EMBEDDED_RIGHT_BOUNDS,
TASK_BOUNDS, TASK_BOUNDS);
info.addChange(embeddingChange);
final TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN, 0)
.addChange(createEmbeddedChange(EMBEDDED_RIGHT_BOUNDS, TASK_BOUNDS, TASK_BOUNDS))
.build();
// ActivityEmbeddingController will handle such transition.
assertTrue(mController.startAnimation(mTransition, info, mStartTransaction,
@@ -170,10 +168,10 @@ public class ActivityEmbeddingControllerTests extends ActivityEmbeddingAnimation
assertThrows(IllegalStateException.class,
() -> mController.onAnimationFinished(mTransition));
final TransitionInfo info = new TransitionInfo(TRANSIT_OPEN, 0);
final TransitionInfo.Change embeddingChange = createEmbeddedChange(EMBEDDED_LEFT_BOUNDS,
EMBEDDED_LEFT_BOUNDS, TASK_BOUNDS);
info.addChange(embeddingChange);
final TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN, 0)
.addChange(createEmbeddedChange(
EMBEDDED_LEFT_BOUNDS, EMBEDDED_LEFT_BOUNDS, TASK_BOUNDS))
.build();
mController.startAnimation(mTransition, info, mStartTransaction,
mFinishTransaction, mFinishCallback);

View File

@@ -37,6 +37,7 @@ import android.window.WindowContainerToken;
import androidx.test.filters.SmallTest;
import com.android.wm.shell.TransitionInfoBuilder;
import com.android.wm.shell.sysui.ShellInit;
import com.android.wm.shell.transition.Transitions;
import com.android.wm.shell.windowdecor.WindowDecorViewModel;
@@ -94,8 +95,8 @@ public class FreeformTaskTransitionObserverTest {
public void testCreatesWindowDecorOnOpenTransition_freeform() {
final TransitionInfo.Change change =
createChange(TRANSIT_OPEN, 1, WINDOWING_MODE_FREEFORM);
final TransitionInfo info = new TransitionInfo(TRANSIT_OPEN, 0);
info.addChange(change);
final TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN, 0)
.addChange(change).build();
final IBinder transition = mock(IBinder.class);
final SurfaceControl.Transaction startT = mock(SurfaceControl.Transaction.class);
@@ -111,8 +112,8 @@ public class FreeformTaskTransitionObserverTest {
public void testPreparesWindowDecorOnCloseTransition_freeform() {
final TransitionInfo.Change change =
createChange(TRANSIT_CLOSE, 1, WINDOWING_MODE_FREEFORM);
final TransitionInfo info = new TransitionInfo(TRANSIT_CLOSE, 0);
info.addChange(change);
final TransitionInfo info = new TransitionInfoBuilder(TRANSIT_CLOSE, 0)
.addChange(change).build();
final IBinder transition = mock(IBinder.class);
final SurfaceControl.Transaction startT = mock(SurfaceControl.Transaction.class);
@@ -128,8 +129,8 @@ public class FreeformTaskTransitionObserverTest {
public void testDoesntCloseWindowDecorDuringCloseTransition() throws Exception {
final TransitionInfo.Change change =
createChange(TRANSIT_CLOSE, 1, WINDOWING_MODE_FREEFORM);
final TransitionInfo info = new TransitionInfo(TRANSIT_CLOSE, 0);
info.addChange(change);
final TransitionInfo info = new TransitionInfoBuilder(TRANSIT_CLOSE, 0)
.addChange(change).build();
final IBinder transition = mock(IBinder.class);
final SurfaceControl.Transaction startT = mock(SurfaceControl.Transaction.class);
@@ -144,8 +145,8 @@ public class FreeformTaskTransitionObserverTest {
public void testClosesWindowDecorAfterCloseTransition() throws Exception {
final TransitionInfo.Change change =
createChange(TRANSIT_CLOSE, 1, WINDOWING_MODE_FREEFORM);
final TransitionInfo info = new TransitionInfo(TRANSIT_CLOSE, 0);
info.addChange(change);
final TransitionInfo info = new TransitionInfoBuilder(TRANSIT_CLOSE, 0)
.addChange(change).build();
final AutoCloseable windowDecor = mock(AutoCloseable.class);
@@ -164,8 +165,8 @@ public class FreeformTaskTransitionObserverTest {
// The playing transition
final TransitionInfo.Change change1 =
createChange(TRANSIT_OPEN, 1, WINDOWING_MODE_FREEFORM);
final TransitionInfo info1 = new TransitionInfo(TRANSIT_OPEN, 0);
info1.addChange(change1);
final TransitionInfo info1 = new TransitionInfoBuilder(TRANSIT_OPEN, 0)
.addChange(change1).build();
final IBinder transition1 = mock(IBinder.class);
final SurfaceControl.Transaction startT1 = mock(SurfaceControl.Transaction.class);
@@ -176,8 +177,8 @@ public class FreeformTaskTransitionObserverTest {
// The merged transition
final TransitionInfo.Change change2 =
createChange(TRANSIT_CLOSE, 2, WINDOWING_MODE_FREEFORM);
final TransitionInfo info2 = new TransitionInfo(TRANSIT_CLOSE, 0);
info2.addChange(change2);
final TransitionInfo info2 = new TransitionInfoBuilder(TRANSIT_CLOSE, 0)
.addChange(change2).build();
final IBinder transition2 = mock(IBinder.class);
final SurfaceControl.Transaction startT2 = mock(SurfaceControl.Transaction.class);
@@ -195,8 +196,8 @@ public class FreeformTaskTransitionObserverTest {
// The playing transition
final TransitionInfo.Change change1 =
createChange(TRANSIT_CLOSE, 1, WINDOWING_MODE_FREEFORM);
final TransitionInfo info1 = new TransitionInfo(TRANSIT_CLOSE, 0);
info1.addChange(change1);
final TransitionInfo info1 = new TransitionInfoBuilder(TRANSIT_CLOSE, 0)
.addChange(change1).build();
final IBinder transition1 = mock(IBinder.class);
final SurfaceControl.Transaction startT1 = mock(SurfaceControl.Transaction.class);
@@ -207,8 +208,8 @@ public class FreeformTaskTransitionObserverTest {
// The merged transition
final TransitionInfo.Change change2 =
createChange(TRANSIT_CLOSE, 2, WINDOWING_MODE_FREEFORM);
final TransitionInfo info2 = new TransitionInfo(TRANSIT_CLOSE, 0);
info2.addChange(change2);
final TransitionInfo info2 = new TransitionInfoBuilder(TRANSIT_CLOSE, 0)
.addChange(change2).build();
final IBinder transition2 = mock(IBinder.class);
final SurfaceControl.Transaction startT2 = mock(SurfaceControl.Transaction.class);

View File

@@ -64,6 +64,7 @@ import com.android.wm.shell.RootTaskDisplayAreaOrganizer;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.TestRunningTaskInfoBuilder;
import com.android.wm.shell.TransitionInfoBuilder;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.DisplayImeController;
import com.android.wm.shell.common.DisplayInsetsController;
@@ -156,12 +157,10 @@ public class SplitTransitionTests extends ShellTestCase {
assertTrue(containsSplitEnter(result));
// simulate the transition
TransitionInfo.Change openChange = createChange(TRANSIT_OPEN, newTask);
TransitionInfo.Change reparentChange = createChange(TRANSIT_CHANGE, reparentTask);
TransitionInfo info = new TransitionInfo(TRANSIT_TO_FRONT, 0);
info.addChange(openChange);
info.addChange(reparentChange);
final TransitionInfo info = new TransitionInfoBuilder(TRANSIT_TO_FRONT, 0)
.addChange(TRANSIT_OPEN, newTask)
.addChange(TRANSIT_CHANGE, reparentTask)
.build();
mSideStage.onTaskAppeared(newTask, createMockSurface());
mMainStage.onTaskAppeared(reparentTask, createMockSurface());
boolean accepted = mStageCoordinator.startAnimation(transition, info,
@@ -216,12 +215,10 @@ public class SplitTransitionTests extends ShellTestCase {
assertFalse(containsSplitExit(result));
// simulate the transition
TransitionInfo.Change openChange = createChange(TRANSIT_TO_FRONT, newTask);
TransitionInfo.Change hideChange = createChange(TRANSIT_TO_BACK, mSideChild);
TransitionInfo info = new TransitionInfo(TRANSIT_TO_FRONT, 0);
info.addChange(openChange);
info.addChange(hideChange);
TransitionInfo info = new TransitionInfoBuilder(TRANSIT_TO_FRONT, 0)
.addChange(TRANSIT_TO_FRONT, newTask)
.addChange(TRANSIT_TO_BACK, mSideChild)
.build();
mSideStage.onTaskAppeared(newTask, createMockSurface());
boolean accepted = mStageCoordinator.startAnimation(transition, info,
mock(SurfaceControl.Transaction.class),
@@ -237,12 +234,10 @@ public class SplitTransitionTests extends ShellTestCase {
assertNotNull(result);
assertFalse(containsSplitExit(result));
TransitionInfo.Change showChange = createChange(TRANSIT_TO_FRONT, mSideChild);
TransitionInfo.Change closeChange = createChange(TRANSIT_CLOSE, newTask);
info = new TransitionInfo(TRANSIT_CLOSE, 0);
info.addChange(showChange);
info.addChange(closeChange);
info = new TransitionInfoBuilder(TRANSIT_CLOSE, 0)
.addChange(TRANSIT_TO_FRONT, mSideChild)
.addChange(TRANSIT_CLOSE, newTask)
.build();
mSideStage.onTaskVanished(newTask);
accepted = mStageCoordinator.startAnimation(transition, info,
mock(SurfaceControl.Transaction.class),
@@ -273,14 +268,11 @@ public class SplitTransitionTests extends ShellTestCase {
assertTrue(mStageCoordinator.isSplitScreenVisible());
// simulate the transition
TransitionInfo.Change homeChange = createChange(TRANSIT_TO_FRONT, homeTask);
TransitionInfo.Change mainChange = createChange(TRANSIT_TO_BACK, mMainChild);
TransitionInfo.Change sideChange = createChange(TRANSIT_TO_BACK, mSideChild);
TransitionInfo info = new TransitionInfo(TRANSIT_TO_FRONT, 0);
info.addChange(homeChange);
info.addChange(mainChange);
info.addChange(sideChange);
TransitionInfo info = new TransitionInfoBuilder(TRANSIT_TO_FRONT, 0)
.addChange(TRANSIT_TO_FRONT, homeTask)
.addChange(TRANSIT_TO_BACK, mMainChild)
.addChange(TRANSIT_TO_BACK, mSideChild)
.build();
mMainStage.onTaskVanished(mMainChild);
mSideStage.onTaskVanished(mSideChild);
mStageCoordinator.startAnimation(transition, info,
@@ -311,14 +303,11 @@ public class SplitTransitionTests extends ShellTestCase {
assertTrue(mStageCoordinator.isSplitScreenVisible());
// simulate the transition
TransitionInfo.Change normalChange = createChange(TRANSIT_TO_FRONT, normalTask);
TransitionInfo.Change mainChange = createChange(TRANSIT_TO_BACK, mMainChild);
TransitionInfo.Change sideChange = createChange(TRANSIT_TO_BACK, mSideChild);
TransitionInfo info = new TransitionInfo(TRANSIT_TO_FRONT, 0);
info.addChange(normalChange);
info.addChange(mainChange);
info.addChange(sideChange);
TransitionInfo info = new TransitionInfoBuilder(TRANSIT_TO_FRONT, 0)
.addChange(TRANSIT_TO_FRONT, normalTask)
.addChange(TRANSIT_TO_BACK, mMainChild)
.addChange(TRANSIT_TO_BACK, mSideChild)
.build();
mMainStage.onTaskVanished(mMainChild);
mSideStage.onTaskVanished(mSideChild);
mStageCoordinator.startAnimation(transition, info,
@@ -334,11 +323,10 @@ public class SplitTransitionTests extends ShellTestCase {
enterSplit();
// simulate the transition
TransitionInfo.Change mainChange = createChange(TRANSIT_TO_BACK, mMainChild);
TransitionInfo.Change sideChange = createChange(TRANSIT_TO_BACK, mSideChild);
TransitionInfo info = new TransitionInfo(TRANSIT_TO_BACK, 0);
info.addChange(mainChange);
info.addChange(sideChange);
TransitionInfo info = new TransitionInfoBuilder(TRANSIT_TO_BACK, 0)
.addChange(TRANSIT_TO_BACK, mMainChild)
.addChange(TRANSIT_TO_BACK, mSideChild)
.build();
IBinder transition = mSplitScreenTransitions.startDismissTransition(
new WindowContainerTransaction(), mStageCoordinator,
EXIT_REASON_APP_DOES_NOT_SUPPORT_MULTIWINDOW, STAGE_TYPE_SIDE);
@@ -356,12 +344,10 @@ public class SplitTransitionTests extends ShellTestCase {
enterSplit();
// simulate the transition
TransitionInfo.Change mainChange = createChange(TRANSIT_TO_BACK, mMainChild);
TransitionInfo.Change sideChange = createChange(TRANSIT_CHANGE, mSideChild);
TransitionInfo info = new TransitionInfo(TRANSIT_TO_BACK, 0);
info.addChange(mainChange);
info.addChange(sideChange);
TransitionInfo info = new TransitionInfoBuilder(TRANSIT_TO_BACK, 0)
.addChange(TRANSIT_TO_BACK, mMainChild)
.addChange(TRANSIT_CHANGE, mSideChild)
.build();
IBinder transition = mSplitScreenTransitions.startDismissTransition(
new WindowContainerTransaction(), mStageCoordinator, EXIT_REASON_DRAG_DIVIDER,
STAGE_TYPE_SIDE);
@@ -391,12 +377,10 @@ public class SplitTransitionTests extends ShellTestCase {
assertTrue(mStageCoordinator.isSplitScreenVisible());
// simulate the transition
TransitionInfo.Change mainChange = createChange(TRANSIT_CHANGE, mMainChild);
TransitionInfo.Change sideChange = createChange(TRANSIT_CLOSE, mSideChild);
TransitionInfo info = new TransitionInfo(TRANSIT_CLOSE, 0);
info.addChange(mainChange);
info.addChange(sideChange);
TransitionInfo info = new TransitionInfoBuilder(TRANSIT_CLOSE, 0)
.addChange(TRANSIT_CHANGE, mMainChild)
.addChange(TRANSIT_CLOSE, mSideChild)
.build();
mMainStage.onTaskVanished(mMainChild);
mSideStage.onTaskVanished(mSideChild);
boolean accepted = mStageCoordinator.startAnimation(transition, info,
@@ -408,13 +392,10 @@ public class SplitTransitionTests extends ShellTestCase {
}
private TransitionInfo createEnterPairInfo() {
TransitionInfo.Change mainChange = createChange(TRANSIT_OPEN, mMainChild);
TransitionInfo.Change sideChange = createChange(TRANSIT_OPEN, mSideChild);
TransitionInfo info = new TransitionInfo(TRANSIT_SPLIT_SCREEN_PAIR_OPEN, 0);
info.addChange(mainChange);
info.addChange(sideChange);
return info;
return new TransitionInfoBuilder(TRANSIT_SPLIT_SCREEN_PAIR_OPEN, 0)
.addChange(TRANSIT_OPEN, mMainChild)
.addChange(TRANSIT_OPEN, mSideChild)
.build();
}
private void enterSplit() {

View File

@@ -84,6 +84,7 @@ import androidx.test.platform.app.InstrumentationRegistry;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.TestShellExecutor;
import com.android.wm.shell.TransitionInfoBuilder;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.DisplayLayout;
import com.android.wm.shell.common.ShellExecutor;
@@ -947,43 +948,6 @@ public class ShellTransitionTests extends ShellTestCase {
verify(observer, times(0)).onTransitionFinished(eq(transitToken3), anyBoolean());
}
class TransitionInfoBuilder {
final TransitionInfo mInfo;
TransitionInfoBuilder(@WindowManager.TransitionType int type) {
this(type, 0 /* flags */);
}
TransitionInfoBuilder(@WindowManager.TransitionType int type,
@WindowManager.TransitionFlags int flags) {
mInfo = new TransitionInfo(type, flags);
mInfo.setRootLeash(createMockSurface(true /* valid */), 0, 0);
}
TransitionInfoBuilder addChange(@WindowManager.TransitionType int mode,
RunningTaskInfo taskInfo) {
final TransitionInfo.Change change =
new TransitionInfo.Change(null /* token */, createMockSurface(true));
change.setMode(mode);
change.setTaskInfo(taskInfo);
mInfo.addChange(change);
return this;
}
TransitionInfoBuilder addChange(@WindowManager.TransitionType int mode) {
return addChange(mode, null /* taskInfo */);
}
TransitionInfoBuilder addChange(TransitionInfo.Change change) {
mInfo.addChange(change);
return this;
}
TransitionInfo build() {
return mInfo;
}
}
class ChangeBuilder {
final TransitionInfo.Change mChange;

View File

@@ -2102,7 +2102,7 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
@VisibleForTesting
ChangeInfo(@NonNull WindowContainer container, boolean visible, boolean existChange) {
mContainer = container;
this(container);
mVisible = visible;
mExistenceChanged = existChange;
mShowWallpaper = false;

View File

@@ -662,6 +662,10 @@ public class TransitionTests extends WindowTestsBase {
changeInChange.setVisibleRequested(true);
openInOpen.setVisibleRequested(true);
openInChange.setVisibleRequested(true);
// Force the change-type changes to be "dirty" so they aren't skipped
changes.get(changeTask).mKnownConfigChanges = 1;
changes.get(changeInChangeTask).mKnownConfigChanges = 1;
changes.get(changeInChange).mKnownConfigChanges = 1;
final int transit = transition.mType;
int flags = 0;
@@ -716,7 +720,7 @@ public class TransitionTests extends WindowTestsBase {
changes.put(closing, new Transition.ChangeInfo(closing, true /* vis */, false /* exChg */));
fillChangeMap(changes, newTask);
// End states.
closing.setVisibleRequested(true);
closing.setVisibleRequested(false);
opening.setVisibleRequested(true);
final int transit = transition.mType;
@@ -757,7 +761,7 @@ public class TransitionTests extends WindowTestsBase {
changes.put(closing, new Transition.ChangeInfo(closing, true /* vis */, false /* exChg */));
fillChangeMap(changes, newTask);
// End states.
closing.setVisibleRequested(true);
closing.setVisibleRequested(false);
opening.setVisibleRequested(true);
final int transit = transition.mType;
@@ -1350,7 +1354,7 @@ public class TransitionTests extends WindowTestsBase {
assertEquals(2, info.getChanges().size());
assertFalse(info.getChanges().get(0).hasFlags(FLAG_FILLS_TASK));
assertEquals(embeddedTf.getBounds(), info.getChanges().get(0).getEndAbsBounds());
assertFalse(info.getChanges().get(1).hasFlags(FLAG_FILLS_TASK));
assertTrue(info.getChanges().get(1).hasFlags(FLAG_FILLS_TASK));
}
@Test