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 |
Jaineel | 78a5715 | 2020-12-08 17:03:00 -0800 | [diff] [blame^] | 38 | from acts_contrib.test_utils.tel.tel_5g_utils import connect_both_devices_to_wifi |
| 39 | from acts_contrib.test_utils.tel.tel_5g_utils import provision_both_devices_for_5g |
| 40 | from acts_contrib.test_utils.tel.tel_5g_utils import provision_both_devices_for_volte |
| 41 | from acts_contrib.test_utils.tel.tel_5g_utils import provision_both_devices_for_wfc_cell_pref |
| 42 | from acts_contrib.test_utils.tel.tel_5g_utils import provision_both_devices_for_wfc_wifi_pref |
| 43 | from acts_contrib.test_utils.tel.tel_5g_utils import verify_5g_attach_for_both_devices |
| 44 | from acts_contrib.test_utils.tel.tel_5g_utils import disable_apm_mode_both_devices |
| 45 | |
Jaineel | 4e4a96a | 2020-12-03 15:11:10 -0800 | [diff] [blame] | 46 | from acts.utils import rand_ascii_str |
| 47 | |
| 48 | class Nsa5gMmsTest(TelephonyBaseTest): |
| 49 | def setup_class(self): |
| 50 | super().setup_class() |
| 51 | self.number_of_devices = 2 |
| 52 | self.message_lengths = (50, 160, 180) |
| 53 | |
| 54 | def setup_test(self): |
| 55 | TelephonyBaseTest.setup_test(self) |
| 56 | |
| 57 | def teardown_test(self): |
| 58 | ensure_phones_idle(self.log, self.android_devices) |
| 59 | |
Jaineel | 4e4a96a | 2020-12-03 15:11:10 -0800 | [diff] [blame] | 60 | |
| 61 | def _mms_test_mo(self, ads, expected_result=True): |
| 62 | return self._mms_test( |
| 63 | [ads[0], ads[1]], expected_result=expected_result) |
| 64 | |
| 65 | def _mms_test_mt(self, ads, expected_result=True): |
| 66 | return self._mms_test( |
| 67 | [ads[1], ads[0]], expected_result=expected_result) |
| 68 | |
| 69 | def _mms_test(self, ads, expected_result=True): |
| 70 | """Test MMS between two phones. |
| 71 | |
| 72 | Returns: |
| 73 | True if success. |
| 74 | False if failed. |
| 75 | """ |
| 76 | for length in self.message_lengths: |
| 77 | message_array = [("Test Message", rand_ascii_str(length), None)] |
| 78 | if not mms_send_receive_verify( |
| 79 | self.log, |
| 80 | ads[0], |
| 81 | ads[1], |
| 82 | message_array, |
| 83 | expected_result=expected_result): |
| 84 | self.log.warning("MMS of body length %s test failed", length) |
| 85 | return False |
| 86 | else: |
| 87 | self.log.info("MMS of body length %s test succeeded", length) |
| 88 | self.log.info("MMS test of body lengths %s succeeded", |
| 89 | self.message_lengths) |
| 90 | return True |
| 91 | |
| 92 | |
| 93 | """ Tests Begin """ |
| 94 | |
| 95 | @test_tracker_info(uuid="bc484c2c-8086-42db-94cd-a1e4a35f35cf") |
| 96 | @TelephonyBaseTest.tel_test_wrap |
| 97 | def test_5g_nsa_mms_mo_mt(self): |
| 98 | """Test MMS between two phones in 5g NSA |
| 99 | |
| 100 | Provision devices in 5g NSA |
| 101 | Send and Verify MMS from PhoneA to PhoneB |
| 102 | Verify both devices are still on 5g NSA |
| 103 | |
| 104 | Returns: |
| 105 | True if success. |
| 106 | False if failed. |
| 107 | """ |
| 108 | ads = self.android_devices |
Jaineel | 78a5715 | 2020-12-08 17:03:00 -0800 | [diff] [blame^] | 109 | if not provision_both_devices_for_5g(self.log, ads): |
Jaineel | 4e4a96a | 2020-12-03 15:11:10 -0800 | [diff] [blame] | 110 | return False |
| 111 | |
| 112 | if not self._mms_test_mo(ads): |
| 113 | return False |
| 114 | |
Jaineel | 78a5715 | 2020-12-08 17:03:00 -0800 | [diff] [blame^] | 115 | if not verify_5g_attach_for_both_devices(self.log, ads): |
Jaineel | 4e4a96a | 2020-12-03 15:11:10 -0800 | [diff] [blame] | 116 | return False |
| 117 | |
| 118 | self.log.info("PASS - mms test over 5g nsa validated") |
| 119 | return True |
| 120 | |
| 121 | @test_tracker_info(uuid="51d42104-cb87-4c9b-9a16-302e246a21dc") |
| 122 | @TelephonyBaseTest.tel_test_wrap |
| 123 | def test_5g_nsa_mms_mo_mt_volte(self): |
| 124 | """Test MMS between two phones with VoLTE on 5G NSA |
| 125 | |
| 126 | Provision devices on VoLTE |
| 127 | Provision devices in 5g NSA |
| 128 | Send and Verify MMS from PhoneA to PhoneB |
| 129 | Verify both devices are still on 5g NSA |
| 130 | |
| 131 | Returns: |
| 132 | True if success. |
| 133 | False if failed. |
| 134 | """ |
| 135 | |
| 136 | ads = self.android_devices |
Jaineel | 78a5715 | 2020-12-08 17:03:00 -0800 | [diff] [blame^] | 137 | if not provision_both_devices_for_volte(self.log, ads): |
Jaineel | 4e4a96a | 2020-12-03 15:11:10 -0800 | [diff] [blame] | 138 | return False |
| 139 | |
Jaineel | 78a5715 | 2020-12-08 17:03:00 -0800 | [diff] [blame^] | 140 | if not provision_both_devices_for_5g(self.log, ads): |
Jaineel | 4e4a96a | 2020-12-03 15:11:10 -0800 | [diff] [blame] | 141 | return False |
| 142 | |
| 143 | if not self._mms_test_mo(ads): |
| 144 | return False |
| 145 | |
Jaineel | 78a5715 | 2020-12-08 17:03:00 -0800 | [diff] [blame^] | 146 | if not verify_5g_attach_for_both_devices(self.log, ads): |
Jaineel | 4e4a96a | 2020-12-03 15:11:10 -0800 | [diff] [blame] | 147 | return False |
| 148 | |
| 149 | self.log.info("PASS - volte mms test over 5g nsa validated") |
| 150 | return True |
| 151 | |
| 152 | @test_tracker_info(uuid="97d6b071-aef2-40c1-8245-7be6c31870a6") |
| 153 | @TelephonyBaseTest.tel_test_wrap |
| 154 | def test_5g_nsa_mms_mo_mt_in_call_volte(self): |
| 155 | """ Test MO MMS during a VoLTE call over 5G NSA. |
| 156 | |
| 157 | Provision devices on VoLTE |
| 158 | Provision devices in 5g NSA |
| 159 | Make a Voice call from PhoneA to PhoneB |
| 160 | Send and Verify MMS from PhoneA to PhoneB |
| 161 | Verify both devices are still on 5g NSA |
| 162 | |
| 163 | Returns: |
| 164 | True if pass; False if fail. |
| 165 | """ |
| 166 | ads = self.android_devices |
Jaineel | 78a5715 | 2020-12-08 17:03:00 -0800 | [diff] [blame^] | 167 | if not provision_both_devices_for_volte(self.log, ads): |
Jaineel | 4e4a96a | 2020-12-03 15:11:10 -0800 | [diff] [blame] | 168 | return False |
| 169 | |
Jaineel | 78a5715 | 2020-12-08 17:03:00 -0800 | [diff] [blame^] | 170 | if not provision_both_devices_for_5g(self.log, ads): |
Jaineel | 4e4a96a | 2020-12-03 15:11:10 -0800 | [diff] [blame] | 171 | return False |
| 172 | |
| 173 | self.log.info("Begin Incall mms test.") |
| 174 | if not call_setup_teardown( |
| 175 | self.log, |
| 176 | ads[0], |
| 177 | ads[1], |
| 178 | ad_hangup=None, |
| 179 | verify_caller_func=is_phone_in_call_volte, |
| 180 | verify_callee_func=None): |
| 181 | return False |
| 182 | |
| 183 | if not self._mms_test_mo(ads): |
| 184 | return False |
| 185 | |
Jaineel | 78a5715 | 2020-12-08 17:03:00 -0800 | [diff] [blame^] | 186 | if not verify_5g_attach_for_both_devices(self.log, ads): |
Jaineel | 4e4a96a | 2020-12-03 15:11:10 -0800 | [diff] [blame] | 187 | return False |
| 188 | self.log.info("PASS - Incall volte mms test over 5g nsa validated") |
| 189 | return True |
| 190 | |
| 191 | |
| 192 | @test_tracker_info(uuid="bbb4b80c-fc1b-4377-b3c7-eeed642c5980") |
| 193 | @TelephonyBaseTest.tel_test_wrap |
| 194 | def test_5g_nsa_mms_mo_mt_iwlan(self): |
| 195 | """ Test MMS text function between two phones, |
| 196 | Phones in APM, WiFi connected, WFC Cell Preferred mode. |
| 197 | |
| 198 | Disable APM on both devices |
| 199 | Provision devices in 5g NSA |
| 200 | Provision devices for WFC Cell Pref with APM ON |
| 201 | Send and Verify MMS from PhoneA to PhoneB |
| 202 | |
| 203 | Returns: |
| 204 | True if pass; False if fail. |
| 205 | """ |
| 206 | |
| 207 | ads = self.android_devices |
Jaineel | 78a5715 | 2020-12-08 17:03:00 -0800 | [diff] [blame^] | 208 | if not disable_apm_mode_both_devices(self.log, ads): |
Jaineel | 4e4a96a | 2020-12-03 15:11:10 -0800 | [diff] [blame] | 209 | return False |
| 210 | |
Jaineel | 78a5715 | 2020-12-08 17:03:00 -0800 | [diff] [blame^] | 211 | if not provision_both_devices_for_5g(self.log, ads): |
Jaineel | 4e4a96a | 2020-12-03 15:11:10 -0800 | [diff] [blame] | 212 | return False |
| 213 | |
Jaineel | 78a5715 | 2020-12-08 17:03:00 -0800 | [diff] [blame^] | 214 | if not provision_both_devices_for_wfc_cell_pref(self.log, |
| 215 | ads, |
| 216 | self.wifi_network_ssid, |
| 217 | self.wifi_network_pass, |
| 218 | apm_mode=True): |
Jaineel | 4e4a96a | 2020-12-03 15:11:10 -0800 | [diff] [blame] | 219 | return False |
| 220 | time.sleep(WAIT_TIME_ANDROID_STATE_SETTLING) |
| 221 | |
| 222 | if not self._mms_test_mo(ads): |
| 223 | return False |
| 224 | |
| 225 | self.log.info("PASS - iwlan mms test over 5g nsa validated") |
| 226 | return True |
| 227 | |
| 228 | |
| 229 | @test_tracker_info(uuid="d36d95dc-0973-4711-bb08-c29ce23495e4") |
| 230 | @TelephonyBaseTest.tel_test_wrap |
| 231 | def test_5g_nsa_mms_mo_mt_iwlan_apm_off(self): |
| 232 | """ Test MO MMS, Phone in APM off, WiFi connected, WFC WiFi Pref Mode |
| 233 | |
| 234 | Disable APM on both devices |
| 235 | Provision devices in 5g NSA |
| 236 | Provision devices for WFC Wifi Pref with APM OFF |
| 237 | Send and Verify MMS from PhoneA to PhoneB |
| 238 | Verify 5g NSA attach for both devices |
| 239 | |
| 240 | Returns: |
| 241 | True if pass; False if fail. |
| 242 | """ |
| 243 | |
| 244 | ads = self.android_devices |
Jaineel | 78a5715 | 2020-12-08 17:03:00 -0800 | [diff] [blame^] | 245 | if not disable_apm_mode_both_devices(self.log, ads): |
Jaineel | 4e4a96a | 2020-12-03 15:11:10 -0800 | [diff] [blame] | 246 | return False |
| 247 | |
Jaineel | 78a5715 | 2020-12-08 17:03:00 -0800 | [diff] [blame^] | 248 | if not provision_both_devices_for_5g(self.log, ads): |
Jaineel | 4e4a96a | 2020-12-03 15:11:10 -0800 | [diff] [blame] | 249 | return False |
| 250 | |
Jaineel | 78a5715 | 2020-12-08 17:03:00 -0800 | [diff] [blame^] | 251 | if not provision_both_devices_for_wfc_wifi_pref(self.log, |
| 252 | ads, |
| 253 | self.wifi_network_ssid, |
| 254 | self.wifi_network_pass, |
| 255 | apm_mode=False): |
Jaineel | 4e4a96a | 2020-12-03 15:11:10 -0800 | [diff] [blame] | 256 | return False |
| 257 | time.sleep(WAIT_TIME_ANDROID_STATE_SETTLING) |
| 258 | |
| 259 | if not self._mms_test_mo(ads): |
| 260 | self.log.error("Failed to send receive sms over 5g nsa") |
| 261 | return False |
| 262 | self.log.info("PASS - iwlan mms test over 5g nsa validated") |
| 263 | |
Jaineel | 78a5715 | 2020-12-08 17:03:00 -0800 | [diff] [blame^] | 264 | if not verify_5g_attach_for_both_devices(self.log, ads): |
Jaineel | 4e4a96a | 2020-12-03 15:11:10 -0800 | [diff] [blame] | 265 | return False |
| 266 | return True |
| 267 | |
| 268 | |
| 269 | @test_tracker_info(uuid="74ffb79e-f1e9-4087-a9d2-e07878e47869") |
| 270 | @TelephonyBaseTest.tel_test_wrap |
| 271 | def test_5g_nsa_mms_mo_mt_in_call_iwlan(self): |
| 272 | """ Test MO MMS, Phone in APM, WiFi connected, WFC WiFi Pref mode |
| 273 | |
| 274 | Disable APM on both devices |
| 275 | Provision devices in 5g NSA |
| 276 | Provision devices for WFC Wifi Pref with APM ON |
| 277 | Make a Voice call from PhoneA to PhoneB |
| 278 | Send and Verify MMS from PhoneA to PhoneB |
| 279 | |
| 280 | Returns: |
| 281 | True if pass; False if fail. |
| 282 | """ |
| 283 | |
| 284 | ads = self.android_devices |
| 285 | |
Jaineel | 78a5715 | 2020-12-08 17:03:00 -0800 | [diff] [blame^] | 286 | if not disable_apm_mode_both_devices(self.log, ads): |
Jaineel | 4e4a96a | 2020-12-03 15:11:10 -0800 | [diff] [blame] | 287 | return False |
| 288 | |
Jaineel | 78a5715 | 2020-12-08 17:03:00 -0800 | [diff] [blame^] | 289 | if not provision_both_devices_for_5g(self.log, ads): |
Jaineel | 4e4a96a | 2020-12-03 15:11:10 -0800 | [diff] [blame] | 290 | return False |
| 291 | |
Jaineel | 78a5715 | 2020-12-08 17:03:00 -0800 | [diff] [blame^] | 292 | if not provision_both_devices_for_wfc_wifi_pref(self.log, |
| 293 | ads, |
| 294 | self.wifi_network_ssid, |
| 295 | self.wifi_network_pass, |
| 296 | apm_mode=True): |
Jaineel | 4e4a96a | 2020-12-03 15:11:10 -0800 | [diff] [blame] | 297 | return False |
| 298 | time.sleep(WAIT_TIME_ANDROID_STATE_SETTLING) |
| 299 | |
| 300 | self.log.info("Begin Incall mms test") |
| 301 | if not call_setup_teardown( |
| 302 | self.log, |
| 303 | ads[0], |
| 304 | ads[1], |
| 305 | ad_hangup=None, |
| 306 | verify_caller_func=is_phone_in_call_iwlan, |
| 307 | verify_callee_func=None): |
| 308 | return False |
| 309 | |
| 310 | return self._mms_test_mo(ads) |
| 311 | |
| 312 | @test_tracker_info(uuid="68c8e0ca-bea4-45e4-92cf-19424ee47ca4") |
| 313 | @TelephonyBaseTest.tel_test_wrap |
| 314 | def test_5g_nsa_mms_mo_mt_in_call_volte_wifi(self): |
| 315 | """ Test MMS during VoLTE call and WiFi connected |
| 316 | |
| 317 | Make sure PhoneA/B are in 5G NSA (with VoLTE). |
| 318 | Make sure PhoneA/B are able to make/receive call. |
| 319 | Connect PhoneA/B to Wifi. |
| 320 | Call from PhoneA to PhoneB, accept on PhoneB, send MMS on PhoneA. |
| 321 | Make sure PhoneA/B are in 5G NSA. |
| 322 | |
| 323 | Returns: |
| 324 | True if pass; False if fail. |
| 325 | """ |
| 326 | ads = self.android_devices |
Jaineel | 78a5715 | 2020-12-08 17:03:00 -0800 | [diff] [blame^] | 327 | if not provision_both_devices_for_volte(self.log, ads): |
Jaineel | 4e4a96a | 2020-12-03 15:11:10 -0800 | [diff] [blame] | 328 | return False |
| 329 | |
Jaineel | 78a5715 | 2020-12-08 17:03:00 -0800 | [diff] [blame^] | 330 | if not provision_both_devices_for_5g(self.log, ads): |
Jaineel | 4e4a96a | 2020-12-03 15:11:10 -0800 | [diff] [blame] | 331 | return False |
| 332 | |
Jaineel | 78a5715 | 2020-12-08 17:03:00 -0800 | [diff] [blame^] | 333 | if not connect_both_devices_to_wifi(self.log, |
| 334 | ads, |
| 335 | self.wifi_network_ssid, |
| 336 | self.wifi_network_pass): |
Jaineel | 4e4a96a | 2020-12-03 15:11:10 -0800 | [diff] [blame] | 337 | return False |
| 338 | |
| 339 | self.log.info("Begin In Call MMS Test.") |
| 340 | if not call_setup_teardown( |
| 341 | self.log, |
| 342 | ads[0], |
| 343 | ads[1], |
| 344 | ad_hangup=None, |
| 345 | verify_caller_func=is_phone_in_call_volte, |
| 346 | verify_callee_func=None): |
| 347 | return False |
| 348 | |
| 349 | if not self._mms_test_mo(ads): |
| 350 | return False |
| 351 | |
Jaineel | 78a5715 | 2020-12-08 17:03:00 -0800 | [diff] [blame^] | 352 | if not verify_5g_attach_for_both_devices(self.log, ads): |
Jaineel | 4e4a96a | 2020-12-03 15:11:10 -0800 | [diff] [blame] | 353 | return False |
| 354 | return True |
| 355 | |
| 356 | """ Tests End """ |