Search in sources :

Example 46 with Preference

use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class NetworkScorerPickerPreferenceControllerTest method updateState_noScorersAvailable_preferenceDisabled.

@Test
public void updateState_noScorersAvailable_preferenceDisabled() {
    when(mNetworkScorer.getAllValidScorers()).thenReturn(Collections.emptyList());
    Preference preference = mock(Preference.class);
    mController.updateState(preference);
    verify(preference).setEnabled(false);
    verify(preference).setSummary(null);
}
Also used : Preference(androidx.preference.Preference) Test(org.junit.Test)

Example 47 with Preference

use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class NetworkScorerPickerPreferenceControllerTest method updateState_scorersAvailable_preferenceEnabled.

@Test
public void updateState_scorersAvailable_preferenceEnabled() {
    ComponentName scorer = new ComponentName(TEST_SCORER_PACKAGE, TEST_SCORER_CLASS);
    NetworkScorerAppData scorerAppData = new NetworkScorerAppData(0, scorer, TEST_SCORER_LABEL, null, /* enableUseOpenWifiActivity */
    null);
    when(mNetworkScorer.getAllValidScorers()).thenReturn(Collections.singletonList(scorerAppData));
    Preference preference = mock(Preference.class);
    mController.updateState(preference);
    verify(preference).setEnabled(true);
}
Also used : Preference(androidx.preference.Preference) ComponentName(android.content.ComponentName) NetworkScorerAppData(android.net.NetworkScorerAppData) Test(org.junit.Test)

Example 48 with Preference

use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class NotificationsOffPreferenceControllerTest method testUpdateState_channel.

@Test
public void testUpdateState_channel() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    NotificationChannel channel = mock(NotificationChannel.class);
    when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
    mController.onResume(appRow, channel, null, null);
    Preference pref = new Preference(RuntimeEnvironment.application);
    mController.updateState(pref);
    assertThat(pref.getTitle().toString()).contains("category");
    assertThat(pref.isSelectable()).isFalse();
}
Also used : NotificationChannel(android.app.NotificationChannel) Preference(androidx.preference.Preference) Test(org.junit.Test)

Example 49 with Preference

use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class NotificationsOffPreferenceControllerTest method testUpdateState_app.

@Test
public void testUpdateState_app() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    appRow.banned = true;
    mController.onResume(appRow, null, null, null);
    Preference pref = new Preference(RuntimeEnvironment.application);
    mController.updateState(pref);
    assertThat(pref.getTitle().toString()).contains("app");
    assertThat(pref.isSelectable()).isFalse();
}
Also used : Preference(androidx.preference.Preference) Test(org.junit.Test)

Example 50 with Preference

use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class NotificationsOffPreferenceControllerTest method testUpdateState_channelGroup.

@Test
public void testUpdateState_channelGroup() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    NotificationChannelGroup group = mock(NotificationChannelGroup.class);
    when(group.isBlocked()).thenReturn(true);
    mController.onResume(appRow, null, group, null);
    Preference pref = new Preference(RuntimeEnvironment.application);
    mController.updateState(pref);
    assertThat(pref.getTitle().toString()).contains("group");
    assertThat(pref.isSelectable()).isFalse();
}
Also used : NotificationChannelGroup(android.app.NotificationChannelGroup) Preference(androidx.preference.Preference) Test(org.junit.Test)

Aggregations

Preference (androidx.preference.Preference)863 Test (org.junit.Test)343 Before (org.junit.Before)164 Intent (android.content.Intent)81 PreferenceScreen (androidx.preference.PreferenceScreen)81 NotificationChannel (android.app.NotificationChannel)77 SwitchPreference (androidx.preference.SwitchPreference)75 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)69 Context (android.content.Context)60 ArrayList (java.util.ArrayList)50 NotificationBackend (com.android.settings.notification.NotificationBackend)45 ListPreference (androidx.preference.ListPreference)43 PreferenceCategory (androidx.preference.PreferenceCategory)40 Tile (com.android.settingslib.drawer.Tile)40 PreferenceManager (androidx.preference.PreferenceManager)39 Activity (android.app.Activity)27 UserHandle (android.os.UserHandle)27 FooterPreference (com.android.settingslib.widget.FooterPreference)27 PackageManager (android.content.pm.PackageManager)26 Bundle (android.os.Bundle)24