Search in sources :

Example 1 with NotificationListenerFilter

use of android.service.notification.NotificationListenerFilter in project android_packages_apps_Settings by omnirom.

the class BridgedAppsLinkPreferenceControllerTest method testAvailable_lowTargetSdk_customizations.

@Test
public void testAvailable_lowTargetSdk_customizations() {
    when(mNm.isNotificationListenerAccessGranted(any())).thenReturn(true);
    mController.setTargetSdk(Build.VERSION_CODES.S);
    NotificationListenerFilter nlf = new NotificationListenerFilter();
    nlf.setTypes(FLAG_FILTER_TYPE_CONVERSATIONS);
    when(mNm.getListenerFilter(mCn, 0)).thenReturn(nlf);
    assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
Also used : NotificationListenerFilter(android.service.notification.NotificationListenerFilter) Test(org.junit.Test)

Example 2 with NotificationListenerFilter

use of android.service.notification.NotificationListenerFilter in project android_packages_apps_Settings by omnirom.

the class PreUpgradePreferenceControllerTest method testAvailable_highTargetSdk_noCustomizations.

@Test
public void testAvailable_highTargetSdk_noCustomizations() {
    when(mNm.isNotificationListenerAccessGranted(any())).thenReturn(true);
    mController.setTargetSdk(Build.VERSION_CODES.CUR_DEVELOPMENT + 1);
    when(mNm.getListenerFilter(mCn, 0)).thenReturn(new NotificationListenerFilter());
    assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
}
Also used : NotificationListenerFilter(android.service.notification.NotificationListenerFilter) Test(org.junit.Test)

Example 3 with NotificationListenerFilter

use of android.service.notification.NotificationListenerFilter in project android_packages_apps_Settings by omnirom.

the class PreUpgradePreferenceControllerTest method testAvailable_lowTargetSdk_customizations.

@Test
public void testAvailable_lowTargetSdk_customizations() {
    when(mNm.isNotificationListenerAccessGranted(any())).thenReturn(true);
    mController.setTargetSdk(Build.VERSION_CODES.S);
    NotificationListenerFilter nlf = new NotificationListenerFilter();
    nlf.setTypes(FLAG_FILTER_TYPE_CONVERSATIONS);
    when(mNm.getListenerFilter(mCn, 0)).thenReturn(nlf);
    assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
}
Also used : NotificationListenerFilter(android.service.notification.NotificationListenerFilter) Test(org.junit.Test)

Example 4 with NotificationListenerFilter

use of android.service.notification.NotificationListenerFilter in project android_packages_apps_Settings by omnirom.

the class PreUpgradePreferenceControllerTest method testAvailable_lowTargetSdk_noCustomizations.

@Test
public void testAvailable_lowTargetSdk_noCustomizations() {
    when(mNm.isNotificationListenerAccessGranted(any())).thenReturn(true);
    mController.setTargetSdk(Build.VERSION_CODES.S);
    when(mNm.getListenerFilter(mCn, 0)).thenReturn(new NotificationListenerFilter());
    assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
Also used : NotificationListenerFilter(android.service.notification.NotificationListenerFilter) Test(org.junit.Test)

Example 5 with NotificationListenerFilter

use of android.service.notification.NotificationListenerFilter in project android_packages_apps_Settings by omnirom.

the class TypeFilterPreferenceControllerTest method updateState_enabled_metaData_disableFilter_notThisField.

@Test
public void updateState_enabled_metaData_disableFilter_notThisField() {
    mSi.metaData = new Bundle();
    mSi.metaData.putCharSequence(NotificationListenerService.META_DATA_DISABLED_FILTER_TYPES, "1|alerting");
    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) Bundle(android.os.Bundle) NotificationListenerFilter(android.service.notification.NotificationListenerFilter) Test(org.junit.Test)

Aggregations

NotificationListenerFilter (android.service.notification.NotificationListenerFilter)25 Test (org.junit.Test)25 CheckBoxPreference (androidx.preference.CheckBoxPreference)15 Bundle (android.os.Bundle)4 ArrayList (java.util.ArrayList)4 ArraySet (android.util.ArraySet)3 VersionedPackage (android.content.pm.VersionedPackage)2 Preference (androidx.preference.Preference)1