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

Commit 1b76df58 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Add null check for tests

Test: NotificationLockscreenUserManagerTest
Fixes: 309843569
Change-Id: Ie93eb1903cb6b55725e58bf8d8868d3767d33f4b
parent dc4b512e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -679,7 +679,7 @@ public class NotificationLockscreenUserManagerImpl implements
        }
        NotificationEntry entry = mCommonNotifCollectionLazy.get().getEntry(key);
        if (mFeatureFlags.isEnabled(Flags.NOTIF_LS_BACKGROUND_THREAD)) {
            return entry != null
            return entry != null && entry.getRanking().getChannel() != null
                    && entry.getRanking().getChannel().getLockscreenVisibility()
                    == Notification.VISIBILITY_PRIVATE;
        } else {
+14 −0
Original line number Diff line number Diff line
@@ -294,6 +294,20 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
        assertTrue(mLockscreenUserManager.needsRedaction(mCurrentUserNotif));
    }

    @Test
    public void testCurrentUserPrivateNotificationsNullChannel() {
        // GIVEN current user allows private notifications to show
        mSettings.putIntForUser(LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1,
                mCurrentUser.id);
        changeSetting(LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS);

        mCurrentUserNotif.setRanking(new RankingBuilder(mCurrentUserNotif.getRanking())
                .setChannel(null)
                .setVisibilityOverride(VISIBILITY_NO_OVERRIDE).build());
        // THEN the notification is not redacted
        assertFalse(mLockscreenUserManager.needsRedaction(mCurrentUserNotif));
    }

    @Test
    public void testWorkPrivateNotificationsRedacted() {
        // GIVEN work profile doesn't private notifications to show