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

Commit 4ad639f5 authored by Chloris Kuo's avatar Chloris Kuo Committed by Automerger Merge Worker
Browse files

Merge "Fix flaky NotificationAssistantPreferenceControllerTest" into sc-dev am: 5c98cae2

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14806111

Change-Id: Iaa5b8cd0e87531951bb0b9fb8e604a5d323c6309
parents b3c4de85 5c98cae2
Loading
Loading
Loading
Loading
+48 −0
Original line number Diff line number Diff line
@@ -3001,6 +3001,54 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        verify(mAssistants, times(1)).getAllowedComponents(mContext.getUserId());
    }

    @Test
    public void testSetNASMigrationDoneAndResetDefault_enableNAS() throws Exception {
        int userId = 10;
        when(mUm.getProfileIds(userId, false)).thenReturn(new int[]{userId});

        mBinderService.setNASMigrationDoneAndResetDefault(userId, true);

        assertTrue(mService.isNASMigrationDone(userId));
        verify(mAssistants, times(1)).resetDefaultFromConfig();
    }

    @Test
    public void testSetNASMigrationDoneAndResetDefault_disableNAS() throws Exception {
        int userId = 10;
        when(mUm.getProfileIds(userId, false)).thenReturn(new int[]{userId});

        mBinderService.setNASMigrationDoneAndResetDefault(userId, false);

        assertTrue(mService.isNASMigrationDone(userId));
        verify(mAssistants, times(1)).clearDefaults();
    }

    @Test
    public void testSetNASMigrationDoneAndResetDefault_multiProfile() throws Exception {
        int userId1 = 11;
        int userId2 = 12; //work profile
        setUsers(new int[]{userId1, userId2});
        when(mUm.isManagedProfile(userId2)).thenReturn(true);
        when(mUm.getProfileIds(userId1, false)).thenReturn(new int[]{userId1, userId2});

        mBinderService.setNASMigrationDoneAndResetDefault(userId1, true);
        assertTrue(mService.isNASMigrationDone(userId1));
        assertTrue(mService.isNASMigrationDone(userId2));
    }

    @Test
    public void testSetNASMigrationDoneAndResetDefault_multiUser() throws Exception {
        int userId1 = 11;
        int userId2 = 12;
        setUsers(new int[]{userId1, userId2});
        when(mUm.getProfileIds(userId1, false)).thenReturn(new int[]{userId1});
        when(mUm.getProfileIds(userId2, false)).thenReturn(new int[]{userId2});

        mBinderService.setNASMigrationDoneAndResetDefault(userId1, true);
        assertTrue(mService.isNASMigrationDone(userId1));
        assertFalse(mService.isNASMigrationDone(userId2));
    }

    @Test
    public void testSetDndAccessForUser() throws Exception {
        UserHandle user = UserHandle.of(mContext.getUserId() + 10);