summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java7
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SupplicantStateTrackerTest.java88
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java2
3 files changed, 90 insertions, 7 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
index d747c113b..f1897c8b2 100644
--- a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
@@ -50,6 +50,7 @@ import android.hidl.manager.V1_0.IServiceNotification;
import android.net.IpConfiguration;
import android.net.wifi.SupplicantState;
import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiManager;
import android.net.wifi.WifiSsid;
import android.os.IHwBinder;
import android.os.RemoteException;
@@ -962,7 +963,7 @@ public class SupplicantStaIfaceHalTest {
NativeUtil.macAddressToByteArray(BSSID), false, reasonCode);
verify(mWifiMonitor, times(2)).broadcastAuthenticationFailureEvent(eq(WLAN_IFACE_NAME),
- eq(WifiMonitor.AUTHENTICATION_FAILURE_REASON_WRONG_PSWD));
+ eq(WifiManager.ERROR_AUTH_FAILURE_WRONG_PSWD));
}
@@ -1015,7 +1016,7 @@ public class SupplicantStaIfaceHalTest {
mISupplicantStaIfaceCallback.onAuthenticationTimeout(
NativeUtil.macAddressToByteArray(BSSID));
verify(mWifiMonitor).broadcastAuthenticationFailureEvent(eq(WLAN_IFACE_NAME),
- eq(WifiMonitor.AUTHENTICATION_FAILURE_REASON_TIMEOUT));
+ eq(WifiManager.ERROR_AUTH_FAILURE_TIMEOUT));
}
/**
@@ -1054,7 +1055,7 @@ public class SupplicantStaIfaceHalTest {
mISupplicantStaIfaceCallback.onEapFailure();
verify(mWifiMonitor).broadcastAuthenticationFailureEvent(eq(WLAN_IFACE_NAME),
- eq(WifiMonitor.AUTHENTICATION_FAILURE_REASON_EAP_FAILURE));
+ eq(WifiManager.ERROR_AUTH_FAILURE_EAP_FAILURE));
}
/**
diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantStateTrackerTest.java b/tests/wifitests/src/com/android/server/wifi/SupplicantStateTrackerTest.java
index f1a9e945d..98fa80046 100644
--- a/tests/wifitests/src/com/android/server/wifi/SupplicantStateTrackerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStateTrackerTest.java
@@ -52,7 +52,6 @@ public class SupplicantStateTrackerTest {
private SupplicantStateTracker mSupplicantStateTracker;
private TestLooper mLooper;
private FrameworkFacade mFacade;
- private BroadcastReceiver mWifiBroadcastReceiver;
private FrameworkFacade getFrameworkFacade() {
FrameworkFacade facade = mock(FrameworkFacade.class);
@@ -83,7 +82,7 @@ public class SupplicantStateTrackerTest {
*/
@Test
public void testSupplicantStateChangeIntent() {
- mWifiBroadcastReceiver = new BroadcastReceiver() {
+ BroadcastReceiver wifiBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
@@ -95,8 +94,91 @@ public class SupplicantStateTrackerTest {
};
IntentFilter mIntentFilter = new IntentFilter();
mIntentFilter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);
- mContext.registerReceiver(mWifiBroadcastReceiver, mIntentFilter);
+ mContext.registerReceiver(wifiBroadcastReceiver, mIntentFilter);
mSupplicantStateTracker.sendMessage(getSupplicantStateChangeMessage(0, sWifiSsid,
sBSSID, SupplicantState.SCANNING));
}
+
+ /**
+ * This test verifies that the current auth status is sent in the Broadcast intent
+ */
+ @Test
+ public void testAuthPassInSupplicantStateChangeIntent() {
+ BroadcastReceiver wifiBroadcastReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ assertTrue(action.equals(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION));
+ SupplicantState recvdState =
+ (SupplicantState) intent.getExtra(WifiManager.EXTRA_NEW_STATE, -1);
+ assertEquals(SupplicantState.AUTHENTICATING, recvdState);
+ boolean authStatus =
+ (boolean) intent.getExtra(WifiManager.EXTRA_SUPPLICANT_ERROR, -1);
+ assertEquals(authStatus, true);
+ }
+ };
+ IntentFilter mIntentFilter = new IntentFilter();
+ mIntentFilter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);
+ mContext.registerReceiver(wifiBroadcastReceiver, mIntentFilter);
+ mSupplicantStateTracker.sendMessage(getSupplicantStateChangeMessage(0, sWifiSsid,
+ sBSSID, SupplicantState.AUTHENTICATING));
+ mSupplicantStateTracker.sendMessage(WifiMonitor.AUTHENTICATION_FAILURE_EVENT);
+ }
+
+ /**
+ * This test verifies that the current auth status is sent in the Broadcast intent
+ */
+ @Test
+ public void testAuthFailedInSupplicantStateChangeIntent() {
+ BroadcastReceiver wifiBroadcastReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ assertTrue(action.equals(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION));
+ SupplicantState recvdState =
+ (SupplicantState) intent.getExtra(WifiManager.EXTRA_NEW_STATE, -1);
+ assertEquals(SupplicantState.AUTHENTICATING, recvdState);
+ boolean authStatus =
+ (boolean) intent.getExtra(WifiManager.EXTRA_SUPPLICANT_ERROR, -1);
+ assertEquals(authStatus, false);
+ }
+ };
+ IntentFilter mIntentFilter = new IntentFilter();
+ mIntentFilter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);
+ mContext.registerReceiver(wifiBroadcastReceiver, mIntentFilter);
+ mSupplicantStateTracker.sendMessage(WifiMonitor.AUTHENTICATION_FAILURE_EVENT);
+ mSupplicantStateTracker.sendMessage(getSupplicantStateChangeMessage(0, sWifiSsid,
+ sBSSID, SupplicantState.AUTHENTICATING));
+ }
+
+ /**
+ * This test verifies the correct reasonCode for auth failure is sent in Broadcast
+ * intent.
+ */
+ @Test
+ public void testReasonCodeInSupplicantStateChangeIntent() {
+ BroadcastReceiver wifiBroadcastReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ assertTrue(action.equals(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION));
+ SupplicantState recvdState =
+ (SupplicantState) intent.getExtra(WifiManager.EXTRA_NEW_STATE, -1);
+ assertEquals(SupplicantState.AUTHENTICATING, recvdState);
+ boolean authStatus =
+ (boolean) intent.getExtra(WifiManager.EXTRA_SUPPLICANT_ERROR, -1);
+ assertEquals(authStatus, false);
+ int reasonCode = (int)
+ intent.getExtra(WifiManager.EXTRA_SUPPLICANT_ERROR_REASON, -1);
+ assertEquals(reasonCode, WifiManager.ERROR_AUTH_FAILURE_WRONG_PSWD);
+ }
+ };
+ IntentFilter mIntentFilter = new IntentFilter();
+ mIntentFilter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);
+ mContext.registerReceiver(wifiBroadcastReceiver, mIntentFilter);
+ mSupplicantStateTracker.sendMessage(WifiMonitor.AUTHENTICATION_FAILURE_EVENT, 0,
+ WifiManager.ERROR_AUTH_FAILURE_WRONG_PSWD);
+ mSupplicantStateTracker.sendMessage(getSupplicantStateChangeMessage(0, sWifiSsid,
+ sBSSID, SupplicantState.AUTHENTICATING));
+ }
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java
index 6e3dbbbcf..4b4a17dce 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java
@@ -343,7 +343,7 @@ public class WifiMonitorTest {
public void testBroadcastAuthenticationFailureEvent() {
mWifiMonitor.registerHandler(
WLAN_IFACE_NAME, WifiMonitor.AUTHENTICATION_FAILURE_EVENT, mHandlerSpy);
- int reason = WifiMonitor.AUTHENTICATION_FAILURE_REASON_WRONG_PSWD;
+ int reason = WifiManager.ERROR_AUTH_FAILURE_WRONG_PSWD;
mWifiMonitor.broadcastAuthenticationFailureEvent(WLAN_IFACE_NAME, reason);
mLooper.dispatchAll();