diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2019-08-10 23:03:43 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2019-08-10 23:03:43 +0000 |
commit | ee87643ec501d335a927c7c293c9623a7361f923 (patch) | |
tree | a58ce471667dfecc399a5a7d0dba0cf3d0bc7f2b | |
parent | bb46b45493f3e6b382ece38bcef50b97815e8355 (diff) | |
parent | f0e73b430bcc486f16cde16b273d5fd7133865f3 (diff) | |
download | platform_tools_test_connectivity-android10-qpr1-d-release.tar.gz platform_tools_test_connectivity-android10-qpr1-d-release.tar.bz2 platform_tools_test_connectivity-android10-qpr1-d-release.zip |
Snap for 5794870 from f0e73b430bcc486f16cde16b273d5fd7133865f3 to qt-qpr1-releaseandroid-10.0.0_r29android-10.0.0_r28android-10.0.0_r27android-10.0.0_r26android-10.0.0_r25android-10.0.0_r24android-10.0.0_r23android-10.0.0_r22android-10.0.0_r21android-10.0.0_r20android-10.0.0_r19android-10.0.0_r18android-10.0.0_r16android-10.0.0_r15android10-qpr1-releaseandroid10-qpr1-d-releaseandroid10-qpr1-c-s1-releaseandroid10-qpr1-c-releaseandroid10-qpr1-b-s1-releaseandroid10-qpr1-b-release
Change-Id: I6d7e5ae58484bdbb8c00b67c340884de1b085505
-rwxr-xr-x | acts/framework/acts/test_utils/wifi/wifi_test_utils.py | 13 | ||||
-rwxr-xr-x | acts/tests/google/wifi/WifiNetworkSuggestionTest.py | 148 |
2 files changed, 77 insertions, 84 deletions
diff --git a/acts/framework/acts/test_utils/wifi/wifi_test_utils.py b/acts/framework/acts/test_utils/wifi/wifi_test_utils.py index b2ae9a4808..6e29e61243 100755 --- a/acts/framework/acts/test_utils/wifi/wifi_test_utils.py +++ b/acts/framework/acts/test_utils/wifi/wifi_test_utils.py @@ -44,7 +44,6 @@ DEFAULT_TIMEOUT = 10 SHORT_TIMEOUT = 30 ROAMING_TIMEOUT = 30 WIFI_CONNECTION_TIMEOUT_DEFAULT = 30 -WIFI_ABNORMAL_CONNECTION_TIME = 10 # Speed of light in m/s. SPEED_OF_LIGHT = 299792458 @@ -1166,9 +1165,7 @@ def _wait_for_connect_event(ad, ssid=None, id=None, tries=1): if id is None and ssid is None: for i in range(tries): try: - start = time.time() conn_result = ad.ed.pop_event(wifi_constants.WIFI_CONNECTED, 30) - _assert_connection_time(start) break except Empty: pass @@ -1176,25 +1173,16 @@ def _wait_for_connect_event(ad, ssid=None, id=None, tries=1): # If ssid or network id is specified, wait for specific connect event. for i in range(tries): try: - start = time.time() conn_result = ad.ed.pop_event(wifi_constants.WIFI_CONNECTED, 30) if id and conn_result['data'][WifiEnums.NETID_KEY] == id: - _assert_connection_time(start) break elif ssid and conn_result['data'][WifiEnums.SSID_KEY] == ssid: - _assert_connection_time(start) break except Empty: pass return conn_result -def _assert_connection_time(start): - duration = time.time() - start - asserts.assert_true( - duration < WIFI_ABNORMAL_CONNECTION_TIME, - "Took " + str(duration) + "s to connect to network, " + - " expected " + str(WIFI_ABNORMAL_CONNECTION_TIME)) def wait_for_disconnect(ad, timeout=10): """Wait for a disconnect event within the specified timeout. @@ -1430,6 +1418,7 @@ def _wifi_connect_by_id(ad, network_id, num_of_tries=1): finally: ad.droid.wifiStopTrackingStateChange() + def wifi_connect_using_network_request(ad, network, network_specifier, num_of_tries=3, assert_on_fail=True): """Connect an Android device to a wifi network using network request. diff --git a/acts/tests/google/wifi/WifiNetworkSuggestionTest.py b/acts/tests/google/wifi/WifiNetworkSuggestionTest.py index 6d97c7e247..275dee5b39 100755 --- a/acts/tests/google/wifi/WifiNetworkSuggestionTest.py +++ b/acts/tests/google/wifi/WifiNetworkSuggestionTest.py @@ -57,10 +57,10 @@ class WifiNetworkSuggestionTest(WifiBaseTest): def setup_class(self): self.dut = self.android_devices[0] wutils.wifi_test_device_init(self.dut) - req_params = ["radius_conf_2g", "radius_conf_5g", "ca_cert", - "eap_identity", "eap_password",] + req_params = [] opt_param = [ - "open_network", "reference_networks" + "open_network", "reference_networks", "radius_conf_2g", "radius_conf_5g", "ca_cert", + "eap_identity", "eap_password", "hidden_networks" ] self.unpack_userparams( req_param_names=req_params, opt_param_names=opt_param) @@ -74,24 +74,29 @@ class WifiNetworkSuggestionTest(WifiBaseTest): asserts.assert_true( len(self.reference_networks) > 0, "Need at least one reference network with psk.") - self.wpa_psk_2g = self.reference_networks[0]["2g"] - self.wpa_psk_5g = self.reference_networks[0]["5g"] - self.open_2g = self.open_network[0]["2g"] - self.open_5g = self.open_network[0]["5g"] - self.ent_network_2g = self.ent_networks[0]["2g"] - self.ent_network_5g = self.ent_networks[0]["5g"] - self.config_aka = { - Ent.EAP: int(EAP.AKA), - WifiEnums.SSID_KEY: self.ent_network_2g[WifiEnums.SSID_KEY], - } - self.config_ttls = { - Ent.EAP: int(EAP.TTLS), - Ent.CA_CERT: self.ca_cert, - Ent.IDENTITY: self.eap_identity, - Ent.PASSWORD: self.eap_password, - Ent.PHASE2: int(EapPhase2.MSCHAPV2), - WifiEnums.SSID_KEY: self.ent_network_2g[WifiEnums.SSID_KEY], - } + if hasattr(self, "reference_networks"): + self.wpa_psk_2g = self.reference_networks[0]["2g"] + self.wpa_psk_5g = self.reference_networks[0]["5g"] + if hasattr(self, "open_network"): + self.open_2g = self.open_network[0]["2g"] + self.open_5g = self.open_network[0]["5g"] + if hasattr(self, "ent_networks"): + self.ent_network_2g = self.ent_networks[0]["2g"] + self.ent_network_5g = self.ent_networks[0]["5g"] + self.config_aka = { + Ent.EAP: int(EAP.AKA), + WifiEnums.SSID_KEY: self.ent_network_2g[WifiEnums.SSID_KEY], + } + self.config_ttls = { + Ent.EAP: int(EAP.TTLS), + Ent.CA_CERT: self.ca_cert, + Ent.IDENTITY: self.eap_identity, + Ent.PASSWORD: self.eap_password, + Ent.PHASE2: int(EapPhase2.MSCHAPV2), + WifiEnums.SSID_KEY: self.ent_network_2g[WifiEnums.SSID_KEY], + } + if hasattr(self, "hidden_networks"): + self.hidden_network = self.hidden_networks[0] self.dut.droid.wifiRemoveNetworkSuggestions([]) def setup_test(self): @@ -173,6 +178,26 @@ class WifiNetworkSuggestionTest(WifiBaseTest): self.dut.droid.wifiStopTrackingNetworkSuggestionStateChange() self.dut.ed.clear_all_events() + def remove_suggestions_disconnect_and_ensure_no_connection_back(self, + network_suggestions, + expected_ssid): + self.dut.log.info("Removing network suggestions") + asserts.assert_true( + self.dut.droid.wifiRemoveNetworkSuggestions(network_suggestions), + "Failed to remove suggestions") + # Ensure we did not disconnect + wutils.ensure_no_disconnect(self.dut) + + # Trigger a disconnect and wait for the disconnect. + self.dut.droid.wifiDisconnect() + wutils.wait_for_disconnect(self.dut) + self.dut.ed.clear_all_events() + + # Now ensure that we didn't connect back. + asserts.assert_false( + wutils.wait_for_connect(self.dut, expected_ssid, assert_on_fail=False), + "Device should not connect back") + def _test_connect_to_wifi_network_reboot_config_store(self, network_suggestions, wifi_network): @@ -192,20 +217,8 @@ class WifiNetworkSuggestionTest(WifiBaseTest): wutils.wait_for_connect(self.dut, wifi_network[WifiEnums.SSID_KEY]) - # Remove suggestion trigger disconnect and wait for the disconnect. - self.dut.log.info("Removing network suggestions") - asserts.assert_true( - self.dut.droid.wifiRemoveNetworkSuggestions(network_suggestions), - "Failed to remove suggestions") - wutils.wait_for_disconnect(self.dut) - self.dut.ed.clear_all_events() - - # Now ensure that we didn't connect back. - asserts.assert_false( - wutils.wait_for_connect(self.dut, - wifi_network[WifiEnums.SSID_KEY], - assert_on_fail=False), - "Device should not connect back") + self.remove_suggestions_disconnect_and_ensure_no_connection_back( + network_suggestions, wifi_network[WifiEnums.SSID_KEY]) @test_tracker_info(uuid="bda8ed20-4382-4380-831a-64cf77eca108") def test_connect_to_wpa_psk_2g(self): @@ -222,20 +235,8 @@ class WifiNetworkSuggestionTest(WifiBaseTest): [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY], False) - # Remove suggestion trigger disconnect and wait for the disconnect. - self.dut.log.info("Removing network suggestions"); - asserts.assert_true( - self.dut.droid.wifiRemoveNetworkSuggestions([self.wpa_psk_2g]), - "Failed to remove suggestions") - wutils.wait_for_disconnect(self.dut) - self.dut.ed.clear_all_events() - - # Now ensure that we didn't connect back. - asserts.assert_false( - wutils.wait_for_connect(self.dut, - self.wpa_psk_2g[WifiEnums.SSID_KEY], - assert_on_fail=False), - "Device should not connect back") + self.remove_suggestions_disconnect_and_ensure_no_connection_back( + [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY]) @test_tracker_info(uuid="f54bc250-d9e9-4f00-8b5b-b866e8550b43") def test_connect_to_highest_priority(self): @@ -262,13 +263,8 @@ class WifiNetworkSuggestionTest(WifiBaseTest): self.wpa_psk_2g[WifiEnums.SSID_KEY], None) - # Remove all suggestions trigger disconnect and wait for the disconnect. - self.dut.log.info("Removing network suggestions") - asserts.assert_true( - self.dut.droid.wifiRemoveNetworkSuggestions([]), - "Failed to remove suggestions") - wutils.wait_for_disconnect(self.dut) - self.dut.ed.clear_all_events() + self.remove_suggestions_disconnect_and_ensure_no_connection_back( + [], self.wpa_psk_2g[WifiEnums.SSID_KEY]) # Reverse the priority. # Add suggestions & wait for the connection event. @@ -296,21 +292,8 @@ class WifiNetworkSuggestionTest(WifiBaseTest): self.add_suggestions_and_ensure_connection( [network_suggestion], self.wpa_psk_2g[WifiEnums.SSID_KEY], True) - - # Remove suggestion trigger disconnect and wait for the disconnect. - self.dut.log.info("Removing network suggestions"); - asserts.assert_true( - self.dut.droid.wifiRemoveNetworkSuggestions([network_suggestion]), - "Failed to remove suggestions") - wutils.wait_for_disconnect(self.dut) - self.dut.ed.clear_all_events() - - # Now ensure that we didn't connect back. - asserts.assert_false( - wutils.wait_for_connect(self.dut, - self.wpa_psk_2g[WifiEnums.SSID_KEY], - assert_on_fail=False), - "Device should not connect back") + self.remove_suggestions_disconnect_and_ensure_no_connection_back( + [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY]) @test_tracker_info(uuid="a036a24d-29c0-456d-ae6a-afdde34da710") def test_connect_to_wpa_psk_5g_reboot_config_store(self): @@ -439,7 +422,7 @@ class WifiNetworkSuggestionTest(WifiBaseTest): [network_suggestion], self.wpa_psk_2g[WifiEnums.SSID_KEY], True) - # Simulate user forgeting the ephemeral network. + # Simulate user forgetting the ephemeral network. self.dut.droid.wifiDisableEphemeralNetwork( self.wpa_psk_2g[WifiEnums.SSID_KEY]) wutils.wait_for_disconnect(self.dut) @@ -453,3 +436,24 @@ class WifiNetworkSuggestionTest(WifiBaseTest): self.wpa_psk_2g[WifiEnums.SSID_KEY], assert_on_fail=False), "Device should not connect back") + + @test_tracker_info(uuid="93c86b05-fa56-4d79-ad27-009a16f691b1") + def test_connect_to_hidden_network(self): + """ + Adds a network suggestion with hidden SSID config, ensure device can scan + and connect to this network. + + Steps: + 1. Send a hidden network suggestion to the device. + 2. Wait for the device to connect to it. + 3. Ensure that we did not receive the post connection broadcast + (isAppInteractionRequired = False). + 4. Remove the suggestions and ensure the device does not connect back. + """ + asserts.skip_if(not hasattr(self, "hidden_networks"), "No hidden networks, skip this test") + + network_suggestion = self.hidden_network + self.add_suggestions_and_ensure_connection( + [network_suggestion], network_suggestion[WifiEnums.SSID_KEY], False) + self.remove_suggestions_disconnect_and_ensure_no_connection_back( + [network_suggestion], network_suggestion[WifiEnums.SSID_KEY]) |