diff options
author | Hsiu-Chang Chen <hsiuchangchen@google.com> | 2023-03-16 10:52:45 +0800 |
---|---|---|
committer | Hsiu-Chang Chen <hsiuchangchen@google.com> | 2023-03-16 03:00:46 +0000 |
commit | 19e71b7dcf8b7065742c9fabca9dc78edf115274 (patch) | |
tree | e5184d7824da895e51429c4c7c7187cd5789c682 | |
parent | 25f46788943196215a15e2122e1c01a8921e5217 (diff) | |
download | connectivity-android-13.0.0_r82.tar.gz |
[WifiIOTConnectionTest] Prevent use a single scan result in a testandroid-13.0.0_r82android-13.0.0_r81android-13.0.0_r80android-13.0.0_r74android-13.0.0_r73android-13.0.0_r72android-13.0.0_r66android-13.0.0_r65android-13.0.0_r64android-13.0.0_r60android-13.0.0_r59android-13.0.0_r58android13-qpr3-c-s8-releaseandroid13-qpr3-c-s7-releaseandroid13-qpr3-c-s6-releaseandroid13-qpr3-c-s5-releaseandroid13-qpr3-c-s4-releaseandroid13-qpr3-c-s3-releaseandroid13-qpr3-c-s2-releaseandroid13-qpr3-c-s12-releaseandroid13-qpr3-c-s11-releaseandroid13-qpr3-c-s10-releaseandroid13-qpr3-c-s1-release
Currently, all conneciton interations use a same single scan result
to decide AP existed or not. It would cause test failures because
the test environment is a dense environment. Do wifi scans before
each interation to prevent this situation.
Bug: 254570241
Test: Verified locally
Change-Id: I7af89ffa59744fadba4aca8a1e71da9663e82bd5
-rw-r--r-- | acts_tests/tests/google/wifi/WifiIOTConnectionTest.py | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/acts_tests/tests/google/wifi/WifiIOTConnectionTest.py b/acts_tests/tests/google/wifi/WifiIOTConnectionTest.py index 98d9e0191..382c4deab 100644 --- a/acts_tests/tests/google/wifi/WifiIOTConnectionTest.py +++ b/acts_tests/tests/google/wifi/WifiIOTConnectionTest.py @@ -60,6 +60,7 @@ class WifiIOTConnectionTest(WifiBaseTest): def setup_test(self): self.dut.droid.wakeLockAcquireBright() self.dut.droid.wakeUpNow() + wutils.reset_wifi(self.dut) def teardown_test(self): self.dut.droid.wakeLockRelease() @@ -165,11 +166,6 @@ class WifiIOTConnectionTest(WifiBaseTest): .format(self.user_params["pdu_wait_time"])) time.sleep(self.user_params["pdu_wait_time"]) - def scan_wifi_list(self, network, test_item): - wutils.reset_wifi(self.dut) - scan_results = self.dut.droid.wifiGetScanResults() - return scan_results - def start_packet_capture(self, band, channel): """Configure wireless packet capture on pre-defined channels. @@ -197,24 +193,26 @@ class WifiIOTConnectionTest(WifiBaseTest): self.dut.log.error('Faild to ping public gateway 8.8.8.8') return False - def connect_to_network_and_ping(self, network, scan_results): + def connect_to_network_and_ping(self, network): ssid = network[WifiEnums.SSID_KEY] connection_pass = 0 for i in range(self.user_params['iot_connection_iteration']): self.dut.log.info('Connection iteration : {}'.format(i + 1)) - for ap in scan_results: - if ap['SSID'] == ssid: - wutils.wifi_connect(self.dut, network, num_of_tries=1, - check_connectivity=False) - time.sleep(WAIT_BETWEEN_ACTIONS) - self.rssi, self.link_speed, self.freq = self.get_wifi_info() - time.sleep(WAIT_BETWEEN_ACTIONS) - if self.ping_public_gateway_ip(): - connection_pass += 1 - wutils.wifi_forget_network(self.dut, ssid) - self.dut.log.info("connection_pass: {}" - .format(connection_pass)) - time.sleep(WAIT_BETWEEN_ACTIONS) + try: + wutils.connect_to_wifi_network(self.dut, network, + num_of_connect_tries=1, + check_connectivity=False) + time.sleep(WAIT_BETWEEN_ACTIONS) + self.rssi, self.link_speed, self.freq = self.get_wifi_info() + time.sleep(WAIT_BETWEEN_ACTIONS) + if self.ping_public_gateway_ip(): + connection_pass += 1 + wutils.wifi_forget_network(self.dut, ssid) + self.dut.log.info("connection_pass: {}" + .format(connection_pass)) + time.sleep(WAIT_BETWEEN_ACTIONS) + except: + self.dut.log.error("connection_fail") # Create a dictionary to store data in a json file. connection_result = {} @@ -282,8 +280,5 @@ class WifiIOTConnectionTest(WifiBaseTest): if hasattr(self, 'packet_capture'): self.start_packet_capture(self.band, self.channel) - # Scan Wi-Fi SSIDs once. - wifi_scan_list = self.scan_wifi_list(network, test_item) - # Connect to Wi-Fi network and ping public gateway for 5 times. - self.connect_to_network_and_ping(network, wifi_scan_list) + self.connect_to_network_and_ping(network) |