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());
}
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());
}
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();
}
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());
}
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());
}
Aggregations