diff options
author | Rebecca Silberstein <silberst@google.com> | 2017-03-25 17:02:03 -0700 |
---|---|---|
committer | Rebecca Silberstein <silberst@google.com> | 2017-04-14 23:08:08 +0000 |
commit | 1e5c1abdeb4e3e180e5344c777f7a7db2095c246 (patch) | |
tree | 211b9f4c85fd6cf2ca383c1e31ba733620254720 /tests | |
parent | 487e3458da4f88bd505eac8456ce50408648499c (diff) |
WifiApConfigStore: create temp sharing AP config
Create a temporary config for use by local only hotspot. These configs
are generated by the WifiApConfigStore, but will not be stored.
Bug: 36704784
Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Change-Id: I3470708a274e97f6e4a752ea1863cfa86bfbf8b6
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java b/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java index 42161fa54..d4a3ff549 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java @@ -49,6 +49,7 @@ public class WifiApConfigStoreTest { private static final String TEST_DEFAULT_2G_CHANNEL_LIST = "1,2,3,4,5,6"; private static final String TEST_DEFAULT_AP_SSID = "TestAP"; private static final String TEST_CONFIGURED_AP_SSID = "ConfiguredAP"; + private static final String TEST_DEFAULT_HOTSPOT_SSID = "TestShare"; private static final int RAND_SSID_INT_MIN = 1000; private static final int RAND_SSID_INT_MAX = 9999; @@ -69,6 +70,8 @@ public class WifiApConfigStoreTest { TEST_DEFAULT_2G_CHANNEL_LIST); resources.setString(R.string.wifi_tether_configure_ssid_default, TEST_DEFAULT_AP_SSID); + resources.setString(R.string.wifi_localhotspot_configure_ssid_default, + TEST_DEFAULT_HOTSPOT_SSID); when(mContext.getResources()).thenReturn(resources); } @@ -107,10 +110,10 @@ public class WifiApConfigStoreTest { assertEquals(config1.apChannel, config2.apChannel); } - private void verifyDefaultApConfig(WifiConfiguration config) { + private void verifyDefaultApConfig(WifiConfiguration config, String expectedSsid) { String[] splitSsid = config.SSID.split("_"); assertEquals(2, splitSsid.length); - assertEquals(TEST_DEFAULT_AP_SSID, splitSsid[0]); + assertEquals(expectedSsid, splitSsid[0]); int randomPortion = Integer.parseInt(splitSsid[1]); assertTrue(randomPortion >= RAND_SSID_INT_MIN && randomPortion <= RAND_SSID_INT_MAX); assertTrue(config.allowedKeyManagement.get(KeyMgmt.WPA2_PSK)); @@ -124,7 +127,7 @@ public class WifiApConfigStoreTest { public void initWithDefaultConfiguration() throws Exception { WifiApConfigStore store = new WifiApConfigStore( mContext, mBackupManagerProxy, mApConfigFile.getPath()); - verifyDefaultApConfig(store.getApConfiguration()); + verifyDefaultApConfig(store.getApConfiguration(), TEST_DEFAULT_AP_SSID); } /** @@ -165,7 +168,7 @@ public class WifiApConfigStoreTest { verifyApConfig(expectedConfig, store.getApConfiguration()); store.setApConfiguration(null); - verifyDefaultApConfig(store.getApConfiguration()); + verifyDefaultApConfig(store.getApConfiguration(), TEST_DEFAULT_AP_SSID); verify(mBackupManagerProxy).notifyDataChanged(); } @@ -177,7 +180,7 @@ public class WifiApConfigStoreTest { /* Initialize WifiApConfigStore with default configuration. */ WifiApConfigStore store = new WifiApConfigStore( mContext, mBackupManagerProxy, mApConfigFile.getPath()); - verifyDefaultApConfig(store.getApConfiguration()); + verifyDefaultApConfig(store.getApConfiguration(), TEST_DEFAULT_AP_SSID); /* Update with a valid configuration. */ WifiConfiguration expectedConfig = setupApConfig( @@ -190,4 +193,14 @@ public class WifiApConfigStoreTest { verifyApConfig(expectedConfig, store.getApConfiguration()); verify(mBackupManagerProxy).notifyDataChanged(); } + + /** + * Verify a proper local only hotspot config is generated when called properly with the valid + * context. + */ + @Test + public void generateLocalOnlyHotspotConfigIsValid() { + WifiConfiguration config = WifiApConfigStore.generateLocalOnlyHotspotConfig(mContext); + verifyDefaultApConfig(config, TEST_DEFAULT_HOTSPOT_SSID); + } } |