use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.
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 android_packages_apps_Settings by omnirom.
the class HardwareInfoPreferenceControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mController = new HardwareInfoPreferenceController(mContext, KEY);
mPreference = new Preference(mContext);
mPreference.setKey(KEY);
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
mPreferenceScreen = preferenceManager.createPreferenceScreen(mContext);
mPreferenceScreen.addPreference(mPreference);
}
use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.
the class ControllerTaskTest method setUp.
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
mScreen = preferenceManager.createPreferenceScreen(mContext);
mTestController = spy(new TestPreferenceController(mContext));
mControllerTask = new ControllerTask(mTestController, mScreen, null, /* metricsFeature */
METRICS_CATEGORY_UNKNOWN);
}
use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.
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 android_packages_apps_Settings by omnirom.
the class UsbDetailsFunctionsControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
mLifecycle = new Lifecycle(() -> mLifecycle);
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);
when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
mDetailsFunctionsController = new UsbDetailsFunctionsController(mContext, mFragment, mUsbBackend);
mPreferenceCategory = new PreferenceCategory(mContext);
mPreferenceCategory.setKey(mDetailsFunctionsController.getPreferenceKey());
mScreen.addPreference(mPreferenceCategory);
mDetailsFunctionsController.displayPreference(mScreen);
mRadioButtonPreference = new RadioButtonPreference(mContext);
}
Aggregations