Merge "Skip merging non-ready transition" into udc-dev
This commit is contained in:
@@ -799,6 +799,12 @@ public class Transitions implements RemoteCallable<Transitions> {
|
|||||||
++mergeIdx;
|
++mergeIdx;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (mergeCandidate.mInfo == null) {
|
||||||
|
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, "Transition merge candidate"
|
||||||
|
+ " %s is not ready yet", mergeCandidate.mToken);
|
||||||
|
// The later transition should not be merged if the prior one is not ready.
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (mergeCandidate.mMerged) {
|
if (mergeCandidate.mMerged) {
|
||||||
throw new IllegalStateException("Can't merge a transition after not-merging"
|
throw new IllegalStateException("Can't merge a transition after not-merging"
|
||||||
+ " a preceding one.");
|
+ " a preceding one.");
|
||||||
|
|||||||
@@ -563,6 +563,33 @@ public class ShellTransitionTests extends ShellTestCase {
|
|||||||
assertEquals(0, mDefaultHandler.activeCount());
|
assertEquals(0, mDefaultHandler.activeCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTransitionMergingOnFinish() {
|
||||||
|
final Transitions transitions = createTestTransitions();
|
||||||
|
transitions.replaceDefaultHandlerForTest(mDefaultHandler);
|
||||||
|
|
||||||
|
// The current transition.
|
||||||
|
final IBinder transitToken1 = new Binder();
|
||||||
|
requestStartTransition(transitions, transitToken1);
|
||||||
|
onTransitionReady(transitions, transitToken1);
|
||||||
|
|
||||||
|
// The next ready transition.
|
||||||
|
final IBinder transitToken2 = new Binder();
|
||||||
|
requestStartTransition(transitions, transitToken2);
|
||||||
|
onTransitionReady(transitions, transitToken2);
|
||||||
|
|
||||||
|
// The non-ready merge candidate.
|
||||||
|
final IBinder transitTokenNotReady = new Binder();
|
||||||
|
requestStartTransition(transitions, transitTokenNotReady);
|
||||||
|
|
||||||
|
mDefaultHandler.setSimulateMerge(true);
|
||||||
|
mDefaultHandler.mFinishes.get(0).onTransitionFinished(null /* wct */, null /* wctCB */);
|
||||||
|
|
||||||
|
// Make sure that the non-ready transition is not merged.
|
||||||
|
assertEquals(0, mDefaultHandler.mergeCount());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTransitionOrderMatchesCore() {
|
public void testTransitionOrderMatchesCore() {
|
||||||
Transitions transitions = createTestTransitions();
|
Transitions transitions = createTestTransitions();
|
||||||
@@ -1036,6 +1063,21 @@ public class ShellTransitionTests extends ShellTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void requestStartTransition(Transitions transitions, IBinder token) {
|
||||||
|
transitions.requestStartTransition(token,
|
||||||
|
new TransitionRequestInfo(TRANSIT_OPEN, null /* trigger */, null /* remote */));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void onTransitionReady(Transitions transitions, IBinder token) {
|
||||||
|
transitions.onTransitionReady(token, createTransitionInfo(),
|
||||||
|
mock(SurfaceControl.Transaction.class), mock(SurfaceControl.Transaction.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TransitionInfo createTransitionInfo() {
|
||||||
|
return new TransitionInfoBuilder(TRANSIT_OPEN)
|
||||||
|
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
|
||||||
|
}
|
||||||
|
|
||||||
private static SurfaceControl createMockSurface(boolean valid) {
|
private static SurfaceControl createMockSurface(boolean valid) {
|
||||||
SurfaceControl sc = mock(SurfaceControl.class);
|
SurfaceControl sc = mock(SurfaceControl.class);
|
||||||
doReturn(valid).when(sc).isValid();
|
doReturn(valid).when(sc).isValid();
|
||||||
|
|||||||
Reference in New Issue
Block a user