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

Commit 5addb3b3 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Clarify unit test testOnStartingWindowDrawn

It becomes flaky with unknown reason.
Make some conditions more explicit to clarify.

Fix: 378177797
Flag: EXEMPT unit test
Test: ActivityRecordTests#testOnStartingWindowDrawn
Change-Id: I9aedeb442e7de473fb8f10b44452f98c37f2f1f8
parent 247a20f2
Loading
Loading
Loading
Loading
+8 −2
Original line number Original line Diff line number Diff line
@@ -3139,11 +3139,13 @@ public class ActivityRecordTests extends WindowTestsBase {


    @Test
    @Test
    public void testOnStartingWindowDrawn() {
    public void testOnStartingWindowDrawn() {
        // Skip unnecessary resume top.
        mSupervisor.beginDeferResume();
        final ActivityRecord activity = new ActivityBuilder(mAtm).setCreateTask(true).build();
        final ActivityRecord activity = new ActivityBuilder(mAtm).setCreateTask(true).build();
        // The task-has-been-visible should not affect the decision of making transition ready.
        // The task-has-been-visible should not affect the decision of making transition ready.
        activity.getTask().setHasBeenVisible(true);
        activity.getTask().setHasBeenVisible(true);
        activity.detachFromProcess();
        activity.detachFromProcess();
        activity.mStartingData = mock(StartingData.class);
        activity.mStartingData = new SplashScreenStartingData(mWm, 0, 0);
        registerTestTransitionPlayer();
        registerTestTransitionPlayer();
        final Transition transition = activity.mTransitionController.requestTransitionIfNeeded(
        final Transition transition = activity.mTransitionController.requestTransitionIfNeeded(
                WindowManager.TRANSIT_OPEN, 0 /* flags */, null /* trigger */, mDisplayContent);
                WindowManager.TRANSIT_OPEN, 0 /* flags */, null /* trigger */, mDisplayContent);
@@ -3151,7 +3153,11 @@ public class ActivityRecordTests extends WindowTestsBase {
        assertTrue(activity.mStartingData.mIsDisplayed);
        assertTrue(activity.mStartingData.mIsDisplayed);
        // The transition can be ready by the starting window of a visible-requested activity
        // The transition can be ready by the starting window of a visible-requested activity
        // without a running process.
        // without a running process.
        assertTrue(transition.allReady());
        if (!transition.allReady()) {
            // Print unsatisfied conditions.
            transition.onReadyTimeout();
            Assert.fail(transition + " must be ready by onStartingWindowDrawn");
        }


        // If other event makes the transition unready, the reentrant of onStartingWindowDrawn
        // If other event makes the transition unready, the reentrant of onStartingWindowDrawn
        // should not replace the readiness again.
        // should not replace the readiness again.