Search in sources :

Example 46 with WifiEntry

use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.

the class WifiScanWorkerTest method getWifiEntry_connectedWifiKey_shouldGetConnectedWifi.

@Test
public void getWifiEntry_connectedWifiKey_shouldGetConnectedWifi() {
    final String key = "key";
    final WifiEntry connectedWifiEntry = mock(WifiEntry.class);
    when(connectedWifiEntry.getKey()).thenReturn(key);
    when(mWifiPickerTracker.getConnectedWifiEntry()).thenReturn(connectedWifiEntry);
    assertThat(mWifiScanWorker.getWifiEntry(key)).isEqualTo(connectedWifiEntry);
}
Also used : WifiEntry(com.android.wifitrackerlib.WifiEntry) Test(org.junit.Test)

Example 47 with WifiEntry

use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.

the class WifiSettingsTest method openSubscriptionHelpPage_shouldCallStartActivityForResult.

@Test
public void openSubscriptionHelpPage_shouldCallStartActivityForResult() {
    doReturn(new Intent()).when(mWifiSettings).getHelpIntent(mContext, FAKE_URI_STRING);
    doNothing().when(mWifiSettings).startActivityForResult(any(Intent.class), anyInt());
    final WifiEntry mockWifiEntry = mock(WifiEntry.class);
    when(mockWifiEntry.getHelpUriString()).thenReturn(FAKE_URI_STRING);
    mWifiSettings.openSubscriptionHelpPage(mockWifiEntry);
    verify(mWifiSettings, times(1)).startActivityForResult(any(), anyInt());
}
Also used : WifiEntry(com.android.wifitrackerlib.WifiEntry) Intent(android.content.Intent) Test(org.junit.Test)

Example 48 with WifiEntry

use of com.android.wifitrackerlib.WifiEntry 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)

Example 49 with WifiEntry

use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.

the class WifiConnectionPreferenceControllerTest method displayPreference_hasConnectedWifiEntry_preferenceAdded.

@Test
public void displayPreference_hasConnectedWifiEntry_preferenceAdded() {
    final WifiEntry wifiEntry = mock(WifiEntry.class);
    when(mWifiPickerTracker.getConnectedWifiEntry()).thenReturn(wifiEntry);
    mController.displayPreference(mScreen);
    verify(mPreferenceCategory).addPreference(any(WifiEntryPreference.class));
}
Also used : WifiEntry(com.android.wifitrackerlib.WifiEntry) WifiEntryPreference(com.android.settingslib.wifi.WifiEntryPreference) Test(org.junit.Test)

Example 50 with WifiEntry

use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.

the class NetworkRequestDialogFragmentTest method onClick_validSelection_shouldCallSelect.

@Test
public void onClick_validSelection_shouldCallSelect() {
    final int indexClickItem = 3;
    final List<WifiEntry> wifiEntryList = createWifiEntryList();
    final WifiEntry clickedWifiEntry = wifiEntryList.get(indexClickItem);
    final WifiConfiguration wifiConfig = new WifiConfiguration();
    when(clickedWifiEntry.getWifiConfiguration()).thenReturn(wifiConfig);
    networkRequestDialogFragment.mFilteredWifiEntries = wifiEntryList;
    final NetworkRequestUserSelectionCallback selectionCallback = mock(NetworkRequestUserSelectionCallback.class);
    final AlertDialog dialog = mock(AlertDialog.class);
    networkRequestDialogFragment.onUserSelectionCallbackRegistration(selectionCallback);
    networkRequestDialogFragment.onClick(dialog, indexClickItem);
    verify(selectionCallback, times(1)).select(wifiConfig);
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) WifiConfiguration(android.net.wifi.WifiConfiguration) NetworkRequestUserSelectionCallback(android.net.wifi.WifiManager.NetworkRequestUserSelectionCallback) WifiEntry(com.android.wifitrackerlib.WifiEntry) Test(org.junit.Test)

Aggregations

WifiEntry (com.android.wifitrackerlib.WifiEntry)54 Test (org.junit.Test)28 WifiConfiguration (android.net.wifi.WifiConfiguration)10 WifiEntryPreference (com.android.settingslib.wifi.WifiEntryPreference)10 LongPressWifiEntryPreference (com.android.settingslib.wifi.LongPressWifiEntryPreference)8 Intent (android.content.Intent)7 Preference (androidx.preference.Preference)5 Context (android.content.Context)4 Bundle (android.os.Bundle)4 DataUsagePreference (com.android.settings.datausage.DataUsagePreference)4 WifiManager (android.net.wifi.WifiManager)3 Handler (android.os.Handler)3 View (android.view.View)3 FragmentActivity (androidx.fragment.app.FragmentActivity)3 SubSettingLauncher (com.android.settings.core.SubSettingLauncher)3 AddWifiNetworkPreference (com.android.settings.wifi.AddWifiNetworkPreference)3 ConnectedWifiEntryPreference (com.android.settings.wifi.ConnectedWifiEntryPreference)3 FooterPreference (com.android.settingslib.widget.FooterPreference)3 LayoutPreference (com.android.settingslib.widget.LayoutPreference)3 ArrayList (java.util.ArrayList)3