summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2017-04-02 16:07:30 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-04-02 16:07:30 +0000
commit31eb1e8997a0ee98df33f6d8b3b907e0fcb070ed (patch)
tree431b4b44231a92ac291197f45b2f61c1b2bada77 /tests
parent39521e6d1069bcaea1865452dc456dea357cf322 (diff)
parente8fd83b34e2d7e7ac275fef0baa1f33b9982a0b1 (diff)
Merge "hotspot2: request ANQP element for OSU Providers" into oc-dev
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/hotspot2/ANQPRequestManagerTest.java6
-rw-r--r--tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java35
2 files changed, 39 insertions, 2 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/ANQPRequestManagerTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/ANQPRequestManagerTest.java
index 022d22dae..10c147274 100644
--- a/tests/wifitests/src/com/android/server/wifi/hotspot2/ANQPRequestManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/ANQPRequestManagerTest.java
@@ -71,7 +71,8 @@ public class ANQPRequestManagerTest {
Constants.ANQPElementType.ANQPDomName,
Constants.ANQPElementType.HSFriendlyName,
Constants.ANQPElementType.HSWANMetrics,
- Constants.ANQPElementType.HSConnCapability);
+ Constants.ANQPElementType.HSConnCapability,
+ Constants.ANQPElementType.HSOSUProviders);
private static final List<Constants.ANQPElementType> R1R2_ANQP_WITH_RC = Arrays.asList(
Constants.ANQPElementType.ANQPVenueName,
@@ -82,7 +83,8 @@ public class ANQPRequestManagerTest {
Constants.ANQPElementType.ANQPRoamingConsortium,
Constants.ANQPElementType.HSFriendlyName,
Constants.ANQPElementType.HSWANMetrics,
- Constants.ANQPElementType.HSConnCapability);
+ Constants.ANQPElementType.HSConnCapability,
+ Constants.ANQPElementType.HSOSUProviders);
@Mock PasspointEventHandler mHandler;
@Mock Clock mClock;
diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java
index 28d7e2df0..cea1c172d 100644
--- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java
@@ -18,7 +18,9 @@ package com.android.server.wifi.hotspot2;
import static android.net.wifi.WifiManager.ACTION_PASSPOINT_DEAUTH_IMMINENT;
import static android.net.wifi.WifiManager.ACTION_PASSPOINT_ICON;
+import static android.net.wifi.WifiManager.ACTION_PASSPOINT_OSU_PROVIDERS_LIST;
import static android.net.wifi.WifiManager.ACTION_PASSPOINT_SUBSCRIPTION_REMEDIATION;
+import static android.net.wifi.WifiManager.EXTRA_ANQP_ELEMENT_DATA;
import static android.net.wifi.WifiManager.EXTRA_BSSID_LONG;
import static android.net.wifi.WifiManager.EXTRA_DELAY;
import static android.net.wifi.WifiManager.EXTRA_ESS;
@@ -70,6 +72,7 @@ import com.android.server.wifi.WifiNative;
import com.android.server.wifi.hotspot2.anqp.ANQPElement;
import com.android.server.wifi.hotspot2.anqp.Constants.ANQPElementType;
import com.android.server.wifi.hotspot2.anqp.DomainNameElement;
+import com.android.server.wifi.hotspot2.anqp.RawByteElement;
import com.android.server.wifi.util.ScanResultUtil;
import org.junit.Before;
@@ -282,6 +285,38 @@ public class PasspointManagerTest {
when(mAnqpRequestManager.onRequestCompleted(TEST_BSSID, true)).thenReturn(TEST_ANQP_KEY);
mCallbacks.onANQPResponse(TEST_BSSID, anqpElementMap);
verify(mAnqpCache).addEntry(TEST_ANQP_KEY, anqpElementMap);
+ verify(mContext, never()).sendBroadcastAsUser(any(Intent.class), any(UserHandle.class),
+ any(String.class));
+ }
+
+ /**
+ * Verify that the ANQP elements will be added to the AQNP cache and an
+ * {@link WifiManager#ACTION_PASSPOINT_OSU_PROVIDER_LIST} intent will be broadcasted when
+ * receiving an ANQP response containing OSU Providers element.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void anqpResponseWithOSUProviders() throws Exception {
+ Map<ANQPElementType, ANQPElement> anqpElementMap = new HashMap<>();
+ byte[] testData = new byte[] {0x12, 0x34, 0x56, 0x78};
+ anqpElementMap.put(ANQPElementType.HSOSUProviders,
+ new RawByteElement(ANQPElementType.HSOSUProviders, testData));
+
+ when(mAnqpRequestManager.onRequestCompleted(TEST_BSSID, true)).thenReturn(TEST_ANQP_KEY);
+ mCallbacks.onANQPResponse(TEST_BSSID, anqpElementMap);
+ verify(mAnqpCache).addEntry(TEST_ANQP_KEY, anqpElementMap);
+
+ // Verify the broadcast intent for OSU providers.
+ ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
+ verify(mContext).sendBroadcastAsUser(intent.capture(), eq(UserHandle.ALL),
+ eq(android.Manifest.permission.ACCESS_WIFI_STATE));
+ assertEquals(ACTION_PASSPOINT_OSU_PROVIDERS_LIST, intent.getValue().getAction());
+ assertTrue(intent.getValue().getExtras().containsKey(EXTRA_BSSID_LONG));
+ assertEquals(TEST_BSSID, intent.getValue().getExtras().getLong(EXTRA_BSSID_LONG));
+ assertTrue(intent.getValue().getExtras().containsKey(EXTRA_ANQP_ELEMENT_DATA));
+ assertTrue(Arrays.equals(testData,
+ intent.getValue().getExtras().getByteArray(EXTRA_ANQP_ELEMENT_DATA)));
}
/**