Jaineel | 4e4a96a | 2020-12-03 15:11:10 -0800 | [diff] [blame^] | 1 | #!/usr/bin/env python3.4 |
| 2 | # |
| 3 | # Copyright 2020 - Google |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | """ |
| 17 | Test Script for 5G MMS scenarios |
| 18 | """ |
| 19 | |
| 20 | import time |
| 21 | |
| 22 | from acts.test_decorators import test_tracker_info |
| 23 | from acts_contrib.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest |
| 24 | from acts_contrib.test_utils.tel.tel_defines import WAIT_TIME_ANDROID_STATE_SETTLING |
| 25 | from acts_contrib.test_utils.tel.tel_defines import WFC_MODE_CELLULAR_PREFERRED |
| 26 | from acts_contrib.test_utils.tel.tel_defines import WFC_MODE_WIFI_PREFERRED |
| 27 | from acts_contrib.test_utils.tel.tel_test_utils import ensure_phones_idle |
| 28 | from acts_contrib.test_utils.tel.tel_test_utils import ensure_wifi_connected |
| 29 | from acts_contrib.test_utils.tel.tel_test_utils import call_setup_teardown |
| 30 | from acts_contrib.test_utils.tel.tel_test_utils import toggle_airplane_mode |
| 31 | from acts_contrib.test_utils.tel.tel_test_utils import mms_send_receive_verify |
| 32 | from acts_contrib.test_utils.tel.tel_test_utils import multithread_func |
| 33 | from acts_contrib.test_utils.tel.tel_voice_utils import phone_setup_volte |
| 34 | from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_volte |
| 35 | from acts_contrib.test_utils.tel.tel_voice_utils import phone_setup_iwlan |
| 36 | from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_iwlan |
| 37 | from acts_contrib.test_utils.tel.tel_5g_utils import is_current_network_5g_nsa |
| 38 | from acts_contrib.test_utils.tel.tel_5g_utils import set_preferred_mode_for_5g |
| 39 | from acts.utils import rand_ascii_str |
| 40 | |
| 41 | class Nsa5gMmsTest(TelephonyBaseTest): |
| 42 | def setup_class(self): |
| 43 | super().setup_class() |
| 44 | self.number_of_devices = 2 |
| 45 | self.message_lengths = (50, 160, 180) |
| 46 | |
| 47 | def setup_test(self): |
| 48 | TelephonyBaseTest.setup_test(self) |
| 49 | |
| 50 | def teardown_test(self): |
| 51 | ensure_phones_idle(self.log, self.android_devices) |
| 52 | |
| 53 | def _provision_both_devices_for_5g(self, ads): |
| 54 | # Mode Pref |
| 55 | tasks = [(set_preferred_mode_for_5g, [ad]) for ad in ads] |
| 56 | if not multithread_func(self.log, tasks): |
| 57 | self.log.error("Failed to set preferred network mode.") |
| 58 | return False |
| 59 | # Attach |
| 60 | tasks = [(is_current_network_5g_nsa, [ad]) for ad in ads] |
| 61 | if not multithread_func(self.log, tasks): |
| 62 | self.log.error("Phone not on 5G NSA before sending SMS.") |
| 63 | return False |
| 64 | |
| 65 | def _provision_both_devices_for_volte(self, ads): |
| 66 | # LTE attach and enable VoLTE on both phones |
| 67 | tasks = [(phone_setup_volte, (self.log, ads[0])), |
| 68 | (phone_setup_volte, (self.log, ads[1]))] |
| 69 | if not multithread_func(self.log, tasks): |
| 70 | self.log.error("Phone Failed to Set Up in VoLTE.") |
| 71 | return False |
| 72 | |
| 73 | def _provision_both_devices_for_wfc_cell_pref(self, ads, apm_mode=True): |
| 74 | tasks = [(phone_setup_iwlan, |
| 75 | (self.log, ads[0], apm_mode, WFC_MODE_CELLULAR_PREFERRED, |
| 76 | self.wifi_network_ssid, self.wifi_network_pass)), |
| 77 | (phone_setup_iwlan, |
| 78 | (self.log, ads[1], apm_mode, WFC_MODE_CELLULAR_PREFERRED, |
| 79 | self.wifi_network_ssid, self.wifi_network_pass))] |
| 80 | if not multithread_func(self.log, tasks): |
| 81 | self.log.error("Failed to setup in wfc_cell_pref mode") |
| 82 | return False |
| 83 | |
| 84 | def _provision_both_devices_for_wfc_wifi_pref(self, ads, apm_mode=False): |
| 85 | tasks = [(phone_setup_iwlan, |
| 86 | (self.log, ads[0], apm_mode, WFC_MODE_WIFI_PREFERRED, |
| 87 | self.wifi_network_ssid, self.wifi_network_pass)), |
| 88 | (phone_setup_iwlan, |
| 89 | (self.log, ads[1], apm_mode, WFC_MODE_WIFI_PREFERRED, |
| 90 | self.wifi_network_ssid, self.wifi_network_pass))] |
| 91 | if not multithread_func(self.log, tasks): |
| 92 | self.log.error("Failed to setup in wfc_wifi_pref mode") |
| 93 | return False |
| 94 | |
| 95 | def _verify_5g_attach_for_both_devices(self, ads): |
| 96 | # Attach |
| 97 | tasks = [(is_current_network_5g_nsa, [ad]) for ad in ads] |
| 98 | if not multithread_func(self.log, tasks): |
| 99 | self.log.error("Phone not on 5G NSA after sending SMS.") |
| 100 | return False |
| 101 | |
| 102 | def _disable_apm_mode_both_devices(self, ads): |
| 103 | # Turn off airplane mode |
| 104 | self.log.info("Turn off APM mode before starting testing.") |
| 105 | tasks = [(toggle_airplane_mode, (self.log, ads[0], False)), |
| 106 | (toggle_airplane_mode, (self.log, ads[1], False))] |
| 107 | if not multithread_func(self.log, tasks): |
| 108 | self.log.error("Failed to turn off airplane mode") |
| 109 | return False |
| 110 | |
| 111 | def _connect_both_devices_to_wifi(self, ads): |
| 112 | tasks = [(ensure_wifi_connected, (self.log, ad, |
| 113 | self.wifi_network_ssid, |
| 114 | self.wifi_network_pass)) |
| 115 | for ad in ads] |
| 116 | if not multithread_func(self.log, tasks): |
| 117 | self.log.error("Phone Failed to connect to wifi.") |
| 118 | return False |
| 119 | |
| 120 | def _mms_test_mo(self, ads, expected_result=True): |
| 121 | return self._mms_test( |
| 122 | [ads[0], ads[1]], expected_result=expected_result) |
| 123 | |
| 124 | def _mms_test_mt(self, ads, expected_result=True): |
| 125 | return self._mms_test( |
| 126 | [ads[1], ads[0]], expected_result=expected_result) |
| 127 | |
| 128 | def _mms_test(self, ads, expected_result=True): |
| 129 | """Test MMS between two phones. |
| 130 | |
| 131 | Returns: |
| 132 | True if success. |
| 133 | False if failed. |
| 134 | """ |
| 135 | for length in self.message_lengths: |
| 136 | message_array = [("Test Message", rand_ascii_str(length), None)] |
| 137 | if not mms_send_receive_verify( |
| 138 | self.log, |
| 139 | ads[0], |
| 140 | ads[1], |
| 141 | message_array, |
| 142 | expected_result=expected_result): |
| 143 | self.log.warning("MMS of body length %s test failed", length) |
| 144 | return False |
| 145 | else: |
| 146 | self.log.info("MMS of body length %s test succeeded", length) |
| 147 | self.log.info("MMS test of body lengths %s succeeded", |
| 148 | self.message_lengths) |
| 149 | return True |
| 150 | |
| 151 | |
| 152 | """ Tests Begin """ |
| 153 | |
| 154 | @test_tracker_info(uuid="bc484c2c-8086-42db-94cd-a1e4a35f35cf") |
| 155 | @TelephonyBaseTest.tel_test_wrap |
| 156 | def test_5g_nsa_mms_mo_mt(self): |
| 157 | """Test MMS between two phones in 5g NSA |
| 158 | |
| 159 | Provision devices in 5g NSA |
| 160 | Send and Verify MMS from PhoneA to PhoneB |
| 161 | Verify both devices are still on 5g NSA |
| 162 | |
| 163 | Returns: |
| 164 | True if success. |
| 165 | False if failed. |
| 166 | """ |
| 167 | ads = self.android_devices |
| 168 | if not self._provision_both_devices_for_5g(ads): |
| 169 | return False |
| 170 | |
| 171 | if not self._mms_test_mo(ads): |
| 172 | return False |
| 173 | |
| 174 | if not self._verify_5g_attach_for_both_devices(ads): |
| 175 | return False |
| 176 | |
| 177 | self.log.info("PASS - mms test over 5g nsa validated") |
| 178 | return True |
| 179 | |
| 180 | @test_tracker_info(uuid="51d42104-cb87-4c9b-9a16-302e246a21dc") |
| 181 | @TelephonyBaseTest.tel_test_wrap |
| 182 | def test_5g_nsa_mms_mo_mt_volte(self): |
| 183 | """Test MMS between two phones with VoLTE on 5G NSA |
| 184 | |
| 185 | Provision devices on VoLTE |
| 186 | Provision devices in 5g NSA |
| 187 | Send and Verify MMS from PhoneA to PhoneB |
| 188 | Verify both devices are still on 5g NSA |
| 189 | |
| 190 | Returns: |
| 191 | True if success. |
| 192 | False if failed. |
| 193 | """ |
| 194 | |
| 195 | ads = self.android_devices |
| 196 | if not self._provision_both_devices_for_volte(ads): |
| 197 | return False |
| 198 | |
| 199 | if not self._provision_both_devices_for_5g(ads): |
| 200 | return False |
| 201 | |
| 202 | if not self._mms_test_mo(ads): |
| 203 | return False |
| 204 | |
| 205 | if not self._verify_5g_attach_for_both_devices(ads): |
| 206 | return False |
| 207 | |
| 208 | self.log.info("PASS - volte mms test over 5g nsa validated") |
| 209 | return True |
| 210 | |
| 211 | @test_tracker_info(uuid="97d6b071-aef2-40c1-8245-7be6c31870a6") |
| 212 | @TelephonyBaseTest.tel_test_wrap |
| 213 | def test_5g_nsa_mms_mo_mt_in_call_volte(self): |
| 214 | """ Test MO MMS during a VoLTE call over 5G NSA. |
| 215 | |
| 216 | Provision devices on VoLTE |
| 217 | Provision devices in 5g NSA |
| 218 | Make a Voice call from PhoneA to PhoneB |
| 219 | Send and Verify MMS from PhoneA to PhoneB |
| 220 | Verify both devices are still on 5g NSA |
| 221 | |
| 222 | Returns: |
| 223 | True if pass; False if fail. |
| 224 | """ |
| 225 | ads = self.android_devices |
| 226 | if not self._provision_both_devices_for_volte(ads): |
| 227 | return False |
| 228 | |
| 229 | if not self._provision_both_devices_for_5g(ads): |
| 230 | return False |
| 231 | |
| 232 | self.log.info("Begin Incall mms test.") |
| 233 | if not call_setup_teardown( |
| 234 | self.log, |
| 235 | ads[0], |
| 236 | ads[1], |
| 237 | ad_hangup=None, |
| 238 | verify_caller_func=is_phone_in_call_volte, |
| 239 | verify_callee_func=None): |
| 240 | return False |
| 241 | |
| 242 | if not self._mms_test_mo(ads): |
| 243 | return False |
| 244 | |
| 245 | if not self._verify_5g_attach_for_both_devices(ads): |
| 246 | return False |
| 247 | self.log.info("PASS - Incall volte mms test over 5g nsa validated") |
| 248 | return True |
| 249 | |
| 250 | |
| 251 | @test_tracker_info(uuid="bbb4b80c-fc1b-4377-b3c7-eeed642c5980") |
| 252 | @TelephonyBaseTest.tel_test_wrap |
| 253 | def test_5g_nsa_mms_mo_mt_iwlan(self): |
| 254 | """ Test MMS text function between two phones, |
| 255 | Phones in APM, WiFi connected, WFC Cell Preferred mode. |
| 256 | |
| 257 | Disable APM on both devices |
| 258 | Provision devices in 5g NSA |
| 259 | Provision devices for WFC Cell Pref with APM ON |
| 260 | Send and Verify MMS from PhoneA to PhoneB |
| 261 | |
| 262 | Returns: |
| 263 | True if pass; False if fail. |
| 264 | """ |
| 265 | |
| 266 | ads = self.android_devices |
| 267 | if not self._disable_apm_mode_both_devices(ads): |
| 268 | return False |
| 269 | |
| 270 | if not self._provision_both_devices_for_5g(ads): |
| 271 | return False |
| 272 | |
| 273 | if not self._provision_both_devices_for_wfc_cell_pref(ads): |
| 274 | return False |
| 275 | time.sleep(WAIT_TIME_ANDROID_STATE_SETTLING) |
| 276 | |
| 277 | if not self._mms_test_mo(ads): |
| 278 | return False |
| 279 | |
| 280 | self.log.info("PASS - iwlan mms test over 5g nsa validated") |
| 281 | return True |
| 282 | |
| 283 | |
| 284 | @test_tracker_info(uuid="d36d95dc-0973-4711-bb08-c29ce23495e4") |
| 285 | @TelephonyBaseTest.tel_test_wrap |
| 286 | def test_5g_nsa_mms_mo_mt_iwlan_apm_off(self): |
| 287 | """ Test MO MMS, Phone in APM off, WiFi connected, WFC WiFi Pref Mode |
| 288 | |
| 289 | Disable APM on both devices |
| 290 | Provision devices in 5g NSA |
| 291 | Provision devices for WFC Wifi Pref with APM OFF |
| 292 | Send and Verify MMS from PhoneA to PhoneB |
| 293 | Verify 5g NSA attach for both devices |
| 294 | |
| 295 | Returns: |
| 296 | True if pass; False if fail. |
| 297 | """ |
| 298 | |
| 299 | ads = self.android_devices |
| 300 | if not self._disable_apm_mode_both_devices(ads): |
| 301 | return False |
| 302 | |
| 303 | if not self._provision_both_devices_for_5g(ads): |
| 304 | return False |
| 305 | |
| 306 | if not self._provision_both_devices_for_wfc_wifi_pref(ads): |
| 307 | return False |
| 308 | time.sleep(WAIT_TIME_ANDROID_STATE_SETTLING) |
| 309 | |
| 310 | if not self._mms_test_mo(ads): |
| 311 | self.log.error("Failed to send receive sms over 5g nsa") |
| 312 | return False |
| 313 | self.log.info("PASS - iwlan mms test over 5g nsa validated") |
| 314 | |
| 315 | if not self._verify_5g_attach_for_both_devices(ads): |
| 316 | return False |
| 317 | return True |
| 318 | |
| 319 | |
| 320 | @test_tracker_info(uuid="74ffb79e-f1e9-4087-a9d2-e07878e47869") |
| 321 | @TelephonyBaseTest.tel_test_wrap |
| 322 | def test_5g_nsa_mms_mo_mt_in_call_iwlan(self): |
| 323 | """ Test MO MMS, Phone in APM, WiFi connected, WFC WiFi Pref mode |
| 324 | |
| 325 | Disable APM on both devices |
| 326 | Provision devices in 5g NSA |
| 327 | Provision devices for WFC Wifi Pref with APM ON |
| 328 | Make a Voice call from PhoneA to PhoneB |
| 329 | Send and Verify MMS from PhoneA to PhoneB |
| 330 | |
| 331 | Returns: |
| 332 | True if pass; False if fail. |
| 333 | """ |
| 334 | |
| 335 | ads = self.android_devices |
| 336 | |
| 337 | if not self._disable_apm_mode_both_devices(ads): |
| 338 | return False |
| 339 | |
| 340 | if not self._provision_both_devices_for_5g(ads): |
| 341 | return False |
| 342 | |
| 343 | if not self._provision_both_devices_for_wfc_wifi_pref(ads, |
| 344 | apm_mode=True): |
| 345 | return False |
| 346 | time.sleep(WAIT_TIME_ANDROID_STATE_SETTLING) |
| 347 | |
| 348 | self.log.info("Begin Incall mms test") |
| 349 | if not call_setup_teardown( |
| 350 | self.log, |
| 351 | ads[0], |
| 352 | ads[1], |
| 353 | ad_hangup=None, |
| 354 | verify_caller_func=is_phone_in_call_iwlan, |
| 355 | verify_callee_func=None): |
| 356 | return False |
| 357 | |
| 358 | return self._mms_test_mo(ads) |
| 359 | |
| 360 | @test_tracker_info(uuid="68c8e0ca-bea4-45e4-92cf-19424ee47ca4") |
| 361 | @TelephonyBaseTest.tel_test_wrap |
| 362 | def test_5g_nsa_mms_mo_mt_in_call_volte_wifi(self): |
| 363 | """ Test MMS during VoLTE call and WiFi connected |
| 364 | |
| 365 | Make sure PhoneA/B are in 5G NSA (with VoLTE). |
| 366 | Make sure PhoneA/B are able to make/receive call. |
| 367 | Connect PhoneA/B to Wifi. |
| 368 | Call from PhoneA to PhoneB, accept on PhoneB, send MMS on PhoneA. |
| 369 | Make sure PhoneA/B are in 5G NSA. |
| 370 | |
| 371 | Returns: |
| 372 | True if pass; False if fail. |
| 373 | """ |
| 374 | ads = self.android_devices |
| 375 | if not self._provision_both_devices_for_volte(ads): |
| 376 | return False |
| 377 | |
| 378 | if not self._provision_both_devices_for_5g(ads): |
| 379 | return False |
| 380 | |
| 381 | if not self._connect_both_devices_to_wifi(ads): |
| 382 | return False |
| 383 | |
| 384 | self.log.info("Begin In Call MMS Test.") |
| 385 | if not call_setup_teardown( |
| 386 | self.log, |
| 387 | ads[0], |
| 388 | ads[1], |
| 389 | ad_hangup=None, |
| 390 | verify_caller_func=is_phone_in_call_volte, |
| 391 | verify_callee_func=None): |
| 392 | return False |
| 393 | |
| 394 | if not self._mms_test_mo(ads): |
| 395 | return False |
| 396 | |
| 397 | if not self._verify_5g_attach_for_both_devices(ads): |
| 398 | return False |
| 399 | return True |
| 400 | |
| 401 | """ Tests End """ |