Bindu Mahadev | ae92381 | 2017-04-12 22:57:49 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python3.4 |
| 2 | |
| 3 | import queue |
| 4 | import time |
| 5 | |
| 6 | import acts.base_test |
| 7 | import acts.test_utils.wifi.wifi_test_utils as wifi_utils |
| 8 | import acts.test_utils.tel.tel_test_utils as tele_utils |
| 9 | import acts.utils |
| 10 | |
| 11 | from acts import asserts |
| 12 | from acts import signals |
Girish Moturu | 43faec8 | 2017-06-12 10:46:51 +0530 | [diff] [blame] | 13 | from acts.test_decorators import test_tracker_info |
Bindu Mahadev | ae92381 | 2017-04-12 22:57:49 +0000 | [diff] [blame] | 14 | from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest |
| 15 | from acts.test_utils.tel.tel_voice_utils import phone_setup_voice_general |
| 16 | from acts.test_utils.tel.tel_voice_utils import two_phone_call_short_seq |
| 17 | |
| 18 | WifiEnums = wifi_utils.WifiEnums |
| 19 | |
| 20 | ATTENUATORS = "attenuators" |
| 21 | WIFI_SSID = "wifi_network_ssid" |
| 22 | WIFI_PWD = "wifi_network_pass" |
| 23 | STRESS_COUNT = "stress_iteration" |
| 24 | |
| 25 | class WifiTeleCoexTest(TelephonyBaseTest): |
| 26 | """Tests for WiFi, Celular Co-existance.""" |
| 27 | |
| 28 | |
Bindu Mahadev | ae92381 | 2017-04-12 22:57:49 +0000 | [diff] [blame] | 29 | def setup_class(self): |
| 30 | TelephonyBaseTest.setup_class(self) |
Xianyuan Jia | 2a8522e | 2019-09-05 17:21:40 -0700 | [diff] [blame] | 31 | |
Bindu Mahadev | ae92381 | 2017-04-12 22:57:49 +0000 | [diff] [blame] | 32 | self.dut = self.android_devices[0] |
| 33 | wifi_utils.wifi_test_device_init(self.dut) |
| 34 | # Set attenuation to 0 on all channels. |
| 35 | if getattr(self, ATTENUATORS, []): |
| 36 | for a in self.attenuators: |
| 37 | a.set_atten(0) |
| 38 | self.ads = self.android_devices |
| 39 | self.dut = self.android_devices[0] |
| 40 | self.wifi_network_ssid = self.user_params.get(WIFI_SSID) |
| 41 | self.wifi_network_pass = self.user_params.get(WIFI_PWD) |
| 42 | self.network = { WifiEnums.SSID_KEY : self.wifi_network_ssid, |
| 43 | WifiEnums.PWD_KEY : self.wifi_network_pass |
| 44 | } |
| 45 | self.stress_count = self.user_params.get(STRESS_COUNT) |
| 46 | |
| 47 | |
| 48 | def setup_test(self): |
| 49 | wifi_utils.wifi_toggle_state(self.dut, True) |
| 50 | |
| 51 | |
| 52 | def teardown_test(self): |
| 53 | wifi_utils.reset_wifi(self.dut) |
| 54 | |
| 55 | |
| 56 | """Helper Functions""" |
| 57 | |
| 58 | |
| 59 | def connect_to_wifi(self, ad, network): |
| 60 | """Connection logic for open and psk wifi networks. |
| 61 | |
| 62 | Args: |
| 63 | ad: Android device object. |
| 64 | network: A JSON dict of the WiFi network configuration. |
| 65 | |
| 66 | """ |
| 67 | ad.ed.clear_all_events() |
| 68 | wifi_utils.start_wifi_connection_scan(ad) |
| 69 | scan_results = ad.droid.wifiGetScanResults() |
| 70 | wifi_utils.assert_network_in_list({WifiEnums.SSID_KEY: |
| 71 | self.wifi_network_ssid}, scan_results) |
| 72 | wifi_utils.wifi_connect(ad, network) |
| 73 | self.log.debug("Connected to %s network on %s device" % ( |
| 74 | network[WifiEnums.SSID_KEY], ad.serial)) |
| 75 | |
| 76 | |
| 77 | def stress_toggle_wifi(self, stress_count): |
| 78 | """Toggle WiFi in a loop. |
| 79 | |
| 80 | Args: |
| 81 | stress_count: Number of times to toggle WiFi OFF and ON. |
| 82 | |
| 83 | """ |
| 84 | for count in range(stress_count): |
| 85 | self.log.debug("stress_toggle_wifi: Iteration %d" % count) |
| 86 | wifi_utils.toggle_wifi_off_and_on(self.dut) |
| 87 | |
| 88 | if not self.dut.droid.wifiGetisWifiEnabled(): |
| 89 | raise signals.TestFailure("WiFi did not turn on after toggling it" |
| 90 | " %d times" % self.stress_count) |
| 91 | |
| 92 | |
| 93 | def stress_toggle_airplane(self, stress_count): |
| 94 | """Toggle Airplane mode in a loop. |
| 95 | |
| 96 | Args: |
| 97 | stress_count: Number of times to toggle Airplane mode OFF and ON. |
| 98 | |
| 99 | """ |
| 100 | for count in range(stress_count): |
| 101 | self.log.debug("stress_toggle_airplane: Iteration %d" % count) |
| 102 | wifi_utils.toggle_airplane_mode_on_and_off(self.dut) |
| 103 | |
| 104 | if not self.dut.droid.wifiGetisWifiEnabled(): |
| 105 | raise signals.TestFailure("WiFi did not turn on after toggling it" |
| 106 | " %d times" % self.stress_count) |
| 107 | |
| 108 | |
| 109 | def stress_toggle_airplane_and_wifi(self, stress_count): |
| 110 | """Toggle Airplane and WiFi modes in a loop. |
| 111 | |
| 112 | Args: |
| 113 | stress_count: Number of times to perform Airplane mode ON, WiFi ON, |
| 114 | Airplane mode OFF, in a sequence. |
| 115 | |
| 116 | """ |
lutina | 9f0a476 | 2019-08-30 17:06:06 +0800 | [diff] [blame] | 117 | for count in range(stress_count): |
| 118 | self.log.debug("stress_toggle_airplane_and_wifi: Iteration %d" % count) |
| 119 | self.log.debug("Toggling Airplane mode ON") |
| 120 | asserts.assert_true( |
| 121 | acts.utils.force_airplane_mode(self.dut, True), |
| 122 | "Can not turn on airplane mode on: %s" % self.dut.serial) |
| 123 | # Sleep for atleast 500ms so that, call to enable wifi is not deferred. |
| 124 | time.sleep(1) |
| 125 | self.log.debug("Toggling wifi ON") |
| 126 | wifi_utils.wifi_toggle_state(self.dut, True) |
| 127 | # Sleep for 1s before getting new WiFi state. |
| 128 | time.sleep(1) |
| 129 | if not self.dut.droid.wifiGetisWifiEnabled(): |
| 130 | raise signals.TestFailure("WiFi did not turn on after turning ON" |
| 131 | " Airplane mode") |
| 132 | asserts.assert_true( |
| 133 | acts.utils.force_airplane_mode(self.dut, False), |
| 134 | "Can not turn on airplane mode on: %s" % self.dut.serial) |
Bindu Mahadev | ae92381 | 2017-04-12 22:57:49 +0000 | [diff] [blame] | 135 | |
| 136 | if not self.dut.droid.wifiGetisWifiEnabled(): |
| 137 | raise signals.TestFailure("WiFi did not turn on after toggling it" |
| 138 | " %d times" % self.stress_count) |
| 139 | |
| 140 | |
| 141 | def setup_cellular_voice_calling(self): |
| 142 | """Setup phone for voice general calling and make sure phone is |
| 143 | attached to voice.""" |
| 144 | # Make sure Phone A and B are attached to voice network. |
| 145 | for ad in self.ads: |
| 146 | if not phone_setup_voice_general(self.log, ad): |
| 147 | raise signals.TestFailure("Phone failed to setup for voice" |
| 148 | " calling serial:%s" % ad.serial) |
| 149 | self.log.debug("Finished setting up phones for voice calling") |
| 150 | |
| 151 | |
| 152 | def validate_cellular_and_wifi(self): |
| 153 | """Validate WiFi, make some cellular calls. |
| 154 | |
| 155 | Steps: |
| 156 | 1. Check if device is still connected to the WiFi network. |
| 157 | 2. If WiFi looks good, check if deivce is attached to voice. |
| 158 | 3. Make a short sequence voice call between Phone A and B. |
| 159 | |
| 160 | """ |
lutina | 9f0a476 | 2019-08-30 17:06:06 +0800 | [diff] [blame] | 161 | # Sleep for 30s before getting new WiFi state. |
| 162 | time.sleep(30) |
Bindu Mahadev | ae92381 | 2017-04-12 22:57:49 +0000 | [diff] [blame] | 163 | wifi_info = self.dut.droid.wifiGetConnectionInfo() |
| 164 | if wifi_info[WifiEnums.SSID_KEY] != self.wifi_network_ssid: |
| 165 | raise signals.TestFailure("Phone failed to connect to %s network on" |
| 166 | " %s" % (self.wifi_network_ssid, |
| 167 | self.dut.serial)) |
| 168 | |
| 169 | # Make short call sequence between Phone A and Phone B. |
| 170 | two_phone_call_short_seq(self.log, self.ads[0], None, None, self.ads[1], |
| 171 | None, None) |
| 172 | |
| 173 | """Tests""" |
| 174 | |
| 175 | |
Girish Moturu | 43faec8 | 2017-06-12 10:46:51 +0530 | [diff] [blame] | 176 | @test_tracker_info(uuid="8b9b6fb9-964b-43e7-b75f-675774ee346f") |
Bindu Mahadev | ae92381 | 2017-04-12 22:57:49 +0000 | [diff] [blame] | 177 | @TelephonyBaseTest.tel_test_wrap |
| 178 | def test_toggle_wifi_call(self): |
| 179 | """Test to toggle WiFi and then perform WiFi connection and |
| 180 | cellular calls. |
| 181 | |
| 182 | Steps: |
| 183 | 1. Attach device to voice subscription network. |
| 184 | 2. Connect to a WiFi network. |
| 185 | 3. Toggle WiFi OFF and ON. |
| 186 | 4. Verify device auto-connects to the WiFi network. |
| 187 | 5. Verify device is attached to voice network. |
| 188 | 6. Make short sequence voice calls. |
| 189 | |
| 190 | """ |
| 191 | self.setup_cellular_voice_calling() |
| 192 | self.connect_to_wifi(self.dut, self.network) |
| 193 | wifi_utils.toggle_wifi_off_and_on(self.dut) |
| 194 | self.validate_cellular_and_wifi() |
Bindu Mahadev | 6077af2 | 2018-02-08 15:04:51 -0800 | [diff] [blame] | 195 | return True |
Bindu Mahadev | ae92381 | 2017-04-12 22:57:49 +0000 | [diff] [blame] | 196 | |
| 197 | |
Girish Moturu | 43faec8 | 2017-06-12 10:46:51 +0530 | [diff] [blame] | 198 | @test_tracker_info(uuid="caf22447-6354-4a2e-99e5-0ff235fc8f20") |
Bindu Mahadev | ae92381 | 2017-04-12 22:57:49 +0000 | [diff] [blame] | 199 | @TelephonyBaseTest.tel_test_wrap |
| 200 | def test_toggle_airplane_call(self): |
| 201 | """Test to toggle Airplane mode and perform WiFi connection and |
| 202 | cellular calls. |
| 203 | |
| 204 | Steps: |
| 205 | 1. Attach device to voice subscription network. |
| 206 | 2. Connect to a WiFi network. |
| 207 | 3. Toggle Airplane mode OFF and ON. |
| 208 | 4. Verify device auto-connects to the WiFi network. |
| 209 | 5. Verify device is attached to voice network. |
| 210 | 6. Make short sequence voice calls. |
| 211 | |
| 212 | """ |
| 213 | self.setup_cellular_voice_calling() |
| 214 | self.connect_to_wifi(self.dut, self.network) |
| 215 | wifi_utils.toggle_airplane_mode_on_and_off(self.dut) |
| 216 | self.validate_cellular_and_wifi() |
Bindu Mahadev | 6077af2 | 2018-02-08 15:04:51 -0800 | [diff] [blame] | 217 | return True |
Bindu Mahadev | ae92381 | 2017-04-12 22:57:49 +0000 | [diff] [blame] | 218 | |
| 219 | |
Girish Moturu | 43faec8 | 2017-06-12 10:46:51 +0530 | [diff] [blame] | 220 | @test_tracker_info(uuid="dd888b35-f820-409a-89af-4b0f6551e4d6") |
Bindu Mahadev | ae92381 | 2017-04-12 22:57:49 +0000 | [diff] [blame] | 221 | @TelephonyBaseTest.tel_test_wrap |
| 222 | def test_toggle_airplane_and_wifi_call(self): |
| 223 | """Test to toggle WiFi in a loop and perform WiFi connection and |
| 224 | cellular calls. |
| 225 | |
| 226 | Steps: |
| 227 | 1. Attach device to voice subscription network. |
| 228 | 2. Connect to a WiFi network. |
| 229 | 3. Toggle Airplane mode ON. |
| 230 | 4. Turn WiFi ON. |
| 231 | 5. Toggle Airplane mode OFF. |
| 232 | 3. Verify device auto-connects to the WiFi network. |
| 233 | 4. Verify device is attached to voice network. |
| 234 | 5. Make short sequence voice calls. |
| 235 | |
| 236 | """ |
| 237 | self.setup_cellular_voice_calling() |
| 238 | self.connect_to_wifi(self.dut, self.network) |
| 239 | self.stress_toggle_airplane_and_wifi(1) |
| 240 | self.validate_cellular_and_wifi() |
Bindu Mahadev | 6077af2 | 2018-02-08 15:04:51 -0800 | [diff] [blame] | 241 | return True |
Bindu Mahadev | ae92381 | 2017-04-12 22:57:49 +0000 | [diff] [blame] | 242 | |
| 243 | |
Girish Moturu | 43faec8 | 2017-06-12 10:46:51 +0530 | [diff] [blame] | 244 | @test_tracker_info(uuid="15db5b7e-827e-4bc8-8e77-7fcce343a323") |
Bindu Mahadev | ae92381 | 2017-04-12 22:57:49 +0000 | [diff] [blame] | 245 | @TelephonyBaseTest.tel_test_wrap |
| 246 | def test_stress_toggle_wifi_call(self): |
| 247 | """Stress test to toggle WiFi in a loop, then perform WiFi connection |
| 248 | and cellular calls. |
| 249 | |
| 250 | Steps: |
| 251 | 1. Attach device to voice subscription network. |
| 252 | 2. Connect to a WiFi network. |
| 253 | 3. Toggle WiFi OFF and ON in a loop. |
| 254 | 4. Verify device auto-connects to the WiFi network. |
| 255 | 5. Verify device is attached to voice network. |
| 256 | 6. Make short sequence voice calls. |
| 257 | |
| 258 | """ |
| 259 | self.setup_cellular_voice_calling() |
| 260 | self.connect_to_wifi(self.dut, self.network) |
| 261 | self.stress_toggle_wifi(self.stress_count) |
| 262 | self.validate_cellular_and_wifi() |
Bindu Mahadev | 6077af2 | 2018-02-08 15:04:51 -0800 | [diff] [blame] | 263 | return True |
Bindu Mahadev | ae92381 | 2017-04-12 22:57:49 +0000 | [diff] [blame] | 264 | |
| 265 | |
Girish Moturu | 43faec8 | 2017-06-12 10:46:51 +0530 | [diff] [blame] | 266 | @test_tracker_info(uuid="80a2f1bf-5e41-453a-9b8e-be3b41d4d313") |
Bindu Mahadev | ae92381 | 2017-04-12 22:57:49 +0000 | [diff] [blame] | 267 | @TelephonyBaseTest.tel_test_wrap |
| 268 | def test_stress_toggle_airplane_call(self): |
| 269 | """Stress test to toggle Airplane mode in a loop, then perform WiFi and |
| 270 | cellular calls. |
| 271 | |
| 272 | Steps: |
| 273 | 1. Attach device to voice subscription network. |
| 274 | 2. Connect to a WiFi network. |
| 275 | 3. Toggle Airplane mode OFF and ON in a loop. |
| 276 | 4. Verify device auto-connects to the WiFi network. |
| 277 | 5. Verify device is attached to voice network. |
| 278 | 6. Make short sequence voice calls. |
| 279 | |
| 280 | """ |
| 281 | self.setup_cellular_voice_calling() |
| 282 | self.connect_to_wifi(self.dut, self.network) |
| 283 | self.stress_toggle_airplane(self.stress_count) |
| 284 | self.validate_cellular_and_wifi() |
Bindu Mahadev | 6077af2 | 2018-02-08 15:04:51 -0800 | [diff] [blame] | 285 | return True |
Bindu Mahadev | ae92381 | 2017-04-12 22:57:49 +0000 | [diff] [blame] | 286 | |
| 287 | |
Girish Moturu | 43faec8 | 2017-06-12 10:46:51 +0530 | [diff] [blame] | 288 | @test_tracker_info(uuid="b88ad3e7-6462-4280-ad57-22d0ac91fdd8") |
Bindu Mahadev | ae92381 | 2017-04-12 22:57:49 +0000 | [diff] [blame] | 289 | @TelephonyBaseTest.tel_test_wrap |
| 290 | def test_stress_toggle_airplane_and_wifi_call(self): |
| 291 | """Stress test to toggle Airplane and WiFi mode in a loop, then perform |
| 292 | WiFi connection and cellular calls. |
| 293 | |
| 294 | Steps: |
| 295 | 1. Attach device to voice subscription network. |
| 296 | 2. Connect to a WiFi network. |
| 297 | 3. Toggle Airplane mode ON. |
| 298 | 4. Turn WiFi ON. |
| 299 | 5. Toggle Airplane mode OFF. |
| 300 | 6. Repeat 3, 4 & 5, in a loop. |
| 301 | 7. Verify device auto-connects to the WiFi network. |
| 302 | 8. Verify device is attached to voice network. |
| 303 | 9. Make short sequence voice calls. |
| 304 | |
| 305 | """ |
| 306 | self.setup_cellular_voice_calling() |
| 307 | self.connect_to_wifi(self.dut, self.network) |
Bindu Mahadev | 65d547e | 2017-05-19 23:58:32 +0000 | [diff] [blame] | 308 | self.stress_toggle_airplane_and_wifi(self.stress_count) |
Bindu Mahadev | ae92381 | 2017-04-12 22:57:49 +0000 | [diff] [blame] | 309 | self.validate_cellular_and_wifi() |
Bindu Mahadev | 6077af2 | 2018-02-08 15:04:51 -0800 | [diff] [blame] | 310 | return True |