use of android.app.people.ConversationChannel in project android_packages_apps_Settings by omnirom.
the class RecentConversationsPreferenceControllerTest method testRemoveConversation.
@Test
public void testRemoveConversation() 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, false);
RecentConversationPreference pref = (RecentConversationPreference) 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);
pref.onBindViewHolder(holder);
pref.getClearView().performClick();
verify(mPs).removeRecentConversation(si.getPackage(), UserHandle.getUserId(ccw.getUid()), si.getId());
}
use of android.app.people.ConversationChannel in project android_packages_apps_Settings by omnirom.
the class RecentConversationsPreferenceControllerTest 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);
ConversationChannel ccw = new ConversationChannel(mock(ShortcutInfo.class), 6, new NotificationChannel("hi", "hi", 4), new NotificationChannelGroup("hi", "hi"), 7, false);
ArrayList<ConversationChannel> list = new ArrayList<>();
list.add(ccw);
mController.populateList(list, outerContainer);
// one for the preference, one for the button ro clear all
verify(outerContainer, times(2)).addPreference(any());
}
use of android.app.people.ConversationChannel in project android_packages_apps_Settings by omnirom.
the class RecentConversationsPreferenceControllerTest method getSummary_noGroup.
@Test
public void getSummary_noGroup() {
ShortcutInfo si = mock(ShortcutInfo.class);
when(si.getLabel()).thenReturn("person");
ConversationChannel ccw = new ConversationChannel(mock(ShortcutInfo.class), 6, new NotificationChannel("hi", "channel", 4), null, 7, true);
assertThat(mController.getSummary(ccw).toString()).isEqualTo(ccw.getNotificationChannel().getName());
}
use of android.app.people.ConversationChannel in project android_packages_apps_Settings by omnirom.
the class RecentConversationsPreferenceControllerTest method testNullSpans.
@Test
public void testNullSpans() {
ConversationChannel ccw = new ConversationChannel(mock(ShortcutInfo.class), 6, new NotificationChannel("hi", "hi", 4), null, 7, true);
ConversationChannel ccw2 = new ConversationChannel(mock(ShortcutInfo.class), 6, new NotificationChannel("hi2", "hi2", 4), null, 7, true);
// no crash
mController.mConversationComparator.compare(ccw, ccw2);
}
use of android.app.people.ConversationChannel in project android_packages_apps_Settings by omnirom.
the class RecentConversationsPreferenceController method populateConversations.
protected boolean populateConversations(List<ConversationChannel> conversations, PreferenceGroup containerGroup) {
int order = 100;
boolean hasClearable = false;
for (ConversationChannel conversation : conversations) {
if (conversation.getNotificationChannel().getImportance() == IMPORTANCE_NONE || (conversation.getNotificationChannelGroup() != null && conversation.getNotificationChannelGroup().isBlocked())) {
continue;
}
RecentConversationPreference pref = createConversationPref(containerGroup, conversation, order++);
containerGroup.addPreference(pref);
if (pref.hasClearListener()) {
hasClearable = true;
}
}
return hasClearable;
}
Aggregations