Search in sources :

Example 26 with ValidatedEditTextPreference

use of com.android.settings.widget.ValidatedEditTextPreference in project android_packages_apps_Settings by omnirom.

the class WifiTetherPasswordPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mPreference = new ValidatedEditTextPreference(RuntimeEnvironment.application);
    mConfig = new SoftApConfiguration.Builder().setSsid("test_1234").setPassphrase(INITIAL_PASSWORD, SoftApConfiguration.SECURITY_TYPE_WPA2_PSK).build();
    doReturn(mWifiManager).when(mContext).getSystemService(WifiManager.class);
    when(mWifiManager.getSoftApConfiguration()).thenReturn(mConfig);
    doReturn(mTetheringManager).when(mContext).getSystemService(TetheringManager.class);
    when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[] { "1", "2" });
    when(mContext.getResources()).thenReturn(RuntimeEnvironment.application.getResources());
    when(mScreen.findPreference(anyString())).thenReturn(mPreference);
    mController = new WifiTetherPasswordPreferenceController(mContext, mListener, mMetricsFeatureProvider);
}
Also used : ValidatedEditTextPreference(com.android.settings.widget.ValidatedEditTextPreference) Before(org.junit.Before)

Example 27 with ValidatedEditTextPreference

use of com.android.settings.widget.ValidatedEditTextPreference 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)

Aggregations

ValidatedEditTextPreference (com.android.settings.widget.ValidatedEditTextPreference)27 WifiConfiguration (android.net.wifi.WifiConfiguration)15 Before (org.junit.Before)15 SoftApConfiguration (android.net.wifi.SoftApConfiguration)3 Intent (android.content.Intent)2 PreferenceManager (androidx.preference.PreferenceManager)1 ShadowApplication (org.robolectric.shadows.ShadowApplication)1