Search in sources :

Example 81 with Preference

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

the class DefaultAutofillPreferenceControllerTest method updateState_hasNoApp_shouldNotReturnLabel.

@Test
public void updateState_hasNoApp_shouldNotReturnLabel() {
    final Preference pref = mock(Preference.class);
    mController.updateState(pref);
    verify(pref).setSummary(R.string.app_list_preference_none);
}
Also used : Preference(androidx.preference.Preference) Test(org.junit.Test)

Example 82 with Preference

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

the class AppSettingPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mActivity = Robolectric.setupActivity(Activity.class);
    mPackageManager = Shadows.shadowOf(RuntimeEnvironment.application.getPackageManager());
    mController = new AppSettingPreferenceController(mActivity, "test_key");
    mController.setPackageName(TEST_PKG_NAME).setParentFragment(mParent);
    mPreference = new Preference(mActivity);
    mPreference.setKey(mController.getPreferenceKey());
}
Also used : Preference(androidx.preference.Preference) Activity(android.app.Activity) Before(org.junit.Before)

Example 83 with Preference

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

the class TimeSpentInAppPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mFeatureFactory = FakeFeatureFactory.setupForTest();
    mContext = RuntimeEnvironment.application;
    mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
    mController = new TimeSpentInAppPreferenceController(mContext, TEST_KEY);
    mPreference = new Preference(mContext);
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
}
Also used : Preference(androidx.preference.Preference) Before(org.junit.Before)

Example 84 with Preference

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

the class MoreSpecialAccessPreferenceControllerTest method handlePreferenceTreeClick_sameKey_shouldReturnTrue.

@Test
public void handlePreferenceTreeClick_sameKey_shouldReturnTrue() {
    when(mPackageManager.getPermissionControllerPackageName()).thenReturn(PERMISSION_CONTROLLER_PACKAGE_NAME);
    MoreSpecialAccessPreferenceController preferenceController = new MoreSpecialAccessPreferenceController(mContext, PREFERENCE_KEY);
    Preference preference = mock(Preference.class);
    when(preference.getKey()).thenReturn(PREFERENCE_KEY);
    assertThat(preferenceController.handlePreferenceTreeClick(preference)).isTrue();
}
Also used : Preference(androidx.preference.Preference) Test(org.junit.Test)

Example 85 with Preference

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

the class MoreSpecialAccessPreferenceControllerTest method handlePreferenceTreeClick_canNotResolveActivity_shouldNotStartActivity.

@Test
public void handlePreferenceTreeClick_canNotResolveActivity_shouldNotStartActivity() {
    when(mPackageManager.getPermissionControllerPackageName()).thenReturn(PERMISSION_CONTROLLER_PACKAGE_NAME);
    MoreSpecialAccessPreferenceController preferenceController = new MoreSpecialAccessPreferenceController(mContext, PREFERENCE_KEY);
    Preference preference = mock(Preference.class);
    when(preference.getKey()).thenReturn(PREFERENCE_KEY);
    preferenceController.handlePreferenceTreeClick(preference);
    verify(mContext, never()).startActivity(any(Intent.class));
}
Also used : Preference(androidx.preference.Preference) Intent(android.content.Intent) Test(org.junit.Test)

Aggregations

Preference (androidx.preference.Preference)863 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)43 PreferenceCategory (androidx.preference.PreferenceCategory)40 Tile (com.android.settingslib.drawer.Tile)40 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