diff options
author | Bartosz Fabianowski <bartfab@google.com> | 2016-01-28 10:26:02 +0000 |
---|---|---|
committer | Android Partner Code Review <android-gerrit-partner@google.com> | 2016-01-28 10:26:02 +0000 |
commit | 8541f6411048c5c6281699153b8c7c73e1f30c4c (patch) | |
tree | 13bd9070792bfee5887c86a7e506b92e444c35da /tests | |
parent | 2c990df82a9e01a29b4cbe682226b22b805f527f (diff) | |
parent | 75a766bae85ee8e94fbaad8fb5214804e7ff97e4 (diff) |
Merge "Test that WifiConfigStore handles duplicate configurations correctly" into mm-wireless-dev
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java index 1d0160370..5c934587c 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java @@ -562,6 +562,40 @@ public class WifiConfigStoreTest extends AndroidTestCase { } /** + * Verifies that loadConfiguredNetworks() correctly handles duplicates when reading network + * configurations from the wpa_supplicant: The second configuration overwrites the first. + */ + public void testLoadConfiguredNetworksEliminatesDuplicates() throws Exception { + final WifiConfiguration config = new WifiConfiguration(CONFIGS.get(0)); + config.networkId = 1; + + // Set up list of network configurations returned by wpa_supplicant. The two configurations + // are identical except for their network IDs. + final String header = "network id / ssid / bssid / flags"; + final String networks = + header + "\n0\t" + config.SSID + "\tany\n1\t" + config.SSID + "\tany"; + when(mWifiNative.listNetworks(anyInt())).thenReturn(header); + when(mWifiNative.listNetworks(-1)).thenReturn(networks); + + // Set up variables returned by wpa_supplicant. + when(mWifiNative.getNetworkVariable(anyInt(), eq(WifiConfiguration.ssidVarName))) + .thenReturn(encodeConfigSSID(config)); + final Map<String, String> metadata = new HashMap<String, String>(); + metadata.put(WifiConfigStore.ID_STRING_KEY_CONFIG_KEY, config.configKey()); + metadata.put(WifiConfigStore.ID_STRING_KEY_CREATOR_UID, + Integer.toString(config.creatorUid)); + when(mWifiNative.getNetworkExtra(anyInt(), eq(WifiConfigStore.ID_STRING_VAR_NAME))) + .thenReturn(metadata); + + // Load network configurations. + mConfigStore.loadConfiguredNetworks(); + + // Verify that the second network configuration (network ID 1) overwrote the first (network + // ID 0). + verifyNetworkConfigs(Arrays.asList(config), mConfiguredNetworks.valuesForAllUsers()); + } + + /** * Verifies that handleUserSwitch() removes ephemeral network configurations, disables network * configurations that should no longer be visible and enables network configurations that * should become visible. |