Search in sources :

Example 6 with ConversationChannel

use of android.app.people.ConversationChannel 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 7 with ConversationChannel

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

the class RecentConversationsPreferenceControllerTest method testSpans.

@Test
public void testSpans() {
    ShortcutInfo si = mock(ShortcutInfo.class);
    when(si.getLabel()).thenReturn(new SpannedString("hello"));
    ConversationChannel ccw = new ConversationChannel(si, 6, new NotificationChannel("hi", "hi", 4), null, 7, true);
    ShortcutInfo si2 = mock(ShortcutInfo.class);
    when(si2.getLabel()).thenReturn("hello");
    ConversationChannel ccw2 = new ConversationChannel(si2, 6, new NotificationChannel("hi2", "hi2", 4), null, 7, true);
    // no crash
    mController.mConversationComparator.compare(ccw, ccw2);
}
Also used : NotificationChannel(android.app.NotificationChannel) ShortcutInfo(android.content.pm.ShortcutInfo) ConversationChannel(android.app.people.ConversationChannel) SpannedString(android.text.SpannedString) Test(org.junit.Test)

Example 8 with ConversationChannel

use of android.app.people.ConversationChannel 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 9 with ConversationChannel

use of android.app.people.ConversationChannel 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 10 with ConversationChannel

use of android.app.people.ConversationChannel 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

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