diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-04-07 02:48:30 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-04-07 02:48:30 +0000 |
commit | 8c6bbc8d45655e705bdc15182afef9830703e0e0 (patch) | |
tree | ef393a13b283f3a8def1903516bd97367cf69834 /tests | |
parent | 147d2219d0f0719560902f09bf569baff538b091 (diff) | |
parent | 1735d4549641ff431997446d02f59810953bda9e (diff) |
Merge "HalDeviceManager: Add a new query API for device capabilities" into rvc-dev
Diffstat (limited to 'tests')
4 files changed, 159 insertions, 43 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java b/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java index c68cd9ac5..701ffb345 100644 --- a/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java @@ -2151,41 +2151,11 @@ public class ActiveModeWardenTest extends WifiBaseTest { } @Test - public void canSupportAtleastOneConcurrentClientAndSoftApManager() throws Exception { - assertNotNull(mClientIfaceAvailableListener.getValue()); - assertNotNull(mSoftApIfaceAvailableListener.getValue()); - - // No mode manager - assertFalse(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()); - - // client mode manager active, but cannot create one more softap manager - enterClientModeActiveState(); - assertFalse(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()); - - // client mode manager active, can create one more softap manager - mSoftApIfaceAvailableListener.getValue().onAvailabilityChanged(true); - mLooper.dispatchAll(); - assertTrue(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()); - - // Tear down client mode manager - enterStaDisabledMode(false); + public void isStaApConcurrencySupported() throws Exception { + when(mWifiNative.isStaApConcurrencySupported()).thenReturn(false); + assertFalse(mActiveModeWarden.isStaApConcurrencySupported()); - // active softap manager, but cannot create one more client mode manager - reset(mSoftApManager, mBatteryStats); - enterSoftApActiveMode(); - assertFalse(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()); - - // active softap manager, can create one more client mode manager - mClientIfaceAvailableListener.getValue().onAvailabilityChanged(true); - mLooper.dispatchAll(); - assertTrue(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()); - - // softap manager + client mode manager active, cannot create any more mode managers - reset(mClientModeManager, mBatteryStats, mScanRequestProxy); - enterClientModeActiveState(); - mSoftApIfaceAvailableListener.getValue().onAvailabilityChanged(false); - mClientIfaceAvailableListener.getValue().onAvailabilityChanged(false); - mLooper.dispatchAll(); - assertTrue(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()); + when(mWifiNative.isStaApConcurrencySupported()).thenReturn(true); + assertTrue(mActiveModeWarden.isStaApConcurrencySupported()); } } diff --git a/tests/wifitests/src/com/android/server/wifi/HalDeviceManagerTest.java b/tests/wifitests/src/com/android/server/wifi/HalDeviceManagerTest.java index 36bf52b6b..1b195cfc7 100644 --- a/tests/wifitests/src/com/android/server/wifi/HalDeviceManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/HalDeviceManagerTest.java @@ -56,6 +56,7 @@ import android.os.Handler; import android.os.IHwBinder; import android.os.test.TestLooper; import android.util.Log; +import android.util.SparseArray; import androidx.test.filters.SmallTest; @@ -1361,6 +1362,66 @@ public class HalDeviceManagerTest extends WifiBaseTest { assertEquals(correctResults, results); } + /** + * Validate {@link HalDeviceManager#canSupportIfaceCombo(SparseArray)} + */ + @Test + public void testCanSupportIfaceComboTestChipV1() throws Exception { + final String name = "wlan0"; + + TestChipV1 chipMock = new TestChipV1(); + chipMock.initialize(); + mInOrder = inOrder(mServiceManagerMock, mWifiMock, chipMock.chip, + mManagerStatusListenerMock); + executeAndValidateInitializationSequence(); + executeAndValidateStartupSequence(); + + assertTrue(mDut.canSupportIfaceCombo(new SparseArray<Integer>() {{ + put(IfaceType.STA, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray<Integer>() {{ + put(IfaceType.AP, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray<Integer>() {{ + put(IfaceType.P2P, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray<Integer>() {{ + put(IfaceType.NAN, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray<Integer>() {{ + put(IfaceType.STA, 1); + put(IfaceType.P2P, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray<Integer>() {{ + put(IfaceType.STA, 1); + put(IfaceType.NAN, 1); + }} + )); + + assertFalse(mDut.canSupportIfaceCombo(new SparseArray<Integer>() {{ + put(IfaceType.STA, 1); + put(IfaceType.AP, 1); + }} + )); + assertFalse(mDut.canSupportIfaceCombo(new SparseArray<Integer>() {{ + put(IfaceType.STA, 2); + }} + )); + assertFalse(mDut.canSupportIfaceCombo(new SparseArray<Integer>() {{ + put(IfaceType.P2P, 1); + put(IfaceType.NAN, 1); + }} + )); + + verifyNoMoreInteractions(mManagerStatusListenerMock); + } + + ////////////////////////////////////////////////////////////////////////////////////// // TestChipV2 Specific Tests ////////////////////////////////////////////////////////////////////////////////////// @@ -1632,6 +1693,91 @@ public class HalDeviceManagerTest extends WifiBaseTest { assertEquals(correctResults, results); } + /** + * Validate {@link HalDeviceManager#canSupportIfaceCombo(SparseArray)} + */ + @Test + public void testCanSupportIfaceComboTestChipV2() throws Exception { + final String name = "wlan0"; + + TestChipV2 chipMock = new TestChipV2(); + chipMock.initialize(); + mInOrder = inOrder(mServiceManagerMock, mWifiMock, chipMock.chip, + mManagerStatusListenerMock); + executeAndValidateInitializationSequence(); + executeAndValidateStartupSequence(); + + assertTrue(mDut.canSupportIfaceCombo(new SparseArray<Integer>() {{ + put(IfaceType.STA, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray<Integer>() {{ + put(IfaceType.AP, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray<Integer>() {{ + put(IfaceType.P2P, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray<Integer>() {{ + put(IfaceType.NAN, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray<Integer>() {{ + put(IfaceType.STA, 1); + put(IfaceType.P2P, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray<Integer>() {{ + put(IfaceType.STA, 1); + put(IfaceType.NAN, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray<Integer>() {{ + put(IfaceType.STA, 1); + put(IfaceType.AP, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray<Integer>() {{ + put(IfaceType.STA, 2); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray<Integer>() {{ + put(IfaceType.P2P, 1); + put(IfaceType.AP, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray<Integer>() {{ + put(IfaceType.STA, 1); + put(IfaceType.P2P, 1); + put(IfaceType.AP, 1); + }} + )); + assertTrue(mDut.canSupportIfaceCombo(new SparseArray<Integer>() {{ + put(IfaceType.STA, 1); + put(IfaceType.AP, 1); + put(IfaceType.NAN, 1); + }} + )); + + assertFalse(mDut.canSupportIfaceCombo(new SparseArray<Integer>() {{ + put(IfaceType.P2P, 1); + put(IfaceType.NAN, 1); + }} + )); + assertFalse(mDut.canSupportIfaceCombo(new SparseArray<Integer>() {{ + put(IfaceType.AP, 2); + }} + )); + assertFalse(mDut.canSupportIfaceCombo(new SparseArray<Integer>() {{ + put(IfaceType.STA, 2); + put(IfaceType.AP, 1); + }} + )); + + verifyNoMoreInteractions(mManagerStatusListenerMock); + } + ////////////////////////////////////////////////////////////////////////////////////// // TestChipV3 Specific Tests ////////////////////////////////////////////////////////////////////////////////////// diff --git a/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java b/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java index 3a5ce5272..50fd4d8c1 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java @@ -112,7 +112,7 @@ public class WifiApConfigStoreTest extends WifiBaseTest { mResources.setString(R.string.wifi_localhotspot_configure_ssid_default, TEST_DEFAULT_HOTSPOT_SSID); /* Default to device that does not require ap band conversion */ - when(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()) + when(mActiveModeWarden.isStaApConcurrencySupported()) .thenReturn(false); when(mContext.getResources()).thenReturn(mResources); @@ -282,7 +282,7 @@ public class WifiApConfigStoreTest extends WifiBaseTest { */ @Test public void convertDevice5GhzToAny() throws Exception { - when(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()) + when(mActiveModeWarden.isStaApConcurrencySupported()) .thenReturn(true); /* Initialize WifiApConfigStore with default configuration. */ @@ -321,7 +321,7 @@ public class WifiApConfigStoreTest extends WifiBaseTest { */ @Test public void deviceAnyNotConverted() throws Exception { - when(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()) + when(mActiveModeWarden.isStaApConcurrencySupported()) .thenReturn(true); /* Initialize WifiApConfigStore with default configuration. */ @@ -350,7 +350,7 @@ public class WifiApConfigStoreTest extends WifiBaseTest { */ @Test public void deviceWithChannelNotConverted() throws Exception { - when(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()) + when(mActiveModeWarden.isStaApConcurrencySupported()) .thenReturn(true); /* Initialize WifiApConfigStore with default configuration. */ @@ -380,7 +380,7 @@ public class WifiApConfigStoreTest extends WifiBaseTest { */ @Test public void device5GhzConvertedToAnyAtRetrieval() throws Exception { - when(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()) + when(mActiveModeWarden.isStaApConcurrencySupported()) .thenReturn(true); SoftApConfiguration persistedConfig = setupApConfig( @@ -414,7 +414,7 @@ public class WifiApConfigStoreTest extends WifiBaseTest { */ @Test public void deviceNotConvertedAtRetrieval() throws Exception { - when(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()) + when(mActiveModeWarden.isStaApConcurrencySupported()) .thenReturn(true); SoftApConfiguration persistedConfig = setupApConfig( diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java index ca8c9dbc6..b5c5e7b42 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java @@ -5632,14 +5632,14 @@ public class WifiServiceImplTest extends WifiBaseTest { when(mClientModeImpl.syncGetSupportedFeatures( any())).thenReturn(supportedFeaturesFromClientModeImpl); - when(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()) + when(mActiveModeWarden.isStaApConcurrencySupported()) .thenReturn(false); mLooper.startAutoDispatch(); assertEquals(supportedFeaturesFromClientModeImpl, mWifiServiceImpl.getSupportedFeatures()); mLooper.stopAutoDispatchAndIgnoreExceptions(); - when(mActiveModeWarden.canSupportAtleastOneConcurrentClientAndSoftApManager()) + when(mActiveModeWarden.isStaApConcurrencySupported()) .thenReturn(true); mLooper.startAutoDispatch(); assertEquals(supportedFeaturesFromClientModeImpl | WifiManager.WIFI_FEATURE_AP_STA, |