Search in sources :

Example 1 with ConversationChannelWrapper

use of android.service.notification.ConversationChannelWrapper in project android_packages_apps_Settings by omnirom.

the class ConversationListPreferenceControllerTest method populateConversations.

@Test
public void populateConversations() {
    PreferenceCategory container = mock(PreferenceCategory.class);
    ConversationChannelWrapper ccw = new ConversationChannelWrapper();
    ccw.setNotificationChannel(mock(NotificationChannel.class));
    ccw.setPkg("pkg");
    ccw.setUid(1);
    ccw.setShortcutInfo(mock(ShortcutInfo.class));
    ConversationChannelWrapper ccwDemoted = new ConversationChannelWrapper();
    NotificationChannel demoted = new NotificationChannel("a", "a", 2);
    demoted.setDemoted(true);
    ccwDemoted.setNotificationChannel(demoted);
    ccwDemoted.setPkg("pkg");
    ccwDemoted.setUid(1);
    ccwDemoted.setShortcutInfo(mock(ShortcutInfo.class));
    ArrayList<ConversationChannelWrapper> list = new ArrayList<>();
    list.add(ccw);
    list.add(ccwDemoted);
    mController.populateConversations(list, container);
    verify(container, times(1)).addPreference(any());
}
Also used : NotificationChannel(android.app.NotificationChannel) ShortcutInfo(android.content.pm.ShortcutInfo) PreferenceCategory(androidx.preference.PreferenceCategory) ConversationChannelWrapper(android.service.notification.ConversationChannelWrapper) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 2 with ConversationChannelWrapper

use of android.service.notification.ConversationChannelWrapper in project android_packages_apps_Settings by omnirom.

the class ConversationListPreferenceControllerTest method testPopulateList_validConversations.

@Test
public void testPopulateList_validConversations() {
    final PreferenceManager preferenceManager = new PreferenceManager(mContext);
    PreferenceScreen ps = preferenceManager.createPreferenceScreen(mContext);
    PreferenceCategory outerContainer = spy(new PreferenceCategory(mContext));
    ps.addPreference(outerContainer);
    ConversationChannelWrapper ccw = new ConversationChannelWrapper();
    ccw.setNotificationChannel(mock(NotificationChannel.class));
    ccw.setPkg("pkg");
    ccw.setUid(1);
    ccw.setShortcutInfo(mock(ShortcutInfo.class));
    ArrayList<ConversationChannelWrapper> list = new ArrayList<>();
    list.add(ccw);
    mController.populateList(list, outerContainer);
    verify(outerContainer, times(1)).addPreference(any());
}
Also used : NotificationChannel(android.app.NotificationChannel) PreferenceScreen(androidx.preference.PreferenceScreen) ShortcutInfo(android.content.pm.ShortcutInfo) PreferenceCategory(androidx.preference.PreferenceCategory) ConversationChannelWrapper(android.service.notification.ConversationChannelWrapper) ArrayList(java.util.ArrayList) PreferenceManager(androidx.preference.PreferenceManager) Test(org.junit.Test)

Example 3 with ConversationChannelWrapper

use of android.service.notification.ConversationChannelWrapper in project android_packages_apps_Settings by omnirom.

the class ConversationListPreferenceControllerTest method getTitle_withShortcut.

@Test
public void getTitle_withShortcut() {
    ConversationChannelWrapper ccw = new ConversationChannelWrapper();
    NotificationChannel channel = new NotificationChannel("a", "child", 2);
    ccw.setNotificationChannel(channel);
    ccw.setPkg("pkg");
    ccw.setUid(1);
    ShortcutInfo si = mock(ShortcutInfo.class);
    when(si.getLabel()).thenReturn("conversation name");
    ccw.setShortcutInfo(si);
    ccw.setGroupLabel("group");
    ccw.setParentChannelLabel("parent");
    assertThat(mController.getTitle(ccw).toString()).isEqualTo(si.getLabel());
}
Also used : NotificationChannel(android.app.NotificationChannel) ShortcutInfo(android.content.pm.ShortcutInfo) ConversationChannelWrapper(android.service.notification.ConversationChannelWrapper) Test(org.junit.Test)

Example 4 with ConversationChannelWrapper

use of android.service.notification.ConversationChannelWrapper in project android_packages_apps_Settings by omnirom.

the class ConversationListPreferenceControllerTest method getSummary_noGroup.

@Test
public void getSummary_noGroup() {
    ConversationChannelWrapper ccw = new ConversationChannelWrapper();
    NotificationChannel channel = new NotificationChannel("a", "child", 2);
    ccw.setNotificationChannel(channel);
    ccw.setPkg("pkg");
    ccw.setUid(1);
    ccw.setShortcutInfo(mock(ShortcutInfo.class));
    ccw.setParentChannelLabel("parent");
    assertThat(mController.getSummary(ccw).toString()).isEqualTo(ccw.getParentChannelLabel());
}
Also used : NotificationChannel(android.app.NotificationChannel) ShortcutInfo(android.content.pm.ShortcutInfo) ConversationChannelWrapper(android.service.notification.ConversationChannelWrapper) Test(org.junit.Test)

Example 5 with ConversationChannelWrapper

use of android.service.notification.ConversationChannelWrapper in project android_packages_apps_Settings by omnirom.

the class ConversationListPreferenceControllerTest method getTitle_noShortcut.

@Test
public void getTitle_noShortcut() {
    ConversationChannelWrapper ccw = new ConversationChannelWrapper();
    NotificationChannel channel = new NotificationChannel("a", "child", 2);
    ccw.setNotificationChannel(channel);
    ccw.setPkg("pkg");
    ccw.setUid(1);
    ccw.setParentChannelLabel("parent");
    assertThat(mController.getTitle(ccw).toString()).isEqualTo(ccw.getNotificationChannel().getName());
}
Also used : NotificationChannel(android.app.NotificationChannel) ConversationChannelWrapper(android.service.notification.ConversationChannelWrapper) Test(org.junit.Test)

Aggregations

ConversationChannelWrapper (android.service.notification.ConversationChannelWrapper)12 NotificationChannel (android.app.NotificationChannel)9 Test (org.junit.Test)9 ShortcutInfo (android.content.pm.ShortcutInfo)7 ArrayList (java.util.ArrayList)4 PreferenceCategory (androidx.preference.PreferenceCategory)3 AppBubbleListPreferenceController (com.android.settings.notification.AppBubbleListPreferenceController)2 Before (org.junit.Before)2 ShadowApplication (org.robolectric.shadows.ShadowApplication)2 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 SpannableStringBuilder (android.text.SpannableStringBuilder)1 SubscriptSpan (android.text.style.SubscriptSpan)1 FragmentTransaction (androidx.fragment.app.FragmentTransaction)1 PreferenceManager (androidx.preference.PreferenceManager)1 PreferenceScreen (androidx.preference.PreferenceScreen)1 NotificationBackend (com.android.settings.notification.NotificationBackend)1