Search in sources :

Example 56 with RestrictedSwitchPreference

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

the class BubblePreferenceControllerTest method testOnPreferenceChange_on_app_offGlobally.

@Test
public void testOnPreferenceChange_on_app_offGlobally() {
    Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_OFF);
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    appRow.allowBubbles = false;
    mController.onResume(appRow, null, null, null);
    RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
    mController.displayPreference(mScreen);
    mController.updateState(pref);
    mController.onPreferenceChange(pref, true);
    assertFalse(appRow.allowBubbles);
    verify(mBackend, never()).setAllowBubbles(any(), anyInt(), eq(true));
    verify(mFragmentManager, times(1)).beginTransaction();
}
Also used : RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Test(org.junit.Test)

Example 57 with RestrictedSwitchPreference

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

the class BubblePreferenceControllerTest method testOnPreferenceChange_off_channel.

@Test
public void testOnPreferenceChange_off_channel() {
    Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    appRow.allowBubbles = true;
    NotificationChannel channel = new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
    channel.setAllowBubbles(true);
    mController.onResume(appRow, channel, null, null);
    RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
    mController.displayPreference(mScreen);
    mController.updateState(pref);
    mController.onPreferenceChange(pref, false);
    verify(mBackend, times(1)).updateChannel(any(), anyInt(), any());
    assertFalse(channel.canBubble());
}
Also used : NotificationChannel(android.app.NotificationChannel) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Test(org.junit.Test)

Example 58 with RestrictedSwitchPreference

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

the class BubblePreferenceControllerTest method testOnPreferenceChange_on_channel.

@Test
public void testOnPreferenceChange_on_channel() {
    Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    appRow.allowBubbles = true;
    NotificationChannel channel = new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
    channel.setAllowBubbles(false);
    mController.onResume(appRow, channel, null, null);
    RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
    mController.displayPreference(mScreen);
    mController.updateState(pref);
    mController.onPreferenceChange(pref, true);
    assertTrue(channel.canBubble());
    verify(mBackend, times(1)).updateChannel(any(), anyInt(), any());
}
Also used : NotificationChannel(android.app.NotificationChannel) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Test(org.junit.Test)

Example 59 with RestrictedSwitchPreference

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

the class BadgePreferenceControllerTest method testOnPreferenceChange_on_app.

@Test
public void testOnPreferenceChange_on_app() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    appRow.showBadge = false;
    mController.onResume(appRow, null, null, null);
    RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
    mController.displayPreference(mScreen);
    mController.updateState(pref);
    mController.onPreferenceChange(pref, true);
    assertTrue(appRow.showBadge);
    verify(mBackend, times(1)).setShowBadge(any(), anyInt(), eq(true));
}
Also used : RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Test(org.junit.Test)

Example 60 with RestrictedSwitchPreference

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

the class BadgePreferenceControllerTest method testUpdateState_channel.

@Test
public void testUpdateState_channel() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    NotificationChannel channel = mock(NotificationChannel.class);
    when(channel.canShowBadge()).thenReturn(true);
    mController.onResume(appRow, channel, null, null);
    RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
    mController.updateState(pref);
    assertTrue(pref.isChecked());
    when(channel.canShowBadge()).thenReturn(false);
    mController.onResume(appRow, channel, null, null);
    mController.updateState(pref);
    assertFalse(pref.isChecked());
}
Also used : NotificationChannel(android.app.NotificationChannel) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) 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