diff options
author | Peter Qiu <zqiu@google.com> | 2017-03-07 14:25:01 -0800 |
---|---|---|
committer | Peter Qiu <zqiu@google.com> | 2017-03-16 11:10:31 -0700 |
commit | ec28f863c5e46c0a75e8bdb92283304b875ee0f2 (patch) | |
tree | f01e3afd8c6b9c8d12bc4c5886b5466340499f0c /tests | |
parent | 15d4e32d0b4ae41eb582aeef9e9c97792e25f703 (diff) |
hotspot2: use ScanResult to match Passpoint providers
This removes ScanDetail and NetworkDetail dependencies from
PasspointManager, and allows provider matching to be performed
using ScanResult instead of ScanDetail.
Bug: 35888100
Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Test: manual test using Global Reach Passpoint profile
Change-Id: I229f042352e2d51cfaf9c154d707f3b6b39b2c5d
Diffstat (limited to 'tests')
4 files changed, 92 insertions, 81 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 08b37deb9..022d22dae 100644 --- a/tests/wifitests/src/com/android/server/wifi/hotspot2/ANQPRequestManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/ANQPRequestManagerTest.java @@ -16,11 +16,11 @@ package com.android.server.wifi.hotspot2; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.anyLong; import static org.mockito.Mockito.anyObject; -import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.verify; @@ -30,7 +30,6 @@ import static org.mockito.MockitoAnnotations.initMocks; import android.test.suitebuilder.annotation.SmallTest; import com.android.server.wifi.Clock; -import com.android.server.wifi.ScanDetail; import com.android.server.wifi.hotspot2.anqp.Constants; import org.junit.Before; @@ -46,7 +45,8 @@ import java.util.List; @SmallTest public class ANQPRequestManagerTest { private static final long TEST_BSSID = 0x123456L; - private static final ScanDetail TEST_SCAN_DETAIL = mock(ScanDetail.class); + private static final ANQPNetworkKey TEST_ANQP_KEY = + new ANQPNetworkKey("TestSSID", TEST_BSSID, 0, 0); private static final List<Constants.ANQPElementType> R1_ANQP_WITHOUT_RC = Arrays.asList( Constants.ANQPElementType.ANQPVenueName, @@ -107,7 +107,7 @@ public class ANQPRequestManagerTest { @Test public void requestR1ANQPElementsWithoutRC() throws Exception { when(mHandler.requestANQP(TEST_BSSID, R1_ANQP_WITHOUT_RC)).thenReturn(true); - assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_SCAN_DETAIL, false, false)); + assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_ANQP_KEY, false, false)); } /** @@ -120,7 +120,7 @@ public class ANQPRequestManagerTest { @Test public void requestR1ANQPElementsWithRC() throws Exception { when(mHandler.requestANQP(TEST_BSSID, R1_ANQP_WITH_RC)).thenReturn(true); - assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_SCAN_DETAIL, true, false)); + assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_ANQP_KEY, true, false)); } /** @@ -133,7 +133,7 @@ public class ANQPRequestManagerTest { @Test public void requestR1R2ANQPElementsWithoutRC() throws Exception { when(mHandler.requestANQP(TEST_BSSID, R1R2_ANQP_WITHOUT_RC)).thenReturn(true); - assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_SCAN_DETAIL, false, true)); + assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_ANQP_KEY, false, true)); } /** @@ -146,7 +146,7 @@ public class ANQPRequestManagerTest { @Test public void requestR1R2ANQPElementsWithRC() throws Exception { when(mHandler.requestANQP(TEST_BSSID, R1R2_ANQP_WITH_RC)).thenReturn(true); - assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_SCAN_DETAIL, true, true)); + assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_ANQP_KEY, true, true)); } /** @@ -161,13 +161,13 @@ public class ANQPRequestManagerTest { long startTime = 0; when(mHandler.requestANQP(TEST_BSSID, R1_ANQP_WITHOUT_RC)).thenReturn(true); when(mClock.getElapsedSinceBootMillis()).thenReturn(startTime); - assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_SCAN_DETAIL, false, false)); + assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_ANQP_KEY, false, false)); reset(mHandler); // Attempt another request will fail while one is still pending and hold off time is not up // yet. when(mClock.getElapsedSinceBootMillis()).thenReturn(startTime + 1); - assertFalse(mManager.requestANQPElements(TEST_BSSID, TEST_SCAN_DETAIL, false, false)); + assertFalse(mManager.requestANQPElements(TEST_BSSID, TEST_ANQP_KEY, false, false)); verify(mHandler, never()).requestANQP(anyLong(), anyObject()); reset(mHandler); @@ -175,7 +175,7 @@ public class ANQPRequestManagerTest { when(mHandler.requestANQP(TEST_BSSID, R1_ANQP_WITHOUT_RC)).thenReturn(true); when(mClock.getElapsedSinceBootMillis()) .thenReturn(startTime + ANQPRequestManager.BASE_HOLDOFF_TIME_MILLISECONDS); - assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_SCAN_DETAIL, false, false)); + assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_ANQP_KEY, false, false)); } /** @@ -190,13 +190,13 @@ public class ANQPRequestManagerTest { long startTime = 0; when(mHandler.requestANQP(TEST_BSSID, R1_ANQP_WITHOUT_RC)).thenReturn(false); when(mClock.getElapsedSinceBootMillis()).thenReturn(startTime); - assertFalse(mManager.requestANQPElements(TEST_BSSID, TEST_SCAN_DETAIL, false, false)); + assertFalse(mManager.requestANQPElements(TEST_BSSID, TEST_ANQP_KEY, false, false)); reset(mHandler); // Verify that new request is not being held off after previous send failure. when(mHandler.requestANQP(TEST_BSSID, R1_ANQP_WITHOUT_RC)).thenReturn(true); when(mClock.getElapsedSinceBootMillis()).thenReturn(startTime); - assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_SCAN_DETAIL, false, false)); + assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_ANQP_KEY, false, false)); } /** @@ -211,15 +211,16 @@ public class ANQPRequestManagerTest { long startTime = 0; when(mHandler.requestANQP(TEST_BSSID, R1_ANQP_WITHOUT_RC)).thenReturn(true); when(mClock.getElapsedSinceBootMillis()).thenReturn(startTime); - assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_SCAN_DETAIL, false, false)); + assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_ANQP_KEY, false, false)); reset(mHandler); - // Request completed with success. - mManager.onRequestCompleted(TEST_BSSID, true); + // Request completed with success. Verify that the key associated with the request + // is returned. + assertEquals(TEST_ANQP_KEY, mManager.onRequestCompleted(TEST_BSSID, true)); when(mHandler.requestANQP(TEST_BSSID, R1_ANQP_WITHOUT_RC)).thenReturn(true); when(mClock.getElapsedSinceBootMillis()).thenReturn(startTime + 1); - assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_SCAN_DETAIL, false, false)); + assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_ANQP_KEY, false, false)); } /** @@ -235,22 +236,23 @@ public class ANQPRequestManagerTest { long startTime = 0; when(mHandler.requestANQP(TEST_BSSID, R1_ANQP_WITHOUT_RC)).thenReturn(true); when(mClock.getElapsedSinceBootMillis()).thenReturn(startTime); - assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_SCAN_DETAIL, false, false)); + assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_ANQP_KEY, false, false)); reset(mHandler); - // Request completed with failure. - mManager.onRequestCompleted(TEST_BSSID, false); + // Request completed with failure. Verify that the key associated with the request + // is returned + assertEquals(TEST_ANQP_KEY, mManager.onRequestCompleted(TEST_BSSID, false)); // Attempt another request will fail since the hold off time is not up yet. when(mClock.getElapsedSinceBootMillis()).thenReturn(startTime + 1); - assertFalse(mManager.requestANQPElements(TEST_BSSID, TEST_SCAN_DETAIL, false, false)); + assertFalse(mManager.requestANQPElements(TEST_BSSID, TEST_ANQP_KEY, false, false)); verify(mHandler, never()).requestANQP(anyLong(), anyObject()); // Attempt another request will succeed after the hold off time is up. when(mHandler.requestANQP(TEST_BSSID, R1_ANQP_WITHOUT_RC)).thenReturn(true); when(mClock.getElapsedSinceBootMillis()) .thenReturn(startTime + ANQPRequestManager.BASE_HOLDOFF_TIME_MILLISECONDS); - assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_SCAN_DETAIL, false, false)); + assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_ANQP_KEY, false, false)); } /** @@ -266,7 +268,7 @@ public class ANQPRequestManagerTest { // Initial request. when(mHandler.requestANQP(TEST_BSSID, R1_ANQP_WITHOUT_RC)).thenReturn(true); when(mClock.getElapsedSinceBootMillis()).thenReturn(currentTime); - assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_SCAN_DETAIL, false, false)); + assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_ANQP_KEY, false, false)); reset(mHandler); // Sending the request with the hold off time based on the current hold off count. @@ -276,14 +278,14 @@ public class ANQPRequestManagerTest { // Request will fail before the hold off time is up. when(mClock.getElapsedSinceBootMillis()).thenReturn(currentTime); - assertFalse(mManager.requestANQPElements(TEST_BSSID, TEST_SCAN_DETAIL, false, false)); + assertFalse(mManager.requestANQPElements(TEST_BSSID, TEST_ANQP_KEY, false, false)); verify(mHandler, never()).requestANQP(anyLong(), anyObject()); // Request will succeed when the hold off time is up. currentTime += 1; when(mHandler.requestANQP(TEST_BSSID, R1_ANQP_WITHOUT_RC)).thenReturn(true); when(mClock.getElapsedSinceBootMillis()).thenReturn(currentTime); - assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_SCAN_DETAIL, false, false)); + assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_ANQP_KEY, false, false)); reset(mHandler); } @@ -292,13 +294,13 @@ public class ANQPRequestManagerTest { * (1 << ANQPRequestManager.MAX_HOLDOFF_COUNT) - 1); when(mClock.getElapsedSinceBootMillis()).thenReturn(currentTime); - assertFalse(mManager.requestANQPElements(TEST_BSSID, TEST_SCAN_DETAIL, false, false)); + assertFalse(mManager.requestANQPElements(TEST_BSSID, TEST_ANQP_KEY, false, false)); verify(mHandler, never()).requestANQP(anyLong(), anyObject()); currentTime += 1; when(mHandler.requestANQP(TEST_BSSID, R1_ANQP_WITHOUT_RC)).thenReturn(true); when(mClock.getElapsedSinceBootMillis()).thenReturn(currentTime); - assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_SCAN_DETAIL, false, false)); + assertTrue(mManager.requestANQPElements(TEST_BSSID, TEST_ANQP_KEY, false, false)); reset(mHandler); } } 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 e424b4dbe..a86d961ba 100644 --- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java @@ -45,6 +45,7 @@ import android.content.Context; import android.content.Intent; import android.net.wifi.EAPConstants; import android.net.wifi.IconInfo; +import android.net.wifi.ScanResult; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiEnterpriseConfig; import android.net.wifi.hotspot2.PasspointConfiguration; @@ -59,7 +60,6 @@ import com.android.server.wifi.Clock; import com.android.server.wifi.FakeKeys; import com.android.server.wifi.IMSIParameter; import com.android.server.wifi.SIMAccessor; -import com.android.server.wifi.ScanDetail; import com.android.server.wifi.WifiConfigManager; import com.android.server.wifi.WifiConfigStore; import com.android.server.wifi.WifiKeyStore; @@ -94,9 +94,12 @@ public class PasspointManagerTest { private static final IMSIParameter TEST_IMSI_PARAM = IMSIParameter.build(TEST_IMSI); private static final String TEST_SSID = "TestSSID"; - private static final long TEST_BSSID = 0x1234L; + private static final long TEST_BSSID = 0x112233445566L; + private static final String TEST_BSSID_STRING = "11:22:33:44:55:66"; private static final long TEST_HESSID = 0x5678L; - private static final int TEST_ANQP_DOMAIN_ID = 1; + private static final int TEST_ANQP_DOMAIN_ID = 0; + private static final ANQPNetworkKey TEST_ANQP_KEY = ANQPNetworkKey.buildKey( + TEST_SSID, TEST_BSSID, TEST_HESSID, TEST_ANQP_DOMAIN_ID); @Mock Context mContext; @Mock WifiNative mWifiNative; @@ -239,20 +242,16 @@ public class PasspointManagerTest { } /** - * Helper function for creating a mock ScanDetail. + * Helper function for creating a ScanResult for testing. * - * @return {@link ScanDetail} + * @return {@link ScanResult} */ - private ScanDetail createMockScanDetail() { - NetworkDetail networkDetail = mock(NetworkDetail.class); - when(networkDetail.getSSID()).thenReturn(TEST_SSID); - when(networkDetail.getBSSID()).thenReturn(TEST_BSSID); - when(networkDetail.getHESSID()).thenReturn(TEST_HESSID); - when(networkDetail.getAnqpDomainID()).thenReturn(TEST_ANQP_DOMAIN_ID); - - ScanDetail scanDetail = mock(ScanDetail.class); - when(scanDetail.getNetworkDetail()).thenReturn(networkDetail); - return scanDetail; + private ScanResult createTestScanResult() { + ScanResult scanResult = new ScanResult(); + scanResult.SSID = TEST_SSID; + scanResult.BSSID = TEST_BSSID_STRING; + scanResult.hessid = TEST_HESSID; + return scanResult; } /** @@ -267,13 +266,9 @@ public class PasspointManagerTest { anqpElementMap.put(ANQPElementType.ANQPDomName, new DomainNameElement(Arrays.asList(new String[] {"test.com"}))); - ScanDetail scanDetail = createMockScanDetail(); - ANQPNetworkKey anqpKey = ANQPNetworkKey.buildKey(TEST_SSID, TEST_BSSID, TEST_HESSID, - TEST_ANQP_DOMAIN_ID); - when(mAnqpRequestManager.onRequestCompleted(TEST_BSSID, true)).thenReturn(scanDetail); + when(mAnqpRequestManager.onRequestCompleted(TEST_BSSID, true)).thenReturn(TEST_ANQP_KEY); mCallbacks.onANQPResponse(TEST_BSSID, anqpElementMap); - verify(mAnqpCache).addEntry(anqpKey, anqpElementMap); - verify(scanDetail).propagateANQPInfo(anqpElementMap); + verify(mAnqpCache).addEntry(TEST_ANQP_KEY, anqpElementMap); } /** @@ -300,11 +295,7 @@ public class PasspointManagerTest { */ @Test public void anqpResponseFailure() throws Exception { - ANQPNetworkKey anqpKey = ANQPNetworkKey.buildKey(TEST_SSID, TEST_BSSID, TEST_HESSID, - TEST_ANQP_DOMAIN_ID); - - ScanDetail scanDetail = createMockScanDetail(); - when(mAnqpRequestManager.onRequestCompleted(TEST_BSSID, false)).thenReturn(scanDetail); + when(mAnqpRequestManager.onRequestCompleted(TEST_BSSID, false)).thenReturn(TEST_ANQP_KEY); mCallbacks.onANQPResponse(TEST_BSSID, null); verify(mAnqpCache, never()).addEntry(any(ANQPNetworkKey.class), anyMap()); @@ -568,7 +559,7 @@ public class PasspointManagerTest { @Test public void matchProviderWithNoProvidersInstalled() throws Exception { List<Pair<PasspointProvider, PasspointMatch>> result = - mManager.matchProvider(createMockScanDetail()); + mManager.matchProvider(createTestScanResult()); assertTrue(result.isEmpty()); } @@ -581,13 +572,11 @@ public class PasspointManagerTest { public void matchProviderWithAnqpCacheMissed() throws Exception { addTestProvider(); - ANQPNetworkKey anqpKey = ANQPNetworkKey.buildKey(TEST_SSID, TEST_BSSID, TEST_HESSID, - TEST_ANQP_DOMAIN_ID); - when(mAnqpCache.getEntry(anqpKey)).thenReturn(null); + when(mAnqpCache.getEntry(TEST_ANQP_KEY)).thenReturn(null); List<Pair<PasspointProvider, PasspointMatch>> result = - mManager.matchProvider(createMockScanDetail()); + mManager.matchProvider(createTestScanResult()); // Verify that a request for ANQP elements is initiated. - verify(mAnqpRequestManager).requestANQPElements(eq(TEST_BSSID), any(ScanDetail.class), + verify(mAnqpRequestManager).requestANQPElements(eq(TEST_BSSID), any(ANQPNetworkKey.class), anyBoolean(), anyBoolean()); assertTrue(result.isEmpty()); } @@ -602,13 +591,11 @@ public class PasspointManagerTest { public void matchProviderAsHomeProvider() throws Exception { PasspointProvider provider = addTestProvider(); ANQPData entry = new ANQPData(mClock, null); - ANQPNetworkKey anqpKey = ANQPNetworkKey.buildKey(TEST_SSID, TEST_BSSID, TEST_HESSID, - TEST_ANQP_DOMAIN_ID); - when(mAnqpCache.getEntry(anqpKey)).thenReturn(entry); + when(mAnqpCache.getEntry(TEST_ANQP_KEY)).thenReturn(entry); when(provider.match(anyMap())).thenReturn(PasspointMatch.HomeProvider); List<Pair<PasspointProvider, PasspointMatch>> result = - mManager.matchProvider(createMockScanDetail()); + mManager.matchProvider(createTestScanResult()); assertEquals(1, result.size()); assertEquals(PasspointMatch.HomeProvider, result.get(0).second); } @@ -623,13 +610,11 @@ public class PasspointManagerTest { public void matchProviderAsRoamingProvider() throws Exception { PasspointProvider provider = addTestProvider(); ANQPData entry = new ANQPData(mClock, null); - ANQPNetworkKey anqpKey = ANQPNetworkKey.buildKey(TEST_SSID, TEST_BSSID, TEST_HESSID, - TEST_ANQP_DOMAIN_ID); - when(mAnqpCache.getEntry(anqpKey)).thenReturn(entry); + when(mAnqpCache.getEntry(TEST_ANQP_KEY)).thenReturn(entry); when(provider.match(anyMap())).thenReturn(PasspointMatch.RoamingProvider); List<Pair<PasspointProvider, PasspointMatch>> result = - mManager.matchProvider(createMockScanDetail()); + mManager.matchProvider(createTestScanResult()); assertEquals(1, result.size()); assertEquals(PasspointMatch.RoamingProvider, result.get(0).second); assertEquals(TEST_FQDN, provider.getConfig().getHomeSp().getFqdn()); @@ -644,13 +629,11 @@ public class PasspointManagerTest { public void matchProviderWithNoMatch() throws Exception { PasspointProvider provider = addTestProvider(); ANQPData entry = new ANQPData(mClock, null); - ANQPNetworkKey anqpKey = ANQPNetworkKey.buildKey(TEST_SSID, TEST_BSSID, TEST_HESSID, - TEST_ANQP_DOMAIN_ID); - when(mAnqpCache.getEntry(anqpKey)).thenReturn(entry); + when(mAnqpCache.getEntry(TEST_ANQP_KEY)).thenReturn(entry); when(provider.match(anyMap())).thenReturn(PasspointMatch.None); List<Pair<PasspointProvider, PasspointMatch>> result = - mManager.matchProvider(createMockScanDetail()); + mManager.matchProvider(createTestScanResult()); assertEquals(0, result.size()); } @@ -666,6 +649,34 @@ public class PasspointManagerTest { } /** + * Verify that an empty map will be returned if ANQP elements are not cached for the given AP. + * + * @throws Exception + */ + @Test + public void getANQPElementsWithNoMatchFound() throws Exception { + when(mAnqpCache.getEntry(TEST_ANQP_KEY)).thenReturn(null); + assertTrue(mManager.getANQPElements(createTestScanResult()).isEmpty()); + } + + /** + * Verify that an expected ANQP elements will be returned if ANQP elements are cached for the + * given AP. + * + * @throws Exception + */ + @Test + public void getANQPElementsWithMatchFound() throws Exception { + Map<ANQPElementType, ANQPElement> anqpElementMap = new HashMap<>(); + anqpElementMap.put(ANQPElementType.ANQPDomName, + new DomainNameElement(Arrays.asList(new String[] {"test.com"}))); + ANQPData entry = new ANQPData(mClock, anqpElementMap); + + when(mAnqpCache.getEntry(TEST_ANQP_KEY)).thenReturn(entry); + assertEquals(anqpElementMap, mManager.getANQPElements(createTestScanResult())); + } + + /** * Verify that the provider list maintained by the PasspointManager after the list is updated * in the data source. * diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointNetworkEvaluatorTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointNetworkEvaluatorTest.java index 616e2161a..05d9ea225 100644 --- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointNetworkEvaluatorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointNetworkEvaluatorTest.java @@ -129,7 +129,7 @@ public class PasspointNetworkEvaluatorTest { generateScanDetail(TEST_SSID1), generateScanDetail(TEST_SSID2)}); List<Pair<ScanDetail, WifiConfiguration>> connectableNetworks = new ArrayList<>(); List<Pair<PasspointProvider, PasspointMatch>> matchedProviders = new ArrayList<>(); - when(mPasspointManager.matchProvider(any(ScanDetail.class))).thenReturn(matchedProviders); + when(mPasspointManager.matchProvider(any(ScanResult.class))).thenReturn(matchedProviders); assertEquals(null, mEvaluator.evaluateNetworks( scanDetails, null, null, false, false, connectableNetworks)); assertTrue(connectableNetworks.isEmpty()); @@ -154,7 +154,7 @@ public class PasspointNetworkEvaluatorTest { scanDetails, null, null, false, false, connectableNetworks)); assertTrue(connectableNetworks.isEmpty()); // Verify that no provider matching is performed. - verify(mPasspointManager, never()).matchProvider(any(ScanDetail.class)); + verify(mPasspointManager, never()).matchProvider(any(ScanResult.class)); } /** @@ -181,7 +181,7 @@ public class PasspointNetworkEvaluatorTest { // Return matchedProviders for the first ScanDetail (TEST_SSID1) and an empty list for // for the second (TEST_SSID2); - when(mPasspointManager.matchProvider(any(ScanDetail.class))).thenReturn(matchedProviders) + when(mPasspointManager.matchProvider(any(ScanResult.class))).thenReturn(matchedProviders) .thenReturn(new ArrayList<Pair<PasspointProvider, PasspointMatch>>()); when(mWifiConfigManager.addOrUpdateNetwork(any(WifiConfiguration.class), anyInt())) .thenReturn(new NetworkUpdateResult(TEST_NETWORK_ID)); @@ -224,7 +224,7 @@ public class PasspointNetworkEvaluatorTest { // Return matchedProviders for the first ScanDetail (TEST_SSID1) and an empty list for // for the second (TEST_SSID2); - when(mPasspointManager.matchProvider(any(ScanDetail.class))).thenReturn(matchedProviders) + when(mPasspointManager.matchProvider(any(ScanResult.class))).thenReturn(matchedProviders) .thenReturn(new ArrayList<Pair<PasspointProvider, PasspointMatch>>()); when(mWifiConfigManager.addOrUpdateNetwork(any(WifiConfiguration.class), anyInt())) .thenReturn(new NetworkUpdateResult(TEST_NETWORK_ID)); @@ -271,7 +271,7 @@ public class PasspointNetworkEvaluatorTest { // Return providerForScanDetail1 for the first ScanDetail (TEST_SSID1) and // providerForScanDetail2 for the second (TEST_SSID2); - when(mPasspointManager.matchProvider(any(ScanDetail.class))) + when(mPasspointManager.matchProvider(any(ScanResult.class))) .thenReturn(providerForScanDetail1).thenReturn(providerForScanDetail2); when(mWifiConfigManager.addOrUpdateNetwork(any(WifiConfiguration.class), anyInt())) .thenReturn(new NetworkUpdateResult(TEST_NETWORK_ID)); @@ -318,7 +318,7 @@ public class PasspointNetworkEvaluatorTest { // Returning the same matching provider for both ScanDetail. List<Pair<ScanDetail, WifiConfiguration>> connectableNetworks = new ArrayList<>(); - when(mPasspointManager.matchProvider(any(ScanDetail.class))) + when(mPasspointManager.matchProvider(any(ScanResult.class))) .thenReturn(matchedProviders).thenReturn(matchedProviders); WifiConfiguration config = mEvaluator.evaluateNetworks(scanDetails, currentNetwork, currentBssid, true, false, connectableNetworks); diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointNetworkScoreTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointNetworkScoreTest.java index cca321233..10c50f5d3 100644 --- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointNetworkScoreTest.java +++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointNetworkScoreTest.java @@ -309,11 +309,10 @@ public class PasspointNetworkScoreTest { * @param rssiLevel RSSI level of the network * @param internetAccess Flag indicating if the network provides Internet access * @param networkType The type of the network - * @param anqpElements The list of ANQP elements * @return {@link ScanDetail} */ private static ScanDetail generateScanDetail(int rssiLevel, boolean internetAccess, - NetworkDetail.Ant networkType, Map<ANQPElementType, ANQPElement> anqpElements) { + NetworkDetail.Ant networkType) { // Setup ScanResult. ScanResult scanResult = new ScanResult(); scanResult.level = -60; @@ -322,7 +321,6 @@ public class PasspointNetworkScoreTest { NetworkDetail networkDetail = mock(NetworkDetail.class); when(networkDetail.isInternet()).thenReturn(internetAccess); when(networkDetail.getAnt()).thenReturn(networkType); - when(networkDetail.getANQPElements()).thenReturn(anqpElements); // Setup ScanDetail. ScanDetail scanDetail = mock(ScanDetail.class); @@ -341,9 +339,9 @@ public class PasspointNetworkScoreTest { public void calculateScore() throws Exception { for (TestData data : TEST_DATA_LIST) { ScanDetail scanDetail = generateScanDetail(data.rssiLevel, data.internetAccess, - data.networkType, data.anqpElements); + data.networkType); assertEquals(data.expectedScore, PasspointNetworkScore.calculateScore( - data.isHomeProvider, scanDetail, data.isActiveNetwork)); + data.isHomeProvider, scanDetail, data.anqpElements, data.isActiveNetwork)); } } |