Search in sources :

Example 11 with ConversationChannel

use of android.app.people.ConversationChannel in project android_packages_apps_Settings by omnirom.

the class RecentConversationsPreferenceControllerTest method testCreatesChannel.

@Test
public void testCreatesChannel() {
    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);
    Preference pref = mController.createConversationPref(new PreferenceCategory(mContext), ccw, 100);
    try {
        pref.performClick();
    } catch (RuntimeException e) {
    // expected since it tries to launch an activity
    }
    verify(mBackend).createConversationNotificationChannel(si.getPackage(), ccw.getUid(), ccw.getNotificationChannel(), si.getId());
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationChannelGroup(android.app.NotificationChannelGroup) ShortcutInfo(android.content.pm.ShortcutInfo) ConversationChannel(android.app.people.ConversationChannel) LayoutPreference(com.android.settingslib.widget.LayoutPreference) Preference(androidx.preference.Preference) PreferenceCategory(androidx.preference.PreferenceCategory) Test(org.junit.Test)

Example 12 with ConversationChannel

use of android.app.people.ConversationChannel in project android_packages_apps_Settings by omnirom.

the class RecentConversationsPreferenceControllerTest method testNonremoveableConversation.

@Test
public void testNonremoveableConversation() 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, true);
    RecentConversationPreference pref = (RecentConversationPreference) mController.createConversationPref(new PreferenceCategory(mContext), ccw, 100);
    assertThat(pref.hasClearListener()).isFalse();
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationChannelGroup(android.app.NotificationChannelGroup) ShortcutInfo(android.content.pm.ShortcutInfo) ConversationChannel(android.app.people.ConversationChannel) PreferenceCategory(androidx.preference.PreferenceCategory) Test(org.junit.Test)

Example 13 with ConversationChannel

use of android.app.people.ConversationChannel in project android_packages_apps_Settings by omnirom.

the class RecentConversationsPreferenceControllerTest method testPopulateList_onlyNonremoveableConversations.

@Test
public void testPopulateList_onlyNonremoveableConversations() {
    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, true);
    ArrayList<ConversationChannel> list = new ArrayList<>();
    list.add(ccw);
    mController.populateList(list, outerContainer);
    // one for the preference, none for 'clear all'
    verify(outerContainer, times(1)).addPreference(any());
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationChannelGroup(android.app.NotificationChannelGroup) PreferenceScreen(androidx.preference.PreferenceScreen) ConversationChannel(android.app.people.ConversationChannel) ShortcutInfo(android.content.pm.ShortcutInfo) PreferenceCategory(androidx.preference.PreferenceCategory) ArrayList(java.util.ArrayList) PreferenceManager(androidx.preference.PreferenceManager) Test(org.junit.Test)

Example 14 with ConversationChannel

use of android.app.people.ConversationChannel in project android_packages_apps_Settings by omnirom.

the class RecentConversationsPreferenceControllerTest method populateConversations_blocked.

@Test
public void populateConversations_blocked() {
    PreferenceCategory container = mock(PreferenceCategory.class);
    ConversationChannel ccw = new ConversationChannel(mock(ShortcutInfo.class), 6, new NotificationChannel("hi", "hi", 4), new NotificationChannelGroup("hi", "hi"), 7, false);
    ConversationChannel ccw2 = new ConversationChannel(mock(ShortcutInfo.class), 6, new NotificationChannel("hi", "hi", 0), new NotificationChannelGroup("hi", "hi"), 7, false);
    NotificationChannelGroup blockedGroup = new NotificationChannelGroup("hi", "hi");
    blockedGroup.setBlocked(true);
    ConversationChannel ccw3 = new ConversationChannel(mock(ShortcutInfo.class), 6, new NotificationChannel("hi", "hi", 4), blockedGroup, 7, false);
    ArrayList<ConversationChannel> list = new ArrayList<>();
    list.add(ccw);
    list.add(ccw2);
    list.add(ccw3);
    mController.populateConversations(list, container);
    verify(container, times(1)).addPreference(any());
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationChannelGroup(android.app.NotificationChannelGroup) ConversationChannel(android.app.people.ConversationChannel) ShortcutInfo(android.content.pm.ShortcutInfo) PreferenceCategory(androidx.preference.PreferenceCategory) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

ConversationChannel (android.app.people.ConversationChannel)14 NotificationChannel (android.app.NotificationChannel)13 ShortcutInfo (android.content.pm.ShortcutInfo)13 Test (org.junit.Test)13 NotificationChannelGroup (android.app.NotificationChannelGroup)10 PreferenceCategory (androidx.preference.PreferenceCategory)7 PreferenceManager (androidx.preference.PreferenceManager)3 PreferenceScreen (androidx.preference.PreferenceScreen)3 ArrayList (java.util.ArrayList)3 View (android.view.View)2 Preference (androidx.preference.Preference)2 PreferenceViewHolder (androidx.preference.PreferenceViewHolder)2 LayoutPreference (com.android.settingslib.widget.LayoutPreference)2 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 SpannedString (android.text.SpannedString)1