Search in sources :

Example 16 with Preference

use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AccessibilityHearingAidPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mShadowApplication = ShadowApplication.getInstance();
    mContext = spy(Robolectric.setupActivity(Activity.class));
    setupBluetoothEnvironment();
    setupHearingAidEnvironment();
    mHearingAidPreference = new Preference(mContext);
    mHearingAidPreference.setKey(HEARING_AID_PREFERENCE);
    mPreferenceController = new AccessibilityHearingAidPreferenceController(mContext, HEARING_AID_PREFERENCE);
    mPreferenceController.setPreference(mHearingAidPreference);
    mHearingAidPreference.setSummary("");
}
Also used : Preference(androidx.preference.Preference) Before(org.junit.Before)

Example 17 with Preference

use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AccessibilitySettingsTest method verifyAccessibilityTimeoutSummary.

private void verifyAccessibilityTimeoutSummary(String preferenceKey, int resId) {
    final Preference preference = new Preference(mContext);
    doReturn(preference).when(mSettings).findPreference(preferenceKey);
    preference.setKey(preferenceKey);
    mSettings.updateAccessibilityTimeoutSummary(mContentResolver, preference);
    assertThat(preference.getSummary()).isEqualTo(mContext.getResources().getString(resId));
}
Also used : Preference(androidx.preference.Preference)

Example 18 with Preference

use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class NotificationVibrationIntensityPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mLifecycleOwner = () -> mLifecycle;
    mLifecycle = new Lifecycle(mLifecycleOwner);
    mContext = spy(RuntimeEnvironment.application);
    mResources = spy(mContext.getResources());
    when(mContext.getResources()).thenReturn(mResources);
    when(mResources.getBoolean(R.bool.config_vibration_supports_multiple_intensities)).thenReturn(true);
    mController = new NotificationVibrationIntensityPreferenceController(mContext) {

        @Override
        protected int getDefaultIntensity() {
            return 10;
        }
    };
    mLifecycle.addObserver(mController);
    mPreference = new Preference(mContext);
    mPreference.setSummary("Test");
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
}
Also used : Preference(androidx.preference.Preference) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) Before(org.junit.Before)

Example 19 with Preference

use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BluetoothPairingPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    when(mFragment.getPreferenceScreen().getContext()).thenReturn(mContext);
    mPreference = new Preference(mContext);
    mPreference.setKey(BluetoothPairingPreferenceController.KEY_PAIRING);
    mController = new BluetoothPairingPreferenceController(mContext, mFragment);
}
Also used : Preference(androidx.preference.Preference) Before(org.junit.Before)

Example 20 with Preference

use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BluetoothPairingPreferenceControllerTest method testCreateBluetoothPairingPreference.

@Test
public void testCreateBluetoothPairingPreference() {
    Preference pref = mController.createBluetoothPairingPreference(ORDER);
    assertThat(pref.getKey()).isEqualTo(BluetoothPairingPreferenceController.KEY_PAIRING);
    DrawableTestHelper.assertDrawableResId(pref.getIcon(), R.drawable.ic_add_24dp);
    assertThat(pref.getOrder()).isEqualTo(ORDER);
    assertThat(pref.getTitle()).isEqualTo(mContext.getString(R.string.bluetooth_pairing_pref_title));
}
Also used : Preference(androidx.preference.Preference) Test(org.junit.Test)

Aggregations

Preference (androidx.preference.Preference)860 Test (org.junit.Test)343 Before (org.junit.Before)164 Intent (android.content.Intent)81 PreferenceScreen (androidx.preference.PreferenceScreen)81 NotificationChannel (android.app.NotificationChannel)77 SwitchPreference (androidx.preference.SwitchPreference)75 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)69 Context (android.content.Context)60 ArrayList (java.util.ArrayList)50 NotificationBackend (com.android.settings.notification.NotificationBackend)45 ListPreference (androidx.preference.ListPreference)41 Tile (com.android.settingslib.drawer.Tile)40 PreferenceCategory (androidx.preference.PreferenceCategory)39 PreferenceManager (androidx.preference.PreferenceManager)39 Activity (android.app.Activity)27 UserHandle (android.os.UserHandle)27 FooterPreference (com.android.settingslib.widget.FooterPreference)27 PackageManager (android.content.pm.PackageManager)26 Bundle (android.os.Bundle)24