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

Commit d3d1cf75 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix VisibilityPreferenceControllerTest."

parents bbdeafe5 8f688568
Loading
Loading
Loading
Loading
+17 −6
Original line number Diff line number Diff line
@@ -205,9 +205,10 @@ public class VisibilityPreferenceControllerTest {
        RestrictedDropDownPreference pref = mock(RestrictedDropDownPreference.class);
        mController.updateState(pref);

        ArgumentCaptor<String[]> argumentCaptor = ArgumentCaptor.forClass(String[].class);
        ArgumentCaptor<CharSequence[]> argumentCaptor =
            ArgumentCaptor.forClass(CharSequence[].class);
        verify(pref, times(1)).setEntryValues(argumentCaptor.capture());
        assertFalse(Arrays.asList(argumentCaptor.getValue())
        assertFalse(toStringList(argumentCaptor.getValue())
                .contains(VISIBILITY_NO_OVERRIDE));
    }

@@ -223,9 +224,10 @@ public class VisibilityPreferenceControllerTest {
        RestrictedDropDownPreference pref = mock(RestrictedDropDownPreference.class);
        mController.updateState(pref);

        ArgumentCaptor<String[]> argumentCaptor = ArgumentCaptor.forClass(String[].class);
        ArgumentCaptor<CharSequence[]> argumentCaptor =
            ArgumentCaptor.forClass(CharSequence[].class);
        verify(pref, times(1)).setEntryValues(argumentCaptor.capture());
        assertFalse(Arrays.asList(argumentCaptor.getValue())
        assertFalse(toStringList(argumentCaptor.getValue())
                .contains(VISIBILITY_NO_OVERRIDE));
    }

@@ -238,15 +240,24 @@ public class VisibilityPreferenceControllerTest {
        RestrictedDropDownPreference pref = mock(RestrictedDropDownPreference.class);
        mController.updateState(pref);

        ArgumentCaptor<String[]> argumentCaptor = ArgumentCaptor.forClass(String[].class);
        ArgumentCaptor<CharSequence[]> argumentCaptor =
            ArgumentCaptor.forClass(CharSequence[].class);
        verify(pref, times(1)).setEntryValues(argumentCaptor.capture());
        List<String> values = Arrays.asList(argumentCaptor.getValue());
        List<String> values = toStringList(argumentCaptor.getValue());
        assertEquals(3, values.size());
        assertTrue(values.contains(String.valueOf(VISIBILITY_NO_OVERRIDE)));
        assertTrue(values.contains(String.valueOf(Notification.VISIBILITY_PRIVATE)));
        assertTrue(values.contains(String.valueOf(Notification.VISIBILITY_SECRET)));
    }

    private static List<String> toStringList(CharSequence[] charSequences) {
        List<String> result = new ArrayList<>();
        for (CharSequence charSequence : charSequences) {
            result.add(charSequence.toString());
        }
        return result;
    }

    @Test
    public void testUpdateState_noChannelOverride() throws Exception {
        Settings.Secure.putInt(mContext.getContentResolver(),