Search in sources :

Example 76 with PreferenceManager

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

the class DisabledSubscriptionControllerTest 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);
    mScreen = mPreferenceManager.createPreferenceScreen(mContext);
    mCategory = new PreferenceCategory(mContext);
    mCategory.setKey(KEY);
    mScreen.addPreference(mCategory);
    mController = new DisabledSubscriptionController(mContext, KEY);
    mController.init(mLifecycle, SUB_ID);
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 77 with PreferenceManager

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

the class CarrierWifiTogglePreferenceControllerTest method setUp.

@Before
public void setUp() {
    mContext = spy(ApplicationProvider.getApplicationContext());
    mController = new CarrierWifiTogglePreferenceController(mContext, CarrierWifiTogglePreferenceController.CARRIER_WIFI_TOGGLE_PREF_KEY);
    mController.init(mock(Lifecycle.class), SUB_ID);
    mController.mIsProviderModelEnabled = true;
    mController.mIsCarrierProvisionWifiEnabled = true;
    doReturn(true).when(mWifiPickerTrackerHelper).isCarrierNetworkActive();
    doReturn(SSID).when(mWifiPickerTrackerHelper).getCarrierNetworkSsid();
    mController.mWifiPickerTrackerHelper = mWifiPickerTrackerHelper;
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    final PreferenceManager preferenceManager = new PreferenceManager(mContext);
    mScreen = preferenceManager.createPreferenceScreen(mContext);
    mTogglePreference = new Preference(mContext);
    mTogglePreference.setKey(CarrierWifiTogglePreferenceController.CARRIER_WIFI_TOGGLE_PREF_KEY);
    mScreen.addPreference(mTogglePreference);
    mNetworkPreference = new Preference(mContext);
    mNetworkPreference.setKey(CarrierWifiTogglePreferenceController.CARRIER_WIFI_NETWORK_PREF_KEY);
    mScreen.addPreference(mNetworkPreference);
    mController.mCarrierNetworkPreference = mNetworkPreference;
}
Also used : Preference(androidx.preference.Preference) Lifecycle(androidx.lifecycle.Lifecycle) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 78 with PreferenceManager

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

the class MobileNetworkPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(ApplicationProvider.getApplicationContext());
    when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
    when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
    when(mContext.getSystemService(UserManager.class)).thenReturn(mUserManager);
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    mPreferenceManager = new PreferenceManager(mContext);
    mScreen = mPreferenceManager.createPreferenceScreen(mContext);
    mPreference = new Preference(mContext);
    mPreference.setKey(MobileNetworkPreferenceController.KEY_MOBILE_NETWORK_SETTINGS);
    mLifecycleRegistry = new LifecycleRegistry(mLifecycleOwner);
    when(mLifecycleOwner.getLifecycle()).thenReturn(mLifecycleRegistry);
}
Also used : LifecycleRegistry(androidx.lifecycle.LifecycleRegistry) RestrictedPreference(com.android.settingslib.RestrictedPreference) Preference(androidx.preference.Preference) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 79 with PreferenceManager

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

the class DefaultSubscriptionControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(ApplicationProvider.getApplicationContext());
    when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubMgr);
    when(mContext.getSystemService(TelecomManager.class)).thenReturn(mTelecomManager);
    final String key = "prefkey";
    mController = new TestDefaultSubscriptionController(mContext, key);
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    mPreferenceManager = new PreferenceManager(mContext);
    mScreen = mPreferenceManager.createPreferenceScreen(mContext);
    mListPreference = new ListPreference(mContext);
    mListPreference.setKey(key);
    mScreen.addPreference(mListPreference);
}
Also used : ListPreference(androidx.preference.ListPreference) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 80 with PreferenceManager

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

the class InternetPreferenceControllerTest method setUp.

@Before
public void setUp() {
    mContext = spy(ApplicationProvider.getApplicationContext());
    when(mContext.getSystemService(ConnectivityManager.class)).thenReturn(mConnectivityManager);
    when(mContext.getSystemService(NetworkScoreManager.class)).thenReturn(mock(NetworkScoreManager.class));
    final WifiManager wifiManager = mock(WifiManager.class);
    when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(wifiManager);
    when(wifiManager.getWifiState()).thenReturn(WifiManager.WIFI_STATE_DISABLED);
    mController = new InternetPreferenceController(mContext, mock(Lifecycle.class));
    mController.sIconMap.put(INTERNET_WIFI, 0);
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    final PreferenceManager preferenceManager = new PreferenceManager(mContext);
    mScreen = preferenceManager.createPreferenceScreen(mContext);
    mPreference = new Preference(mContext);
    mPreference.setKey(InternetPreferenceController.KEY);
    mScreen.addPreference(mPreference);
}
Also used : WifiManager(android.net.wifi.WifiManager) NetworkScoreManager(android.net.NetworkScoreManager) 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