Search in sources :

Example 31 with PreferenceManager

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));
}
Also used : PersistableBundle(android.os.PersistableBundle) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 32 with PreferenceManager

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();
}
Also used : BluetoothManager(android.bluetooth.BluetoothManager) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 33 with PreferenceManager

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, "");
}
Also used : PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 34 with PreferenceManager

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());
}
Also used : Context(android.content.Context) Arrays(java.util.Arrays) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) PackageManager(android.content.pm.PackageManager) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) AppHibernationManager(android.apphibernation.AppHibernationManager) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) RemoteException(android.os.RemoteException) Mockito.spy(org.mockito.Mockito.spy) PackageInfo(android.content.pm.PackageInfo) AndroidJUnit4(androidx.test.ext.junit.runners.AndroidJUnit4) AVAILABLE(com.android.settings.core.BasePreferenceController.AVAILABLE) ApplicationProvider(androidx.test.core.app.ApplicationProvider) IUsageStatsManager(android.app.usage.IUsageStatsManager) MockitoAnnotations(org.mockito.MockitoAnnotations) UsageStats(android.app.usage.UsageStats) Looper(android.os.Looper) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) Before(org.junit.Before) PreferenceScreen(androidx.preference.PreferenceScreen) ParceledListSlice(android.content.pm.ParceledListSlice) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Truth.assertThat(com.google.common.truth.Truth.assertThat) Preference(androidx.preference.Preference) Mockito.verify(org.mockito.Mockito.verify) UsageStatsManager(android.app.usage.UsageStatsManager) NAMESPACE_APP_HIBERNATION(android.provider.DeviceConfig.NAMESPACE_APP_HIBERNATION) PreferenceManager(androidx.preference.PreferenceManager) DeviceConfig(android.provider.DeviceConfig) PROPERTY_APP_HIBERNATION_ENABLED(com.android.settings.Utils.PROPERTY_APP_HIBERNATION_ENABLED) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Mockito.mock(org.mockito.Mockito.mock) Resources(android.content.res.Resources) Preference(androidx.preference.Preference) IUsageStatsManager(android.app.usage.IUsageStatsManager) UsageStatsManager(android.app.usage.UsageStatsManager) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 35 with PreferenceManager

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);
}
Also used : Preference(androidx.preference.Preference) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Aggregations

PreferenceManager (androidx.preference.PreferenceManager)87 Before (org.junit.Before)67 Preference (androidx.preference.Preference)23 PreferenceCategory (androidx.preference.PreferenceCategory)22 PreferenceScreen (androidx.preference.PreferenceScreen)19 Test (org.junit.Test)18 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)15 Context (android.content.Context)5 LifecycleRegistry (androidx.lifecycle.LifecycleRegistry)5 ArrayList (java.util.ArrayList)5 NotificationChannel (android.app.NotificationChannel)4 ShortcutInfo (android.content.pm.ShortcutInfo)4 View (android.view.View)4 NotificationChannelGroup (android.app.NotificationChannelGroup)3 ConversationChannel (android.app.people.ConversationChannel)3 PackageInfo (android.content.pm.PackageInfo)3 PersistableBundle (android.os.PersistableBundle)3 BluetoothManager (android.bluetooth.BluetoothManager)2 SoftApConfiguration (android.net.wifi.SoftApConfiguration)2 WifiManager (android.net.wifi.WifiManager)2