summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBindu Mahadev <bmahadev@google.com>2017-03-02 23:28:07 -0800
committerBindu Mahadev <bmahadev@google.com>2017-03-02 23:28:07 -0800
commit8c52abab9d5627f6c5d9e153a5bd8cef063fde37 (patch)
tree0cbf93d741285c82e135ce2e02f22c562975c505
parent3c54c4907e85be377de9c76fd46c8f5979e19a0e (diff)
downloadplatform_tools_test_connectivity-8c52abab9d5627f6c5d9e153a5bd8cef063fde37.tar.gz
platform_tools_test_connectivity-8c52abab9d5627f6c5d9e153a5bd8cef063fde37.tar.bz2
platform_tools_test_connectivity-8c52abab9d5627f6c5d9e153a5bd8cef063fde37.zip
[Tests]Adding tests to check config store networks during reboot.
Added new tests to test networks returned from config store after reboot and toggling wifi and airplane mode, in various scenarios. Bug: 34503068 Test: Tested and verified locally. Change-Id: I1a68e60d01de452c16db0e21edff49d03ceca155
-rwxr-xr-xacts/tests/google/wifi/WifiManagerTest.py115
1 files changed, 115 insertions, 0 deletions
diff --git a/acts/tests/google/wifi/WifiManagerTest.py b/acts/tests/google/wifi/WifiManagerTest.py
index 55ef8cff49..e11f640200 100755
--- a/acts/tests/google/wifi/WifiManagerTest.py
+++ b/acts/tests/google/wifi/WifiManagerTest.py
@@ -151,6 +151,60 @@ class WifiManagerTest(acts.base_test.BaseTestClass):
network_list.append(connect_5g_data)
return network_list
+ def get_enabled_network(self, network1, network2):
+ """Check network status and return currently unconnected network.
+
+ Args:
+ network1: dict representing a network.
+ network2: dict representing a network.
+
+ Return:
+ Network dict of the unconnected network.
+
+ """
+ wifi_info = self.dut.droid.wifiGetConnectionInfo()
+ enabled = network1
+ if wifi_info[WifiEnums.SSID_KEY] == network1[WifiEnums.SSID_KEY]:
+ enabled = network2
+ return enabled
+
+ def check_configstore_networks(self, networks):
+ """Verify that all previously configured networks are presistent after
+ reboot.
+
+ Args:
+ networks: List of network dicts.
+
+ Return:
+ None. Raises TestFailure.
+
+ """
+ network_info = self.dut.droid.wifiGetConfiguredNetworks()
+ if len(network_info) != len(networks):
+ msg = ("Length of configured networks before and after reboot don't"
+ " match. \nBefore reboot = %s \n After reboot = %s" %
+ (networks, network_info))
+ raise signals.TestFailure(msg)
+ current_count = 0
+ # For each network, check if it exists in configured list after reboot
+ for network in networks:
+ exists = wutils.match_networks(
+ {WifiEnums.SSID_KEY:network[WifiEnums.SSID_KEY]},
+ network_info)
+ if not len(exists):
+ raise signals.TestFailure("%s network is not present in the"
+ " configured list after reboot" %
+ network[WifiEnums.SSID_KEY])
+ # Get the new network id for each network after reboot.
+ network['id'] = exists[0]['networkId']
+ if exists[0]['status'] == 'CURRENT':
+ current_count += 1
+ # At any given point, there can only be one currently active
+ # network, defined with 'status':'CURRENT'
+ if current_count > 1:
+ raise signals.TestFailure("More than one network showing"
+ "as 'CURRENT' after reboot")
+
def connect_to_wifi_network_with_id(self, network_id, network_ssid):
"""Connect to the given network using network id and verify SSID.
@@ -393,6 +447,67 @@ class WifiManagerTest(acts.base_test.BaseTestClass):
raise signals.TestFailure("Device did not connect to the correct"
" network after toggling Airplane mode.")
+ def test_reboot_configstore_reconnect(self):
+ """Connect to multiple networks, reboot then reconnect to previously
+ connected network.
+
+ Steps:
+ 1. Connect to a 2GHz network.
+ 2. Connect to a 5GHz network.
+ 3. Reboot device.
+ 4. Verify all networks are persistent after reboot.
+ 5. Reconnect to the non-current network.
+
+ """
+ network_list = self.connect_multiple_networks(self.dut)
+ self.dut.reboot()
+ time.sleep(DEFAULT_TIMEOUT)
+ self.check_configstore_networks(network_list)
+
+ reconnect_to = self.get_enabled_network(network_list[BAND_2GHZ],
+ network_list[BAND_5GHZ])
+
+ reconnect = self.reconnect_to_wifi_network(
+ reconnect_to[WifiEnums.NETID_KEY],
+ reconnect_to[WifiEnums.SSID_KEY])
+ if not reconnect:
+ raise signals.TestFailure("Device failed to reconnect to the correct"
+ " network after reboot.")
+
+ def test_toggle_wifi_reboot_configstore_reconnect(self):
+ """Connect to multiple networks, disable WiFi, reboot, then
+ reconnect to previously connected network.
+
+ Steps:
+ 1. Connect to a 2GHz network.
+ 2. Connect to a 5GHz network.
+ 3. Turn WiFi OFF.
+ 4. Reboot device.
+ 5. Turn WiFi ON.
+ 4. Verify all networks are persistent after reboot.
+ 5. Reconnect to the non-current network.
+
+ """
+ network_list = self.connect_multiple_networks(self.dut)
+ self.log.debug("Toggling wifi OFF")
+ wutils.wifi_toggle_state(self.dut, False)
+ time.sleep(DEFAULT_TIMEOUT)
+ self.dut.reboot()
+ time.sleep(DEFAULT_TIMEOUT)
+ self.log.debug("Toggling wifi ON")
+ wutils.wifi_toggle_state(self.dut, True)
+ time.sleep(DEFAULT_TIMEOUT)
+ self.check_configstore_networks(network_list)
+ reconnect_to = self.get_enabled_network(network_list[BAND_2GHZ],
+ network_list[BAND_5GHZ])
+ reconnect = self.reconnect_to_wifi_network(
+ reconnect_to[WifiEnums.NETID_KEY],
+ reconnect_to[WifiEnums.SSID_KEY])
+ if not reconnect:
+ msg = ("Device failed to reconnect to the correct network after"
+ " toggling WiFi and rebooting.")
+ raise signals.TestFailure(msg)
+
@acts.signals.generated_test
def test_iot_with_password(self):
params = list(