diff options
Diffstat (limited to 'tests')
4 files changed, 42 insertions, 12 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/BssidBlocklistMonitorTest.java b/tests/wifitests/src/com/android/server/wifi/BssidBlocklistMonitorTest.java index 8cb2e376a..4d2db7b02 100644 --- a/tests/wifitests/src/com/android/server/wifi/BssidBlocklistMonitorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/BssidBlocklistMonitorTest.java @@ -164,13 +164,13 @@ public class BssidBlocklistMonitorTest { } /** - * Verify getNumBlockedBssidsForSsid returns the correct number of blocked BSSIDs. + * Verify updateAndGetNumBlockedBssidsForSsid returns the correct number of blocked BSSIDs. */ @Test - public void testGetNumBlockedBssidsForSsid() { + public void testUpdateAndGetNumBlockedBssidsForSsid() { verifyAddMultipleBssidsToBlocklist(); - assertEquals(2, mBssidBlocklistMonitor.getNumBlockedBssidsForSsid(TEST_SSID_1)); - assertEquals(1, mBssidBlocklistMonitor.getNumBlockedBssidsForSsid(TEST_SSID_2)); + assertEquals(2, mBssidBlocklistMonitor.updateAndGetNumBlockedBssidsForSsid(TEST_SSID_1)); + assertEquals(1, mBssidBlocklistMonitor.updateAndGetNumBlockedBssidsForSsid(TEST_SSID_2)); } /** @@ -208,6 +208,34 @@ public class BssidBlocklistMonitorTest { } /** + * Verify that updateAndGetBssidBlocklist(ssid) updates firmware roaming configuration + * if a BSSID that belongs to the ssid is removed from blocklist. + */ + @Test + public void testBssidRemovalUpdatesFirmwareConfiguration() { + verifyAddTestBssidToBlocklist(); + when(mClock.getWallClockMillis()).thenReturn(BASE_BLOCKLIST_DURATION + 1); + assertEquals(0, mBssidBlocklistMonitor + .updateAndGetBssidBlocklistForSsid(TEST_SSID_1).size()); + verify(mWifiConnectivityHelper).setFirmwareRoamingConfiguration(eq(new ArrayList<>()), + eq(new ArrayList<>())); + } + + /** + * Verify that updateAndGetBssidBlocklist(ssid) does not update firmware roaming configuration + * if there are no BSSIDs belonging to the ssid removed from blocklist. + */ + @Test + public void testBssidRemovalNotUpdateFirmwareConfiguration() { + verifyAddTestBssidToBlocklist(); + when(mClock.getWallClockMillis()).thenReturn(BASE_BLOCKLIST_DURATION + 1); + assertEquals(0, mBssidBlocklistMonitor + .updateAndGetBssidBlocklistForSsid(TEST_SSID_2).size()); + verify(mWifiConnectivityHelper, never()).setFirmwareRoamingConfiguration( + eq(new ArrayList<>()), eq(new ArrayList<>())); + } + + /** * Verify that when adding a AP that had already been failing (therefore has a blocklist * streak), we are setting the blocklist duration using an exponential backoff technique. */ diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java index 3de8cb98b..28fdade18 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java @@ -621,7 +621,7 @@ public class WifiConfigManagerTest extends WifiBaseTest { return (int) mBssidStatusMap.entrySet().stream() .filter(e -> e.getValue().equals(ssid)).count(); } - }).when(mBssidBlocklistMonitor).getNumBlockedBssidsForSsid( + }).when(mBssidBlocklistMonitor).updateAndGetNumBlockedBssidsForSsid( anyString()); // add bssid to the blocklist mBssidStatusMap.put(TEST_BSSID, openNetwork.SSID); @@ -649,7 +649,8 @@ public class WifiConfigManagerTest extends WifiBaseTest { assertTrue(oldConfig.trusted); assertNull(oldConfig.BSSID); - assertEquals(0, mBssidBlocklistMonitor.getNumBlockedBssidsForSsid(openNetwork.SSID)); + assertEquals(0, mBssidBlocklistMonitor.updateAndGetNumBlockedBssidsForSsid( + openNetwork.SSID)); } /** @@ -1375,7 +1376,7 @@ public class WifiConfigManagerTest extends WifiBaseTest { for (int i = 1; i < MAX_BLOCKED_BSSID_PER_NETWORK + 1; i++) { verifyDisableNetwork(result, disableReason); int numBssidsInBlocklist = i; - when(mBssidBlocklistMonitor.getNumBlockedBssidsForSsid(anyString())) + when(mBssidBlocklistMonitor.updateAndGetNumBlockedBssidsForSsid(anyString())) .thenReturn(numBssidsInBlocklist); timeout = WifiConfigManager.getNetworkSelectionDisableTimeoutMillis(disableReason) * multiplier; @@ -1386,7 +1387,7 @@ public class WifiConfigManagerTest extends WifiBaseTest { // Verify one last time that the disable duration is capped at some maximum. verifyDisableNetwork(result, disableReason); - when(mBssidBlocklistMonitor.getNumBlockedBssidsForSsid(anyString())) + when(mBssidBlocklistMonitor.updateAndGetNumBlockedBssidsForSsid(anyString())) .thenReturn(MAX_BLOCKED_BSSID_PER_NETWORK + 1); verifyNetworkIsEnabledAfter(result.getNetworkId(), TEST_ELAPSED_UPDATE_NETWORK_SELECTION_TIME_MILLIS + timeout); @@ -1404,7 +1405,7 @@ public class WifiConfigManagerTest extends WifiBaseTest { // Verify that with 0 BSSIDs in blocklist we enable the network immediately verifyDisableNetwork(result, disableReason); - when(mBssidBlocklistMonitor.getNumBlockedBssidsForSsid(anyString())).thenReturn(0); + when(mBssidBlocklistMonitor.updateAndGetNumBlockedBssidsForSsid(anyString())).thenReturn(0); when(mClock.getElapsedSinceBootMillis()) .thenReturn(TEST_ELAPSED_UPDATE_NETWORK_SELECTION_TIME_MILLIS); assertTrue(mWifiConfigManager.tryEnableNetwork(result.getNetworkId())); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java index ba1c4f976..9203a8d9b 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java @@ -2211,9 +2211,9 @@ public class WifiConnectivityManagerTest extends WifiBaseTest { when(mWifiConnectivityHelper.isFirmwareRoamingSupported()).thenReturn(true); // Force a connectivity scan - verify(mBssidBlocklistMonitor, never()).updateAndGetBssidBlocklist(); + verify(mBssidBlocklistMonitor, never()).updateAndGetBssidBlocklistForSsid(anyString()); mWifiConnectivityManager.forceConnectivityScan(WIFI_WORK_SOURCE); - verify(mBssidBlocklistMonitor).updateAndGetBssidBlocklist(); + verify(mBssidBlocklistMonitor).updateAndGetBssidBlocklistForSsid(anyString()); } /** diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java index 4e895e488..c2436a751 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java @@ -1727,7 +1727,8 @@ public class WifiMetricsTest extends WifiBaseTest { config.allowedKeyManagement = new BitSet(); when(config.getNetworkSelectionStatus()).thenReturn( mock(WifiConfiguration.NetworkSelectionStatus.class)); - when(mBssidBlocklistMonitor.getNumBlockedBssidsForSsid(eq(config.SSID))).thenReturn(3); + when(mBssidBlocklistMonitor.updateAndGetNumBlockedBssidsForSsid(eq(config.SSID))) + .thenReturn(3); mWifiMetrics.startConnectionEvent(config, "RED", WifiMetricsProto.ConnectionEvent.ROAM_NONE); mWifiMetrics.endConnectionEvent( |