Search in sources :

Example 21 with Preference

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

the class DeviceListPreferenceFragmentTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mFragment = spy(new TestFragment());
    doReturn(mContext).when(mFragment).getContext();
    doReturn(mResource).when(mFragment).getResources();
    mFragment.mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    mMyDevicePreference = new Preference(RuntimeEnvironment.application);
}
Also used : Preference(androidx.preference.Preference) Before(org.junit.Before)

Example 22 with Preference

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

the class BluetoothDeviceNamePreferenceControllerTest method testCreateBluetoothDeviceNamePreference.

@Test
public void testCreateBluetoothDeviceNamePreference() {
    Preference preference = mController.createBluetoothDeviceNamePreference(mPreferenceScreen, ORDER);
    assertThat(preference.getKey()).isEqualTo(mController.getPreferenceKey());
    assertThat(preference.getOrder()).isEqualTo(ORDER);
    verify(mPreferenceScreen).addPreference(preference);
}
Also used : Preference(androidx.preference.Preference) Test(org.junit.Test)

Example 23 with Preference

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

the class BluetoothFilesPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    mController = new BluetoothFilesPreferenceController(mContext);
    mPreference = new Preference(mContext);
    mPreference.setKey(BluetoothFilesPreferenceController.KEY_RECEIVED_FILES);
    doReturn(mPackageManager).when(mContext).getPackageManager();
    doReturn(true).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_BLUETOOTH);
}
Also used : Preference(androidx.preference.Preference) Before(org.junit.Before)

Example 24 with Preference

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

the class FingerprintStatusPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    when(mContext.getPackageManager()).thenReturn(mPackageManager);
    when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)).thenReturn(true);
    ShadowApplication.getInstance().setSystemService(Context.FINGERPRINT_SERVICE, mFingerprintManager);
    ShadowApplication.getInstance().setSystemService(Context.USER_SERVICE, mUm);
    mPreference = new Preference(mContext);
    mFeatureFactory = FakeFeatureFactory.setupForTest();
    when(mFeatureFactory.securityFeatureProvider.getLockPatternUtils(mContext)).thenReturn(mLockPatternUtils);
    when(mUm.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[] { 1234 });
    mController = new FingerprintStatusPreferenceController(mContext);
}
Also used : Preference(androidx.preference.Preference) Before(org.junit.Before)

Example 25 with Preference

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

the class AppPrefLoaderTest method loadInBackground_shouldReturnPreference.

@Test
public void loadInBackground_shouldReturnPreference() throws NameNotFoundException {
    ApplicationInfo info = mock(ApplicationInfo.class);
    when(mPackageManager.getApplicationInfo(anyString(), anyInt())).thenReturn(info);
    final Drawable drawable = mock(Drawable.class);
    final String label = "Label1";
    when(info.loadIcon(mPackageManager)).thenReturn(drawable);
    when(info.loadLabel(mPackageManager)).thenReturn(label);
    Preference preference = mLoader.loadInBackground().valueAt(0);
    assertThat(preference.getTitle()).isEqualTo(label);
    assertThat(preference.getIcon()).isEqualTo(drawable);
    assertThat(preference.isSelectable()).isFalse();
}
Also used : Preference(androidx.preference.Preference) ApplicationInfo(android.content.pm.ApplicationInfo) Drawable(android.graphics.drawable.Drawable) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) 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