Search in sources :

Example 6 with WifiEntryPreference

use of com.android.settingslib.wifi.WifiEntryPreference in project android_packages_apps_Settings by omnirom.

the class SavedAccessPointsPreferenceController2Test method displayPreference_noAccessPoint_shouldRemoveIt.

@Test
public void displayPreference_noAccessPoint_shouldRemoveIt() {
    final String title = "ssid_title";
    final String key = "key";
    final WifiEntry mockWifiEntry = mock(WifiEntry.class);
    when(mockWifiEntry.getTitle()).thenReturn(title);
    when(mockWifiEntry.getKey()).thenReturn(key);
    final WifiEntryPreference preference = new WifiEntryPreference(mContext, mockWifiEntry);
    preference.setKey(key);
    mPreferenceCategory.addPreference(preference);
    mController.displayPreference(mPreferenceScreen, new ArrayList<>());
    assertThat(mPreferenceCategory.getPreferenceCount()).isEqualTo(0);
}
Also used : WifiEntry(com.android.wifitrackerlib.WifiEntry) WifiEntryPreference(com.android.settingslib.wifi.WifiEntryPreference) Test(org.junit.Test)

Example 7 with WifiEntryPreference

use of com.android.settingslib.wifi.WifiEntryPreference in project android_packages_apps_Settings by omnirom.

the class SavedAccessPointsPreferenceController2Test method displayPreference_oneAccessPoint_shouldListIt.

@Test
public void displayPreference_oneAccessPoint_shouldListIt() {
    final String title = "ssid_title";
    final WifiEntry mockWifiEntry = mock(WifiEntry.class);
    when(mockWifiEntry.getTitle()).thenReturn(title);
    final ArgumentCaptor<WifiEntryPreference> captor = ArgumentCaptor.forClass(WifiEntryPreference.class);
    mController.displayPreference(mPreferenceScreen, Arrays.asList(mockWifiEntry));
    verify(mPreferenceCategory).addPreference(captor.capture());
    final List<WifiEntryPreference> prefs = captor.getAllValues();
    assertThat(prefs.size()).isEqualTo(1);
    assertThat(prefs.get(0).getTitle()).isEqualTo(title);
}
Also used : WifiEntry(com.android.wifitrackerlib.WifiEntry) WifiEntryPreference(com.android.settingslib.wifi.WifiEntryPreference) Test(org.junit.Test)

Example 8 with WifiEntryPreference

use of com.android.settingslib.wifi.WifiEntryPreference in project android_packages_apps_Settings by omnirom.

the class SavedAccessPointsPreferenceController2Test method onPreferenceClick_shouldCallShowWifiPage.

@Test
public void onPreferenceClick_shouldCallShowWifiPage() {
    mContext = spy(RuntimeEnvironment.application);
    doNothing().when(mContext).startActivity(any());
    doReturn(mContext).when(mSettings).getContext();
    final String title = "ssid_title";
    final String key = "key";
    final WifiEntry mockWifiEntry = mock(WifiEntry.class);
    when(mockWifiEntry.getTitle()).thenReturn(title);
    when(mockWifiEntry.getKey()).thenReturn(key);
    final WifiEntryPreference preference = new WifiEntryPreference(mContext, mockWifiEntry);
    preference.setKey(key);
    mController.onPreferenceClick(preference);
    verify(mSettings, times(1)).showWifiPage(key, title);
}
Also used : WifiEntry(com.android.wifitrackerlib.WifiEntry) WifiEntryPreference(com.android.settingslib.wifi.WifiEntryPreference) Test(org.junit.Test)

Example 9 with WifiEntryPreference

use of com.android.settingslib.wifi.WifiEntryPreference in project android_packages_apps_Settings by omnirom.

the class WifiConnectionPreferenceControllerTest method onConnectedChanged_wifiBecameDisconnected_preferenceRemoved.

@Test
public void onConnectedChanged_wifiBecameDisconnected_preferenceRemoved() {
    final WifiEntry wifiEntry = mock(WifiEntry.class);
    when(mWifiPickerTracker.getConnectedWifiEntry()).thenReturn(wifiEntry);
    mController.displayPreference(mScreen);
    final ArgumentCaptor<WifiEntryPreference> captor = ArgumentCaptor.forClass(WifiEntryPreference.class);
    verify(mPreferenceCategory).addPreference(captor.capture());
    final WifiEntryPreference pref = captor.getValue();
    // Become disconnected.
    when(mWifiPickerTracker.getConnectedWifiEntry()).thenReturn(null);
    final int onUpdatedCountBefore = mOnChildUpdatedCount;
    mController.onWifiStateChanged();
    verify(mPreferenceCategory).removePreference(pref);
    assertThat(mOnChildUpdatedCount).isEqualTo(onUpdatedCountBefore + 1);
}
Also used : WifiEntry(com.android.wifitrackerlib.WifiEntry) WifiEntryPreference(com.android.settingslib.wifi.WifiEntryPreference) Test(org.junit.Test)

Aggregations

WifiEntryPreference (com.android.settingslib.wifi.WifiEntryPreference)9 WifiEntry (com.android.wifitrackerlib.WifiEntry)8 Test (org.junit.Test)6 WifiConfiguration (android.net.wifi.WifiConfiguration)2 SubSettingLauncher (com.android.settings.core.SubSettingLauncher)2 Bundle (android.os.Bundle)1 AddNetworkFragment (com.android.settings.wifi.AddNetworkFragment)1 ArrayList (java.util.ArrayList)1