summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2017-02-15 17:03:14 -0800
committerRoshan Pius <rpius@google.com>2017-02-16 11:29:27 -0800
commit1e1381333657f0a02bf1b300d1e600f87e5aae38 (patch)
tree566f2349cbb5bff12c9a3fdef981dd5b812a4124 /tests
parent7f21b7a68872183ae89545b07f716aafa7dc3674 (diff)
WifiMonitor: Methods to broadcast network requests
These requests are sent from wpa_supplicant and needs to be handled by framework. Bug: 35357251 Test: Unit tests Change-Id: I4d5e151063ec1bc50260fe6f6f7f35b1394e2a7d
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java
index edc5f9aa7..6e91eab04 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java
@@ -16,6 +16,7 @@
package com.android.server.wifi;
+import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.spy;
@@ -23,6 +24,7 @@ import static org.mockito.Mockito.verify;
import android.hardware.wifi.supplicant.V1_0.ISupplicantStaIfaceCallback.WpsConfigError;
import android.hardware.wifi.supplicant.V1_0.ISupplicantStaIfaceCallback.WpsErrorIndication;
+import android.net.wifi.WifiEnterpriseConfig;
import android.net.wifi.WifiManager;
import android.os.Handler;
import android.os.Message;
@@ -31,6 +33,7 @@ import android.test.suitebuilder.annotation.SmallTest;
import com.android.server.wifi.hotspot2.AnqpEvent;
import com.android.server.wifi.hotspot2.IconEvent;
+import com.android.server.wifi.util.TelephonyUtil;
import org.junit.Before;
import org.junit.Test;
@@ -235,4 +238,52 @@ public class WifiMonitorTest {
assertEquals(fileSize, ((IconEvent) messageCaptor.getValue().obj).getSize());
assertNull(((IconEvent) messageCaptor.getValue().obj).getData());
}
+
+ /**
+ * Broadcast network Gsm auth request test.
+ */
+ @Test
+ public void testBroadcastNetworkGsmAuthRequestEvent() {
+ mWifiMonitor.registerHandler(
+ WLAN_IFACE_NAME, WifiMonitor.SUP_REQUEST_SIM_AUTH, mHandlerSpy);
+ int networkId = 45;
+ String ssid = "\"test124\"";
+ String[] data = new String[] { "45adbc", "fead45", "0x3452"};
+ mWifiMonitor.broadcastNetworkGsmAuthRequestEvent(WLAN_IFACE_NAME, networkId, ssid, data);
+ mLooper.dispatchAll();
+
+ ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class);
+ verify(mHandlerSpy).handleMessage(messageCaptor.capture());
+ assertEquals(WifiMonitor.SUP_REQUEST_SIM_AUTH, messageCaptor.getValue().what);
+ TelephonyUtil.SimAuthRequestData authData =
+ (TelephonyUtil.SimAuthRequestData) messageCaptor.getValue().obj;
+ assertEquals(networkId, authData.networkId);
+ assertEquals(ssid, authData.ssid);
+ assertEquals(WifiEnterpriseConfig.Eap.SIM, authData.protocol);
+ assertArrayEquals(data, authData.data);
+ }
+
+ /**
+ * Broadcast network Umts auth request test.
+ */
+ @Test
+ public void testBroadcastNetworkUmtsAuthRequestEvent() {
+ mWifiMonitor.registerHandler(
+ WLAN_IFACE_NAME, WifiMonitor.SUP_REQUEST_SIM_AUTH, mHandlerSpy);
+ int networkId = 45;
+ String ssid = "\"test124\"";
+ String[] data = new String[] { "45adbc", "fead45"};
+ mWifiMonitor.broadcastNetworkUmtsAuthRequestEvent(WLAN_IFACE_NAME, networkId, ssid, data);
+ mLooper.dispatchAll();
+
+ ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class);
+ verify(mHandlerSpy).handleMessage(messageCaptor.capture());
+ assertEquals(WifiMonitor.SUP_REQUEST_SIM_AUTH, messageCaptor.getValue().what);
+ TelephonyUtil.SimAuthRequestData authData =
+ (TelephonyUtil.SimAuthRequestData) messageCaptor.getValue().obj;
+ assertEquals(networkId, authData.networkId);
+ assertEquals(ssid, authData.ssid);
+ assertEquals(WifiEnterpriseConfig.Eap.AKA, authData.protocol);
+ assertArrayEquals(data, authData.data);
+ }
}