Search in sources :

Example 6 with NetworkRequestUserSelectionCallback

use of android.net.wifi.WifiManager.NetworkRequestUserSelectionCallback in project android_packages_apps_Settings by omnirom.

the class NetworkRequestDialogFragmentTest method cancelDialog_callsReject.

@Test
public void cancelDialog_callsReject() {
    networkRequestDialogFragment.show(mActivity.getSupportFragmentManager(), /* tag */
    null);
    final AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
    final NetworkRequestUserSelectionCallback selectionCallback = mock(NetworkRequestUserSelectionCallback.class);
    networkRequestDialogFragment.onUserSelectionCallbackRegistration(selectionCallback);
    // Action
    final Button button = alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
    button.performClick();
    // Check
    verify(selectionCallback, times(1)).reject();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Button(android.widget.Button) NetworkRequestUserSelectionCallback(android.net.wifi.WifiManager.NetworkRequestUserSelectionCallback) Test(org.junit.Test)

Example 7 with NetworkRequestUserSelectionCallback

use of android.net.wifi.WifiManager.NetworkRequestUserSelectionCallback 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

NetworkRequestUserSelectionCallback (android.net.wifi.WifiManager.NetworkRequestUserSelectionCallback)7 Test (org.junit.Test)7 AlertDialog (androidx.appcompat.app.AlertDialog)6 Button (android.widget.Button)4 ScanResult (android.net.wifi.ScanResult)1 WifiConfiguration (android.net.wifi.WifiConfiguration)1 AccessPoint (com.android.settingslib.wifi.AccessPoint)1 WifiEntry (com.android.wifitrackerlib.WifiEntry)1 ArrayList (java.util.ArrayList)1