Search in sources :

Example 71 with PreferenceManager

use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.

the class NetworkProviderDownloadedSimsCategoryControllerTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    mContext = spy(ApplicationProvider.getApplicationContext());
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    mPreferenceManager = new PreferenceManager(mContext);
    mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
    mPreferenceCategory = new PreferenceCategory(mContext);
    mPreferenceCategory.setKey(KEY_PREFERENCE_CATEGORY_DOWNLOADED_SIM);
    mAddMorePreference = new Preference(mContext);
    mAddMorePreference.setKey(KEY_ADD_MORE);
    mAddMorePreference.setVisible(true);
    mPreferenceScreen.addPreference(mPreferenceCategory);
    mPreferenceScreen.addPreference(mAddMorePreference);
    mCategoryController = new NetworkProviderDownloadedSimsCategoryController(mContext, KEY_PREFERENCE_CATEGORY_DOWNLOADED_SIM, mLifecycle);
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory) Preference(androidx.preference.Preference) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 72 with PreferenceManager

use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.

the class NetworkProviderDownloadedSimListControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(ApplicationProvider.getApplicationContext());
    when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    mPreferenceManager = new PreferenceManager(mContext);
    mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
    mPreference = new Preference(mContext);
    mPreference.setKey(KEY_PREFERENCE_DOWNLOADED_SIM);
    mController = new MockNetworkProviderDownloadedSimListController(mContext, mLifecycle);
    mAddMorePreference = new Preference(mContext);
    mAddMorePreference.setKey(KEY_ADD_MORE);
    mAddMorePreference.setVisible(true);
    mLifecycleRegistry = new LifecycleRegistry(mLifecycleOwner);
    when(mLifecycleOwner.getLifecycle()).thenReturn(mLifecycleRegistry);
}
Also used : LifecycleRegistry(androidx.lifecycle.LifecycleRegistry) Preference(androidx.preference.Preference) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 73 with PreferenceManager

use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.

the class WifiSwitchPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    final Context context = spy(ApplicationProvider.getApplicationContext());
    doReturn(mWifiManager).when(context).getSystemService(Context.WIFI_SERVICE);
    mController = new WifiSwitchPreferenceController(context, mock(Lifecycle.class));
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    final PreferenceManager preferenceManager = new PreferenceManager(context);
    mScreen = preferenceManager.createPreferenceScreen(context);
    mPreference = new RestrictedSwitchPreference(context);
    mPreference.setKey(WifiSwitchPreferenceController.KEY);
    mScreen.addPreference(mPreference);
}
Also used : Context(android.content.Context) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 74 with PreferenceManager

use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.

the class VpnPreferenceControllerTest method setUp.

@Before
@UiThreadTest
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(ApplicationProvider.getApplicationContext());
    when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(mConnectivityManager);
    when(mContext.getSystemService(VpnManager.class)).thenReturn(mVpnManager);
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    PreferenceManager preferenceManager = new PreferenceManager(mContext);
    mScreen = preferenceManager.createPreferenceScreen(mContext);
    when(mPreference.getKey()).thenReturn(VPN_PREFERENCE_KEY);
    mScreen.addPreference(mPreference);
    mController = spy(new VpnPreferenceController(mContext));
    mLifecycleOwner = () -> mLifecycle;
    mLifecycle = new Lifecycle(mLifecycleOwner);
    mLifecycle.addObserver(mController);
}
Also used : Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 75 with PreferenceManager

use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.

the class DeleteSimProfilePreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(ApplicationProvider.getApplicationContext());
    SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(mSubscriptionInfo));
    when(mSubscriptionInfo.getSubscriptionId()).thenReturn(SUB_ID);
    when(mSubscriptionInfo.isEmbedded()).thenReturn(true);
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    PreferenceManager preferenceManager = new PreferenceManager(mContext);
    mScreen = preferenceManager.createPreferenceScreen(mContext);
    mPreference = new Preference(mContext);
    mPreference.setKey(PREF_KEY);
    mScreen.addPreference(mPreference);
    mController = new DeleteSimProfilePreferenceController(mContext, PREF_KEY);
}
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