Search in sources :

Example 6 with ConversationChannelWrapper

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

the class AppBubbleListPreferenceControllerTest method clickConversationPref_updatesChannel.

@Test
public void clickConversationPref_updatesChannel() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    appRow.bubblePreference = BUBBLE_PREFERENCE_ALL;
    appRow.pkg = "PKG";
    mController.onResume(appRow, null, null, null, null, null, null);
    mController.mPreference = new PreferenceCategory(mContext);
    ConversationChannelWrapper ccw = mConvoList.getList().get(0);
    AppBubbleListPreferenceController.ConversationPreference pref = (AppBubbleListPreferenceController.ConversationPreference) mController.createConversationPref(ccw);
    pref.onClick(null);
    verify(ccw.getNotificationChannel()).setAllowBubbles(DEFAULT_ALLOW_BUBBLE);
    verify(mBackend).updateChannel(anyString(), anyInt(), any(NotificationChannel.class));
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationBackend(com.android.settings.notification.NotificationBackend) PreferenceCategory(androidx.preference.PreferenceCategory) ConversationChannelWrapper(android.service.notification.ConversationChannelWrapper) AppBubbleListPreferenceController(com.android.settings.notification.AppBubbleListPreferenceController) Test(org.junit.Test)

Example 7 with ConversationChannelWrapper

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

the class AppBubbleListPreferenceControllerTest method getConvo.

ConversationChannelWrapper getConvo(int bubbleChannelPref, String channelId) {
    ConversationChannelWrapper ccw = new ConversationChannelWrapper();
    NotificationChannel channel = mock(NotificationChannel.class);
    when(channel.getId()).thenReturn(channelId);
    when(channel.getAllowBubbles()).thenReturn(bubbleChannelPref);
    when(channel.canBubble()).thenReturn(bubbleChannelPref == 1);
    ccw.setNotificationChannel(channel);
    ccw.setPkg("pkg");
    ccw.setUid(1);
    ccw.setShortcutInfo(mock(ShortcutInfo.class));
    return ccw;
}
Also used : NotificationChannel(android.app.NotificationChannel) ShortcutInfo(android.content.pm.ShortcutInfo) ConversationChannelWrapper(android.service.notification.ConversationChannelWrapper)

Example 8 with ConversationChannelWrapper

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

the class AppBubbleListPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    ShadowApplication shadowApplication = ShadowApplication.getInstance();
    shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNm);
    shadowApplication.setSystemService(Context.USER_SERVICE, mUm);
    mContext = RuntimeEnvironment.application;
    List<ConversationChannelWrapper> convoList = new ArrayList<>();
    convoList.add(getConvo(-1, "default"));
    convoList.add(getConvo(1, "selected"));
    convoList.add(getConvo(0, "excluded"));
    mConvoList = new ParceledListSlice<>(convoList);
    when(mBackend.getConversations(anyString(), anyInt())).thenReturn(mConvoList);
    mController = new AppBubbleListPreferenceController(mContext, mBackend);
}
Also used : ConversationChannelWrapper(android.service.notification.ConversationChannelWrapper) ArrayList(java.util.ArrayList) AppBubbleListPreferenceController(com.android.settings.notification.AppBubbleListPreferenceController) ShadowApplication(org.robolectric.shadows.ShadowApplication) Before(org.junit.Before)

Example 9 with ConversationChannelWrapper

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

the class ConversationListPreferenceControllerTest method testGetSubSettingLauncher.

@Test
public void testGetSubSettingLauncher() {
    ConversationChannelWrapper ccw = new ConversationChannelWrapper();
    NotificationChannel channel = new NotificationChannel("a", "child", 2);
    channel.setConversationId("parent", "convo id");
    ccw.setNotificationChannel(channel);
    ccw.setPkg("pkg");
    ccw.setUid(1);
    ccw.setParentChannelLabel("parent label");
    Intent intent = mController.getSubSettingLauncher(ccw, "title").toIntent();
    Bundle extras = intent.getExtras();
    assertThat(extras.getString(AppInfoBase.ARG_PACKAGE_NAME)).isEqualTo(ccw.getPkg());
    assertThat(extras.getInt(AppInfoBase.ARG_PACKAGE_UID)).isEqualTo(ccw.getUid());
    assertThat(extras.getString(Settings.EXTRA_CHANNEL_ID)).isEqualTo(ccw.getNotificationChannel().getId());
    assertThat(extras.getString(Settings.EXTRA_CONVERSATION_ID)).isEqualTo(ccw.getNotificationChannel().getConversationId());
}
Also used : NotificationChannel(android.app.NotificationChannel) Bundle(android.os.Bundle) ConversationChannelWrapper(android.service.notification.ConversationChannelWrapper) Intent(android.content.Intent) Test(org.junit.Test)

Example 10 with ConversationChannelWrapper

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

the class ConversationListPreferenceControllerTest method getSummary_withGroup.

@Test
public void getSummary_withGroup() {
    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.setGroupLabel("group");
    ccw.setParentChannelLabel("parent");
    assertThat(mController.getSummary(ccw).toString()).contains(ccw.getGroupLabel());
    assertThat(mController.getSummary(ccw).toString()).contains(ccw.getParentChannelLabel());
}
Also used : NotificationChannel(android.app.NotificationChannel) ShortcutInfo(android.content.pm.ShortcutInfo) 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