Merge "Test Recents Transition sleep re-entry" into udc-dev

This commit is contained in:
Robin Lee
2023-05-01 14:59:56 +00:00
committed by Android (Google) Code Review
12 changed files with 185 additions and 59 deletions

View File

@@ -48,6 +48,7 @@ import android.window.TransitionRequestInfo;
import android.window.WindowContainerToken;
import android.window.WindowContainerTransaction;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.protolog.common.ProtoLog;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.protolog.ShellProtoLogGroup;
@@ -97,7 +98,8 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler {
mMixers.remove(mixer);
}
void startRecentsTransition(PendingIntent intent, Intent fillIn, Bundle options,
@VisibleForTesting
public IBinder startRecentsTransition(PendingIntent intent, Intent fillIn, Bundle options,
IApplicationThread appThread, IRecentsAnimationRunner listener) {
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION,
"RecentsTransitionHandler.startRecentsTransition");
@@ -121,12 +123,13 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler {
if (mixer != null) {
mixer.setRecentsTransition(transition);
}
if (transition == null) {
if (transition != null) {
controller.setTransition(transition);
mControllers.add(controller);
} else {
controller.cancel("startRecentsTransition");
return;
}
controller.setTransition(transition);
mControllers.add(controller);
return transition;
}
@Override

View File

@@ -47,7 +47,7 @@ android_test {
"truth-prebuilt",
"testables",
"platform-test-annotations",
"frameworks-base-testutils",
"servicestests-utils",
],
libs: [

View File

@@ -17,6 +17,7 @@
package com.android.wm.shell.transition;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
@@ -50,6 +51,7 @@ import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.after;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.inOrder;
@@ -58,14 +60,19 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import android.app.ActivityManager.RunningTaskInfo;
import android.app.IApplicationThread;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.RemoteException;
import android.util.ArraySet;
import android.util.Pair;
import android.view.IRecentsAnimationRunner;
import android.view.Surface;
import android.view.SurfaceControl;
import android.view.WindowManager;
@@ -86,6 +93,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import androidx.test.platform.app.InstrumentationRegistry;
import com.android.server.testutils.StubTransaction;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.TestShellExecutor;
import com.android.wm.shell.TransitionInfoBuilder;
@@ -93,6 +101,7 @@ import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.DisplayLayout;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.TransactionPool;
import com.android.wm.shell.recents.RecentsTransitionHandler;
import com.android.wm.shell.sysui.ShellController;
import com.android.wm.shell.sysui.ShellInit;
import com.android.wm.shell.sysui.ShellSharedConstants;
@@ -100,6 +109,7 @@ import com.android.wm.shell.sysui.ShellSharedConstants;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.InOrder;
import java.util.ArrayList;
@@ -162,8 +172,8 @@ public class ShellTransitionTests extends ShellTestCase {
verify(mOrganizer, times(1)).startTransition(eq(transitToken), any());
TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
transitions.onTransitionReady(transitToken, info, mock(SurfaceControl.Transaction.class),
mock(SurfaceControl.Transaction.class));
transitions.onTransitionReady(transitToken, info, new StubTransaction(),
new StubTransaction());
assertEquals(1, mDefaultHandler.activeCount());
mDefaultHandler.finishAll();
mMainExecutor.flushAll();
@@ -212,8 +222,8 @@ public class ShellTransitionTests extends ShellTestCase {
transitions.requestStartTransition(transitToken,
new TransitionRequestInfo(TRANSIT_OPEN, null /* trigger */, null /* remote */));
verify(mOrganizer, times(1)).startTransition(eq(transitToken), isNull());
transitions.onTransitionReady(transitToken, open, mock(SurfaceControl.Transaction.class),
mock(SurfaceControl.Transaction.class));
transitions.onTransitionReady(transitToken, open, new StubTransaction(),
new StubTransaction());
assertEquals(1, mDefaultHandler.activeCount());
assertEquals(0, testHandler.activeCount());
mDefaultHandler.finishAll();
@@ -228,8 +238,8 @@ public class ShellTransitionTests extends ShellTestCase {
new TransitionRequestInfo(TRANSIT_OPEN, mwTaskInfo, null /* remote */));
verify(mOrganizer, times(1)).startTransition(
eq(transitToken), eq(handlerWCT));
transitions.onTransitionReady(transitToken, open, mock(SurfaceControl.Transaction.class),
mock(SurfaceControl.Transaction.class));
transitions.onTransitionReady(transitToken, open, new StubTransaction(),
new StubTransaction());
assertEquals(1, mDefaultHandler.activeCount());
assertEquals(0, testHandler.activeCount());
mDefaultHandler.finishAll();
@@ -246,8 +256,8 @@ public class ShellTransitionTests extends ShellTestCase {
eq(transitToken), eq(handlerWCT));
TransitionInfo change = new TransitionInfoBuilder(TRANSIT_CHANGE)
.addChange(TRANSIT_CHANGE).build();
transitions.onTransitionReady(transitToken, change, mock(SurfaceControl.Transaction.class),
mock(SurfaceControl.Transaction.class));
transitions.onTransitionReady(transitToken, change, new StubTransaction(),
new StubTransaction());
assertEquals(0, mDefaultHandler.activeCount());
assertEquals(1, testHandler.activeCount());
assertEquals(0, topHandler.activeCount());
@@ -284,8 +294,8 @@ public class ShellTransitionTests extends ShellTestCase {
verify(mOrganizer, times(1)).startTransition(eq(transitToken), any());
TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
transitions.onTransitionReady(transitToken, info, mock(SurfaceControl.Transaction.class),
mock(SurfaceControl.Transaction.class));
transitions.onTransitionReady(transitToken, info, new StubTransaction(),
new StubTransaction());
assertEquals(0, mDefaultHandler.activeCount());
assertTrue(remoteCalled[0]);
mDefaultHandler.finishAll();
@@ -434,8 +444,8 @@ public class ShellTransitionTests extends ShellTestCase {
verify(mOrganizer, times(1)).startTransition(eq(transitToken), any());
TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
transitions.onTransitionReady(transitToken, info, mock(SurfaceControl.Transaction.class),
mock(SurfaceControl.Transaction.class));
transitions.onTransitionReady(transitToken, info, new StubTransaction(),
new StubTransaction());
assertEquals(0, mDefaultHandler.activeCount());
assertTrue(remoteCalled[0]);
mDefaultHandler.finishAll();
@@ -484,10 +494,10 @@ public class ShellTransitionTests extends ShellTestCase {
oneShot.setTransition(transitToken);
IBinder anotherToken = new Binder();
assertFalse(oneShot.startAnimation(anotherToken, new TransitionInfo(transitType, 0),
mock(SurfaceControl.Transaction.class), mock(SurfaceControl.Transaction.class),
new StubTransaction(), new StubTransaction(),
testFinish));
assertTrue(oneShot.startAnimation(transitToken, new TransitionInfo(transitType, 0),
mock(SurfaceControl.Transaction.class), mock(SurfaceControl.Transaction.class),
new StubTransaction(), new StubTransaction(),
testFinish));
}
@@ -501,8 +511,8 @@ public class ShellTransitionTests extends ShellTestCase {
new TransitionRequestInfo(TRANSIT_OPEN, null /* trigger */, null /* remote */));
TransitionInfo info1 = new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
transitions.onTransitionReady(transitToken1, info1, mock(SurfaceControl.Transaction.class),
mock(SurfaceControl.Transaction.class));
transitions.onTransitionReady(transitToken1, info1, new StubTransaction(),
new StubTransaction());
assertEquals(1, mDefaultHandler.activeCount());
IBinder transitToken2 = new Binder();
@@ -510,8 +520,8 @@ public class ShellTransitionTests extends ShellTestCase {
new TransitionRequestInfo(TRANSIT_CLOSE, null /* trigger */, null /* remote */));
TransitionInfo info2 = new TransitionInfoBuilder(TRANSIT_CLOSE)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
transitions.onTransitionReady(transitToken2, info2, mock(SurfaceControl.Transaction.class),
mock(SurfaceControl.Transaction.class));
transitions.onTransitionReady(transitToken2, info2, new StubTransaction(),
new StubTransaction());
// default handler doesn't merge by default, so it shouldn't increment active count.
assertEquals(1, mDefaultHandler.activeCount());
assertEquals(0, mDefaultHandler.mergeCount());
@@ -542,8 +552,8 @@ public class ShellTransitionTests extends ShellTestCase {
new TransitionRequestInfo(TRANSIT_OPEN, null /* trigger */, null /* remote */));
TransitionInfo info1 = new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
transitions.onTransitionReady(transitToken1, info1, mock(SurfaceControl.Transaction.class),
mock(SurfaceControl.Transaction.class));
transitions.onTransitionReady(transitToken1, info1, new StubTransaction(),
new StubTransaction());
assertEquals(1, mDefaultHandler.activeCount());
IBinder transitToken2 = new Binder();
@@ -551,8 +561,8 @@ public class ShellTransitionTests extends ShellTestCase {
new TransitionRequestInfo(TRANSIT_CLOSE, null /* trigger */, null /* remote */));
TransitionInfo info2 = new TransitionInfoBuilder(TRANSIT_CLOSE)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
transitions.onTransitionReady(transitToken2, info2, mock(SurfaceControl.Transaction.class),
mock(SurfaceControl.Transaction.class));
transitions.onTransitionReady(transitToken2, info2, new StubTransaction(),
new StubTransaction());
// it should still only have 1 active, but then show 1 merged
assertEquals(1, mDefaultHandler.activeCount());
assertEquals(1, mDefaultHandler.mergeCount());
@@ -611,8 +621,8 @@ public class ShellTransitionTests extends ShellTestCase {
new TransitionRequestInfo(TRANSIT_OPEN, null /* trigger */, null /* remote */));
TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
transitions.onTransitionReady(token, info, mock(SurfaceControl.Transaction.class),
mock(SurfaceControl.Transaction.class));
transitions.onTransitionReady(token, info, new StubTransaction(),
new StubTransaction());
return token;
};
@@ -678,8 +688,8 @@ public class ShellTransitionTests extends ShellTestCase {
// queued), so continue the transition lifecycle for that.
TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
transitions.onTransitionReady(transitToken, info, mock(SurfaceControl.Transaction.class),
mock(SurfaceControl.Transaction.class));
transitions.onTransitionReady(transitToken, info, new StubTransaction(),
new StubTransaction());
// At this point, if things are not working, we'd get an NPE due to attempting to merge
// into the shellInit transition which hasn't started yet.
assertEquals(1, mDefaultHandler.activeCount());
@@ -791,8 +801,8 @@ public class ShellTransitionTests extends ShellTestCase {
new TransitionRequestInfo(TRANSIT_OPEN, null /* trigger */, null /* remote */));
TransitionInfo info1 = new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
transitions.onTransitionReady(transitToken1, info1, mock(SurfaceControl.Transaction.class),
mock(SurfaceControl.Transaction.class));
transitions.onTransitionReady(transitToken1, info1, new StubTransaction(),
new StubTransaction());
assertEquals(1, mDefaultHandler.activeCount());
transitions.runOnIdle(runnable2);
@@ -806,8 +816,8 @@ public class ShellTransitionTests extends ShellTestCase {
new TransitionRequestInfo(TRANSIT_CLOSE, null /* trigger */, null /* remote */));
TransitionInfo info2 = new TransitionInfoBuilder(TRANSIT_CLOSE)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
transitions.onTransitionReady(transitToken2, info2, mock(SurfaceControl.Transaction.class),
mock(SurfaceControl.Transaction.class));
transitions.onTransitionReady(transitToken2, info2, new StubTransaction(),
new StubTransaction());
assertEquals(1, mDefaultHandler.activeCount());
mDefaultHandler.finishAll();
@@ -858,8 +868,8 @@ public class ShellTransitionTests extends ShellTestCase {
new TransitionRequestInfo(TRANSIT_OPEN, null /* trigger */, null /* remote */));
TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
SurfaceControl.Transaction startT = mock(SurfaceControl.Transaction.class);
SurfaceControl.Transaction finishT = mock(SurfaceControl.Transaction.class);
SurfaceControl.Transaction startT = new StubTransaction();
SurfaceControl.Transaction finishT = new StubTransaction();
transitions.onTransitionReady(transitToken, info, startT, finishT);
InOrder observerOrder = inOrder(observer);
@@ -883,8 +893,8 @@ public class ShellTransitionTests extends ShellTestCase {
new TransitionRequestInfo(TRANSIT_OPEN, null /* trigger */, null /* remote */));
TransitionInfo info1 = new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
SurfaceControl.Transaction startT1 = mock(SurfaceControl.Transaction.class);
SurfaceControl.Transaction finishT1 = mock(SurfaceControl.Transaction.class);
SurfaceControl.Transaction startT1 = new StubTransaction();
SurfaceControl.Transaction finishT1 = new StubTransaction();
transitions.onTransitionReady(transitToken1, info1, startT1, finishT1);
verify(observer).onTransitionReady(transitToken1, info1, startT1, finishT1);
@@ -893,8 +903,8 @@ public class ShellTransitionTests extends ShellTestCase {
new TransitionRequestInfo(TRANSIT_CLOSE, null /* trigger */, null /* remote */));
TransitionInfo info2 = new TransitionInfoBuilder(TRANSIT_CLOSE)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
SurfaceControl.Transaction startT2 = mock(SurfaceControl.Transaction.class);
SurfaceControl.Transaction finishT2 = mock(SurfaceControl.Transaction.class);
SurfaceControl.Transaction startT2 = new StubTransaction();
SurfaceControl.Transaction finishT2 = new StubTransaction();
transitions.onTransitionReady(transitToken2, info2, startT2, finishT2);
verify(observer, times(1)).onTransitionReady(transitToken2, info2, startT2, finishT2);
verify(observer, times(0)).onTransitionStarting(transitToken2);
@@ -927,8 +937,8 @@ public class ShellTransitionTests extends ShellTestCase {
new TransitionRequestInfo(TRANSIT_OPEN, null /* trigger */, null /* remote */));
TransitionInfo info1 = new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
SurfaceControl.Transaction startT1 = mock(SurfaceControl.Transaction.class);
SurfaceControl.Transaction finishT1 = mock(SurfaceControl.Transaction.class);
SurfaceControl.Transaction startT1 = new StubTransaction();
SurfaceControl.Transaction finishT1 = new StubTransaction();
transitions.onTransitionReady(transitToken1, info1, startT1, finishT1);
IBinder transitToken2 = new Binder();
@@ -936,8 +946,8 @@ public class ShellTransitionTests extends ShellTestCase {
new TransitionRequestInfo(TRANSIT_CLOSE, null /* trigger */, null /* remote */));
TransitionInfo info2 = new TransitionInfoBuilder(TRANSIT_CLOSE)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
SurfaceControl.Transaction startT2 = mock(SurfaceControl.Transaction.class);
SurfaceControl.Transaction finishT2 = mock(SurfaceControl.Transaction.class);
SurfaceControl.Transaction startT2 = new StubTransaction();
SurfaceControl.Transaction finishT2 = new StubTransaction();
transitions.onTransitionReady(transitToken2, info2, startT2, finishT2);
InOrder observerOrder = inOrder(observer);
@@ -999,8 +1009,8 @@ public class ShellTransitionTests extends ShellTestCase {
new TransitionRequestInfo(TRANSIT_CHANGE, mwTaskInfo, null /* remote */));
TransitionInfo change = new TransitionInfoBuilder(TRANSIT_CHANGE)
.addChange(TRANSIT_CHANGE).build();
SurfaceControl.Transaction startT1 = mock(SurfaceControl.Transaction.class);
SurfaceControl.Transaction finishT1 = mock(SurfaceControl.Transaction.class);
SurfaceControl.Transaction startT1 = new StubTransaction();
SurfaceControl.Transaction finishT1 = new StubTransaction();
transitions.onTransitionReady(transitToken1, change, startT1, finishT1);
// Request the second transition that should be handled by the default handler
@@ -1009,8 +1019,8 @@ public class ShellTransitionTests extends ShellTestCase {
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
transitions.requestStartTransition(transitToken2,
new TransitionRequestInfo(TRANSIT_OPEN, null /* trigger */, null /* remote */));
SurfaceControl.Transaction startT2 = mock(SurfaceControl.Transaction.class);
SurfaceControl.Transaction finishT2 = mock(SurfaceControl.Transaction.class);
SurfaceControl.Transaction startT2 = new StubTransaction();
SurfaceControl.Transaction finishT2 = new StubTransaction();
transitions.onTransitionReady(transitToken2, open, startT2, finishT2);
verify(observer).onTransitionReady(transitToken2, open, startT2, finishT2);
verify(observer, times(0)).onTransitionStarting(transitToken2);
@@ -1019,8 +1029,8 @@ public class ShellTransitionTests extends ShellTestCase {
IBinder transitToken3 = new Binder();
transitions.requestStartTransition(transitToken3,
new TransitionRequestInfo(TRANSIT_OPEN, null /* trigger */, null /* remote */));
SurfaceControl.Transaction startT3 = mock(SurfaceControl.Transaction.class);
SurfaceControl.Transaction finishT3 = mock(SurfaceControl.Transaction.class);
SurfaceControl.Transaction startT3 = new StubTransaction();
SurfaceControl.Transaction finishT3 = new StubTransaction();
transitions.onTransitionReady(transitToken3, open, startT3, finishT3);
verify(observer, times(0)).onTransitionStarting(transitToken2);
verify(observer).onTransitionReady(transitToken3, open, startT3, finishT3);
@@ -1044,6 +1054,104 @@ public class ShellTransitionTests extends ShellTestCase {
verify(observer, times(0)).onTransitionFinished(eq(transitToken3), anyBoolean());
}
@Test
public void testTransitSleep_squashesRecents() {
ShellInit shellInit = new ShellInit(mMainExecutor);
final Transitions transitions =
new Transitions(mContext, shellInit, mock(ShellController.class), mOrganizer,
mTransactionPool, createTestDisplayController(), mMainExecutor,
mMainHandler, mAnimExecutor);
final RecentsTransitionHandler recentsHandler =
new RecentsTransitionHandler(shellInit, transitions, null);
transitions.replaceDefaultHandlerForTest(mDefaultHandler);
shellInit.init();
Transitions.TransitionObserver observer = mock(Transitions.TransitionObserver.class);
transitions.registerObserver(observer);
RunningTaskInfo task1 = createTaskInfo(1, WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_RECENTS);
RunningTaskInfo task2 = createTaskInfo(2);
// Start an open transition for the purpose of occupying the ready queue
final IBinder transitOpen1 = new Binder("transitOpen1");
final TransitionInfo infoOpen1 =
new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN, task1)
.build();
mMainExecutor.execute(() -> {
transitions.requestStartTransition(transitOpen1, new TransitionRequestInfo(
TRANSIT_OPEN, task1 /* trigger */, null /* remote */));
onTransitionReady(transitions, transitOpen1, infoOpen1);
});
// First transition on the queue should start immediately.
mMainExecutor.flushAll();
verify(observer).onTransitionReady(eq(transitOpen1), any(), any(), any());
verify(observer).onTransitionStarting(eq(transitOpen1));
// Start recents
final IRecentsAnimationRunner recentsListener =
mock(IRecentsAnimationRunner.class, Answers.RETURNS_DEEP_STUBS);
final IBinder transitRecents = recentsHandler.startRecentsTransition(
mock(PendingIntent.class) /* intent */,
mock(Intent.class) /* fillIn */,
new Bundle() /* options */,
mock(IApplicationThread.class) /* appThread */,
recentsListener);
final TransitionInfo infoRecents =
new TransitionInfoBuilder(TRANSIT_TO_FRONT)
.addChange(TRANSIT_TO_FRONT, task1)
.addChange(TRANSIT_CLOSE, task2)
.build();
onTransitionReady(transitions, transitRecents, infoRecents);
// Start another open transition during recents
final IBinder transitOpen2 = new Binder("transitOpen2");
final TransitionInfo infoOpen2 =
new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN, task2)
.addChange(TRANSIT_TO_BACK, task1)
.build();
mMainExecutor.execute(() -> {
transitions.requestStartTransition(transitOpen2, new TransitionRequestInfo(
TRANSIT_OPEN, task2 /* trigger */, null /* remote */));
onTransitionReady(transitions, transitOpen2, infoOpen2);
});
// Finish testOpen1 to start processing the other transitions
mMainExecutor.execute(() -> {
mDefaultHandler.finishOne();
});
mMainExecutor.flushAll();
// Recents transition SHOULD start, and merge the open transition, which should NOT start.
verify(observer).onTransitionFinished(eq(transitOpen1), eq(false) /* aborted */);
verify(observer).onTransitionReady(eq(transitRecents), any(), any(), any());
verify(observer).onTransitionStarting(eq(transitRecents));
verify(observer).onTransitionReady(eq(transitOpen2), any(), any(), any());
verify(observer).onTransitionMerged(eq(transitOpen2), eq(transitRecents));
// verify(observer).onTransitionFinished(eq(transitOpen2), eq(true) /* aborted */);
// Go to sleep
final IBinder transitSleep = new Binder("transitSleep");
final TransitionInfo infoSleep = new TransitionInfoBuilder(TRANSIT_SLEEP).build();
mMainExecutor.execute(() -> {
transitions.requestStartTransition(transitSleep, new TransitionRequestInfo(
TRANSIT_SLEEP, null /* trigger */, null /* remote */));
onTransitionReady(transitions, transitSleep, infoSleep);
});
mMainExecutor.flushAll();
// Recents transition should finish itself when it sees the sleep transition coming.
verify(observer).onTransitionFinished(eq(transitRecents), eq(false));
verify(observer).onTransitionFinished(eq(transitSleep), eq(false));
}
private void onTransitionReady(Transitions transitions, IBinder token, TransitionInfo info) {
transitions.onTransitionReady(token, info, new StubTransaction(),
new StubTransaction());
}
@Test
public void testEmptyTransitionStillReportsKeyguardGoingAway() {
Transitions transitions = createTestTransitions();
@@ -1056,8 +1164,8 @@ public class ShellTransitionTests extends ShellTestCase {
// Make a no-op transition
TransitionInfo info = new TransitionInfoBuilder(
TRANSIT_OPEN, TRANSIT_FLAG_KEYGUARD_GOING_AWAY, true /* noOp */).build();
transitions.onTransitionReady(transitToken, info, mock(SurfaceControl.Transaction.class),
mock(SurfaceControl.Transaction.class));
transitions.onTransitionReady(transitToken, info, new StubTransaction(),
new StubTransaction());
// If keyguard-going-away flag set, then it shouldn't be aborted.
assertEquals(1, mDefaultHandler.activeCount());
@@ -1397,7 +1505,7 @@ public class ShellTransitionTests extends ShellTestCase {
private static void onTransitionReady(Transitions transitions, IBinder token) {
transitions.onTransitionReady(token, createTransitionInfo(),
mock(SurfaceControl.Transaction.class), mock(SurfaceControl.Transaction.class));
new StubTransaction(), new StubTransaction());
}
private static TransitionInfo createTransitionInfo() {
@@ -1414,15 +1522,15 @@ public class ShellTransitionTests extends ShellTestCase {
private static RunningTaskInfo createTaskInfo(int taskId, int windowingMode, int activityType) {
RunningTaskInfo taskInfo = new RunningTaskInfo();
taskInfo.taskId = taskId;
taskInfo.topActivityType = activityType;
taskInfo.configuration.windowConfiguration.setWindowingMode(windowingMode);
taskInfo.configuration.windowConfiguration.setActivityType(activityType);
taskInfo.token = mock(WindowContainerToken.class);
return taskInfo;
}
private static RunningTaskInfo createTaskInfo(int taskId) {
RunningTaskInfo taskInfo = new RunningTaskInfo();
taskInfo.taskId = taskId;
return taskInfo;
return createTaskInfo(taskId, WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD);
}
private DisplayController createTestDisplayController() {

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.android.server.wm;
package com.android.server.testutils;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -30,6 +30,8 @@ import android.view.InputWindowHandle;
import android.view.Surface;
import android.view.SurfaceControl;
import com.android.server.testutils.StubTransaction;
import java.util.HashSet;
import java.util.concurrent.Executor;

View File

@@ -36,6 +36,7 @@ import android.view.SurfaceControl;
import android.view.SurfaceSession;
import com.android.server.wm.SurfaceAnimator.AnimationType;
import com.android.server.testutils.StubTransaction;
import org.junit.Before;
import org.junit.Test;

View File

@@ -37,6 +37,8 @@ import android.view.SurfaceControl;
import androidx.test.filters.SmallTest;
import com.android.server.testutils.StubTransaction;
import org.junit.Before;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;

View File

@@ -30,6 +30,8 @@ import android.window.SurfaceSyncGroup;
import androidx.test.filters.SmallTest;
import com.android.server.testutils.StubTransaction;
import org.junit.Before;
import org.junit.Test;

View File

@@ -42,6 +42,7 @@ import android.view.SurfaceControl;
import androidx.test.filters.SmallTest;
import com.android.server.testutils.StubTransaction;
import com.android.server.testutils.TestHandler;
import org.junit.Before;

View File

@@ -88,6 +88,7 @@ import com.android.server.pm.UserManagerService;
import com.android.server.policy.PermissionPolicyInternal;
import com.android.server.policy.WindowManagerPolicy;
import com.android.server.statusbar.StatusBarManagerInternal;
import com.android.server.testutils.StubTransaction;
import com.android.server.uri.UriGrantsManagerInternal;
import org.junit.rules.TestRule;

View File

@@ -38,6 +38,8 @@ import android.view.animation.ClipRectAnimation;
import androidx.test.filters.SmallTest;
import com.android.server.testutils.StubTransaction;
import org.junit.Test;
/**

View File

@@ -28,6 +28,8 @@ import android.platform.test.annotations.Presubmit;
import androidx.test.filters.SmallTest;
import com.android.server.testutils.StubTransaction;
import org.junit.Test;
import org.junit.runner.RunWith;

View File

@@ -110,6 +110,8 @@ import android.window.TaskFragmentOrganizer;
import androidx.test.filters.SmallTest;
import com.android.server.testutils.StubTransaction;
import org.junit.Test;
import org.junit.runner.RunWith;