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