diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-04-21 08:17:28 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-04-21 08:17:28 +0000 |
commit | e4fce8a805927c19dbbf2fc6e0ff41017ae1000f (patch) | |
tree | 6fc6d8c7451643be3f3601daa0ba30fd2fad4faa /tests | |
parent | 7935833ba18cc2386d985e2f6677e4a9a44776a3 (diff) | |
parent | 2ca3fb29b5a4ff4d6aee905884c8e1c82fa147ea (diff) |
Merge "Softap: Disconnect all connected clients during Softap turn-off." into rvc-dev
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java | 24 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java | 29 |
2 files changed, 51 insertions, 2 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java b/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java index 9db553f3b..52a28eafe 100644 --- a/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java +++ b/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java @@ -34,6 +34,7 @@ import android.hidl.manager.V1_0.IServiceNotification; import android.net.MacAddress; import android.net.wifi.SoftApConfiguration; import android.net.wifi.SoftApConfiguration.Builder; +import android.net.wifi.WifiManager; import android.net.wifi.nl80211.WifiNl80211Manager; import android.os.Handler; import android.os.IHwBinder; @@ -820,10 +821,28 @@ public class HostapdHalTest extends WifiBaseTest { when(mIHostapdMockV12.forceClientDisconnect(any(), any(), anyShort())) .thenReturn(mStatusSuccess12); - assertTrue(mHostapdHal.forceClientDisconnect(IFACE_NAME, test_client, 0)); + assertTrue(mHostapdHal.forceClientDisconnect(IFACE_NAME, test_client, + WifiManager.SAP_CLIENT_BLOCK_REASON_CODE_BLOCKED_BY_USER)); verify(mIHostapdMockV12).forceClientDisconnect(any(), any(), anyShort()); } + @Test + public void testForceClientDisconnectFailureDueToInvalidArg() throws Exception { + executeAndValidateInitializationSequence(); + when(mServiceManagerMock.getTransport(anyString(), anyString())) + .thenReturn(IServiceManager.Transport.HWBINDER); + MacAddress test_client = MacAddress.fromString("da:a1:19:0:0:0"); + mIHostapdMockV12 = mock(android.hardware.wifi.hostapd.V1_2.IHostapd.class); + when(mIHostapdMockV12.forceClientDisconnect(any(), any(), anyShort())) + .thenReturn(mStatusSuccess12); + + try { + mHostapdHal.forceClientDisconnect(IFACE_NAME, test_client, -1); + fail(); + } catch (IllegalArgumentException e) { + } + } + /** * Verifies the failure handling in forceClientDisconnect. */ @@ -837,7 +856,8 @@ public class HostapdHalTest extends WifiBaseTest { when(mIHostapdMockV12.forceClientDisconnect(any(), any(), anyShort())) .thenReturn(mStatusFailure12); - assertFalse(mHostapdHal.forceClientDisconnect(IFACE_NAME, test_client, 0)); + assertFalse(mHostapdHal.forceClientDisconnect(IFACE_NAME, test_client, + WifiManager.SAP_CLIENT_BLOCK_REASON_CODE_BLOCKED_BY_USER)); verify(mIHostapdMockV12).forceClientDisconnect(any(), any(), anyShort()); } diff --git a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java index a7e21c996..ca7bc627c 100644 --- a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java @@ -23,6 +23,7 @@ import static android.net.wifi.WifiManager.EXTRA_WIFI_AP_INTERFACE_NAME; import static android.net.wifi.WifiManager.EXTRA_WIFI_AP_MODE; import static android.net.wifi.WifiManager.EXTRA_WIFI_AP_STATE; import static android.net.wifi.WifiManager.IFACE_IP_MODE_LOCAL_ONLY; +import static android.net.wifi.WifiManager.SAP_CLIENT_DISCONNECT_REASON_CODE_UNSPECIFIED; import static android.net.wifi.WifiManager.WIFI_AP_STATE_DISABLED; import static android.net.wifi.WifiManager.WIFI_AP_STATE_DISABLING; import static android.net.wifi.WifiManager.WIFI_AP_STATE_ENABLED; @@ -1106,6 +1107,34 @@ public class SoftApManagerTest extends WifiBaseTest { } @Test + public void stopDisconnectsConnectedClients() throws Exception { + InOrder order = inOrder(mCallback, mWifiMetrics); + SoftApModeConfiguration apConfig = + new SoftApModeConfiguration(WifiManager.IFACE_IP_MODE_TETHERED, null, + mTestSoftApCapability); + startSoftApAndVerifyEnabled(apConfig); + + order.verify(mCallback).onConnectedClientsChanged(new ArrayList<>()); + + mSoftApListenerCaptor.getValue().onConnectedClientsChanged( + TEST_NATIVE_CLIENT, true); + mLooper.dispatchAll(); + + order.verify(mCallback).onConnectedClientsChanged( + Mockito.argThat((List<WifiClient> clients) -> + clients.contains(TEST_CONNECTED_CLIENT)) + ); + verify(mWifiMetrics).addSoftApNumAssociatedStationsChangedEvent( + 1, apConfig.getTargetMode()); + + mSoftApManager.stop(); + mLooper.dispatchAll(); + + verify(mWifiNative).forceClientDisconnect(TEST_INTERFACE_NAME, TEST_MAC_ADDRESS, + SAP_CLIENT_DISCONNECT_REASON_CODE_UNSPECIFIED); + } + + @Test public void handlesInvalidConnectedClients() throws Exception { SoftApModeConfiguration apConfig = new SoftApModeConfiguration(WifiManager.IFACE_IP_MODE_TETHERED, null, |