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);
}
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);
}
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);
}
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);
}
Aggregations