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

Commit 308824cb authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Add test to verify transient launch with keyguard

To simulate the case: a show-when-locked activity occluded
keyguard. Then when using gesture navigation to swipe-up
to trigger a transient transition, both the top app and recent
activity should be collected to transition with change. So
the condition "(mKeyguardLocked && mRecentsTask != null)" in
RecentsTransitionHandler will be satisfied.

Bug: 291123560
Test: atest ActivityStarterTests#testTransientLaunchWithKeyguard
Change-Id: Ie708af9cba9fa934cacad7b8338453da3ec871a3
parent 9b302377
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -1424,6 +1424,30 @@ public class ActivityStarterTests extends WindowTestsBase {
        assertThat(outActivity[0].inMultiWindowMode()).isTrue();
    }

    @Test
    public void testTransientLaunchWithKeyguard() {
        final ActivityStarter starter = prepareStarter(0 /* flags */);
        final ActivityRecord target = new ActivityBuilder(mAtm).setCreateTask(true).build();
        final ActivityRecord top = new ActivityBuilder(mAtm).setCreateTask(true).build();
        final KeyguardController keyguard = mSupervisor.getKeyguardController();
        doReturn(true).when(keyguard).isKeyguardLocked(anyInt());
        doReturn(true).when(keyguard).isDisplayOccluded(anyInt());
        registerTestTransitionPlayer();
        starter.setReason("testTransientLaunchWithKeyguard")
                .setActivityOptions(ActivityOptions.makeBasic().setTransientLaunch().toBundle())
                .setIntent(target.intent)
                .execute();
        final TransitionController controller = mRootWindowContainer.mTransitionController;
        final Transition transition = controller.getCollectingTransition();
        final Transition.ChangeInfo targetChangeInfo = transition.mChanges.get(target);

        assertThat(targetChangeInfo).isNotNull();
        assertThat(targetChangeInfo.hasChanged()).isTrue();
        assertThat(controller.isCollecting(top.getTask())).isTrue();
        assertThat(transition.isTransientLaunch(target)).isTrue();
        assertThat(transition.isInTransientHide(top.getTask())).isTrue();
    }

    @Test
    public void testActivityStart_expectAddedToRecentTask() {
        RecentTasks recentTasks = mock(RecentTasks.class);