1 #!/usr/bin/env python3.4 2 # 3 # Copyright 2016 - 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 Telephony Settings 18 """ 19 20 import time 21 from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest 22 from acts.test_utils.tel.tel_defines import MAX_WAIT_TIME_WIFI_CONNECTION 23 from acts.test_utils.tel.tel_defines import NETWORK_SERVICE_DATA 24 from acts.test_utils.tel.tel_defines import MAX_WAIT_TIME_IMS_REGISTRATION 25 from acts.test_utils.tel.tel_defines import MAX_WAIT_TIME_VOLTE_ENABLED 26 from acts.test_utils.tel.tel_defines import MAX_WAIT_TIME_WFC_ENABLED 27 from acts.test_utils.tel.tel_defines import RAT_FAMILY_WLAN 28 from acts.test_utils.tel.tel_defines import WFC_MODE_CELLULAR_PREFERRED 29 from acts.test_utils.tel.tel_defines import WFC_MODE_DISABLED 30 from acts.test_utils.tel.tel_defines import WFC_MODE_WIFI_PREFERRED 31 from acts.test_utils.tel.tel_test_utils import ensure_wifi_connected 32 from acts.test_utils.tel.tel_test_utils import is_droid_in_rat_family 33 from acts.test_utils.tel.tel_test_utils import is_wfc_enabled 34 from acts.test_utils.tel.tel_test_utils import set_wfc_mode 35 from acts.test_utils.tel.tel_test_utils import toggle_airplane_mode 36 from acts.test_utils.tel.tel_test_utils import toggle_volte 37 from acts.test_utils.tel.tel_test_utils import verify_http_connection 38 from acts.test_utils.tel.tel_test_utils import wait_for_ims_registered 39 from acts.test_utils.tel.tel_test_utils import wait_for_network_rat 40 from acts.test_utils.tel.tel_test_utils import wait_for_not_network_rat 41 from acts.test_utils.tel.tel_test_utils import wait_for_volte_enabled 42 from acts.test_utils.tel.tel_test_utils import wait_for_wfc_disabled 43 from acts.test_utils.tel.tel_test_utils import wait_for_wfc_enabled 44 from acts.test_utils.tel.tel_test_utils import wait_for_wifi_data_connection 45 from acts.test_utils.tel.tel_test_utils import WifiUtils 46 from acts.test_utils.tel.tel_voice_utils import phone_setup_voice_3g 47 from acts.test_utils.tel.tel_voice_utils import phone_setup_csfb 48 from acts.test_utils.tel.tel_voice_utils import phone_setup_iwlan 49 from acts.test_utils.tel.tel_voice_utils import phone_setup_volte 50 from acts.test_utils.tel.tel_voice_utils import phone_idle_iwlan 51 52 class TelLiveSettingsTest(TelephonyBaseTest): 53 54 _TEAR_DOWN_OPERATION_DISCONNECT_WIFI = "disconnect_wifi" 55 _TEAR_DOWN_OPERATION_RESET_WIFI = "reset_wifi" 56 _TEAR_DOWN_OPERATION_DISABLE_WFC = "disable_wfc" 57 _DEFAULT_STRESS_NUMBER = 5 58 59 def __init__(self, controllers): 60 TelephonyBaseTest.__init__(self, controllers) 61 self.tests = ( 62 "test_lte_volte_wifi_connected_toggle_wfc", 63 "test_lte_wifi_connected_toggle_wfc", 64 "test_3g_wifi_connected_toggle_wfc", 65 "test_apm_wifi_connected_toggle_wfc", 66 67 "test_lte_volte_wfc_enabled_toggle_wifi", 68 "test_lte_wfc_enabled_toggle_wifi", 69 "test_3g_wfc_enabled_toggle_wifi", 70 "test_apm_wfc_enabled_toggle_wifi", 71 72 "test_lte_wfc_enabled_wifi_connected_toggle_volte", 73 74 "test_lte_volte_wfc_wifi_preferred_to_cellular_preferred", 75 "test_lte_wfc_wifi_preferred_to_cellular_preferred", 76 "test_3g_wfc_wifi_preferred_to_cellular_preferred", 77 "test_apm_wfc_wifi_preferred_to_cellular_preferred", 78 "test_lte_volte_wfc_cellular_preferred_to_wifi_preferred", 79 "test_lte_wfc_cellular_preferred_to_wifi_preferred", 80 "test_3g_wfc_cellular_preferred_to_wifi_preferred", 81 "test_apm_wfc_cellular_preferred_to_wifi_preferred", 82 83 "test_apm_wfc_wifi_preferred_turn_off_apm", 84 "test_apm_wfc_cellular_preferred_turn_off_apm", 85 86 "test_wfc_setup_timing", 87 "test_lte_volte_wfc_enabled_toggle_wifi_stress", 88 "test_lte_volte_wfc_enabled_reset_wifi_stress", 89 "test_lte_volte_wfc_wifi_preferred_to_cellular_preferred_stress" 90 91 ) 92 self.ad = self.android_devices[0] 93 self.wifi_network_ssid = self.user_params["wifi_network_ssid"] 94 try: 95 self.wifi_network_pass = self.user_params["wifi_network_pass"] 96 except KeyError: 97 self.wifi_network_pass = None 98 try: 99 self.stress_test_number = int(self.user_params["stress_test_number"]) 100 except KeyError: 101 self.stress_test_number = self._DEFAULT_STRESS_NUMBER 102 103 def _wifi_connected_enable_wfc_teardown_wfc(self, 104 tear_down_operation, initial_setup_wifi=True, 105 initial_setup_wfc_mode=WFC_MODE_WIFI_PREFERRED, 106 check_volte_after_wfc_disabled=False): 107 if initial_setup_wifi and not ensure_wifi_connected( 108 self.log, self.ad, self.wifi_network_ssid, self.wifi_network_pass): 109 self.log.error("Failed to connect WiFi") 110 return False 111 if initial_setup_wfc_mode and not set_wfc_mode( 112 self.log, self.ad, initial_setup_wfc_mode): 113 self.log.error("Failed to set WFC mode.") 114 return False 115 if not phone_idle_iwlan(self.log, self.ad): 116 self.log.error("WFC is not available.") 117 return False 118 119 # Tear Down WFC based on tear_down_operation 120 if tear_down_operation == self._TEAR_DOWN_OPERATION_DISCONNECT_WIFI: 121 if not WifiUtils.wifi_toggle_state(self.log, self.ad, False): 122 self.log.error("Failed to turn off WiFi.") 123 return False 124 elif tear_down_operation == self._TEAR_DOWN_OPERATION_RESET_WIFI: 125 if not WifiUtils.wifi_reset(self.log, self.ad, False): 126 self.log.error("Failed to reset WiFi") 127 return False 128 elif tear_down_operation == self._TEAR_DOWN_OPERATION_DISABLE_WFC: 129 if not set_wfc_mode(self.log, self.ad, WFC_MODE_DISABLED): 130 self.log.error("Failed to turn off WFC.") 131 return False 132 else: 133 self.log.error("No tear down operation") 134 return False 135 136 if not wait_for_not_network_rat(self.log, self.ad, RAT_FAMILY_WLAN, 137 voice_or_data=NETWORK_SERVICE_DATA): 138 self.log.error("Data Rat is still iwlan.") 139 return False 140 if not wait_for_wfc_disabled(self.log, self.ad): 141 self.log.error("WFC is still available after turn off WFC.") 142 return False 143 144 # If VoLTE was previous available, after tear down WFC, DUT should have 145 # VoLTE service. 146 if check_volte_after_wfc_disabled and not wait_for_volte_enabled( 147 self.log, self.ad, MAX_WAIT_TIME_VOLTE_ENABLED): 148 self.log.error("Device failed to acquire VoLTE service") 149 return False 150 return True 151 152 def _wifi_connected_set_wfc_mode_change_wfc_mode(self, 153 initial_wfc_mode, 154 new_wfc_mode, 155 is_wfc_available_in_initial_wfc_mode, 156 is_wfc_available_in_new_wfc_mode, 157 initial_setup_wifi=True, 158 check_volte_after_wfc_disabled=False): 159 if initial_setup_wifi and not ensure_wifi_connected( 160 self.log, self.ad, self.wifi_network_ssid, self.wifi_network_pass): 161 self.log.error("Failed to connect WiFi") 162 return False 163 # Set to initial_wfc_mode first, then change to new_wfc_mode 164 for (wfc_mode, is_wfc_available) in \ 165 [(initial_wfc_mode, is_wfc_available_in_initial_wfc_mode), 166 (new_wfc_mode, is_wfc_available_in_new_wfc_mode)]: 167 current_wfc_status = is_wfc_enabled(self.log, self.ad) 168 self.log.info("Current WFC: {}, Set WFC to {}". 169 format(current_wfc_status, wfc_mode)) 170 if not set_wfc_mode(self.log, self.ad, wfc_mode): 171 self.log.error("Failed to set WFC mode.") 172 return False 173 if is_wfc_available: 174 if current_wfc_status: 175 # Previous is True, after set it still need to be true 176 # wait and check if DUT WFC got disabled. 177 if wait_for_wfc_disabled(self.log, self.ad): 178 self.log.error("WFC is not available.") 179 return False 180 else: 181 # Previous is False, after set it will be true, 182 # wait and check if DUT WFC got enabled. 183 if not wait_for_wfc_enabled(self.log, self.ad): 184 self.log.error("WFC is not available.") 185 return False 186 else: 187 if current_wfc_status: 188 # Previous is True, after set it will be false, 189 # wait and check if DUT WFC got disabled. 190 if not wait_for_wfc_disabled(self.log, self.ad): 191 self.log.error("WFC is available.") 192 return False 193 else: 194 # Previous is False, after set it still need to be false 195 # Wait and check if DUT WFC got enabled. 196 if wait_for_wfc_enabled(self.log, self.ad): 197 self.log.error("WFC is available.") 198 return False 199 if check_volte_after_wfc_disabled and not wait_for_volte_enabled( 200 self.log, self.ad, MAX_WAIT_TIME_VOLTE_ENABLED): 201 self.log.error("Device failed to acquire VoLTE service") 202 return False 203 return True 204 205 def _wifi_connected_set_wfc_mode_turn_off_apm(self, wfc_mode, 206 is_wfc_available_after_turn_off_apm): 207 if not ensure_wifi_connected(self.log, self.ad, self.wifi_network_ssid, 208 self.wifi_network_pass): 209 self.log.error("Failed to connect WiFi") 210 return False 211 if not set_wfc_mode(self.log, self.ad, wfc_mode): 212 self.log.error("Failed to set WFC mode.") 213 return False 214 if not phone_idle_iwlan(self.log, self.ad): 215 self.log.error("WFC is not available.") 216 return False 217 if not toggle_airplane_mode(self.log, self.ad, False): 218 self.log.error("Failed to turn off airplane mode") 219 return False 220 is_wfc_not_available = wait_for_wfc_disabled(self.log, self.ad) 221 if is_wfc_available_after_turn_off_apm and is_wfc_not_available: 222 self.log.error("WFC is not available.") 223 return False 224 elif (not is_wfc_available_after_turn_off_apm and 225 not is_wfc_not_available): 226 self.log.error("WFC is available.") 227 return False 228 return True 229 230 @TelephonyBaseTest.tel_test_wrap 231 def test_lte_volte_wifi_connected_toggle_wfc(self): 232 """Test for WiFi Calling settings: 233 LTE + VoLTE Enabled + WiFi Connected, Toggling WFC 234 235 Steps: 236 1. Setup DUT Idle, LTE network type, VoLTE enabled. 237 2. Make sure DUT WiFi connected, WFC disabled. 238 3. Set DUT WFC enabled (WiFi Preferred), verify DUT WFC available, 239 report iwlan rat. 240 4. Set DUT WFC disabled, verify DUT WFC unavailable, 241 not report iwlan rat. 242 243 Expected Results: 244 3. DUT WiFi Calling feature bit return True, network rat is iwlan. 245 4. DUT WiFi Calling feature bit return False, network rat is not iwlan. 246 """ 247 248 if not phone_setup_volte(self.log, self.ad): 249 self.log.error("Failed to setup VoLTE") 250 return False 251 return self._wifi_connected_enable_wfc_teardown_wfc( 252 tear_down_operation=self._TEAR_DOWN_OPERATION_DISABLE_WFC, 253 initial_setup_wifi=True, 254 initial_setup_wfc_mode=WFC_MODE_WIFI_PREFERRED, 255 check_volte_after_wfc_disabled=True) 256 257 @TelephonyBaseTest.tel_test_wrap 258 def test_lte_wifi_connected_toggle_wfc(self): 259 """Test for WiFi Calling settings: 260 LTE + VoLTE Disabled + WiFi Connected, Toggling WFC 261 262 Steps: 263 1. Setup DUT Idle, LTE network type, VoLTE disabled. 264 2. Make sure DUT WiFi connected, WFC disabled. 265 3. Set DUT WFC enabled (WiFi Preferred), verify DUT WFC available, 266 report iwlan rat. 267 4. Set DUT WFC disabled, verify DUT WFC unavailable, 268 not report iwlan rat. 269 270 Expected Results: 271 3. DUT WiFi Calling feature bit return True, network rat is iwlan. 272 4. DUT WiFi Calling feature bit return False, network rat is not iwlan. 273 """ 274 275 if not phone_setup_csfb(self.log, self.ad): 276 self.log.error("Failed to setup LTE") 277 return False 278 return self._wifi_connected_enable_wfc_teardown_wfc( 279 tear_down_operation=self._TEAR_DOWN_OPERATION_DISABLE_WFC, 280 initial_setup_wifi=True, 281 initial_setup_wfc_mode=WFC_MODE_WIFI_PREFERRED) 282 283 @TelephonyBaseTest.tel_test_wrap 284 def test_3g_wifi_connected_toggle_wfc(self): 285 """Test for WiFi Calling settings: 286 3G + WiFi Connected, Toggling WFC 287 288 Steps: 289 1. Setup DUT Idle, 3G network type. 290 2. Make sure DUT WiFi connected, WFC disabled. 291 3. Set DUT WFC enabled (WiFi Preferred), verify DUT WFC available, 292 report iwlan rat. 293 4. Set DUT WFC disabled, verify DUT WFC unavailable, 294 not report iwlan rat. 295 296 Expected Results: 297 3. DUT WiFi Calling feature bit return True, network rat is iwlan. 298 4. DUT WiFi Calling feature bit return False, network rat is not iwlan. 299 """ 300 301 if not phone_setup_voice_3g(self.log, self.ad): 302 self.log.error("Failed to setup 3G") 303 return False 304 return self._wifi_connected_enable_wfc_teardown_wfc( 305 tear_down_operation=self._TEAR_DOWN_OPERATION_DISABLE_WFC, 306 initial_setup_wifi=True, 307 initial_setup_wfc_mode=WFC_MODE_WIFI_PREFERRED) 308 309 @TelephonyBaseTest.tel_test_wrap 310 def test_apm_wifi_connected_toggle_wfc(self): 311 """Test for WiFi Calling settings: 312 APM + WiFi Connected, Toggling WFC 313 314 Steps: 315 1. Setup DUT Idle, Airplane mode. 316 2. Make sure DUT WiFi connected, WFC disabled. 317 3. Set DUT WFC enabled (WiFi Preferred), verify DUT WFC available, 318 report iwlan rat. 319 4. Set DUT WFC disabled, verify DUT WFC unavailable, 320 not report iwlan rat. 321 322 Expected Results: 323 3. DUT WiFi Calling feature bit return True, network rat is iwlan. 324 4. DUT WiFi Calling feature bit return False, network rat is not iwlan. 325 """ 326 327 if not toggle_airplane_mode(self.log, self.ad, True): 328 self.log.error("Failed to turn on airplane mode") 329 return False 330 return self._wifi_connected_enable_wfc_teardown_wfc( 331 tear_down_operation=self._TEAR_DOWN_OPERATION_DISABLE_WFC, 332 initial_setup_wifi=True, 333 initial_setup_wfc_mode=WFC_MODE_WIFI_PREFERRED) 334 335 @TelephonyBaseTest.tel_test_wrap 336 def test_lte_volte_wfc_enabled_toggle_wifi(self): 337 """Test for WiFi Calling settings: 338 LTE + VoLTE Enabled + WFC enabled, Toggling WiFi 339 340 Steps: 341 1. Setup DUT Idle, LTE network type, VoLTE enabled. 342 2. Make sure DUT WiFi disconnected, WFC enabled (WiFi Preferred). 343 3. DUT connect WiFi, verify DUT WFC available, report iwlan rat. 344 4. DUT disconnect WiFi,verify DUT WFC unavailable, not report iwlan rat. 345 346 Expected Results: 347 3. DUT WiFi Calling feature bit return True, network rat is iwlan. 348 4. DUT WiFi Calling feature bit return False, network rat is not iwlan. 349 """ 350 351 if not phone_setup_volte(self.log, self.ad): 352 self.log.error("Failed to setup VoLTE") 353 return False 354 return self._wifi_connected_enable_wfc_teardown_wfc( 355 tear_down_operation=self._TEAR_DOWN_OPERATION_DISCONNECT_WIFI, 356 initial_setup_wifi=True, 357 initial_setup_wfc_mode=WFC_MODE_WIFI_PREFERRED, 358 check_volte_after_wfc_disabled=True) 359 360 @TelephonyBaseTest.tel_test_wrap 361 def test_lte_wfc_enabled_toggle_wifi(self): 362 """Test for WiFi Calling settings: 363 LTE + VoLTE Disabled + WFC enabled, Toggling WiFi 364 365 Steps: 366 1. Setup DUT Idle, LTE network type, VoLTE disabled. 367 2. Make sure DUT WiFi disconnected, WFC enabled (WiFi Preferred). 368 3. DUT connect WiFi, verify DUT WFC available, report iwlan rat. 369 4. DUT disconnect WiFi,verify DUT WFC unavailable, not report iwlan rat. 370 371 Expected Results: 372 3. DUT WiFi Calling feature bit return True, network rat is iwlan. 373 4. DUT WiFi Calling feature bit return False, network rat is not iwlan. 374 """ 375 376 if not phone_setup_csfb(self.log, self.ad): 377 self.log.error("Failed to setup LTE") 378 return False 379 return self._wifi_connected_enable_wfc_teardown_wfc( 380 tear_down_operation=self._TEAR_DOWN_OPERATION_DISCONNECT_WIFI, 381 initial_setup_wifi=True, 382 initial_setup_wfc_mode=WFC_MODE_WIFI_PREFERRED) 383 384 @TelephonyBaseTest.tel_test_wrap 385 def test_3g_wfc_enabled_toggle_wifi(self): 386 """Test for WiFi Calling settings: 387 3G + WFC enabled, Toggling WiFi 388 389 Steps: 390 1. Setup DUT Idle, 3G network type. 391 2. Make sure DUT WiFi disconnected, WFC enabled (WiFi Preferred). 392 3. DUT connect WiFi, verify DUT WFC available, report iwlan rat. 393 4. DUT disconnect WiFi,verify DUT WFC unavailable, not report iwlan rat. 394 395 Expected Results: 396 3. DUT WiFi Calling feature bit return True, network rat is iwlan. 397 4. DUT WiFi Calling feature bit return False, network rat is not iwlan. 398 """ 399 400 if not phone_setup_voice_3g(self.log, self.ad): 401 self.log.error("Failed to setup 3G") 402 return False 403 return self._wifi_connected_enable_wfc_teardown_wfc( 404 tear_down_operation=self._TEAR_DOWN_OPERATION_DISCONNECT_WIFI, 405 initial_setup_wifi=True, 406 initial_setup_wfc_mode=WFC_MODE_WIFI_PREFERRED) 407 408 @TelephonyBaseTest.tel_test_wrap 409 def test_apm_wfc_enabled_toggle_wifi(self): 410 """Test for WiFi Calling settings: 411 APM + WFC enabled, Toggling WiFi 412 413 Steps: 414 1. Setup DUT Idle, Airplane mode. 415 2. Make sure DUT WiFi disconnected, WFC enabled (WiFi Preferred). 416 3. DUT connect WiFi, verify DUT WFC available, report iwlan rat. 417 4. DUT disconnect WiFi,verify DUT WFC unavailable, not report iwlan rat. 418 419 Expected Results: 420 3. DUT WiFi Calling feature bit return True, network rat is iwlan. 421 4. DUT WiFi Calling feature bit return False, network rat is not iwlan. 422 """ 423 424 if not toggle_airplane_mode(self.log, self.ad, True): 425 self.log.error("Failed to turn on airplane mode") 426 return False 427 return self._wifi_connected_enable_wfc_teardown_wfc( 428 tear_down_operation=self._TEAR_DOWN_OPERATION_DISCONNECT_WIFI, 429 initial_setup_wifi=True, 430 initial_setup_wfc_mode=WFC_MODE_WIFI_PREFERRED) 431 432 @TelephonyBaseTest.tel_test_wrap 433 def test_lte_wfc_enabled_wifi_connected_toggle_volte(self): 434 """Test for WiFi Calling settings: 435 LTE + VoLTE Enabled + WiFi Connected + WFC enabled, toggle VoLTE setting 436 437 Steps: 438 1. Setup DUT Idle, LTE network type, VoLTE enabled. 439 2. Make sure DUT WiFi connected, WFC enabled (WiFi Preferred). 440 Verify DUT WFC available, report iwlan rat. 441 3. Disable VoLTE on DUT, verify in 2 minutes period, 442 DUT does not lost WiFi Calling, DUT still report WFC available, 443 rat iwlan. 444 4. Enable VoLTE on DUT, verify in 2 minutes period, 445 DUT does not lost WiFi Calling, DUT still report WFC available, 446 rat iwlan. 447 448 Expected Results: 449 2. DUT WiFi Calling feature bit return True, network rat is iwlan. 450 3. DUT WiFi Calling feature bit return True, network rat is iwlan. 451 4. DUT WiFi Calling feature bit return True, network rat is iwlan. 452 """ 453 if not phone_setup_volte(self.log, self.ad): 454 self.log.error("Failed to setup VoLTE.") 455 return False 456 if not phone_setup_iwlan(self.log, self.ad, False, 457 WFC_MODE_WIFI_PREFERRED, 458 self.wifi_network_ssid, 459 self.wifi_network_pass): 460 self.log.error("Failed to setup WFC.") 461 return False 462 # Turn Off VoLTE, then Turn On VoLTE 463 for i in range(2): 464 if not toggle_volte(self.log, self.ad): 465 self.log.error("Failed to toggle VoLTE.") 466 return False 467 if wait_for_wfc_disabled(self.log, self.ad): 468 self.log.error("WFC is not available.") 469 return False 470 if not is_droid_in_rat_family(self.log, self.ad, RAT_FAMILY_WLAN, 471 NETWORK_SERVICE_DATA): 472 self.log.error("Data Rat is not iwlan.") 473 return False 474 return True 475 476 @TelephonyBaseTest.tel_test_wrap 477 def test_lte_volte_wfc_wifi_preferred_to_cellular_preferred(self): 478 """Test for WiFi Calling settings: 479 LTE + VoLTE Enabled + WiFi Connected + WiFi Preferred, 480 change WFC to Cellular Preferred 481 482 Steps: 483 1. Setup DUT Idle, LTE network type, VoLTE enabled. 484 2. Make sure DUT WiFi connected, WFC is set to WiFi Preferred. 485 Verify DUT WFC available, report iwlan rat. 486 3. Change WFC setting to Cellular Preferred. 487 4. Verify DUT report WFC not available. 488 489 Expected Results: 490 2. DUT WiFi Calling feature bit return True, network rat is iwlan. 491 4. DUT WiFI Calling feature bit return False, network rat is not iwlan. 492 """ 493 if not phone_setup_volte(self.log, self.ad): 494 self.log.error("Failed to setup VoLTE.") 495 return False 496 return self._wifi_connected_set_wfc_mode_change_wfc_mode( 497 WFC_MODE_WIFI_PREFERRED, WFC_MODE_CELLULAR_PREFERRED, 498 True, False, 499 check_volte_after_wfc_disabled=True) 500 501 @TelephonyBaseTest.tel_test_wrap 502 def test_lte_wfc_wifi_preferred_to_cellular_preferred(self): 503 """Test for WiFi Calling settings: 504 LTE + WiFi Connected + WiFi Preferred, change WFC to Cellular Preferred 505 506 Steps: 507 1. Setup DUT Idle, LTE network type, VoLTE disabled. 508 2. Make sure DUT WiFi connected, WFC is set to WiFi Preferred. 509 Verify DUT WFC available, report iwlan rat. 510 3. Change WFC setting to Cellular Preferred. 511 4. Verify DUT report WFC not available. 512 513 Expected Results: 514 2. DUT WiFi Calling feature bit return True, network rat is iwlan. 515 4. DUT WiFI Calling feature bit return False, network rat is not iwlan. 516 """ 517 if not phone_setup_csfb(self.log, self.ad): 518 self.log.error("Failed to setup LTE.") 519 return False 520 return self._wifi_connected_set_wfc_mode_change_wfc_mode( 521 WFC_MODE_WIFI_PREFERRED, WFC_MODE_CELLULAR_PREFERRED, 522 True, False, 523 check_volte_after_wfc_disabled=False) 524 525 @TelephonyBaseTest.tel_test_wrap 526 def test_3g_wfc_wifi_preferred_to_cellular_preferred(self): 527 """Test for WiFi Calling settings: 528 3G + WiFi Connected + WiFi Preferred, change WFC to Cellular Preferred 529 530 Steps: 531 1. Setup DUT Idle, 3G network type. 532 2. Make sure DUT WiFi connected, WFC is set to WiFi Preferred. 533 Verify DUT WFC available, report iwlan rat. 534 3. Change WFC setting to Cellular Preferred. 535 4. Verify DUT report WFC not available. 536 537 Expected Results: 538 2. DUT WiFi Calling feature bit return True, network rat is iwlan. 539 4. DUT WiFI Calling feature bit return False, network rat is not iwlan. 540 """ 541 if not phone_setup_voice_3g(self.log, self.ad): 542 self.log.error("Failed to setup 3G.") 543 return False 544 return self._wifi_connected_set_wfc_mode_change_wfc_mode( 545 WFC_MODE_WIFI_PREFERRED, WFC_MODE_CELLULAR_PREFERRED, 546 True, False) 547 548 @TelephonyBaseTest.tel_test_wrap 549 def test_3g_wfc_wifi_preferred_to_cellular_preferred(self): 550 """Test for WiFi Calling settings: 551 3G + WiFi Connected + WiFi Preferred, change WFC to Cellular Preferred 552 553 Steps: 554 1. Setup DUT Idle, 3G network type. 555 2. Make sure DUT WiFi connected, WFC is set to WiFi Preferred. 556 Verify DUT WFC available, report iwlan rat. 557 3. Change WFC setting to Cellular Preferred. 558 4. Verify DUT report WFC not available. 559 560 Expected Results: 561 2. DUT WiFi Calling feature bit return True, network rat is iwlan. 562 4. DUT WiFI Calling feature bit return False, network rat is not iwlan. 563 """ 564 if not phone_setup_voice_3g(self.log, self.ad): 565 self.log.error("Failed to setup 3G.") 566 return False 567 return self._wifi_connected_set_wfc_mode_change_wfc_mode( 568 WFC_MODE_WIFI_PREFERRED, WFC_MODE_CELLULAR_PREFERRED, 569 True, False) 570 571 @TelephonyBaseTest.tel_test_wrap 572 def test_apm_wfc_wifi_preferred_to_cellular_preferred(self): 573 """Test for WiFi Calling settings: 574 APM + WiFi Connected + WiFi Preferred, change WFC to Cellular Preferred 575 576 Steps: 577 1. Setup DUT Idle, airplane mode. 578 2. Make sure DUT WiFi connected, WFC is set to WiFi Preferred. 579 Verify DUT WFC available, report iwlan rat. 580 3. Change WFC setting to Cellular Preferred. 581 4. Verify DUT report WFC not available. 582 583 Expected Results: 584 2. DUT WiFi Calling feature bit return True, network rat is iwlan. 585 4. DUT WiFI Calling feature bit return True, network rat is iwlan. 586 """ 587 if not toggle_airplane_mode(self.log, self.ad, True): 588 self.log.error("Failed to turn on airplane mode") 589 return False 590 return self._wifi_connected_set_wfc_mode_change_wfc_mode( 591 WFC_MODE_WIFI_PREFERRED, WFC_MODE_CELLULAR_PREFERRED, 592 True, True) 593 594 @TelephonyBaseTest.tel_test_wrap 595 def test_lte_volte_wfc_cellular_preferred_to_wifi_preferred(self): 596 """Test for WiFi Calling settings: 597 LTE + VoLTE Enabled + WiFi Connected + Cellular Preferred, 598 change WFC to WiFi Preferred 599 600 Steps: 601 1. Setup DUT Idle, LTE network type, VoLTE enabled. 602 2. Make sure DUT WiFi connected, WFC is set to Cellular Preferred. 603 Verify DUT WFC not available. 604 3. Change WFC setting to WiFi Preferred. 605 4. Verify DUT report WFC available. 606 607 Expected Results: 608 2. DUT WiFi Calling feature bit return False, network rat is not iwlan. 609 4. DUT WiFI Calling feature bit return True, network rat is iwlan. 610 """ 611 if not phone_setup_volte(self.log, self.ad): 612 self.log.error("Failed to setup VoLTE.") 613 return False 614 return self._wifi_connected_set_wfc_mode_change_wfc_mode( 615 WFC_MODE_CELLULAR_PREFERRED, WFC_MODE_WIFI_PREFERRED, 616 False, True, 617 check_volte_after_wfc_disabled=True) 618 619 @TelephonyBaseTest.tel_test_wrap 620 def test_lte_wfc_cellular_preferred_to_wifi_preferred(self): 621 """Test for WiFi Calling settings: 622 LTE + WiFi Connected + Cellular Preferred, change WFC to WiFi Preferred 623 624 Steps: 625 1. Setup DUT Idle, LTE network type, VoLTE disabled. 626 2. Make sure DUT WiFi connected, WFC is set to Cellular Preferred. 627 Verify DUT WFC not available. 628 3. Change WFC setting to WiFi Preferred. 629 4. Verify DUT report WFC available. 630 631 Expected Results: 632 2. DUT WiFi Calling feature bit return False, network rat is not iwlan. 633 4. DUT WiFI Calling feature bit return True, network rat is iwlan. 634 """ 635 if not phone_setup_csfb(self.log, self.ad): 636 self.log.error("Failed to setup LTE.") 637 return False 638 return self._wifi_connected_set_wfc_mode_change_wfc_mode( 639 WFC_MODE_CELLULAR_PREFERRED, WFC_MODE_WIFI_PREFERRED, 640 False, True, 641 check_volte_after_wfc_disabled=False) 642 643 @TelephonyBaseTest.tel_test_wrap 644 def test_3g_wfc_cellular_preferred_to_wifi_preferred(self): 645 """Test for WiFi Calling settings: 646 3G + WiFi Connected + Cellular Preferred, change WFC to WiFi Preferred 647 648 Steps: 649 1. Setup DUT Idle, 3G network type. 650 2. Make sure DUT WiFi connected, WFC is set to Cellular Preferred. 651 Verify DUT WFC not available. 652 3. Change WFC setting to WiFi Preferred. 653 4. Verify DUT report WFC available. 654 655 Expected Results: 656 2. DUT WiFi Calling feature bit return False, network rat is not iwlan. 657 4. DUT WiFI Calling feature bit return True, network rat is iwlan. 658 """ 659 if not phone_setup_voice_3g(self.log, self.ad): 660 self.log.error("Failed to setup 3G.") 661 return False 662 return self._wifi_connected_set_wfc_mode_change_wfc_mode( 663 WFC_MODE_CELLULAR_PREFERRED, WFC_MODE_WIFI_PREFERRED, 664 False, True) 665 666 @TelephonyBaseTest.tel_test_wrap 667 def test_apm_wfc_cellular_preferred_to_wifi_preferred(self): 668 """Test for WiFi Calling settings: 669 APM + WiFi Connected + Cellular Preferred, change WFC to WiFi Preferred 670 671 Steps: 672 1. Setup DUT Idle, airplane mode. 673 2. Make sure DUT WiFi connected, WFC is set to Cellular Preferred. 674 Verify DUT WFC not available. 675 3. Change WFC setting to WiFi Preferred. 676 4. Verify DUT report WFC available. 677 678 Expected Results: 679 2. DUT WiFi Calling feature bit return True, network rat is iwlan. 680 4. DUT WiFI Calling feature bit return True, network rat is iwlan. 681 """ 682 if not toggle_airplane_mode(self.log, self.ad, True): 683 self.log.error("Failed to turn on airplane mode") 684 return False 685 return self._wifi_connected_set_wfc_mode_change_wfc_mode( 686 WFC_MODE_CELLULAR_PREFERRED, WFC_MODE_WIFI_PREFERRED, 687 True, True) 688 689 @TelephonyBaseTest.tel_test_wrap 690 def test_apm_wfc_wifi_preferred_turn_off_apm(self): 691 """Test for WiFi Calling settings: 692 APM + WiFi Connected + WiFi Preferred + turn off APM 693 694 Steps: 695 1. Setup DUT Idle in Airplane mode. 696 2. Make sure DUT WiFi connected, set WFC mode to WiFi preferred. 697 3. verify DUT WFC available, report iwlan rat. 698 4. Turn off airplane mode. 699 5. Verify DUT WFC still available, report iwlan rat 700 701 Expected Results: 702 3. DUT WiFi Calling feature bit return True, network rat is iwlan. 703 5. DUT WiFI Calling feature bit return True, network rat is iwlan. 704 """ 705 if not toggle_airplane_mode(self.log, self.ad, True): 706 self.log.error("Failed to turn on airplane mode") 707 return False 708 return self._wifi_connected_set_wfc_mode_turn_off_apm( 709 WFC_MODE_WIFI_PREFERRED, True) 710 711 @TelephonyBaseTest.tel_test_wrap 712 def test_apm_wfc_cellular_preferred_turn_off_apm(self): 713 """Test for WiFi Calling settings: 714 APM + WiFi Connected + Cellular Preferred + turn off APM 715 716 Steps: 717 1. Setup DUT Idle in Airplane mode. 718 2. Make sure DUT WiFi connected, set WFC mode to Cellular preferred. 719 3. verify DUT WFC available, report iwlan rat. 720 4. Turn off airplane mode. 721 5. Verify DUT WFC not available, not report iwlan rat 722 723 Expected Results: 724 3. DUT WiFi Calling feature bit return True, network rat is iwlan. 725 5. DUT WiFI Calling feature bit return False, network rat is not iwlan. 726 """ 727 if not toggle_airplane_mode(self.log, self.ad, True): 728 self.log.error("Failed to turn on airplane mode") 729 return False 730 return self._wifi_connected_set_wfc_mode_turn_off_apm( 731 WFC_MODE_CELLULAR_PREFERRED, False) 732 733 @TelephonyBaseTest.tel_test_wrap 734 def test_wfc_setup_timing(self): 735 """ Measures the time delay in enabling WiFi calling 736 737 Steps: 738 1. Make sure DUT idle. 739 2. Turn on Airplane Mode, Set WiFi Calling to WiFi_Preferred. 740 3. Turn on WiFi, connect to WiFi AP and measure time delay. 741 4. Wait for WiFi connected, verify Internet and measure time delay. 742 5. Wait for rat to be reported as iwlan and measure time delay. 743 6. Wait for ims registered and measure time delay. 744 7. Wait for WiFi Calling feature bit to be True and measure time delay. 745 746 Expected results: 747 Time Delay in each step should be within pre-defined limit. 748 749 Returns: 750 Currently always return True. 751 """ 752 # TODO: b/26338119 Set pass/fail criteria 753 ad = self.android_devices[0] 754 755 time_values = { 756 'start': 0, 757 'wifi_enabled': 0, 758 'wifi_connected': 0, 759 'wifi_data': 0, 760 'iwlan_rat': 0, 761 'ims_registered': 0, 762 'wfc_enabled': 0, 763 'mo_call_success': 0 764 } 765 766 WifiUtils.wifi_reset(self.log, ad) 767 toggle_airplane_mode(self.log, ad, True) 768 769 set_wfc_mode(self.log, ad, WFC_MODE_WIFI_PREFERRED) 770 771 time_values['start'] = time.time() 772 773 self.log.info("Start Time {}s".format(time_values['start'])) 774 775 WifiUtils.wifi_toggle_state(self.log, ad, True) 776 time_values['wifi_enabled'] = time.time() 777 self.log.info("WiFi Enabled After {}s".format(time_values[ 778 'wifi_enabled'] - time_values['start'])) 779 780 WifiUtils.wifi_connect(self.log, ad, self.wifi_network_ssid, 781 self.wifi_network_pass) 782 783 ad.droid.wakeUpNow() 784 785 if not wait_for_wifi_data_connection(self.log, ad, True, 786 MAX_WAIT_TIME_WIFI_CONNECTION): 787 self.log.error("Failed WiFi connection, aborting!") 788 return False 789 time_values['wifi_connected'] = time.time() 790 791 self.log.info("WiFi Connected After {}s".format(time_values[ 792 'wifi_connected'] - time_values['wifi_enabled'])) 793 794 if not verify_http_connection(self.log, ad, 'http://www.google.com', 795 100, .1): 796 self.log.error("Failed to get user-plane traffic, aborting!") 797 return False 798 799 time_values['wifi_data'] = time.time() 800 self.log.info("WifiData After {}s".format(time_values[ 801 'wifi_data'] - time_values['wifi_connected'])) 802 803 if not wait_for_network_rat(self.log, 804 ad, 805 RAT_FAMILY_WLAN, 806 voice_or_data=NETWORK_SERVICE_DATA): 807 self.log.error("Failed to set-up iwlan, aborting!") 808 if is_droid_in_rat_family(self.log, ad, RAT_FAMILY_WLAN, 809 NETWORK_SERVICE_DATA): 810 self.log.error("Never received the event, but droid in iwlan") 811 else: 812 return False 813 time_values['iwlan_rat'] = time.time() 814 self.log.info("iWLAN Reported After {}s".format(time_values[ 815 'iwlan_rat'] - time_values['wifi_data'])) 816 817 if not wait_for_ims_registered(self.log, ad, 818 MAX_WAIT_TIME_IMS_REGISTRATION): 819 self.log.error("Never received IMS registered, aborting") 820 return False 821 time_values['ims_registered'] = time.time() 822 self.log.info("Ims Registered After {}s".format(time_values[ 823 'ims_registered'] - time_values['iwlan_rat'])) 824 825 if not wait_for_wfc_enabled(self.log, ad, MAX_WAIT_TIME_WFC_ENABLED): 826 self.log.error("Never received WFC feature, aborting") 827 return False 828 829 time_values['wfc_enabled'] = time.time() 830 self.log.info("Wifi Calling Feature Enabled After {}s".format( 831 time_values['wfc_enabled'] - time_values['ims_registered'])) 832 833 set_wfc_mode(self.log, ad, WFC_MODE_DISABLED) 834 835 wait_for_not_network_rat(self.log, 836 ad, 837 RAT_FAMILY_WLAN, 838 voice_or_data=NETWORK_SERVICE_DATA) 839 840 self.log.info("\n\n------------------summary-----------------") 841 self.log.info("WiFi Enabled After {0:.2f} s".format(time_values[ 842 'wifi_enabled'] - time_values['start'])) 843 self.log.info("WiFi Connected After {0:.2f} s".format(time_values[ 844 'wifi_connected'] - time_values['wifi_enabled'])) 845 self.log.info("WifiData After {0:.2f} s".format(time_values[ 846 'wifi_data'] - time_values['wifi_connected'])) 847 self.log.info("iWLAN Reported After {0:.2f} s".format(time_values[ 848 'iwlan_rat'] - time_values['wifi_data'])) 849 self.log.info("Ims Registered After {0:.2f} s".format(time_values[ 850 'ims_registered'] - time_values['iwlan_rat'])) 851 self.log.info("Wifi Calling Feature Enabled After {0:.2f} s".format( 852 time_values['wfc_enabled'] - time_values['ims_registered'])) 853 self.log.info("\n\n") 854 return True 855 856 @TelephonyBaseTest.tel_test_wrap 857 def test_lte_volte_wfc_enabled_toggle_wifi_stress(self): 858 """Test for WiFi Calling settings: 859 LTE + VoLTE Enabled + WFC enabled, Toggling WiFi Stress test 860 861 Steps: 862 1. Setup DUT Idle, LTE network type, VoLTE enabled. 863 2. Make sure DUT WiFi disconnected, WFC enabled (WiFi Preferred). 864 3. DUT connect WiFi, verify DUT WFC available, report iwlan rat. 865 4. DUT disconnect WiFi, verify DUT WFC unavailable, not report iwlan rat. 866 5. Verify DUT report VoLTE available. 867 6. Repeat steps 3~5 for N times. 868 869 Expected Results: 870 3. DUT WiFi Calling feature bit return True, network rat is iwlan. 871 4. DUT WiFi Calling feature bit return False, network rat is not iwlan. 872 5. DUT report VoLTE available. 873 """ 874 875 if not phone_setup_volte(self.log, self.ad): 876 self.log.error("Failed to setup VoLTE") 877 return False 878 set_wfc_mode(self.log, self.ad, WFC_MODE_WIFI_PREFERRED) 879 880 for i in range(1, self.stress_test_number + 1): 881 self.log.info("Start Iteration {}.".format(i)) 882 result = self._wifi_connected_enable_wfc_teardown_wfc( 883 tear_down_operation=self._TEAR_DOWN_OPERATION_DISCONNECT_WIFI, 884 initial_setup_wifi=True, 885 initial_setup_wfc_mode=None, 886 check_volte_after_wfc_disabled=True) 887 if not result: 888 self.log.error("Test Failed in iteration: {}.".format(i)) 889 return False 890 return True 891 892 @TelephonyBaseTest.tel_test_wrap 893 def test_lte_volte_wfc_enabled_reset_wifi_stress(self): 894 """Test for WiFi Calling settings: 895 LTE + VoLTE Enabled + WFC enabled, Reset WiFi Stress test 896 897 Steps: 898 1. Setup DUT Idle, LTE network type, VoLTE enabled. 899 2. Make sure DUT WiFi disconnected, WFC enabled (WiFi Preferred). 900 3. DUT connect WiFi, verify DUT WFC available, report iwlan rat. 901 4. DUT Reset WiFi, verify DUT WFC unavailable, not report iwlan rat. 902 5. Verify DUT report VoLTE available. 903 6. Repeat steps 3~5 for N times. 904 905 Expected Results: 906 3. DUT WiFi Calling feature bit return True, network rat is iwlan. 907 4. DUT WiFi Calling feature bit return False, network rat is not iwlan. 908 5. DUT report VoLTE available. 909 """ 910 911 if not phone_setup_volte(self.log, self.ad): 912 self.log.error("Failed to setup VoLTE") 913 return False 914 set_wfc_mode(self.log, self.ad, WFC_MODE_WIFI_PREFERRED) 915 916 for i in range(1, self.stress_test_number + 1): 917 self.log.info("Start Iteration {}.".format(i)) 918 result = self._wifi_connected_enable_wfc_teardown_wfc( 919 tear_down_operation=self._TEAR_DOWN_OPERATION_RESET_WIFI, 920 initial_setup_wifi=True, 921 initial_setup_wfc_mode=None, 922 check_volte_after_wfc_disabled=True) 923 if not result: 924 self.log.error("Test Failed in iteration: {}.".format(i)) 925 return False 926 return True 927 928 @TelephonyBaseTest.tel_test_wrap 929 def test_lte_volte_wfc_wifi_preferred_to_cellular_preferred_stress(self): 930 """Test for WiFi Calling settings: 931 LTE + VoLTE Enabled + WiFi Connected + WiFi Preferred, 932 change WFC to Cellular Preferred stress 933 934 Steps: 935 1. Setup DUT Idle, LTE network type, VoLTE enabled. 936 2. Make sure DUT WiFi connected, WFC is set to WiFi Preferred. 937 Verify DUT WFC available, report iwlan rat. 938 3. Change WFC setting to Cellular Preferred. 939 4. Verify DUT report WFC not available. 940 5. Verify DUT report VoLTE available. 941 6. Repeat steps 3~5 for N times. 942 943 Expected Results: 944 2. DUT WiFi Calling feature bit return True, network rat is iwlan. 945 4. DUT WiFI Calling feature bit return False, network rat is not iwlan. 946 5. DUT report VoLTE available. 947 """ 948 if not phone_setup_volte(self.log, self.ad): 949 self.log.error("Failed to setup VoLTE.") 950 return False 951 if not ensure_wifi_connected( 952 self.log, self.ad, self.wifi_network_ssid, self.wifi_network_pass): 953 self.log.error("Failed to connect WiFi") 954 return False 955 956 for i in range(1, self.stress_test_number + 1): 957 self.log.info("Start Iteration {}.".format(i)) 958 result = self._wifi_connected_set_wfc_mode_change_wfc_mode( 959 WFC_MODE_WIFI_PREFERRED, WFC_MODE_CELLULAR_PREFERRED, 960 True, False, 961 initial_setup_wifi=False, 962 check_volte_after_wfc_disabled=True) 963 if not result: 964 self.log.error("Test Failed in iteration: {}.".format(i)) 965 return False 966 return True 967