use of androidx.preference.CheckBoxPreference in project android_packages_apps_Settings by omnirom.
the class BridgedAppsPreferenceControllerTest method onPreferenceChange_true.
@Test
public void onPreferenceChange_true() {
VersionedPackage vp = new VersionedPackage("pkg", 567);
VersionedPackage vp2 = new VersionedPackage("pkg", 10567);
ArraySet<VersionedPackage> vps = new ArraySet<>();
vps.add(vp);
vps.add(vp2);
NotificationListenerFilter nlf = new NotificationListenerFilter(FLAG_FILTER_TYPE_ONGOING | FLAG_FILTER_TYPE_CONVERSATIONS, vps);
when(mNm.isNotificationListenerAccessGranted(mCn)).thenReturn(true);
when(mNm.getListenerFilter(mCn, 0)).thenReturn(nlf);
CheckBoxPreference pref = new CheckBoxPreference(mContext);
pref.setKey("pkg|567");
mController.onPreferenceChange(pref, true);
ArgumentCaptor<NotificationListenerFilter> captor = ArgumentCaptor.forClass(NotificationListenerFilter.class);
verify(mNm).setListenerFilter(eq(mCn), eq(0), captor.capture());
assertThat(captor.getValue().getDisallowedPackages().size()).isEqualTo(1);
assertThat(captor.getValue().getDisallowedPackages()).contains(new VersionedPackage("pkg", 10567));
}
use of androidx.preference.CheckBoxPreference in project android_packages_apps_Settings by omnirom.
the class BridgedAppsPreferenceControllerTest method onRebuildComplete_doesNotReaddToScreen.
@Test
public void onRebuildComplete_doesNotReaddToScreen() {
when(mNm.isNotificationListenerAccessGranted(mCn)).thenReturn(true);
when(mNm.getListenerFilter(mCn, 0)).thenReturn(new NotificationListenerFilter());
CheckBoxPreference p = mock(CheckBoxPreference.class);
when(p.getKey()).thenReturn("pkg|12300");
mScreen.addPreference(p);
ArrayList<ApplicationsState.AppEntry> entries = new ArrayList<>();
entries.add(mAppEntry);
entries.add(mAppEntry2);
mController.onRebuildComplete(entries);
assertThat(mScreen.getPreferenceCount()).isEqualTo(2);
}
use of androidx.preference.CheckBoxPreference in project android_packages_apps_Settings by omnirom.
the class TypeFilterPreferenceControllerTest method onPreferenceChange_true.
@Test
public void onPreferenceChange_true() {
NotificationListenerFilter nlf = new NotificationListenerFilter(FLAG_FILTER_TYPE_ONGOING | FLAG_FILTER_TYPE_CONVERSATIONS, new ArraySet<>());
when(mNm.isNotificationListenerAccessGranted(mCn)).thenReturn(true);
when(mNm.getListenerFilter(mCn, 0)).thenReturn(nlf);
CheckBoxPreference pref = new CheckBoxPreference(mContext);
mController.onPreferenceChange(pref, true);
ArgumentCaptor<NotificationListenerFilter> captor = ArgumentCaptor.forClass(NotificationListenerFilter.class);
verify(mNm).setListenerFilter(eq(mCn), eq(0), captor.capture());
assertThat(captor.getValue().getTypes()).isEqualTo(FLAG_FILTER_TYPE_CONVERSATIONS | FLAG_FILTER_TYPE_ONGOING | mController.getType());
}
use of androidx.preference.CheckBoxPreference in project android_packages_apps_Settings by omnirom.
the class TypeFilterPreferenceControllerTest method updateState_enabled_metaData_notTheDisableFilter.
@Test
public void updateState_enabled_metaData_notTheDisableFilter() {
mSi.metaData = new Bundle();
mSi.metaData.putCharSequence("test", "value");
when(mNm.isNotificationListenerAccessGranted(mCn)).thenReturn(true);
when(mNm.getListenerFilter(mCn, 0)).thenReturn(new NotificationListenerFilter());
CheckBoxPreference pref = new CheckBoxPreference(mContext);
mController.updateState(pref);
assertThat(pref.isEnabled()).isTrue();
}
use of androidx.preference.CheckBoxPreference in project android_packages_apps_Settings by omnirom.
the class TypeFilterPreferenceControllerTest method updateState_unchecked.
@Test
public void updateState_unchecked() {
NotificationListenerFilter nlf = new NotificationListenerFilter(mController.getType() - 1, new ArraySet<>());
when(mNm.isNotificationListenerAccessGranted(mCn)).thenReturn(true);
when(mNm.getListenerFilter(mCn, 0)).thenReturn(nlf);
CheckBoxPreference pref = new CheckBoxPreference(mContext);
mController.updateState(pref);
assertThat(pref.isChecked()).isFalse();
}
Aggregations