Search in sources :

Example 86 with PreferenceManager

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

the class DeviceNamePreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(ApplicationProvider.getApplicationContext());
    when(mContext.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
    mResources = spy(mContext.getResources());
    when(mContext.getResources()).thenReturn(mResources);
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    PreferenceManager preferenceManager = new PreferenceManager(mContext);
    mScreen = preferenceManager.createPreferenceScreen(mContext);
    mPreference = new ValidatedEditTextPreference(mContext);
    mPreference.setKey(TEST_PREFERENCE_KEY);
    mScreen.addPreference(mPreference);
    final SoftApConfiguration configuration = new SoftApConfiguration.Builder().setSsid("test-ap").build();
    when(mWifiManager.getSoftApConfiguration()).thenReturn(configuration);
    mController = new DeviceNamePreferenceController(mContext, TEST_PREFERENCE_KEY);
    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
}
Also used : ValidatedEditTextPreference(com.android.settings.widget.ValidatedEditTextPreference) SoftApConfiguration(android.net.wifi.SoftApConfiguration) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 87 with PreferenceManager

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

the class AirplaneModePreferenceControllerTest method setUp.

@Before
public void setUp() {
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    MockitoAnnotations.initMocks(this);
    mContext = spy(ApplicationProvider.getApplicationContext());
    mResolver = mContext.getContentResolver();
    doReturn(mPackageManager).when(mContext).getPackageManager();
    mController = new AirplaneModePreferenceController(mContext, SettingsSlicesContract.KEY_AIRPLANE_MODE);
    mPreferenceManager = new PreferenceManager(mContext);
    mScreen = mPreferenceManager.createPreferenceScreen(mContext);
    mPreference = new RestrictedSwitchPreference(mContext);
    mPreference.setKey(SettingsSlicesContract.KEY_AIRPLANE_MODE);
    mScreen.addPreference(mPreference);
    mController.setFragment(null);
}
Also used : RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) 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