Search in sources :

Example 11 with NotificationChannelGroup

use of android.app.NotificationChannelGroup in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class NotificationsOffPreferenceControllerTest method testIsAvailable_yesIfChannelGroupBlocked.

@Test
public void testIsAvailable_yesIfChannelGroupBlocked() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    NotificationChannelGroup group = mock(NotificationChannelGroup.class);
    when(group.isBlocked()).thenReturn(true);
    mController.onResume(appRow, null, group, null);
    assertThat(mController.isAvailable()).isTrue();
}
Also used : NotificationChannelGroup(android.app.NotificationChannelGroup) Test(org.junit.Test)

Example 12 with NotificationChannelGroup

use of android.app.NotificationChannelGroup 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)

Example 13 with NotificationChannelGroup

use of android.app.NotificationChannelGroup in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class HeaderPreferenceControllerTest method testGetSummary.

@Test
public void testGetSummary() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    appRow.label = "bananas";
    mController.onResume(appRow, null, null, null);
    assertEquals("", mController.getSummary());
    NotificationChannelGroup group = new NotificationChannelGroup("id", "name");
    mController.onResume(appRow, null, group, null);
    assertEquals(appRow.label, mController.getSummary());
    NotificationChannel channel = new NotificationChannel("cid", "cname", IMPORTANCE_NONE);
    mController.onResume(appRow, channel, group, null);
    assertTrue(mController.getSummary().toString().contains(group.getName()));
    assertTrue(mController.getSummary().toString().contains(appRow.label));
    mController.onResume(appRow, channel, null, null);
    assertFalse(mController.getSummary().toString().contains(group.getName()));
    assertTrue(mController.getSummary().toString().contains(appRow.label));
    NotificationChannel defaultChannel = new NotificationChannel(NotificationChannel.DEFAULT_CHANNEL_ID, "", IMPORTANCE_NONE);
    mController.onResume(appRow, defaultChannel, null, null);
    assertEquals("", mController.getSummary());
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationChannelGroup(android.app.NotificationChannelGroup) Test(org.junit.Test)

Example 14 with NotificationChannelGroup

use of android.app.NotificationChannelGroup in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class NotificationPreferenceControllerTest method testIsChannelGroupBlockable_canUndoSystemBlock.

@Test
public void testIsChannelGroupBlockable_canUndoSystemBlock() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    appRow.systemApp = true;
    NotificationChannelGroup group = mock(NotificationChannelGroup.class);
    when(group.isBlocked()).thenReturn(true);
    mController.onResume(appRow, null, group, null);
    assertTrue(mController.isChannelGroupBlockable());
}
Also used : NotificationChannelGroup(android.app.NotificationChannelGroup) Test(org.junit.Test)

Example 15 with NotificationChannelGroup

use of android.app.NotificationChannelGroup in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class NotificationPreferenceControllerTest method testIsChannelGroupBlockable_SystemNotBlockable.

@Test
public void testIsChannelGroupBlockable_SystemNotBlockable() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    appRow.systemApp = true;
    NotificationChannelGroup group = mock(NotificationChannelGroup.class);
    when(group.isBlocked()).thenReturn(false);
    mController.onResume(appRow, null, group, null);
    assertFalse(mController.isChannelGroupBlockable());
}
Also used : NotificationChannelGroup(android.app.NotificationChannelGroup) Test(org.junit.Test)

Aggregations

NotificationChannelGroup (android.app.NotificationChannelGroup)46 NotificationChannel (android.app.NotificationChannel)31 Test (org.junit.Test)20 TargetApi (android.annotation.TargetApi)8 Preference (android.support.v7.preference.Preference)6 PreferenceCategory (android.support.v7.preference.PreferenceCategory)6 LayoutPreference (com.android.settings.applications.LayoutPreference)6 MasterSwitchPreference (com.android.settings.widget.MasterSwitchPreference)6 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)6 FooterPreference (com.android.settingslib.widget.FooterPreference)6 NotificationManager (android.app.NotificationManager)5 Notification (android.app.Notification)4 AudioAttributes (android.media.AudioAttributes)4 ArrayList (java.util.ArrayList)4 Context (android.content.Context)2 Uri (android.net.Uri)2 RequiresApi (androidx.annotation.RequiresApi)2 Preference (androidx.preference.Preference)2 JSONObject (org.json.JSONObject)2 Application (android.app.Application)1