From 591518f378b39bc7a5b7f5e0b040a53c819966a6 Mon Sep 17 00:00:00 2001 From: Etan Cohen Date: Mon, 16 Oct 2017 14:51:46 -0700 Subject: [PATCH] [CTS][PASSPOINT] Update the check for passpoint network for preloaded passpoint network Before calling the testAddPasspointConfigWithCertCredential we need to check number of network already present in device Bug: 67630919 Test: android.server.cts.CtsNetTestCases, WifiManagerTest Change-Id: If643ab7bde760a65e9a5b1e9d47af53378a178fd --- .../android/net/wifi/cts/WifiManagerTest.java | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java b/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java index ea63f787cf..b2d912e56c 100644 --- a/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java +++ b/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java @@ -697,6 +697,12 @@ public class WifiManagerTest extends AndroidTestCase { */ private void testAddPasspointConfig(PasspointConfiguration config) throws Exception { try { + + // obtain number of passpoint networks already present in device (preloaded) + List preConfigList = mWifiManager.getPasspointConfigurations(); + int numOfNetworks = preConfigList.size(); + + // add new (test) configuration mWifiManager.addOrUpdatePasspointConfiguration(config); // Certificates and keys will be set to null after it is installed to the KeyStore by @@ -706,14 +712,23 @@ public class WifiManagerTest extends AndroidTestCase { config.getCredential().setClientCertificateChain(null); config.getCredential().setClientPrivateKey(null); - // Retrieve the configuration and verify it. + // retrieve the configuration and verify it. The retrieved list may not be in order - + // check all configs to see if any match List configList = mWifiManager.getPasspointConfigurations(); - assertEquals(1, configList.size()); - assertEquals(config, configList.get(0)); + assertEquals(numOfNetworks + 1, configList.size()); - // Remove the configuration and verify no installed configuration. + boolean anyMatch = false; + for (PasspointConfiguration passpointConfiguration : configList) { + if (passpointConfiguration.equals(config)) { + anyMatch = true; + break; + } + } + assertTrue(anyMatch); + + // remove the (test) configuration and verify number of installed configurations mWifiManager.removePasspointConfiguration(config.getHomeSp().getFqdn()); - assertTrue(mWifiManager.getPasspointConfigurations().isEmpty()); + assertEquals(mWifiManager.getPasspointConfigurations().size(), numOfNetworks); } catch (UnsupportedOperationException e) { // Passpoint build config |config_wifi_hotspot2_enabled| is disabled, so noop. }