Search in sources :

Example 6 with CheckBoxPreference

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();
}
Also used : CheckBoxPreference(androidx.preference.CheckBoxPreference) Bundle(android.os.Bundle) NotificationListenerFilter(android.service.notification.NotificationListenerFilter) Test(org.junit.Test)

Example 7 with CheckBoxPreference

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();
}
Also used : CheckBoxPreference(androidx.preference.CheckBoxPreference) NotificationListenerFilter(android.service.notification.NotificationListenerFilter) Test(org.junit.Test)

Example 8 with CheckBoxPreference

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();
}
Also used : CheckBoxPreference(androidx.preference.CheckBoxPreference) NotificationListenerFilter(android.service.notification.NotificationListenerFilter) Test(org.junit.Test)

Example 9 with CheckBoxPreference

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);
}
Also used : CheckBoxPreference(androidx.preference.CheckBoxPreference) NotificationListenerFilter(android.service.notification.NotificationListenerFilter) Test(org.junit.Test)

Example 10 with CheckBoxPreference

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();
}
Also used : ArraySet(android.util.ArraySet) CheckBoxPreference(androidx.preference.CheckBoxPreference) Bundle(android.os.Bundle) NotificationListenerFilter(android.service.notification.NotificationListenerFilter) Test(org.junit.Test)

Aggregations

CheckBoxPreference (androidx.preference.CheckBoxPreference)36 Test (org.junit.Test)16 NotificationListenerFilter (android.service.notification.NotificationListenerFilter)14 Preference (androidx.preference.Preference)8 ListPreference (androidx.preference.ListPreference)7 Bundle (android.os.Bundle)6 VersionedPackage (android.content.pm.VersionedPackage)4 SparseLongArray (android.util.SparseLongArray)4 AppInfo (com.android.settings.fuelgauge.batterytip.AppInfo)4 AppCheckBoxPreference (com.android.settings.widget.AppCheckBoxPreference)4 Context (android.content.Context)3 SharedPreferences (android.content.SharedPreferences)3 PackageManager (android.content.pm.PackageManager)3 ArraySet (android.util.ArraySet)3 EditTextPreference (androidx.preference.EditTextPreference)3 PreferenceCategory (androidx.preference.PreferenceCategory)3 SeekBarPreference (androidx.preference.SeekBarPreference)3 ArrayList (java.util.ArrayList)3 ApplicationInfo (android.content.pm.ApplicationInfo)2 VisibleForTesting (androidx.annotation.VisibleForTesting)2