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));
}
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();
}
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);
}
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);
}
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);
}
Aggregations