use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.
the class NetworkProviderBackupCallingGroupTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mContext = spy(ApplicationProvider.getApplicationContext());
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager1);
when(mTelephonyManager1.createForSubscriptionId(SUB_ID_1)).thenReturn(mTelephonyManager1);
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager2);
when(mTelephonyManager2.createForSubscriptionId(SUB_ID_2)).thenReturn(mTelephonyManager2);
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
when(mSubscriptionInfo1.getSubscriptionId()).thenReturn(SUB_ID_1);
when(mSubscriptionInfo1.getDisplayName()).thenReturn(DISPLAY_NAME_1);
doReturn(true).when(mNetworkProviderBackupCallingGroup).isCrossSimEnabledByPlatform(mContext, SUB_ID_1);
mSubscriptionInfoList.add(mSubscriptionInfo1);
when(mSubscriptionInfo2.getSubscriptionId()).thenReturn(SUB_ID_2);
when(mSubscriptionInfo2.getDisplayName()).thenReturn(DISPLAY_NAME_2);
doReturn(true).when(mNetworkProviderBackupCallingGroup).isCrossSimEnabledByPlatform(mContext, SUB_ID_2);
mSubscriptionInfoList.add(mSubscriptionInfo2);
when(mSubscriptionManager.getActiveSubscriptionInfoList()).thenReturn(mSubscriptionInfoList);
mCarrierConfig = new PersistableBundle();
doReturn(mCarrierConfig).when(mCarrierConfigManager).getConfigForSubId(SUB_ID_1);
mCarrierConfig.putBoolean(CarrierConfigManager.KEY_CARRIER_CROSS_SIM_IMS_AVAILABLE_BOOL, true);
doReturn(mCarrierConfig).when(mCarrierConfigManager).getConfigForSubId(SUB_ID_2);
mCarrierConfig.putBoolean(CarrierConfigManager.KEY_CARRIER_CROSS_SIM_IMS_AVAILABLE_BOOL, true);
if (Looper.myLooper() == null) {
Looper.prepare();
}
mPreferenceManager = new PreferenceManager(mContext);
mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
when(mPreferenceGroup.getKey()).thenReturn(KEY_PREFERENCE_CATEGORY_BACKUP_CALLING);
when(mPreferenceGroup.getPreferenceCount()).thenReturn(2);
mPreferenceScreen.addPreference(mPreferenceGroup);
mNetworkProviderBackupCallingGroup = spy(new NetworkProviderBackupCallingGroup(mContext, mLifecycle, mSubscriptionInfoList, KEY_PREFERENCE_CATEGORY_BACKUP_CALLING));
}
use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.
the class BluetoothDetailsControllerTestBase method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mPreferenceManager = new PreferenceManager(mContext);
mScreen = mPreferenceManager.createPreferenceScreen(mContext);
mDeviceConfig = makeDefaultDeviceConfig();
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);
mLifecycleOwner = () -> mLifecycle;
mLifecycle = spy(new Lifecycle(mLifecycleOwner));
mBluetoothManager = new BluetoothManager(mContext);
mBluetoothAdapter = mBluetoothManager.getAdapter();
}
use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.
the class InputMethodAndSubtypePreferenceControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mPreferenceManager = new PreferenceManager(mContext);
when(mFragment.getContext()).thenReturn(mContext);
when(mFragment.getResources()).thenReturn(mContext.getResources());
when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
mController = new InputMethodAndSubtypePreferenceController(mContext, "pref_key");
mController.initialize(mFragment, "");
}
use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.
the class HibernatedAppsPreferenceControllerTest method setUp.
@Before
public void setUp() {
if (Looper.myLooper() == null) {
Looper.prepare();
}
MockitoAnnotations.initMocks(this);
DeviceConfig.setProperty(NAMESPACE_APP_HIBERNATION, PROPERTY_APP_HIBERNATION_ENABLED, "true", false);
mContext = spy(ApplicationProvider.getApplicationContext());
when(mContext.getPackageManager()).thenReturn(mPackageManager);
when(mContext.getSystemService(AppHibernationManager.class)).thenReturn(mAppHibernationManager);
when(mContext.getSystemService(UsageStatsManager.class)).thenReturn(new UsageStatsManager(mContext, mIUsageStatsManager));
PreferenceManager manager = new PreferenceManager(mContext);
mPreferenceScreen = manager.createPreferenceScreen(mContext);
Preference preference = mock(Preference.class);
when(preference.getKey()).thenReturn(KEY);
mPreferenceScreen.addPreference(preference);
mController = new HibernatedAppsPreferenceController(mContext, KEY, command -> command.run(), command -> command.run());
}
use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.
the class MagnificationModePreferenceControllerTest method setUp.
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
mScreen = preferenceManager.createPreferenceScreen(mContext);
mModePreference = new Preference(mContext);
mModePreference.setKey(PREF_KEY);
mScreen.addPreference(mModePreference);
MagnificationCapabilities.setCapabilities(mContext, MAGNIFICATION_MODE_DEFAULT);
mController = new MagnificationModePreferenceController(mContext, PREF_KEY);
showPreferenceOnTheScreen(null);
}
Aggregations