summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRebecca Silberstein <silberst@google.com>2017-03-25 17:02:03 -0700
committerRebecca Silberstein <silberst@google.com>2017-04-15 14:54:24 -0700
commit5303b9cb6acc2149b454e8aad58f33d8df88ba78 (patch)
tree7c12404d8a26186564182ace60fc69b89b49057e /tests
parent9440acb666a0ec018fb9e0a6ff682d97ca97c076 (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 Merged-In: I3470708a274e97f6e4a752ea1863cfa86bfbf8b6
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java23
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);
+ }
}