Search in sources :

Example 71 with NotificationChannelGroup

use of android.app.NotificationChannelGroup in project android_packages_apps_Settings by omnirom.

the class RecentConversationsPreferenceControllerTest method testCreatesChannel.

@Test
public void testCreatesChannel() {
    ShortcutInfo si = mock(ShortcutInfo.class);
    when(si.getId()).thenReturn("person");
    when(si.getPackage()).thenReturn("pkg");
    ConversationChannel ccw = new ConversationChannel(si, 6, new NotificationChannel("hi", "channel", 4), new NotificationChannelGroup("hi", "group"), 7, true);
    Preference pref = mController.createConversationPref(new PreferenceCategory(mContext), ccw, 100);
    try {
        pref.performClick();
    } catch (RuntimeException e) {
    // expected since it tries to launch an activity
    }
    verify(mBackend).createConversationNotificationChannel(si.getPackage(), ccw.getUid(), ccw.getNotificationChannel(), si.getId());
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationChannelGroup(android.app.NotificationChannelGroup) ShortcutInfo(android.content.pm.ShortcutInfo) ConversationChannel(android.app.people.ConversationChannel) LayoutPreference(com.android.settingslib.widget.LayoutPreference) Preference(androidx.preference.Preference) PreferenceCategory(androidx.preference.PreferenceCategory) Test(org.junit.Test)

Example 72 with NotificationChannelGroup

use of android.app.NotificationChannelGroup in project android_packages_apps_Settings by omnirom.

the class RecentConversationsPreferenceControllerTest method testNonremoveableConversation.

@Test
public void testNonremoveableConversation() throws Exception {
    ShortcutInfo si = mock(ShortcutInfo.class);
    when(si.getId()).thenReturn("person");
    when(si.getPackage()).thenReturn("pkg");
    ConversationChannel ccw = new ConversationChannel(si, 6, new NotificationChannel("hi", "channel", 4), new NotificationChannelGroup("hi", "group"), 7, true);
    RecentConversationPreference pref = (RecentConversationPreference) mController.createConversationPref(new PreferenceCategory(mContext), ccw, 100);
    assertThat(pref.hasClearListener()).isFalse();
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationChannelGroup(android.app.NotificationChannelGroup) ShortcutInfo(android.content.pm.ShortcutInfo) ConversationChannel(android.app.people.ConversationChannel) PreferenceCategory(androidx.preference.PreferenceCategory) Test(org.junit.Test)

Example 73 with NotificationChannelGroup

use of android.app.NotificationChannelGroup in project android_packages_apps_Settings by omnirom.

the class RecentConversationsPreferenceControllerTest method testPopulateList_onlyNonremoveableConversations.

@Test
public void testPopulateList_onlyNonremoveableConversations() {
    final PreferenceManager preferenceManager = new PreferenceManager(mContext);
    PreferenceScreen ps = preferenceManager.createPreferenceScreen(mContext);
    PreferenceCategory outerContainer = spy(new PreferenceCategory(mContext));
    ps.addPreference(outerContainer);
    ConversationChannel ccw = new ConversationChannel(mock(ShortcutInfo.class), 6, new NotificationChannel("hi", "hi", 4), new NotificationChannelGroup("hi", "hi"), 7, true);
    ArrayList<ConversationChannel> list = new ArrayList<>();
    list.add(ccw);
    mController.populateList(list, outerContainer);
    // one for the preference, none for 'clear all'
    verify(outerContainer, times(1)).addPreference(any());
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationChannelGroup(android.app.NotificationChannelGroup) PreferenceScreen(androidx.preference.PreferenceScreen) ConversationChannel(android.app.people.ConversationChannel) ShortcutInfo(android.content.pm.ShortcutInfo) PreferenceCategory(androidx.preference.PreferenceCategory) ArrayList(java.util.ArrayList) PreferenceManager(androidx.preference.PreferenceManager) Test(org.junit.Test)

Example 74 with NotificationChannelGroup

use of android.app.NotificationChannelGroup in project android_packages_apps_Settings by omnirom.

the class RecentConversationsPreferenceControllerTest method populateConversations_blocked.

@Test
public void populateConversations_blocked() {
    PreferenceCategory container = mock(PreferenceCategory.class);
    ConversationChannel ccw = new ConversationChannel(mock(ShortcutInfo.class), 6, new NotificationChannel("hi", "hi", 4), new NotificationChannelGroup("hi", "hi"), 7, false);
    ConversationChannel ccw2 = new ConversationChannel(mock(ShortcutInfo.class), 6, new NotificationChannel("hi", "hi", 0), new NotificationChannelGroup("hi", "hi"), 7, false);
    NotificationChannelGroup blockedGroup = new NotificationChannelGroup("hi", "hi");
    blockedGroup.setBlocked(true);
    ConversationChannel ccw3 = new ConversationChannel(mock(ShortcutInfo.class), 6, new NotificationChannel("hi", "hi", 4), blockedGroup, 7, false);
    ArrayList<ConversationChannel> list = new ArrayList<>();
    list.add(ccw);
    list.add(ccw2);
    list.add(ccw3);
    mController.populateConversations(list, container);
    verify(container, times(1)).addPreference(any());
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationChannelGroup(android.app.NotificationChannelGroup) ConversationChannel(android.app.people.ConversationChannel) ShortcutInfo(android.content.pm.ShortcutInfo) PreferenceCategory(androidx.preference.PreferenceCategory) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 75 with NotificationChannelGroup

use of android.app.NotificationChannelGroup in project android_packages_apps_Settings by omnirom.

the class DescriptionPreferenceControllerTest method testIsAvailable_notIfChannelGroupBlocked.

@Test
public void testIsAvailable_notIfChannelGroupBlocked() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    NotificationChannelGroup group = mock(NotificationChannelGroup.class);
    mController.onResume(appRow, null, group, null, null, null, null);
    assertFalse(mController.isAvailable());
}
Also used : NotificationChannelGroup(android.app.NotificationChannelGroup) NotificationBackend(com.android.settings.notification.NotificationBackend) Test(org.junit.Test)

Aggregations

NotificationChannelGroup (android.app.NotificationChannelGroup)80 NotificationChannel (android.app.NotificationChannel)54 Test (org.junit.Test)53 NotificationBackend (com.android.settings.notification.NotificationBackend)21 ArrayList (java.util.ArrayList)12 ConversationChannel (android.app.people.ConversationChannel)10 ShortcutInfo (android.content.pm.ShortcutInfo)10 PreferenceCategory (androidx.preference.PreferenceCategory)9 TargetApi (android.annotation.TargetApi)8 Preference (android.support.v7.preference.Preference)6 PreferenceCategory (android.support.v7.preference.PreferenceCategory)6 Preference (androidx.preference.Preference)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 PreferenceGroup (androidx.preference.PreferenceGroup)3