use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.
the class ChannelListPreferenceControllerTest method setUp.
@Before
public void setUp() throws Exception {
Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
mContext = instrumentation.getTargetContext();
instrumentation.runOnMainSync(() -> {
mBackend = new NotificationBackend();
mAppRow = mBackend.loadAppRow(mContext, mContext.getPackageManager(), mContext.getApplicationInfo());
mController = new ChannelListPreferenceController(mContext, mBackend);
mController.onResume(mAppRow, null, null, null, null, null);
mPreferenceManager = new PreferenceManager(mContext);
mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
mGroupList = new PreferenceCategory(mContext);
mPreferenceScreen.addPreference(mGroupList);
});
}
use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.
the class ConversationListPreferenceControllerTest method testPopulateList_hideIfNoConversations.
@Test
public void testPopulateList_hideIfNoConversations() {
PreferenceCategory outerContainer = mock(PreferenceCategory.class);
mController.populateList(new ArrayList<>(), outerContainer);
verify(outerContainer).setVisible(false);
verify(outerContainer, never()).addPreference(any());
}
use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.
the class ConversationListPreferenceControllerTest method populateConversations.
@Test
public void populateConversations() {
PreferenceCategory container = mock(PreferenceCategory.class);
ConversationChannelWrapper ccw = new ConversationChannelWrapper();
ccw.setNotificationChannel(mock(NotificationChannel.class));
ccw.setPkg("pkg");
ccw.setUid(1);
ccw.setShortcutInfo(mock(ShortcutInfo.class));
ConversationChannelWrapper ccwDemoted = new ConversationChannelWrapper();
NotificationChannel demoted = new NotificationChannel("a", "a", 2);
demoted.setDemoted(true);
ccwDemoted.setNotificationChannel(demoted);
ccwDemoted.setPkg("pkg");
ccwDemoted.setUid(1);
ccwDemoted.setShortcutInfo(mock(ShortcutInfo.class));
ArrayList<ConversationChannelWrapper> list = new ArrayList<>();
list.add(ccw);
list.add(ccwDemoted);
mController.populateConversations(list, container);
verify(container, times(1)).addPreference(any());
}
use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.
the class ConversationListPreferenceControllerTest 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);
ConversationChannelWrapper ccw = new ConversationChannelWrapper();
ccw.setNotificationChannel(mock(NotificationChannel.class));
ccw.setPkg("pkg");
ccw.setUid(1);
ccw.setShortcutInfo(mock(ShortcutInfo.class));
ArrayList<ConversationChannelWrapper> list = new ArrayList<>();
list.add(ccw);
mController.populateList(list, outerContainer);
verify(outerContainer, times(1)).addPreference(any());
}
use of androidx.preference.PreferenceCategory 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());
}
Aggregations