Search in sources :

Example 51 with RestrictedSwitchPreference

use of com.android.settingslib.RestrictedSwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AllowSoundPreferenceControllerTest method testUpdateState_notCheckedForLowImportanceChannel.

@Test
public void testUpdateState_notCheckedForLowImportanceChannel() {
    NotificationChannel channel = mock(NotificationChannel.class);
    when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
    mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
    RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
    mController.updateState(pref);
    assertFalse(pref.isChecked());
}
Also used : NotificationChannel(android.app.NotificationChannel) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Test(org.junit.Test)

Example 52 with RestrictedSwitchPreference

use of com.android.settingslib.RestrictedSwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AllowSoundPreferenceControllerTest method testOnPreferenceChange_on.

@Test
public void testOnPreferenceChange_on() {
    NotificationChannel channel = new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
    mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
    RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
    mController.displayPreference(mScreen);
    mController.updateState(pref);
    pref.setChecked(true);
    mController.onPreferenceChange(pref, true);
    assertEquals(IMPORTANCE_UNSPECIFIED, mController.mChannel.getImportance());
    verify(mImportanceListener, times(1)).onImportanceChanged();
}
Also used : NotificationChannel(android.app.NotificationChannel) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Test(org.junit.Test)

Example 53 with RestrictedSwitchPreference

use of com.android.settingslib.RestrictedSwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AllowSoundPreferenceControllerTest method testUpdateState_checkedForHighImportanceChannel.

@Test
public void testUpdateState_checkedForHighImportanceChannel() {
    NotificationChannel channel = mock(NotificationChannel.class);
    when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
    mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
    RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
    mController.updateState(pref);
    assertTrue(pref.isChecked());
}
Also used : NotificationChannel(android.app.NotificationChannel) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Test(org.junit.Test)

Example 54 with RestrictedSwitchPreference

use of com.android.settingslib.RestrictedSwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AllowSoundPreferenceControllerTest method testUpdateState_checkedForUnspecifiedImportanceChannel.

@Test
public void testUpdateState_checkedForUnspecifiedImportanceChannel() {
    NotificationChannel channel = mock(NotificationChannel.class);
    when(channel.getImportance()).thenReturn(IMPORTANCE_UNSPECIFIED);
    mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
    RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
    mController.updateState(pref);
    assertTrue(pref.isChecked());
}
Also used : NotificationChannel(android.app.NotificationChannel) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Test(org.junit.Test)

Example 55 with RestrictedSwitchPreference

use of com.android.settingslib.RestrictedSwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BubblePreferenceControllerTest method testUpdateState_channelNotBlockable.

@Test
public void testUpdateState_channelNotBlockable() {
    Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    NotificationChannel channel = mock(NotificationChannel.class);
    when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
    mController.onResume(appRow, channel, null, null);
    Preference pref = new RestrictedSwitchPreference(mContext);
    mController.updateState(pref);
    assertTrue(pref.isEnabled());
}
Also used : NotificationChannel(android.app.NotificationChannel) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Preference(androidx.preference.Preference) Test(org.junit.Test)

Aggregations

RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)146 Test (org.junit.Test)101 NotificationChannel (android.app.NotificationChannel)52 Preference (androidx.preference.Preference)23 PreferenceGroup (android.support.v7.preference.PreferenceGroup)15 Preference (android.support.v7.preference.Preference)14 EnforcedAdmin (com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)10 Before (org.junit.Before)10 SwitchPreference (android.support.v14.preference.SwitchPreference)8 Context (android.content.Context)7 IBinder (android.os.IBinder)7 RemoteException (android.os.RemoteException)7 ListPreference (android.support.v7.preference.ListPreference)7 LockPatternUtils (com.android.internal.widget.LockPatternUtils)7 IStorageManager (android.os.storage.IStorageManager)6 WebViewAppPreferenceController (com.android.settings.webview.WebViewAppPreferenceController)6 AbstractEnableAdbPreferenceController (com.android.settingslib.development.AbstractEnableAdbPreferenceController)6 ContentResolver (android.content.ContentResolver)2 ResolveInfo (android.content.pm.ResolveInfo)2 PersistableBundle (android.os.PersistableBundle)2