use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.
the class ControllerFutureTaskTest method setUp.
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
mTestController = new TestPreferenceController(mContext, KEY);
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
mScreen = preferenceManager.createPreferenceScreen(mContext);
}
use of androidx.preference.PreferenceManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RestrictedAppDetailsTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
mRestrictedAppDetails = spy(new RestrictedAppDetails());
mAppInfo = new AppInfo.Builder().setPackageName(PACKAGE_NAME).setUid(UID).build();
mPreferenceManager = new PreferenceManager(mContext);
doReturn(mPreferenceManager).when(mRestrictedAppDetails).getPreferenceManager();
doReturn(mContext).when(mFragment).getContext();
doReturn(mContext).when(mRestrictedAppDetails).getContext();
mRestrictedAppDetails.mPackageManager = mPackageManager;
mRestrictedAppDetails.mIconDrawableFactory = mIconDrawableFactory;
mRestrictedAppDetails.mAppInfos = new ArrayList<>();
mRestrictedAppDetails.mAppInfos.add(mAppInfo);
mRestrictedAppDetails.mRestrictedAppListGroup = spy(new PreferenceCategory(mContext));
mRestrictedAppDetails.mBatteryUtils = spy(new BatteryUtils(mContext));
mRestrictedAppDetails.mBatteryDatabaseManager = mBatteryDatabaseManager;
doReturn(mPreferenceManager).when(mRestrictedAppDetails.mRestrictedAppListGroup).getPreferenceManager();
mCheckBoxPreference = new CheckBoxPreference(mContext);
mCheckBoxPreference.setKey(mRestrictedAppDetails.getKeyFromAppInfo(mAppInfo));
}
use of androidx.preference.PreferenceManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AccountTypePreferenceLoaderTest method updatePreferenceIntents_shouldRunRecursively.
@Test
@Config(shadows = { ShadowAccountManager.class, ShadowContentResolver.class })
public void updatePreferenceIntents_shouldRunRecursively() {
final PreferenceManager preferenceManager = mock(PreferenceManager.class);
// Top level
PreferenceGroup prefRoot = spy(new PreferenceScreen(mContext, null));
when(prefRoot.getPreferenceManager()).thenReturn(preferenceManager);
Preference pref1 = mock(Preference.class);
PreferenceGroup prefGroup2 = spy(new PreferenceScreen(mContext, null));
when(prefGroup2.getPreferenceManager()).thenReturn(preferenceManager);
Preference pref3 = mock(Preference.class);
PreferenceGroup prefGroup4 = spy(new PreferenceScreen(mContext, null));
when(prefGroup4.getPreferenceManager()).thenReturn(preferenceManager);
prefRoot.addPreference(pref1);
prefRoot.addPreference(prefGroup2);
prefRoot.addPreference(pref3);
prefRoot.addPreference(prefGroup4);
// 2nd level
Preference pref21 = mock(Preference.class);
Preference pref22 = mock(Preference.class);
prefGroup2.addPreference(pref21);
prefGroup2.addPreference(pref22);
PreferenceGroup prefGroup41 = spy(new PreferenceScreen(mContext, null));
when(prefGroup41.getPreferenceManager()).thenReturn(preferenceManager);
Preference pref42 = mock(Preference.class);
prefGroup4.addPreference(prefGroup41);
prefGroup4.addPreference(pref42);
// 3rd level
Preference pref411 = mock(Preference.class);
Preference pref412 = mock(Preference.class);
prefGroup41.addPreference(pref411);
prefGroup41.addPreference(pref412);
final String acctType = "testType";
mPrefLoader.updatePreferenceIntents(prefRoot, acctType, mAccount);
verify(mPrefLoader).updatePreferenceIntents(prefGroup2, acctType, mAccount);
verify(mPrefLoader).updatePreferenceIntents(prefGroup4, acctType, mAccount);
verify(mPrefLoader).updatePreferenceIntents(prefGroup41, acctType, mAccount);
}
use of androidx.preference.PreferenceManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ChooseAccountPreferenceControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mController = spy(new ChooseAccountPreferenceController(mContext, "controller_key"));
mActivity = Robolectric.setupActivity(FragmentActivity.class);
mPreferenceManager = new PreferenceManager(mContext);
mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
}
use of androidx.preference.PreferenceManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class UsbDetailsHeaderControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
mPreferenceManager = new PreferenceManager(mContext);
mScreen = mPreferenceManager.createPreferenceScreen(mContext);
when(mFragment.getActivity()).thenReturn(mActivity);
when(mActivity.getApplicationContext()).thenReturn(mContext);
when(mFragment.getContext()).thenReturn(mContext);
when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
ShadowEntityHeaderController.setUseMock(mHeaderController);
mDetailsHeaderController = new UsbDetailsHeaderController(mContext, mFragment, mUsbBackend);
mPreference = new LayoutPreference(mContext, R.layout.settings_entity_header);
mPreference.setKey(mDetailsHeaderController.getPreferenceKey());
mScreen.addPreference(mPreference);
}
Aggregations