summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Qiu <zqiu@google.com>2017-06-06 13:59:04 -0700
committerPeter Qiu <zqiu@google.com>2017-06-13 16:10:34 +0000
commitac4ab1bfb7f7cdd4e1d9dd9eb8107aef1b960df2 (patch)
tree0b5a6ec3bca44377bc799cf036fee3dcf839ffc0 /tests
parent2d511b3ad304301a3459f434b973525a23107ad1 (diff)
hotspot2: PasspointManager: add support for retrieving OSU providers info
The OSU provider icon data is included, will be added when icon data retrieval/caching support is added. Bug: 62235301 Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh Change-Id: Ifbddc3c3626063b3c89361c09c7adbf0b054692d Merged-In: Ifbddc3c3626063b3c89361c09c7adbf0b054692d
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java94
1 files changed, 94 insertions, 0 deletions
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 2b871b2db..d2762d022 100644
--- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java
@@ -47,10 +47,13 @@ import static org.mockito.MockitoAnnotations.initMocks;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Icon;
+import android.net.Uri;
import android.net.wifi.EAPConstants;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiEnterpriseConfig;
+import android.net.wifi.WifiSsid;
+import android.net.wifi.hotspot2.OsuProvider;
import android.net.wifi.hotspot2.PasspointConfiguration;
import android.net.wifi.hotspot2.pps.Credential;
import android.net.wifi.hotspot2.pps.HomeSp;
@@ -70,6 +73,9 @@ 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.HSOsuProvidersElement;
+import com.android.server.wifi.hotspot2.anqp.I18Name;
+import com.android.server.wifi.hotspot2.anqp.OsuProviderInfo;
import com.android.server.wifi.util.ScanResultUtil;
import org.junit.Before;
@@ -84,6 +90,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
/**
@@ -821,6 +828,93 @@ public class PasspointManagerTest {
}
/**
+ * Verify that an empty list will be returned when retrieving OSU providers for an AP with
+ * null scan result.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void getMatchingOsuProvidersForNullScanResult() throws Exception {
+ assertTrue(mManager.getMatchingOsuProviders(null).isEmpty());
+ }
+
+ /**
+ * Verify that an empty list will be returned when retrieving OSU providers for an AP with
+ * invalid BSSID.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void getMatchingOsuProvidersForInvalidBSSID() throws Exception {
+ ScanResult scanResult = createTestScanResult();
+ scanResult.BSSID = "asdfdasfas";
+ assertTrue(mManager.getMatchingOsuProviders(scanResult).isEmpty());
+ }
+
+ /**
+ * Verify that an empty list will be returned when retrieving OSU providers for a
+ * non-Passpoint AP.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void getMatchingOsuProvidersForNonPasspointAP() throws Exception {
+ ScanResult scanResult = createTestScanResult();
+ scanResult.flags = 0;
+ assertTrue(mManager.getMatchingOsuProviders(scanResult).isEmpty());
+ }
+
+ /**
+ * Verify that an empty list will be returned when no match is found from the ANQP cache.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void getMatchingOsuProviderWithNoMatch() throws Exception {
+ when(mAnqpCache.getEntry(TEST_ANQP_KEY)).thenReturn(null);
+ assertTrue(mManager.getMatchingOsuProviders(createTestScanResult()).isEmpty());
+ }
+
+ /**
+ * Verify that an expected provider list will be returned when a match is found from
+ * the ANQP cache.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void getMatchingOsuProvidersWithMatch() throws Exception {
+ // Test data.
+ WifiSsid osuSsid = WifiSsid.createFromAsciiEncoded("Test SSID");
+ String friendlyName = "Test Provider";
+ String serviceDescription = "Dummy Service";
+ Uri serverUri = Uri.parse("https://test.com");
+ String nai = "access.test.com";
+ List<Integer> methodList = Arrays.asList(1);
+ List<I18Name> friendlyNames = Arrays.asList(
+ new I18Name(Locale.ENGLISH.getLanguage(), Locale.ENGLISH, friendlyName));
+ List<I18Name> serviceDescriptions = Arrays.asList(
+ new I18Name(Locale.ENGLISH.getLanguage(), Locale.ENGLISH, serviceDescription));
+
+ // Setup OSU providers ANQP element.
+ List<OsuProviderInfo> providerInfoList = new ArrayList<>();
+ providerInfoList.add(new OsuProviderInfo(
+ friendlyNames, serverUri, methodList, null, nai, serviceDescriptions));
+ Map<ANQPElementType, ANQPElement> anqpElementMap = new HashMap<>();
+ anqpElementMap.put(ANQPElementType.HSOSUProviders,
+ new HSOsuProvidersElement(osuSsid, providerInfoList));
+ ANQPData entry = new ANQPData(mClock, anqpElementMap);
+
+ // Setup expectation.
+ OsuProvider provider = new OsuProvider(
+ osuSsid, friendlyName, serviceDescription, serverUri, nai, methodList, null);
+ List<OsuProvider> expectedList = new ArrayList<>();
+ expectedList.add(provider);
+
+ when(mAnqpCache.getEntry(TEST_ANQP_KEY)).thenReturn(entry);
+ assertEquals(expectedList, mManager.getMatchingOsuProviders(createTestScanResult()));
+ }
+
+ /**
* Verify that the provider list maintained by the PasspointManager after the list is updated
* in the data source.
*