Search in sources :

Example 66 with NotificationChannelGroup

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

the class ConversationHeaderPreferenceControllerTest method testGetSummary.

@Test
public void testGetSummary() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    appRow.label = "bananas";
    mController.onResume(appRow, null, null, null, null, null, null);
    assertEquals("", mController.getSummary());
    NotificationChannelGroup group = new NotificationChannelGroup("id", "name");
    mController.onResume(appRow, null, group, null, null, null, null);
    assertEquals(appRow.label, mController.getSummary());
    NotificationChannel channel = new NotificationChannel("cid", "cname", IMPORTANCE_NONE);
    mController.onResume(appRow, channel, group, null, null, null, null);
    assertTrue(mController.getSummary().toString().contains(group.getName()));
    assertTrue(mController.getSummary().toString().contains(appRow.label));
    mController.onResume(appRow, channel, null, null, null, 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, null, null, null);
    assertEquals("", mController.getSummary());
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationChannelGroup(android.app.NotificationChannelGroup) NotificationBackend(com.android.settings.notification.NotificationBackend) Test(org.junit.Test)

Example 67 with NotificationChannelGroup

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

the class RecentConversationsPreferenceControllerTest method getSummary_withGroup.

@Test
public void getSummary_withGroup() {
    ShortcutInfo si = mock(ShortcutInfo.class);
    when(si.getLabel()).thenReturn("person");
    ConversationChannel ccw = new ConversationChannel(mock(ShortcutInfo.class), 6, new NotificationChannel("hi", "channel", 4), new NotificationChannelGroup("hi", "group"), 7, true);
    assertThat(mController.getSummary(ccw).toString()).contains(ccw.getNotificationChannelGroup().getName());
    assertThat(mController.getSummary(ccw).toString()).contains(ccw.getNotificationChannel().getName());
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationChannelGroup(android.app.NotificationChannelGroup) ShortcutInfo(android.content.pm.ShortcutInfo) ConversationChannel(android.app.people.ConversationChannel) Test(org.junit.Test)

Example 68 with NotificationChannelGroup

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

the class RecentConversationsPreferenceControllerTest method testRemoveConversations.

@Test
public void testRemoveConversations() 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", "hi", 4), new NotificationChannelGroup("hi", "group"), 7, false);
    ConversationChannel ccw2 = new ConversationChannel(si, 6, new NotificationChannel("bye", "bye", 4), new NotificationChannelGroup("hi", "group"), 7, true);
    PreferenceCategory group = new PreferenceCategory(mContext);
    PreferenceScreen screen = new PreferenceManager(mContext).createPreferenceScreen(mContext);
    screen.addPreference(group);
    RecentConversationPreference pref = mController.createConversationPref(new PreferenceCategory(mContext), ccw, 100);
    final View view = View.inflate(mContext, pref.getLayoutResource(), null);
    PreferenceViewHolder holder = spy(PreferenceViewHolder.createInstanceForTests(view));
    View delete = View.inflate(mContext, pref.getSecondTargetResId(), null);
    when(holder.findViewById(pref.getClearId())).thenReturn(delete);
    group.addPreference(pref);
    RecentConversationPreference pref2 = mController.createConversationPref(new PreferenceCategory(mContext), ccw2, 100);
    final View view2 = View.inflate(mContext, pref2.getLayoutResource(), null);
    PreferenceViewHolder holder2 = spy(PreferenceViewHolder.createInstanceForTests(view2));
    View delete2 = View.inflate(mContext, pref2.getSecondTargetResId(), null);
    when(holder2.findViewById(pref.getClearId())).thenReturn(delete2);
    group.addPreference(pref2);
    LayoutPreference clearAll = mController.getClearAll(group);
    group.addPreference(clearAll);
    clearAll.findViewById(R.id.conversation_settings_clear_recents).performClick();
    verify(mPs).removeAllRecentConversations();
    assertThat((Preference) group.findPreference("hi:person")).isNull();
    assertThat((Preference) group.findPreference("bye:person")).isNotNull();
}
Also used : NotificationChannel(android.app.NotificationChannel) LayoutPreference(com.android.settingslib.widget.LayoutPreference) NotificationChannelGroup(android.app.NotificationChannelGroup) ShortcutInfo(android.content.pm.ShortcutInfo) ConversationChannel(android.app.people.ConversationChannel) PreferenceScreen(androidx.preference.PreferenceScreen) PreferenceCategory(androidx.preference.PreferenceCategory) LayoutPreference(com.android.settingslib.widget.LayoutPreference) Preference(androidx.preference.Preference) PreferenceManager(androidx.preference.PreferenceManager) View(android.view.View) PreferenceViewHolder(androidx.preference.PreferenceViewHolder) Test(org.junit.Test)

Example 69 with NotificationChannelGroup

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

the class RecentConversationsPreferenceControllerTest method testGetSubSettingLauncher.

@Test
public void testGetSubSettingLauncher() {
    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);
    Intent intent = mController.getSubSettingLauncher(ccw, "title").toIntent();
    Bundle extras = intent.getExtras();
    assertThat(extras.getString(AppInfoBase.ARG_PACKAGE_NAME)).isEqualTo(ccw.getShortcutInfo().getPackage());
    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.getShortcutInfo().getId());
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationChannelGroup(android.app.NotificationChannelGroup) ShortcutInfo(android.content.pm.ShortcutInfo) ConversationChannel(android.app.people.ConversationChannel) Bundle(android.os.Bundle) Intent(android.content.Intent) Test(org.junit.Test)

Example 70 with NotificationChannelGroup

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

the class RecentConversationsPreferenceControllerTest method getTitle_withShortcut.

@Test
public void getTitle_withShortcut() {
    ShortcutInfo si = mock(ShortcutInfo.class);
    when(si.getLabel()).thenReturn("person");
    ConversationChannel ccw = new ConversationChannel(si, 6, new NotificationChannel("hi", "channel", 4), new NotificationChannelGroup("hi", "group"), 7, true);
    assertThat(mController.getTitle(ccw).toString()).isEqualTo(si.getLabel());
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationChannelGroup(android.app.NotificationChannelGroup) ShortcutInfo(android.content.pm.ShortcutInfo) ConversationChannel(android.app.people.ConversationChannel) 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