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

Commit a132412e authored by Julia Reynolds's avatar Julia Reynolds Committed by android-build-merger
Browse files

Merge "Add missing @Test" into qt-dev am: be19a6ab

am: 7dee570c

Change-Id: I8b69bf5ef527c4b20f2b5becbacf8cf01a97db76
parents 757e0c25 7dee570c
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -1515,6 +1515,11 @@ public class NotificationManagerService extends SystemService {
        mRankingHandler = rankingHandler;
    }

    @VisibleForTesting
    void setZenHelper(ZenModeHelper zenHelper) {
        mZenModeHelper = zenHelper;
    }

    @VisibleForTesting
    void setIsAutomotive(boolean isAutomotive) {
        mIsAutomotive = isAutomotive;
@@ -3563,7 +3568,7 @@ public class NotificationManagerService extends SystemService {
                return;
            }
            boolean accessAllowed = false;
            String[] packages = getContext().getPackageManager().getPackagesForUid(uid);
            String[] packages = mPackageManagerClient.getPackagesForUid(uid);
            final int packageCount = packages.length;
            for (int i = 0; i < packageCount; i++) {
                if (mConditionProviders.isPackageOrComponentAllowed(
+13 −2
Original line number Diff line number Diff line
@@ -348,6 +348,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        when(mPackageManagerClient.hasSystemFeature(FEATURE_WATCH)).thenReturn(false);
        when(mUgmInternal.newUriPermissionOwner(anyString())).thenReturn(mPermOwner);
        when(mPackageManager.getPackagesForUid(mUid)).thenReturn(new String[]{PKG});
        when(mPackageManagerClient.getPackagesForUid(anyInt())).thenReturn(new String[]{PKG});

        // write to a test file; the system file isn't readable from tests
        mFile = new File(mContext.getCacheDir(), "test.xml");
@@ -4948,6 +4949,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        assertEquals(1, mService.getNotificationRecordCount());
    }

    @Test
    public void testGetAllowedAssistantAdjustments() throws Exception {
        List<String> capabilities = mBinderService.getAllowedAssistantAdjustments(null);
        assertNotNull(capabilities);
@@ -4962,8 +4964,11 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        }
    }

    @Test
    public void testAdjustRestrictedKey() throws Exception {
        NotificationRecord r = generateNotificationRecord(mTestNotificationChannel);
        mService.addNotification(r);
        when(mAssistants.isSameUser(any(), anyInt())).thenReturn(true);

        when(mAssistants.isAdjustmentAllowed(KEY_IMPORTANCE)).thenReturn(true);
        when(mAssistants.isAdjustmentAllowed(KEY_USER_SENTIMENT)).thenReturn(false);
@@ -4981,8 +4986,12 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        assertEquals(USER_SENTIMENT_NEUTRAL, r.getUserSentiment());
    }

    @Test
    public void testAutomaticZenRuleValidation_policyFilterAgreement() throws Exception {
        ComponentName owner = mock(ComponentName.class);
        when(mConditionProviders.isPackageOrComponentAllowed(anyString(), anyInt()))
                .thenReturn(true);
        mService.setZenHelper(mock(ZenModeHelper.class));
        ComponentName owner = new ComponentName(mContext, this.getClass());
        ZenPolicy zenPolicy = new ZenPolicy.Builder().allowAlarms(true).build();
        boolean isEnabled = true;
        AutomaticZenRule rule = new AutomaticZenRule("test", owner, owner, mock(Uri.class),
@@ -4990,7 +4999,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {

        try {
            mBinderService.addAutomaticZenRule(rule);
            fail("Zen policy only aplies to priority only mode");
            fail("Zen policy only applies to priority only mode");
        } catch (IllegalArgumentException e) {
            // yay
        }
@@ -5004,6 +5013,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        mBinderService.addAutomaticZenRule(rule);
    }

    @Test
    public void testAreNotificationsEnabledForPackage_crossUser() throws Exception {
        try {
            mBinderService.areNotificationsEnabledForPackage(mContext.getPackageName(),
@@ -5020,6 +5030,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
                mUid + UserHandle.PER_USER_RANGE);
    }

    @Test
    public void testAreBubblesAllowedForPackage_crossUser() throws Exception {
        try {
            mBinderService.areBubblesAllowedForPackage(mContext.getPackageName(),