Search in sources :

Example 36 with Preference

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

the class WallpaperPreferenceControllerTest method handlePreferenceTreeClick_stylesAndWallpaper.

@Test
public void handlePreferenceTreeClick_stylesAndWallpaper() {
    mShadowPackageManager.setResolveInfosForIntent(mWallpaperIntent, Lists.newArrayList());
    mShadowPackageManager.setResolveInfosForIntent(mStylesAndWallpaperIntent, Lists.newArrayList(mock(ResolveInfo.class)));
    Preference preference = new Preference(mContext);
    preference.setKey(TEST_KEY);
    mController.handlePreferenceTreeClick(preference);
    assertThat(Shadows.shadowOf(mContext).getNextStartedActivityForResult().intent.getComponent().getClassName()).isEqualTo(mContext.getString(R.string.config_styles_and_wallpaper_picker_class));
}
Also used : Preference(androidx.preference.Preference) Test(org.junit.Test)

Example 37 with Preference

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

the class RestrictAppPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    final AppOpsManager.OpEntry allowOpEntry = new AppOpsManager.OpEntry(AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, false, AppOpsManager.MODE_ALLOWED, null, /*accessTimes*/
    null, /*rejectTimes*/
    null, /*durations*/
    null, /* proxyUids */
    null);
    final List<AppOpsManager.OpEntry> allowOps = new ArrayList<>();
    allowOps.add(allowOpEntry);
    final AppOpsManager.OpEntry restrictedOpEntry = new AppOpsManager.OpEntry(AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, false, AppOpsManager.MODE_IGNORED, null, /*accessTimes*/
    null, /*rejectTimes*/
    null, /*durations*/
    null, /* proxyUids */
    null);
    final List<AppOpsManager.OpEntry> restrictedOps = new ArrayList<>();
    restrictedOps.add(restrictedOpEntry);
    mAllowedPackageOps = new AppOpsManager.PackageOps(ALLOWED_PACKAGE_NAME, ALLOWED_UID, allowOps);
    mRestrictedPackageOps = new AppOpsManager.PackageOps(RESTRICTED_PACKAGE_NAME, RESTRICTED_UID, restrictedOps);
    mOtherUserPackageOps = new AppOpsManager.PackageOps(RESTRICTED_PACKAGE_NAME, OTHER_USER_UID, restrictedOps);
    mContext = spy(Robolectric.setupActivity(Activity.class));
    doReturn(mAppOpsManager).when(mContext).getSystemService(Context.APP_OPS_SERVICE);
    doReturn(mUserManager).when(mContext).getSystemService(UserManager.class);
    doReturn(mContext).when(mFragment).getContext();
    mRestrictAppPreferenceController = new RestrictAppPreferenceController(mFragment);
    mPackageOpsList = new ArrayList<>();
    mPreference = new Preference(mContext);
    mPreference.setKey(mRestrictAppPreferenceController.getPreferenceKey());
    final List<UserHandle> userHandles = new ArrayList<>();
    userHandles.add(new UserHandle(0));
    doReturn(userHandles).when(mUserManager).getUserProfiles();
}
Also used : AppOpsManager(android.app.AppOpsManager) Preference(androidx.preference.Preference) UserHandle(android.os.UserHandle) ArrayList(java.util.ArrayList) Before(org.junit.Before)

Example 38 with Preference

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

the class BatteryTipTest method buildPreference.

@Test
public void buildPreference() {
    final Preference preference = new Preference(mContext);
    mBatteryTip.updatePreference(preference);
    assertThat(preference.getTitle()).isEqualTo(TITLE);
    assertThat(preference.getSummary()).isEqualTo(SUMMARY);
    DrawableTestHelper.assertDrawableResId(preference.getIcon(), ICON_ID);
}
Also used : Preference(androidx.preference.Preference) Test(org.junit.Test)

Example 39 with Preference

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

the class UserDictionaryPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    FakeFeatureFactory.setupForTest();
    mController = new TestController(mContext);
    mPreference = new Preference(RuntimeEnvironment.application);
}
Also used : Preference(androidx.preference.Preference) Before(org.junit.Before)

Example 40 with Preference

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

the class LocationServicePreferenceControllerTest method updateState_shouldRemoveAllAndAddInjectedSettings.

@Test
public void updateState_shouldRemoveAllAndAddInjectedSettings() {
    final List<Preference> preferences = new ArrayList<>();
    final Map<Integer, List<Preference>> map = new ArrayMap<>();
    final Preference pref1 = new Preference(mContext);
    pref1.setTitle("Title1");
    final Preference pref2 = new Preference(mContext);
    pref2.setTitle("Title2");
    preferences.add(pref1);
    preferences.add(pref2);
    map.put(UserHandle.myUserId(), preferences);
    doReturn(map).when(mSettingsInjector).getInjectedSettings(any(Context.class), anyInt());
    when(mFragment.getPreferenceManager().getContext()).thenReturn(mContext);
    ShadowUserManager.getShadow().setProfileIdsWithDisabled(new int[] { UserHandle.myUserId() });
    mController.displayPreference(mScreen);
    mController.updateState(mCategoryPrimary);
    verify(mCategoryPrimary).removeAll();
    verify(mCategoryPrimary).addPreference(pref1);
    verify(mCategoryPrimary).addPreference(pref2);
}
Also used : Context(android.content.Context) RestrictedAppPreference(com.android.settings.widget.RestrictedAppPreference) Preference(androidx.preference.Preference) ArrayList(java.util.ArrayList) ArrayMap(android.util.ArrayMap) ArrayList(java.util.ArrayList) List(java.util.List) 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