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

Commit 3afbdae8 authored by Vladimir Komsiyski's avatar Vladimir Komsiyski
Browse files

Add GWPC test for user not allowed to launch.

The test passes even when the blocked loop is in place because
the BlockedAppStreamingActivity is not launched from GWPC.

Bug: 309036757
Test: presubmit
Change-Id: Id6f6c46a5d00ee28406fc7546762b25ffd2da13f
parent 54b89873
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
@@ -150,6 +150,19 @@ public class GenericWindowPolicyControllerTest {
        verify(mPipBlockedCallback, after(TIMEOUT_MILLIS).never()).onEnteringPipBlocked(TEST_UID);
    }

    @Test
    public void userNotAllowlisted_launchIsBlocked() {
        GenericWindowPolicyController gwpc = createGwpcWithNoAllowedUsers();
        gwpc.setDisplayId(DISPLAY_ID, /* isMirrorDisplay= */ false);

        ActivityInfo activityInfo = getActivityInfo(
                NONBLOCKED_APP_PACKAGE_NAME,
                NONBLOCKED_APP_PACKAGE_NAME,
                /* displayOnRemoteDevices */ true,
                /* targetDisplayCategory */ null);
        assertActivityIsBlocked(gwpc, activityInfo);
    }

    @Test
    public void openNonBlockedAppOnVirtualDisplay_isNotBlocked() {
        GenericWindowPolicyController gwpc = createGwpc();
@@ -702,6 +715,26 @@ public class GenericWindowPolicyControllerTest {
                /* customHomeComponent= */ null);
    }

    private GenericWindowPolicyController createGwpcWithNoAllowedUsers() {
        return new GenericWindowPolicyController(
                0,
                0,
                /* allowedUsers= */ new ArraySet<>(),
                /* activityLaunchAllowedByDefault= */ true,
                /* activityPolicyExemptions= */ new ArraySet<>(),
                /* crossTaskNavigationAllowedByDefault= */ true,
                /* crossTaskNavigationExemptions= */ new ArraySet<>(),
                /* permissionDialogComponent= */ null,
                /* activityListener= */ mActivityListener,
                /* pipBlockedCallback= */ mPipBlockedCallback,
                /* activityBlockedCallback= */ mActivityBlockedCallback,
                /* secureWindowCallback= */ mSecureWindowCallback,
                /* intentListenerCallback= */ mIntentListenerCallback,
                /* displayCategories= */ new ArraySet<>(),
                /* showTasksInHostDeviceRecents= */ true,
                /* customHomeComponent= */ null);
    }

    private GenericWindowPolicyController createGwpcWithCustomHomeComponent(
            ComponentName homeComponent) {
        return new GenericWindowPolicyController(