use of androidx.preference.CheckBoxPreference in project android_packages_apps_Settings by omnirom.
the class TypeFilterPreferenceControllerTest method updateState_disabled_metaData_disableFilter_thisField_stateIsNotChecked.
@Test
public void updateState_disabled_metaData_disableFilter_thisField_stateIsNotChecked() {
mSi.metaData = new Bundle();
mSi.metaData.putCharSequence(NotificationListenerService.META_DATA_DISABLED_FILTER_TYPES, "1|2|32");
when(mNm.isNotificationListenerAccessGranted(mCn)).thenReturn(true);
NotificationListenerFilter before = new NotificationListenerFilter(4, new ArraySet<>());
when(mNm.getListenerFilter(mCn, 0)).thenReturn(before);
CheckBoxPreference pref = new CheckBoxPreference(mContext);
mController.updateState(pref);
assertThat(pref.isChecked()).isFalse();
assertThat(pref.isEnabled()).isFalse();
}
use of androidx.preference.CheckBoxPreference in project android_packages_apps_Settings by omnirom.
the class TypeFilterPreferenceControllerTest method updateState_enabled_noMetaData.
@Test
public void updateState_enabled_noMetaData() {
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_disabled.
@Test
public void updateState_disabled() {
when(mNm.isNotificationListenerAccessGranted(mCn)).thenReturn(false);
when(mNm.getListenerFilter(mCn, 0)).thenReturn(new NotificationListenerFilter());
CheckBoxPreference pref = new CheckBoxPreference(mContext);
mController.updateState(pref);
assertThat(pref.isEnabled()).isFalse();
}
use of androidx.preference.CheckBoxPreference in project android_packages_apps_Settings by omnirom.
the class TypeFilterPreferenceControllerTest method onPreferenceChange_false.
@Test
public void onPreferenceChange_false() {
NotificationListenerFilter nlf = new NotificationListenerFilter(FLAG_FILTER_TYPE_ONGOING | FLAG_FILTER_TYPE_CONVERSATIONS | mController.getType(), new ArraySet<>());
when(mNm.isNotificationListenerAccessGranted(mCn)).thenReturn(true);
when(mNm.getListenerFilter(mCn, 0)).thenReturn(nlf);
CheckBoxPreference pref = new CheckBoxPreference(mContext);
mController.onPreferenceChange(pref, false);
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);
}
use of androidx.preference.CheckBoxPreference in project android_packages_apps_Settings by omnirom.
the class TypeFilterPreferenceControllerTest method updateState_enabled_metaData_disableFilter_thisField_stateIsChecked.
@Test
public void updateState_enabled_metaData_disableFilter_thisField_stateIsChecked() {
mSi.metaData = new Bundle();
mSi.metaData.putCharSequence(NotificationListenerService.META_DATA_DISABLED_FILTER_TYPES, "conversations|2|32");
when(mNm.isNotificationListenerAccessGranted(mCn)).thenReturn(true);
when(mNm.getListenerFilter(mCn, 0)).thenReturn(new NotificationListenerFilter(32, new ArraySet<>()));
CheckBoxPreference pref = new CheckBoxPreference(mContext);
mController.updateState(pref);
assertThat(pref.isEnabled()).isTrue();
}
Aggregations