Search in sources :

Example 1 with NetworkRequestUserSelectionCallback

use of android.net.wifi.WifiManager.NetworkRequestUserSelectionCallback in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class NetworkRequestDialogFragmentTest method onUserSelectionCallbackRegistration_onClick_shouldCallSelect.

@Test
public void onUserSelectionCallbackRegistration_onClick_shouldCallSelect() {
    // Assert.
    final int indexClickItem = 3;
    List<AccessPoint> accessPointList = createAccessPointList();
    AccessPoint clickedAccessPoint = accessPointList.get(indexClickItem);
    clickedAccessPoint.generateOpenNetworkConfig();
    when(networkRequestDialogFragment.getAccessPointList()).thenReturn(accessPointList);
    NetworkRequestUserSelectionCallback selectionCallback = mock(NetworkRequestUserSelectionCallback.class);
    AlertDialog dialog = mock(AlertDialog.class);
    networkRequestDialogFragment.onUserSelectionCallbackRegistration(selectionCallback);
    // Act.
    networkRequestDialogFragment.onClick(dialog, indexClickItem);
    // Check.
    verify(selectionCallback, times(1)).select(clickedAccessPoint.getConfig());
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) NetworkRequestUserSelectionCallback(android.net.wifi.WifiManager.NetworkRequestUserSelectionCallback) AccessPoint(com.android.settingslib.wifi.AccessPoint) AccessPoint(com.android.settingslib.wifi.AccessPoint) Test(org.junit.Test)

Example 2 with NetworkRequestUserSelectionCallback

use of android.net.wifi.WifiManager.NetworkRequestUserSelectionCallback in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class NetworkRequestErrorDialogFragmentTest method clickNegativeButton_shouldCallReject.

@Test
public void clickNegativeButton_shouldCallReject() {
    final NetworkRequestUserSelectionCallback rejectCallback = mock(NetworkRequestUserSelectionCallback.class);
    mFragment.setRejectCallback(rejectCallback);
    final AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
    final Button negativeButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE);
    negativeButton.performClick();
    verify(rejectCallback, 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 3 with NetworkRequestUserSelectionCallback

use of android.net.wifi.WifiManager.NetworkRequestUserSelectionCallback in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class NetworkRequestDialogFragmentTest method cancelDialog_callsReject.

@Test
public void cancelDialog_callsReject() {
    // Assert
    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 4 with NetworkRequestUserSelectionCallback

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

the class NetworkRequestDialogActivityTest method onClickConnectButton_shouldShowProgressDialog.

@Test
public void onClickConnectButton_shouldShowProgressDialog() {
    NetworkRequestUserSelectionCallback networkRequestUserSelectionCallback = mock(NetworkRequestUserSelectionCallback.class);
    startSpecifiedActivity();
    final List<ScanResult> scanResults = new ArrayList<>();
    scanResults.add(getScanResult(TEST_SSID, TEST_CAPABILITY));
    mActivity.onMatch(scanResults);
    mActivity.onUserSelectionCallbackRegistration(networkRequestUserSelectionCallback);
    mActivity.onClickConnectButton();
    assertThat(mActivity.mProgressDialog.isShowing()).isTrue();
    assertThat(mActivity.mDialogFragment).isNull();
}
Also used : ScanResult(android.net.wifi.ScanResult) NetworkRequestUserSelectionCallback(android.net.wifi.WifiManager.NetworkRequestUserSelectionCallback) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 5 with NetworkRequestUserSelectionCallback

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

the class NetworkRequestErrorDialogFragmentTest method clickNegativeButton_shouldCallReject.

@Test
public void clickNegativeButton_shouldCallReject() {
    final NetworkRequestUserSelectionCallback rejectCallback = mock(NetworkRequestUserSelectionCallback.class);
    mFragment.setRejectCallback(rejectCallback);
    final AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
    final Button negativeButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE);
    negativeButton.performClick();
    verify(rejectCallback, times(1)).reject();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Button(android.widget.Button) NetworkRequestUserSelectionCallback(android.net.wifi.WifiManager.NetworkRequestUserSelectionCallback) 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