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 Pre Check In Sanity 18""" 19 20import collections 21import random 22import time 23import os 24 25from acts import signals 26from acts.utils import disable_doze 27from acts.utils import enable_doze 28from acts.utils import rand_ascii_str 29from acts.test_decorators import test_tracker_info 30from acts_contrib.test_utils.tel.tel_subscription_utils import \ 31 get_subid_from_slot_index 32from acts_contrib.test_utils.tel.tel_subscription_utils import set_subid_for_data 33from acts_contrib.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest 34from acts_contrib.test_utils.tel.tel_defines import DIRECTION_MOBILE_ORIGINATED 35from acts_contrib.test_utils.tel.tel_defines import DIRECTION_MOBILE_TERMINATED 36from acts_contrib.test_utils.tel.tel_defines import DATA_STATE_CONNECTED 37from acts_contrib.test_utils.tel.tel_defines import FAKE_DATE_TIME 38from acts_contrib.test_utils.tel.tel_defines import FAKE_YEAR 39from acts_contrib.test_utils.tel.tel_defines import GEN_2G 40from acts_contrib.test_utils.tel.tel_defines import GEN_3G 41from acts_contrib.test_utils.tel.tel_defines import GEN_4G 42from acts_contrib.test_utils.tel.tel_defines import NETWORK_SERVICE_DATA 43from acts_contrib.test_utils.tel.tel_defines import RAT_2G 44from acts_contrib.test_utils.tel.tel_defines import RAT_3G 45from acts_contrib.test_utils.tel.tel_defines import RAT_4G 46from acts_contrib.test_utils.tel.tel_defines import SIM1_SLOT_INDEX 47from acts_contrib.test_utils.tel.tel_defines import SIM2_SLOT_INDEX 48from acts_contrib.test_utils.tel.tel_defines import MAX_WAIT_TIME_NW_SELECTION 49from acts_contrib.test_utils.tel.tel_defines import MAX_WAIT_TIME_TETHERING_ENTITLEMENT_CHECK 50from acts_contrib.test_utils.tel.tel_defines import TETHERING_MODE_WIFI 51from acts_contrib.test_utils.tel.tel_defines import WAIT_TIME_AFTER_REBOOT 52from acts_contrib.test_utils.tel.tel_defines import WAIT_TIME_ANDROID_STATE_SETTLING 53from acts_contrib.test_utils.tel.tel_defines import \ 54 WAIT_TIME_DATA_STATUS_CHANGE_DURING_WIFI_TETHERING 55from acts_contrib.test_utils.tel.tel_defines import WAIT_TIME_TETHERING_AFTER_REBOOT 56from acts_contrib.test_utils.tel.tel_defines import TETHERING_PASSWORD_HAS_ESCAPE 57from acts_contrib.test_utils.tel.tel_defines import TETHERING_SPECIAL_SSID_LIST 58from acts_contrib.test_utils.tel.tel_defines import TETHERING_SPECIAL_PASSWORD_LIST 59from acts_contrib.test_utils.tel.tel_data_utils import airplane_mode_test 60from acts_contrib.test_utils.tel.tel_data_utils import browsing_test 61from acts_contrib.test_utils.tel.tel_data_utils import reboot_test 62from acts_contrib.test_utils.tel.tel_data_utils import change_data_sim_and_verify_data 63from acts_contrib.test_utils.tel.tel_data_utils import data_connectivity_single_bearer 64from acts_contrib.test_utils.tel.tel_data_utils import tethering_check_internet_connection 65from acts_contrib.test_utils.tel.tel_data_utils import test_data_connectivity_multi_bearer 66from acts_contrib.test_utils.tel.tel_data_utils import test_setup_tethering 67from acts_contrib.test_utils.tel.tel_data_utils import test_tethering_wifi_and_voice_call 68from acts_contrib.test_utils.tel.tel_data_utils import test_wifi_connect_disconnect 69from acts_contrib.test_utils.tel.tel_data_utils import verify_bluetooth_tethering_connection 70from acts_contrib.test_utils.tel.tel_data_utils import wifi_cell_switching 71from acts_contrib.test_utils.tel.tel_data_utils import wifi_tethering_cleanup 72from acts_contrib.test_utils.tel.tel_data_utils import verify_toggle_apm_tethering_internet_connection 73from acts_contrib.test_utils.tel.tel_data_utils import verify_tethering_entitlement_check 74from acts_contrib.test_utils.tel.tel_data_utils import wifi_tethering_setup_teardown 75from acts_contrib.test_utils.tel.tel_data_utils import test_wifi_tethering 76from acts_contrib.test_utils.tel.tel_data_utils import test_start_wifi_tethering_connect_teardown 77from acts_contrib.test_utils.tel.tel_data_utils import run_stress_test 78from acts_contrib.test_utils.tel.tel_data_utils import verify_wifi_tethering_when_reboot 79from acts_contrib.test_utils.tel.tel_data_utils import wait_and_verify_device_internet_connection 80from acts_contrib.test_utils.tel.tel_data_utils import setup_device_internet_connection 81from acts_contrib.test_utils.tel.tel_data_utils import setup_device_internet_connection_then_reboot 82from acts_contrib.test_utils.tel.tel_data_utils import verify_internet_connection_in_doze_mode 83from acts_contrib.test_utils.tel.tel_data_utils import verify_toggle_data_during_wifi_tethering 84from acts_contrib.test_utils.tel.tel_test_utils import active_file_download_test 85from acts_contrib.test_utils.tel.tel_test_utils import call_setup_teardown 86from acts_contrib.test_utils.tel.tel_test_utils import check_is_wifi_connected 87from acts_contrib.test_utils.tel.tel_test_utils import ensure_phones_default_state 88from acts_contrib.test_utils.tel.tel_test_utils import ensure_network_generation 89from acts_contrib.test_utils.tel.tel_test_utils import \ 90 ensure_network_generation_for_subscription 91from acts_contrib.test_utils.tel.tel_test_utils import ensure_wifi_connected 92from acts_contrib.test_utils.tel.tel_test_utils import get_mobile_data_usage 93from acts_contrib.test_utils.tel.tel_test_utils import get_slot_index_from_subid 94from acts_contrib.test_utils.tel.tel_test_utils import hangup_call 95from acts_contrib.test_utils.tel.tel_test_utils import remove_mobile_data_usage_limit 96from acts_contrib.test_utils.tel.tel_test_utils import set_mobile_data_usage_limit 97from acts_contrib.test_utils.tel.tel_test_utils import stop_wifi_tethering 98from acts_contrib.test_utils.tel.tel_test_utils import start_wifi_tethering 99from acts_contrib.test_utils.tel.tel_test_utils import toggle_airplane_mode 100from acts_contrib.test_utils.tel.tel_test_utils import toggle_airplane_mode_by_adb 101from acts_contrib.test_utils.tel.tel_test_utils import verify_internet_connection 102from acts_contrib.test_utils.tel.tel_test_utils import wait_for_cell_data_connection 103from acts_contrib.test_utils.tel.tel_test_utils import \ 104 wait_for_data_attach_for_subscription 105from acts_contrib.test_utils.tel.tel_test_utils import wait_for_wifi_data_connection 106from acts_contrib.test_utils.tel.tel_test_utils import wifi_reset 107from acts_contrib.test_utils.tel.tel_test_utils import wifi_toggle_state 108from acts_contrib.test_utils.tel.tel_test_utils import WIFI_CONFIG_APBAND_2G 109from acts_contrib.test_utils.tel.tel_test_utils import WIFI_CONFIG_APBAND_5G 110from acts_contrib.test_utils.tel.tel_test_utils import WIFI_SSID_KEY 111from acts_contrib.test_utils.tel.tel_test_utils import check_data_stall_detection 112from acts_contrib.test_utils.tel.tel_test_utils import check_network_validation_fail 113from acts_contrib.test_utils.tel.tel_test_utils import break_internet_except_sl4a_port 114from acts_contrib.test_utils.tel.tel_test_utils import resume_internet_with_sl4a_port 115from acts_contrib.test_utils.tel.tel_test_utils import get_device_epoch_time 116from acts_contrib.test_utils.tel.tel_test_utils import check_data_stall_recovery 117from acts_contrib.test_utils.tel.tel_test_utils import \ 118 test_data_browsing_success_using_sl4a 119from acts_contrib.test_utils.tel.tel_test_utils import \ 120 test_data_browsing_failure_using_sl4a 121from acts_contrib.test_utils.tel.tel_test_utils import set_time_sync_from_network 122from acts_contrib.test_utils.tel.tel_test_utils import datetime_handle 123from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_3g 124from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_csfb 125from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_volte 126from acts_contrib.test_utils.tel.tel_voice_utils import phone_setup_3g 127from acts_contrib.test_utils.tel.tel_voice_utils import phone_setup_voice_3g 128from acts_contrib.test_utils.tel.tel_voice_utils import phone_setup_csfb 129from acts_contrib.test_utils.tel.tel_voice_utils import phone_setup_volte 130from acts_contrib.test_utils.tel.tel_voice_utils import phone_setup_4g 131 132 133class TelLiveDataTest(TelephonyBaseTest): 134 def setup_class(self): 135 super().setup_class() 136 137 self.stress_test_number = self.get_stress_test_number() 138 self.provider = self.android_devices[0] 139 self.clients = self.android_devices[1:] 140 141 def setup_test(self): 142 TelephonyBaseTest.setup_test(self) 143 self.number_of_devices = 1 144 145 def teardown_class(self): 146 TelephonyBaseTest.teardown_class(self) 147 148 149 """ Tests Begin """ 150 151 152 @test_tracker_info(uuid="ba24f9a3-0126-436c-8a5c-9f88859c273c") 153 @TelephonyBaseTest.tel_test_wrap 154 def test_data_browsing_for_single_phone(self): 155 """ Browsing websites on cellular. 156 157 Ensure phone attach, data on, WiFi off 158 Verify 5 websites on cellular. 159 160 Returns: 161 True if pass; False if fail. 162 """ 163 ad = self.android_devices[0] 164 wifi_toggle_state(ad.log, ad, False) 165 for iteration in range(3): 166 ad.log.info("Attempt %d", iteration + 1) 167 if test_data_browsing_success_using_sl4a(ad.log, ad): 168 ad.log.info("Call test PASS in iteration %d", iteration + 1) 169 return True 170 time.sleep(WAIT_TIME_ANDROID_STATE_SETTLING) 171 ad.log.info("Data Browsing test FAIL for all 3 iterations") 172 return False 173 174 175 @test_tracker_info(uuid="0679214b-9002-476d-83a7-3532b3cca209") 176 @TelephonyBaseTest.tel_test_wrap 177 def test_wifi_browsing_for_single_phone(self): 178 """ Browsing websites on wifi. 179 180 Ensure phone attach, data on, WiFi On, WiFi Connected. 181 Verify 5 websites on WiFi. 182 183 Returns: 184 True if pass; False if fail. 185 """ 186 ad = self.android_devices[0] 187 wifi_toggle_state(ad.log, ad, True) 188 if not ensure_wifi_connected(ad.log, ad, self.wifi_network_ssid, 189 self.wifi_network_pass): 190 ad.log.error("WiFi connect fail.") 191 return False 192 for iteration in range(3): 193 ad.log.info("Attempt %d", iteration + 1) 194 if test_data_browsing_success_using_sl4a(ad.log, ad): 195 ad.log.info("Call test PASS in iteration %d", iteration + 1) 196 wifi_toggle_state(ad.log, ad, False) 197 return True 198 time.sleep(WAIT_TIME_ANDROID_STATE_SETTLING) 199 ad.log.info("Data Browsing test FAIL for all 3 iterations") 200 wifi_toggle_state(ad.log, ad, False) 201 return False 202 203 204 @test_tracker_info(uuid="1b0354f3-8668-4a28-90a5-3b3d2b2756d3") 205 @TelephonyBaseTest.tel_test_wrap 206 def test_airplane_mode(self): 207 """ Test airplane mode basic on Phone and Live SIM. 208 209 Ensure phone attach, data on, WiFi off and verify Internet. 210 Turn on airplane mode to make sure detach. 211 Turn off airplane mode to make sure attach. 212 Verify Internet connection. 213 214 Returns: 215 True if pass; False if fail. 216 """ 217 return airplane_mode_test(self.log, self.android_devices[0]) 218 219 @test_tracker_info(uuid="47430f01-583f-4efb-923a-285a51b75d50") 220 @TelephonyBaseTest.tel_test_wrap 221 def test_lte_wifi_switching(self): 222 """Test data connection network switching when phone camped on LTE. 223 224 Ensure phone is camped on LTE 225 Ensure WiFi can connect to live network, 226 Airplane mode is off, data connection is on, WiFi is on. 227 Turn off WiFi, verify data is on cell and browse to google.com is OK. 228 Turn on WiFi, verify data is on WiFi and browse to google.com is OK. 229 Turn off WiFi, verify data is on cell and browse to google.com is OK. 230 231 Returns: 232 True if pass. 233 """ 234 return wifi_cell_switching(self.log, self.android_devices[0], GEN_4G, 235 self.wifi_network_ssid, 236 self.wifi_network_pass) 237 238 @test_tracker_info(uuid="98d9f8c9-0532-49b6-85a3-5246b8314755") 239 @TelephonyBaseTest.tel_test_wrap 240 def test_lte_wifi_switching_stress(self): 241 """LTE WiFi Switching Data Connection Check 242 243 Same steps as test_lte_wifi_switching with stress testing 244 245 Returns: 246 True if pass. 247 """ 248 MINIMUM_SUCCESS_RATE = .95 249 success_count = 0 250 fail_count = 0 251 self.stress_test_number = 10 252 253 for i in range(1, self.stress_test_number + 1): 254 ensure_phones_default_state( 255 self.log, [self.android_devices[0]]) 256 257 if wifi_cell_switching(self.log, self.android_devices[0], GEN_4G, 258 self.wifi_network_ssid, 259 self.wifi_network_pass): 260 success_count += 1 261 result_str = "Succeeded" 262 else: 263 fail_count += 1 264 result_str = "Failed" 265 self.log.info("Iteration {} {}. Current: {} / {} passed.".format( 266 i, result_str, success_count, self.stress_test_number)) 267 268 self.log.info("Final Count - Success: {}, Failure: {} - {}%".format( 269 success_count, fail_count, 270 str(100 * success_count / (success_count + fail_count)))) 271 if success_count / ( 272 success_count + fail_count) >= MINIMUM_SUCCESS_RATE: 273 return True 274 else: 275 return False 276 277 @test_tracker_info(uuid="8a836cf1-600b-4cf3-abfe-2e3da5c11396") 278 @TelephonyBaseTest.tel_test_wrap 279 def test_wcdma_wifi_switching(self): 280 """Test data connection network switching when phone camped on WCDMA. 281 282 Ensure phone is camped on WCDMA 283 Ensure WiFi can connect to live network, 284 Airplane mode is off, data connection is on, WiFi is on. 285 Turn off WiFi, verify data is on cell and browse to google.com is OK. 286 Turn on WiFi, verify data is on WiFi and browse to google.com is OK. 287 Turn off WiFi, verify data is on cell and browse to google.com is OK. 288 289 Returns: 290 True if pass. 291 """ 292 return wifi_cell_switching(self.log, self.android_devices[0], GEN_3G, 293 self.wifi_network_ssid, 294 self.wifi_network_pass) 295 296 @test_tracker_info(uuid="c016f2e8-0af6-42e4-a3cb-a2b7d8b564d0") 297 @TelephonyBaseTest.tel_test_wrap 298 def test_gsm_wifi_switching(self): 299 """Test data connection network switching when phone camped on GSM. 300 301 Ensure phone is camped on GSM 302 Ensure WiFi can connect to live network,, 303 Airplane mode is off, data connection is on, WiFi is on. 304 Turn off WiFi, verify data is on cell and browse to google.com is OK. 305 Turn on WiFi, verify data is on WiFi and browse to google.com is OK. 306 Turn off WiFi, verify data is on cell and browse to google.com is OK. 307 308 Returns: 309 True if pass. 310 """ 311 return wifi_cell_switching(self.log, self.android_devices[0], GEN_2G, 312 self.wifi_network_ssid, 313 self.wifi_network_pass) 314 315 @test_tracker_info(uuid="78d6b258-82d4-47b4-8723-3b3a15412d2d") 316 @TelephonyBaseTest.tel_test_wrap 317 def test_lte_multi_bearer(self): 318 """Test LTE data connection before call and in call. (VoLTE call) 319 320 321 Turn off airplane mode, disable WiFi, enable Cellular Data. 322 Make sure phone in LTE, verify Internet. 323 Initiate a voice call. verify Internet. 324 Disable Cellular Data, verify Internet is inaccessible. 325 Enable Cellular Data, verify Internet. 326 Hangup Voice Call, verify Internet. 327 328 Returns: 329 True if success. 330 False if failed. 331 """ 332 ads = self.android_devices 333 if not phone_setup_volte(self.log, self.android_devices[0]): 334 self.log.error("Failed to setup VoLTE") 335 return False 336 return test_data_connectivity_multi_bearer(self.log, ads, GEN_4G) 337 338 @test_tracker_info(uuid="5c9cb076-0c26-4517-95dc-2ec4974e8ce3") 339 @TelephonyBaseTest.tel_test_wrap 340 def test_wcdma_multi_bearer(self): 341 """Test WCDMA data connection before call and in call. 342 343 Turn off airplane mode, disable WiFi, enable Cellular Data. 344 Make sure phone in WCDMA, verify Internet. 345 Initiate a voice call. verify Internet. 346 Disable Cellular Data, verify Internet is inaccessible. 347 Enable Cellular Data, verify Internet. 348 Hangup Voice Call, verify Internet. 349 350 Returns: 351 True if success. 352 False if failed. 353 """ 354 355 return test_data_connectivity_multi_bearer(self.log, self.android_devices, GEN_3G) 356 357 @test_tracker_info(uuid="314bbf1c-073f-4d48-9817-a6e14f96f3c0") 358 @TelephonyBaseTest.tel_test_wrap 359 def test_gsm_multi_bearer_mo(self): 360 """Test gsm data connection before call and in call. 361 362 Turn off airplane mode, disable WiFi, enable Cellular Data. 363 Make sure phone in GSM, verify Internet. 364 Initiate a MO voice call. Verify there is no Internet during call. 365 Hangup Voice Call, verify Internet. 366 367 Returns: 368 True if success. 369 False if failed. 370 """ 371 372 return test_data_connectivity_multi_bearer(self.log, self.android_devices, 373 GEN_2G, False, DIRECTION_MOBILE_ORIGINATED) 374 375 @test_tracker_info(uuid="549271ff-1034-4d02-8d92-b9d1b2bb912e") 376 @TelephonyBaseTest.tel_test_wrap 377 def test_gsm_multi_bearer_mt(self): 378 """Test gsm data connection before call and in call. 379 380 Turn off airplane mode, disable WiFi, enable Cellular Data. 381 Make sure phone in GSM, verify Internet. 382 Initiate a MT voice call. Verify there is no Internet during call. 383 Hangup Voice Call, verify Internet. 384 385 Returns: 386 True if success. 387 False if failed. 388 """ 389 390 return test_data_connectivity_multi_bearer(self.log, self.android_devices, 391 GEN_2G, False, DIRECTION_MOBILE_TERMINATED) 392 393 @test_tracker_info(uuid="111de471-559a-4bc3-9d3e-de18f098c162") 394 @TelephonyBaseTest.tel_test_wrap 395 def test_wcdma_multi_bearer_stress(self): 396 """Stress Test WCDMA data connection before call and in call. 397 398 This is a stress test for "test_wcdma_multi_bearer". 399 Default MINIMUM_SUCCESS_RATE is set to 95%. 400 401 Returns: 402 True stress pass rate is higher than MINIMUM_SUCCESS_RATE. 403 False otherwise. 404 """ 405 MINIMUM_SUCCESS_RATE = .95 406 success_count = 0 407 fail_count = 0 408 self.number_of_devices = 2 409 410 for i in range(1, self.stress_test_number + 1): 411 412 ensure_phones_default_state( 413 self.log, [self.android_devices[0], self.android_devices[1]]) 414 415 if self.test_wcdma_multi_bearer(): 416 success_count += 1 417 result_str = "Succeeded" 418 else: 419 fail_count += 1 420 result_str = "Failed" 421 self.log.info("Iteration {} {}. Current: {} / {} passed.".format( 422 i, result_str, success_count, self.stress_test_number)) 423 424 self.log.info("Final Count - Success: {}, Failure: {} - {}%".format( 425 success_count, fail_count, 426 str(100 * success_count / (success_count + fail_count)))) 427 if success_count / ( 428 success_count + fail_count) >= MINIMUM_SUCCESS_RATE: 429 return True 430 else: 431 return False 432 433 @test_tracker_info(uuid="c7f14ba7-7ac3-45d2-b391-5ed5c4b0e70b") 434 @TelephonyBaseTest.tel_test_wrap 435 def test_lte_multi_bearer_stress(self): 436 """Stress Test LTE data connection before call and in call. (VoLTE call) 437 438 This is a stress test for "test_lte_multi_bearer". 439 Default MINIMUM_SUCCESS_RATE is set to 95%. 440 441 Returns: 442 True stress pass rate is higher than MINIMUM_SUCCESS_RATE. 443 False otherwise. 444 """ 445 ads = self.android_devices 446 MINIMUM_SUCCESS_RATE = .95 447 success_count = 0 448 fail_count = 0 449 450 for i in range(1, self.stress_test_number + 1): 451 452 ensure_phones_default_state( 453 self.log, [self.android_devices[0], self.android_devices[1]]) 454 455 if self.test_lte_multi_bearer(): 456 success_count += 1 457 result_str = "Succeeded" 458 else: 459 fail_count += 1 460 result_str = "Failed" 461 self.log.info("Iteration {} {}. Current: {} / {} passed.".format( 462 i, result_str, success_count, self.stress_test_number)) 463 464 self.log.info("Final Count - Success: {}, Failure: {} - {}%".format( 465 success_count, fail_count, 466 str(100 * success_count / (success_count + fail_count)))) 467 if success_count / ( 468 success_count + fail_count) >= MINIMUM_SUCCESS_RATE: 469 return True 470 else: 471 return False 472 473 474 @test_tracker_info(uuid="dcb9bdc6-dbe2-47e1-9c2d-6f37c529d366") 475 @TelephonyBaseTest.tel_test_wrap 476 def test_2g(self): 477 """Test data connection in 2G. 478 479 Turn off airplane mode, disable WiFi, enable Cellular Data. 480 Ensure phone data generation is 2G. 481 Verify Internet. 482 Disable Cellular Data, verify Internet is inaccessible. 483 Enable Cellular Data, verify Internet. 484 485 Returns: 486 True if success. 487 False if failed. 488 """ 489 wifi_reset(self.log, self.android_devices[0]) 490 wifi_toggle_state(self.log, self.android_devices[0], False) 491 return data_connectivity_single_bearer(self.log, 492 self.android_devices[0], RAT_2G) 493 494 @test_tracker_info(uuid="84197a49-d73f-44ce-8b9e-9479e5c4dfdc") 495 @TelephonyBaseTest.tel_test_wrap 496 def test_2g_wifi_not_associated(self): 497 """Test data connection in 2G. 498 499 Turn off airplane mode, enable WiFi (but not connected), enable Cellular Data. 500 Ensure phone data generation is 2G. 501 Verify Internet. 502 Disable Cellular Data, verify Internet is inaccessible. 503 Enable Cellular Data, verify Internet. 504 505 Returns: 506 True if success. 507 False if failed. 508 """ 509 wifi_reset(self.log, self.android_devices[0]) 510 wifi_toggle_state(self.log, self.android_devices[0], False) 511 wifi_toggle_state(self.log, self.android_devices[0], True) 512 return data_connectivity_single_bearer(self.log, 513 self.android_devices[0], RAT_2G) 514 515 @test_tracker_info(uuid="97067ebb-130a-4fcb-8e6b-f4ec5874828f") 516 @TelephonyBaseTest.tel_test_wrap 517 def test_3g(self): 518 """Test data connection in 3G. 519 520 Turn off airplane mode, disable WiFi, enable Cellular Data. 521 Ensure phone data generation is 3G. 522 Verify Internet. 523 Disable Cellular Data, verify Internet is inaccessible. 524 Enable Cellular Data, verify Internet. 525 526 Returns: 527 True if success. 528 False if failed. 529 """ 530 wifi_reset(self.log, self.android_devices[0]) 531 wifi_toggle_state(self.log, self.android_devices[0], False) 532 return data_connectivity_single_bearer(self.log, 533 self.android_devices[0], RAT_3G) 534 535 @test_tracker_info(uuid="ffe2a392-95b8-4a4d-8a6f-bfa846c3462f") 536 @TelephonyBaseTest.tel_test_wrap 537 def test_3g_wifi_not_associated(self): 538 """Test data connection in 3G. 539 540 Turn off airplane mode, enable WiFi (but not connected), enable Cellular Data. 541 Ensure phone data generation is 3G. 542 Verify Internet. 543 Disable Cellular Data, verify Internet is inaccessible. 544 Enable Cellular Data, verify Internet. 545 546 Returns: 547 True if success. 548 False if failed. 549 """ 550 wifi_reset(self.log, self.android_devices[0]) 551 wifi_toggle_state(self.log, self.android_devices[0], False) 552 wifi_toggle_state(self.log, self.android_devices[0], True) 553 return data_connectivity_single_bearer(self.log, 554 self.android_devices[0], RAT_3G) 555 556 @test_tracker_info(uuid="9c2f459f-1aac-4c68-818b-8698e8124c8b") 557 @TelephonyBaseTest.tel_test_wrap 558 def test_4g(self): 559 """Test data connection in 4g. 560 561 Turn off airplane mode, disable WiFi, enable Cellular Data. 562 Ensure phone data generation is 4g. 563 Verify Internet. 564 Disable Cellular Data, verify Internet is inaccessible. 565 Enable Cellular Data, verify Internet. 566 567 Returns: 568 True if success. 569 False if failed. 570 """ 571 wifi_reset(self.log, self.android_devices[0]) 572 wifi_toggle_state(self.log, self.android_devices[0], False) 573 return data_connectivity_single_bearer(self.log, 574 self.android_devices[0], RAT_4G) 575 576 @test_tracker_info(uuid="015a39a1-15ac-4b76-962b-d7d82d52d425") 577 @TelephonyBaseTest.tel_test_wrap 578 def test_4g_wifi_not_associated(self): 579 """Test data connection in 4g. 580 581 Turn off airplane mode, enable WiFi (but not connected), enable Cellular Data. 582 Ensure phone data generation is 4g. 583 Verify Internet. 584 Disable Cellular Data, verify Internet is inaccessible. 585 Enable Cellular Data, verify Internet. 586 587 Returns: 588 True if success. 589 False if failed. 590 """ 591 wifi_reset(self.log, self.android_devices[0]) 592 wifi_toggle_state(self.log, self.android_devices[0], False) 593 wifi_toggle_state(self.log, self.android_devices[0], True) 594 return data_connectivity_single_bearer(self.log, 595 self.android_devices[0], RAT_4G) 596 597 @test_tracker_info(uuid="44f47b64-f8bc-4a17-9195-42dcca0806bb") 598 @TelephonyBaseTest.tel_test_wrap 599 def test_3g_stress(self): 600 """Stress Test data connection in 3G. 601 602 This is a stress test for "test_3g". 603 Default MINIMUM_SUCCESS_RATE is set to 95%. 604 605 Returns: 606 True stress pass rate is higher than MINIMUM_SUCCESS_RATE. 607 False otherwise. 608 """ 609 MINIMUM_SUCCESS_RATE = .95 610 success_count = 0 611 fail_count = 0 612 613 for i in range(1, self.stress_test_number + 1): 614 615 ensure_phones_default_state(self.log, [self.android_devices[0]]) 616 wifi_reset(self.log, self.android_devices[0]) 617 wifi_toggle_state(self.log, self.android_devices[0], False) 618 619 if data_connectivity_single_bearer( 620 self.log, self.android_devices[0], RAT_3G): 621 success_count += 1 622 result_str = "Succeeded" 623 else: 624 fail_count += 1 625 result_str = "Failed" 626 self.log.info("Iteration {} {}. Current: {} / {} passed.".format( 627 i, result_str, success_count, self.stress_test_number)) 628 629 self.log.info("Final Count - Success: {}, Failure: {} - {}%".format( 630 success_count, fail_count, 631 str(100 * success_count / (success_count + fail_count)))) 632 if success_count / ( 633 success_count + fail_count) >= MINIMUM_SUCCESS_RATE: 634 return True 635 else: 636 return False 637 638 @test_tracker_info(uuid="c8876388-0441-4a51-81e6-ac2cb358a531") 639 @TelephonyBaseTest.tel_test_wrap 640 def test_4g_stress(self): 641 """Stress Test data connection in 4g. 642 643 This is a stress test for "test_4g". 644 Default MINIMUM_SUCCESS_RATE is set to 95%. 645 646 Returns: 647 True stress pass rate is higher than MINIMUM_SUCCESS_RATE. 648 False otherwise. 649 """ 650 MINIMUM_SUCCESS_RATE = .95 651 success_count = 0 652 fail_count = 0 653 self.number_of_devices = 1 654 655 for i in range(1, self.stress_test_number + 1): 656 657 ensure_phones_default_state(self.log, [self.android_devices[0]]) 658 wifi_reset(self.log, self.android_devices[0]) 659 wifi_toggle_state(self.log, self.android_devices[0], False) 660 661 if data_connectivity_single_bearer( 662 self.log, self.android_devices[0], RAT_4G): 663 success_count += 1 664 result_str = "Succeeded" 665 else: 666 fail_count += 1 667 result_str = "Failed" 668 self.log.info("Iteration {} {}. Current: {} / {} passed.".format( 669 i, result_str, success_count, self.stress_test_number)) 670 671 self.log.info("Final Count - Success: {}, Failure: {} - {}%".format( 672 success_count, fail_count, 673 str(100 * success_count / (success_count + fail_count)))) 674 if success_count / ( 675 success_count + fail_count) >= MINIMUM_SUCCESS_RATE: 676 return True 677 else: 678 return False 679 680 681 @test_tracker_info(uuid="2d945656-22f7-4610-9a84-40ce04d603a4") 682 @TelephonyBaseTest.tel_test_wrap 683 def test_tethering_4g_to_bluetooth(self): 684 """Bluetooth Tethering test: LTE to Bluetooth Tethering 685 686 1. DUT in LTE mode, idle. 687 2. DUT start Bluetooth Tethering 688 3. PhoneB disable data, connect to DUT's softAP 689 4. Verify Internet access on DUT and PhoneB 690 5. Toggle provider bluetooth connection 691 6. Verify Internet access on DUT and PhoneB 692 693 Returns: 694 True if success. 695 False if failed. 696 """ 697 if not test_setup_tethering(self.log, self.provider, self.clients, RAT_4G): 698 self.log.error("Verify 4G Internet access failed.") 699 return False 700 701 return verify_bluetooth_tethering_connection(self.log, self.provider, self.clients) 702 703 @test_tracker_info(uuid="8d2ae56b-c2c1-4c32-9b8e-5044007b5b90") 704 @TelephonyBaseTest.tel_test_wrap 705 def test_tethering_4g_to_bluetooth_with_voice_call(self): 706 """Bluetooth Tethering test: LTE to Bluetooth Tethering 707 708 1. DUT in LTE mode, idle. 709 2. DUT start Bluetooth Tethering 710 3. PhoneB disable data, connect to DUT's softAP 711 4. Verify Internet access on DUT and PhoneB 712 5. Verify provider and client are able to make or receive phone call 713 6. Verify Internet access on DUT and PhoneB 714 715 Returns: 716 True if success. 717 False if failed. 718 """ 719 if not test_setup_tethering(self.log, self.provider, self.clients, RAT_4G): 720 self.log.error("Verify 4G Internet access failed.") 721 return False 722 723 return verify_bluetooth_tethering_connection(self.log, self.provider, self.clients, 724 toggle_tethering=False, toggle_bluetooth=False, voice_call=True) 725 726 @test_tracker_info(uuid="b4617727-fa83-4451-89d7-7e574c0a0938") 727 @TelephonyBaseTest.tel_test_wrap 728 def test_tethering_4g_to_bluetooth_toggle_data(self): 729 """Bluetooth Tethering test: LTE to Bluetooth Tethering 730 731 1. DUT in LTE mode, idle. 732 2. DUT start Bluetooth Tethering 733 3. PhoneB disable data, connect to DUT's softAP 734 4. Verify Internet access on DUT and PhoneB 735 5. Toggle provider data connection 736 6. Verify Internet access on DUT and PhoneB 737 738 Returns: 739 True if success. 740 False if failed. 741 """ 742 if not test_setup_tethering(self.log, self.provider, self.clients, RAT_4G): 743 self.log.error("Verify 4G Internet access failed.") 744 return False 745 746 return verify_bluetooth_tethering_connection(self.log, self.provider, self.clients, 747 toggle_tethering=False, toggle_bluetooth=False, toggle_data=True) 748 749 @test_tracker_info(uuid="6a0f6001-609d-41f2-ad09-c8ae19f73ac8") 750 @TelephonyBaseTest.tel_test_wrap 751 def test_tethering_4g_to_bluetooth_toggle_tethering(self): 752 """Bluetooth Tethering test: LTE to Bluetooth Tethering 753 754 1. DUT in LTE mode, idle. 755 2. DUT start Bluetooth Tethering 756 3. PhoneB disable data, connect to DUT's softAP 757 4. Verify Internet access on DUT and PhoneB 758 5. Toggle provider bluetooth tethering 759 6. Verify Internet access on DUT and PhoneB 760 761 Returns: 762 True if success. 763 False if failed. 764 """ 765 if not test_setup_tethering(self.log, self.provider, self.clients, RAT_4G): 766 self.log.error("Verify 4G Internet access failed.") 767 return False 768 769 return verify_bluetooth_tethering_connection(self.log, self.provider, self.clients, 770 toggle_tethering=True, toggle_bluetooth=False, toggle_data=False) 771 772 @test_tracker_info(uuid="b1abc1ac-8018-4956-a17e-bf2ceaf264ea") 773 @TelephonyBaseTest.tel_test_wrap 774 def test_tethering_3g_to_bluetooth(self): 775 """Bluetooth Tethering test: 3G to Bluetoothing Tethering 776 777 1. DUT in 3G mode, idle. 778 2. DUT start bluetooth Tethering 779 3. PhoneB disable data, connect to DUT's softAP 780 4. Verify Internet access on DUT and PhoneB 781 5. Toggle provider bluetooth connection 782 6. Verify Internet access on DUT and PhoneB 783 784 Returns: 785 True if success. 786 False if failed. 787 """ 788 if not test_setup_tethering(self.log, self.provider, self.clients, RAT_3G): 789 self.log.error("Verify 3G Internet access failed.") 790 return False 791 792 return verify_bluetooth_tethering_connection(self.log, self.provider, self.clients) 793 794 @test_tracker_info(uuid="69793745-0c49-4cef-9879-d372e3a3f4c7") 795 @TelephonyBaseTest.tel_test_wrap 796 def test_tethering_3g_to_bluetooth_with_voice_call(self): 797 """Bluetooth Tethering test: 3G to Bluetooth Tethering 798 799 1. DUT in 3G mode, idle. 800 2. DUT start Bluetooth Tethering 801 3. PhoneB disable data, connect to DUT's softAP 802 4. Verify Internet access on DUT and PhoneB 803 5. Verify provider and client are able to make or receive phone call 804 6. Verify Internet access on DUT and PhoneB 805 806 Returns: 807 True if success. 808 False if failed. 809 """ 810 if not test_setup_tethering(self.log, self.provider, self.clients, RAT_3G): 811 self.log.error("Verify 3G Internet access failed.") 812 return False 813 814 return verify_bluetooth_tethering_connection(self.log, self.provider, self.clients, 815 toggle_tethering=False, toggle_bluetooth=False, voice_call=True) 816 817 @test_tracker_info(uuid="4275ee69-dfdf-4f47-82c5-4224fceee761") 818 @TelephonyBaseTest.tel_test_wrap 819 def test_tethering_3g_to_bluetooth_toggle_data(self): 820 """Bluetooth Tethering test: 3G to Bluetoothing Tethering 821 822 1. DUT in 3G mode, idle. 823 2. DUT start bluetooth Tethering 824 3. PhoneB disable data, connect to DUT's softAP 825 4. Verify Internet access on DUT and PhoneB 826 5. Toggle provider data connection 827 6. Verify Internet access on DUT and PhoneB 828 829 Returns: 830 True if success. 831 False if failed. 832 """ 833 if not test_setup_tethering(self.log, self.provider, self.clients, RAT_3G): 834 self.log.error("Verify 3G Internet access failed.") 835 return False 836 837 return verify_bluetooth_tethering_connection(self.log, self.provider, self.clients, 838 toggle_tethering=False, toggle_bluetooth=False, toggle_data=True) 839 840 @test_tracker_info(uuid="db0e0f27-1a4f-4301-832d-b66415e289f3") 841 @TelephonyBaseTest.tel_test_wrap 842 def test_tethering_2g_to_bluetooth(self): 843 """Bluetooth Tethering test: 2G to Bluetooth Tethering 844 845 1. DUT in 2G mode, idle. 846 2. DUT start bluetooth Tethering 847 3. PhoneB disable data, connect to DUT's softAP 848 4. Verify Internet access on DUT and PhoneB 849 5. Toggle provider bluetooth connection 850 6. Verify Internet access on DUT and PhoneB 851 852 Returns: 853 True if success. 854 False if failed. 855 """ 856 for a in self.android_devices: 857 a.adb.shell("setprop persist.bluetooth.btsnoopenable true") 858 if not toggle_airplane_mode_by_adb(self.log, a, True): 859 self.log.error("Failed to toggle airplane mode on") 860 return False 861 if not toggle_airplane_mode_by_adb(self.log, a, False): 862 self.log.error("Failed to toggle airplane mode off") 863 return False 864 865 if not test_setup_tethering(self.log, self.provider, self.clients, RAT_2G): 866 self.log.error("Verify 3G Internet access failed.") 867 return False 868 869 return verify_bluetooth_tethering_connection(self.log, self.provider, self.clients) 870 871 @test_tracker_info(uuid="584e9fa5-a38e-47cd-aa33-fcf8d72c423e") 872 @TelephonyBaseTest.tel_test_wrap 873 def test_tethering_2g_to_bluetooth_with_voice_call(self): 874 """Bluetooth Tethering test: 2G to Bluetooth Tethering 875 876 1. DUT in 2G mode, idle. 877 2. DUT start Bluetooth Tethering 878 3. PhoneB disable data, connect to DUT's softAP 879 4. Verify Internet access on DUT and PhoneB 880 5. Verify provider and client are able to make or receive phone call 881 6. Verify Internet access on DUT and PhoneB 882 883 Returns: 884 True if success. 885 False if failed. 886 """ 887 if not test_setup_tethering(self.log, self.provider, self.clients, RAT_2G): 888 self.log.error("Verify 2G Internet access failed.") 889 return False 890 891 return verify_bluetooth_tethering_connection(self.log, self.provider, self.clients, 892 toggle_tethering=False, toggle_bluetooth=False, voice_call=True) 893 894 @test_tracker_info(uuid="be3e74f9-3dc8-4b72-8a33-32bff0868a44") 895 @TelephonyBaseTest.tel_test_wrap 896 def test_tethering_2g_to_bluetooth_toggle_data(self): 897 """Bluetooth Tethering test: 2G to Bluetooth Tethering 898 899 1. DUT in 2G mode, idle. 900 2. DUT start Bluetooth Tethering 901 3. PhoneB disable data, connect to DUT's softAP 902 4. Verify Internet access on DUT and PhoneB 903 5. Toggle provider data connection 904 6. Verify Internet access on DUT and PhoneB 905 906 Returns: 907 True if success. 908 False if failed. 909 """ 910 if not test_setup_tethering(self.log, self.provider, self.clients, RAT_2G): 911 self.log.error("Verify 4G Internet access failed.") 912 return False 913 914 return verify_bluetooth_tethering_connection(self.log, self.provider, self.clients, 915 toggle_tethering=False, toggle_bluetooth=False, toggle_data=True) 916 917 @test_tracker_info(uuid="4a106549-0bfa-4c8f-8e66-edec93fabadf") 918 @TelephonyBaseTest.tel_test_wrap 919 def test_tethering_rat_from_4g_to_3g_bluetooth(self): 920 """Bluetooth Tethering test: 2G to Bluetooth Tethering 921 922 1. DUT in 4G mode, idle. 923 2. DUT start bluetooth Tethering 924 3. PhoneB disable data, connect to DUT's softAP 925 4. Verify Internet access on DUT and PhoneB 926 5. Change provider RAT to 3G 927 6. Verify Internet access on DUT and PhoneB 928 929 Returns: 930 True if success. 931 False if failed. 932 """ 933 if not test_setup_tethering(self.log, self.provider, self.clients, RAT_4G): 934 self.log.error("Verify 3G Internet access failed.") 935 return False 936 937 return verify_bluetooth_tethering_connection(self.log, self.provider, self.clients, 938 toggle_tethering=False, 939 toggle_bluetooth=False, 940 toggle_data=False, 941 change_rat=RAT_3G) 942 943 @test_tracker_info(uuid="eaa5b61b-f054-437f-ae82-8d80f6487785") 944 @TelephonyBaseTest.tel_test_wrap 945 def test_tethering_rat_from_4g_to_2g_bluetooth(self): 946 """Bluetooth Tethering test: 2G to Bluetooth Tethering 947 948 1. DUT in 4G mode, idle. 949 2. DUT start bluetooth Tethering 950 3. PhoneB disable data, connect to DUT's softAP 951 4. Verify Internet access on DUT and PhoneB 952 5. Change provider RAT to 2G 953 6. Verify Internet access on DUT and PhoneB 954 955 Returns: 956 True if success. 957 False if failed. 958 """ 959 if not test_setup_tethering(self.log, self.provider, self.clients, RAT_4G): 960 self.log.error("Verify 3G Internet access failed.") 961 return False 962 963 return verify_bluetooth_tethering_connection(self.log, self.provider, self.clients, 964 toggle_tethering=False, 965 toggle_bluetooth=False, 966 toggle_data=False, 967 change_rat=RAT_2G) 968 969 @test_tracker_info(uuid="912a11a3-14b3-4928-885f-cea69f14a571") 970 @TelephonyBaseTest.tel_test_wrap 971 def test_tethering_4g_to_2gwifi(self): 972 """WiFi Tethering test: LTE to WiFI 2.4G Tethering 973 974 1. DUT in LTE mode, idle. 975 2. DUT start 2.4G WiFi Tethering 976 3. PhoneB disable data, connect to DUT's softAP 977 4. Verify Internet access on DUT and PhoneB 978 979 Returns: 980 True if success. 981 False if failed. 982 """ 983 if not test_setup_tethering(self.log, self.provider, self.clients, RAT_4G): 984 self.log.error("Verify 4G Internet access failed.") 985 return False 986 987 return wifi_tethering_setup_teardown( 988 self.log, 989 self.provider, 990 self.clients, 991 ap_band=WIFI_CONFIG_APBAND_2G, 992 check_interval=10, 993 check_iteration=10) 994 995 @test_tracker_info(uuid="743e3998-d39f-42b9-b11f-009dcee34f3f") 996 @TelephonyBaseTest.tel_test_wrap 997 def test_tethering_4g_to_5gwifi(self): 998 """WiFi Tethering test: LTE to WiFI 5G Tethering 999 1000 1. DUT in LTE mode, idle. 1001 2. DUT start 5G WiFi Tethering 1002 3. PhoneB disable data, connect to DUT's softAP 1003 4. Verify Internet access on DUT and PhoneB 1004 1005 Returns: 1006 True if success. 1007 False if failed. 1008 """ 1009 if not test_setup_tethering(self.log, self.provider, self.clients, RAT_4G): 1010 self.log.error("Verify 4G Internet access failed.") 1011 return False 1012 1013 return wifi_tethering_setup_teardown( 1014 self.log, 1015 self.provider, 1016 self.clients, 1017 ap_band=WIFI_CONFIG_APBAND_5G, 1018 check_interval=10, 1019 check_iteration=10) 1020 1021 1022 @test_tracker_info(uuid="c1a16464-3800-40d3-ba63-35db784e0383") 1023 @TelephonyBaseTest.tel_test_wrap 1024 def test_tethering_default_to_5gwifi(self): 1025 """WiFi Tethering test: Default to WiFI 5G Tethering 1026 1027 1. DUT in default mode, idle. 1028 2. DUT start 5G WiFi Tethering 1029 3. PhoneB disable data, connect to DUT's softAP 1030 4. Verify Internet access on DUT and PhoneB 1031 5. True: Stop 1032 False: Change DUT to next device and repeat until find the device 1033 with tethering capability 1034 1035 Returns: 1036 True if success. 1037 False if no device has tethering capability. 1038 """ 1039 num = len(self.android_devices) 1040 for idx, ad in enumerate(self.android_devices): 1041 self.provider = self.android_devices[idx] 1042 self.clients = self.android_devices[: 1043 idx] + self.android_devices[idx 1044 + 1045 1:] 1046 ensure_phones_default_state(self.log, self.android_devices) 1047 wifi_toggle_state(self.log, self.provider, False) 1048 1049 if not test_setup_tethering(self.log, self.provider, self.clients, None): 1050 self.provider.log.error("Data connection check failed.") 1051 continue 1052 1053 if not self.provider.droid.carrierConfigIsTetheringModeAllowed( 1054 TETHERING_MODE_WIFI, 1055 MAX_WAIT_TIME_TETHERING_ENTITLEMENT_CHECK): 1056 self.provider.log.info("Tethering is not entitled") 1057 continue 1058 1059 if wifi_tethering_setup_teardown( 1060 self.log, 1061 self.provider, [self.clients[0]], 1062 ap_band=WIFI_CONFIG_APBAND_5G, 1063 check_interval=10, 1064 check_iteration=10): 1065 self.android_devices = [self.provider] + self.clients 1066 return True 1067 elif idx == num - 1: 1068 self.log.error("Tethering is not working on all devices") 1069 return False 1070 self.log.error( 1071 "Failed to enable tethering on any device in this testbed") 1072 raise signals.TestAbortClass( 1073 "Tethering is not available on all devices in this testbed") 1074 1075 @test_tracker_info(uuid="c9a570b0-838c-44ba-991c-f1ddeee21f3c") 1076 @TelephonyBaseTest.tel_test_wrap 1077 def test_tethering_default_to_2gwifi(self): 1078 """WiFi Tethering test: Default to WiFI 2G Tethering 1079 1080 1. DUT in default mode, idle. 1081 2. DUT start 2G WiFi Tethering 1082 3. PhoneB disable data, connect to DUT's softAP 1083 4. Verify Internet access on DUT and PhoneB 1084 5. True: Stop 1085 False: Change DUT to next device and repeat until find the device 1086 with tethering capability 1087 1088 Returns: 1089 True if success. 1090 False if no device has tethering capability. 1091 """ 1092 num = len(self.android_devices) 1093 for idx, ad in enumerate(self.android_devices): 1094 self.provider = self.android_devices[idx] 1095 self.clients = self.android_devices[: 1096 idx] + self.android_devices[idx 1097 + 1098 1:] 1099 ensure_phones_default_state(self.log, self.android_devices) 1100 wifi_toggle_state(self.log, self.provider, False) 1101 1102 if not test_setup_tethering(self.log, self.provider, self.clients, None): 1103 self.provider.log.error("Data connection check failed.") 1104 continue 1105 1106 if not self.provider.droid.carrierConfigIsTetheringModeAllowed( 1107 TETHERING_MODE_WIFI, 1108 MAX_WAIT_TIME_TETHERING_ENTITLEMENT_CHECK): 1109 self.provider.log.info("Tethering is not entitled") 1110 continue 1111 1112 if wifi_tethering_setup_teardown( 1113 self.log, 1114 self.provider, [self.clients[0]], 1115 ap_band=WIFI_CONFIG_APBAND_2G, 1116 check_interval=10, 1117 check_iteration=10): 1118 self.android_devices = [self.provider] + self.clients 1119 return True 1120 elif idx == num - 1: 1121 self.log.error("Tethering is not working on all devices") 1122 return False 1123 self.log.error( 1124 "Failed to enable tethering on any device in this testbed") 1125 raise signals.TestAbortClass( 1126 "Tethering is not available on all devices in this testbed") 1127 1128 @test_tracker_info(uuid="59be8d68-f05b-4448-8584-de971174fd81") 1129 @TelephonyBaseTest.tel_test_wrap 1130 def test_tethering_3g_to_2gwifi(self): 1131 """WiFi Tethering test: 3G to WiFI 2.4G Tethering 1132 1133 1. DUT in 3G mode, idle. 1134 2. DUT start 2.4G WiFi Tethering 1135 3. PhoneB disable data, connect to DUT's softAP 1136 4. Verify Internet access on DUT and PhoneB 1137 1138 Returns: 1139 True if success. 1140 False if failed. 1141 """ 1142 if not test_setup_tethering(self.log, self.provider, self.clients, RAT_3G): 1143 self.log.error("Verify 3G Internet access failed.") 1144 return False 1145 1146 return wifi_tethering_setup_teardown( 1147 self.log, 1148 self.provider, 1149 self.clients, 1150 ap_band=WIFI_CONFIG_APBAND_2G, 1151 check_interval=10, 1152 check_iteration=10) 1153 1154 @test_tracker_info(uuid="1be6b741-92e8-4ee1-9f59-e7f9f369b065") 1155 @TelephonyBaseTest.tel_test_wrap 1156 def test_tethering_3g_to_5gwifi(self): 1157 """WiFi Tethering test: 3G to WiFI 5G Tethering 1158 1159 1. DUT in 3G mode, idle. 1160 2. DUT start 5G WiFi Tethering 1161 3. PhoneB disable data, connect to DUT's softAP 1162 4. Verify Internet access on DUT and PhoneB 1163 1164 Returns: 1165 True if success. 1166 False if failed. 1167 """ 1168 if not test_setup_tethering(self.log, self.provider, self.clients, RAT_3G): 1169 self.log.error("Verify 3G Internet access failed.") 1170 return False 1171 1172 return wifi_tethering_setup_teardown( 1173 self.log, 1174 self.provider, 1175 self.clients, 1176 ap_band=WIFI_CONFIG_APBAND_5G, 1177 check_interval=10, 1178 check_iteration=10) 1179 1180 @test_tracker_info(uuid="89fe6321-4c0d-40c0-89b2-54008ecca68f") 1181 @TelephonyBaseTest.tel_test_wrap 1182 def test_tethering_2g_to_2gwifi(self): 1183 """WiFi Tethering test: 2G to WiFI 2.4G Tethering 1184 1185 1. DUT in 2G mode, idle. 1186 2. DUT start 2.4G WiFi Tethering 1187 3. PhoneB disable data, connect to DUT's softAP 1188 4. Verify Internet access on DUT and PhoneB 1189 1190 Returns: 1191 True if success. 1192 False if failed. 1193 """ 1194 if not test_setup_tethering(self.log, self.provider, self.clients, RAT_2G): 1195 self.log.error("Verify 2G Internet access failed.") 1196 return False 1197 1198 return wifi_tethering_setup_teardown( 1199 self.log, 1200 self.provider, [self.clients[0]], 1201 ap_band=WIFI_CONFIG_APBAND_2G, 1202 check_interval=10, 1203 check_iteration=10) 1204 1205 @test_tracker_info(uuid="b8258d51-9581-4d52-80b6-501941ec1191") 1206 @TelephonyBaseTest.tel_test_wrap 1207 def test_tethering_2g_to_5gwifi(self): 1208 """WiFi Tethering test: 2G to WiFI 5G Tethering 1209 1210 1. DUT in 2G mode, idle. 1211 2. DUT start 5G WiFi Tethering 1212 3. PhoneB disable data, connect to DUT's softAP 1213 4. Verify Internet access on DUT and PhoneB 1214 1215 Returns: 1216 True if success. 1217 False if failed. 1218 """ 1219 if not test_setup_tethering(self.log, self.provider, self.clients, RAT_2G): 1220 self.log.error("Verify 2G Internet access failed.") 1221 return False 1222 1223 return wifi_tethering_setup_teardown( 1224 self.log, 1225 self.provider, [self.clients[0]], 1226 ap_band=WIFI_CONFIG_APBAND_5G, 1227 check_interval=10, 1228 check_iteration=10) 1229 1230 @test_tracker_info(uuid="8ed766a6-71c5-4b3b-8897-a4e796c75619") 1231 @TelephonyBaseTest.tel_test_wrap 1232 def test_disable_wifi_tethering_resume_connected_wifi(self): 1233 """WiFi Tethering test: WiFI connected to 2.4G network, 1234 start (LTE) 2.4G WiFi tethering, then stop tethering 1235 1236 1. DUT in data connected, idle. WiFi connected to 2.4G Network 1237 2. DUT start 2.4G WiFi Tethering 1238 3. PhoneB disable data, connect to DUT's softAP 1239 4. Verify Internet access on DUT and PhoneB 1240 5. Disable WiFi Tethering on DUT. 1241 6. Verify DUT automatically connect to previous WiFI network 1242 1243 Returns: 1244 True if success. 1245 False if failed. 1246 """ 1247 # Ensure provider connecting to wifi network. 1248 def setup_provider_internet_connection(): 1249 return setup_device_internet_connection(self.log, 1250 self.provider, 1251 self.wifi_network_ssid, 1252 self.wifi_network_pass) 1253 1254 if not test_wifi_tethering(self.log, 1255 self.provider, 1256 self.clients, 1257 [self.clients[0]], 1258 None, 1259 WIFI_CONFIG_APBAND_2G, 1260 check_interval=10, 1261 check_iteration=2, 1262 pre_teardown_func=setup_provider_internet_connection): 1263 return False 1264 1265 if not wait_and_verify_device_internet_connection(self.log, self.provider): 1266 return False 1267 return True 1268 1269 @test_tracker_info(uuid="b879ceb2-1b80-4762-93f9-afef4d688c28") 1270 @TelephonyBaseTest.tel_test_wrap 1271 def test_toggle_data_during_active_wifi_tethering(self): 1272 """WiFi Tethering test: Toggle Data during active WiFi Tethering 1273 1274 1. DUT data connection is on and idle. 1275 2. DUT start 2.4G WiFi Tethering 1276 3. PhoneB disable data, connect to DUT's softAP 1277 4. Verify Internet access on DUT and PhoneB 1278 5. Disable Data on DUT, verify PhoneB still connected to WiFi, but no Internet access. 1279 6. Enable Data on DUT, verify PhoneB still connected to WiFi and have Internet access. 1280 1281 Returns: 1282 True if success. 1283 False if failed. 1284 """ 1285 if not verify_toggle_data_during_wifi_tethering(self.log, 1286 self.provider, 1287 self.clients): 1288 return False 1289 return True 1290 1291 # Invalid Live Test. Can't rely on the result of this test with live network. 1292 # Network may decide not to change the RAT when data conenction is active. 1293 @test_tracker_info(uuid="c92a961b-e85d-435c-8988-052928add591") 1294 @TelephonyBaseTest.tel_test_wrap 1295 def test_change_rat_during_active_wifi_tethering_lte_to_3g(self): 1296 """WiFi Tethering test: Change Cellular Data RAT generation from LTE to 3G, 1297 during active WiFi Tethering. 1298 1299 1. DUT in LTE mode, idle. 1300 2. DUT start 2.4G WiFi Tethering 1301 3. PhoneB disable data, connect to DUT's softAP 1302 4. Verily Internet access on DUT and PhoneB 1303 5. Change DUT Cellular Data RAT generation from LTE to 3G. 1304 6. Verify both DUT and PhoneB have Internet access. 1305 1306 Returns: 1307 True if success. 1308 False if failed. 1309 """ 1310 if not test_setup_tethering(self.log, self.provider, self.clients, RAT_4G): 1311 self.log.error("Verify 4G Internet access failed.") 1312 return False 1313 try: 1314 if not wifi_tethering_setup_teardown( 1315 self.log, 1316 self.provider, [self.clients[0]], 1317 ap_band=WIFI_CONFIG_APBAND_2G, 1318 check_interval=10, 1319 check_iteration=2, 1320 do_cleanup=False): 1321 self.log.error("WiFi Tethering failed.") 1322 return False 1323 1324 if not self.provider.droid.wifiIsApEnabled(): 1325 self.provider.log.error("Provider WiFi tethering stopped.") 1326 return False 1327 1328 self.log.info("Provider change RAT from LTE to 3G.") 1329 if not ensure_network_generation( 1330 self.log, 1331 self.provider, 1332 RAT_3G, 1333 voice_or_data=NETWORK_SERVICE_DATA, 1334 toggle_apm_after_setting=False): 1335 self.provider.log.error("Provider failed to reselect to 3G.") 1336 return False 1337 time.sleep(WAIT_TIME_DATA_STATUS_CHANGE_DURING_WIFI_TETHERING) 1338 if not verify_internet_connection(self.log, self.provider): 1339 self.provider.log.error("Data not available on Provider.") 1340 return False 1341 if not self.provider.droid.wifiIsApEnabled(): 1342 self.provider.log.error("Provider WiFi tethering stopped.") 1343 return False 1344 if not tethering_check_internet_connection( 1345 self.log, self.provider, [self.clients[0]], 10, 5): 1346 return False 1347 finally: 1348 if not wifi_tethering_cleanup(self.log, self.provider, 1349 self.clients): 1350 return False 1351 return True 1352 1353 # Invalid Live Test. Can't rely on the result of this test with live network. 1354 # Network may decide not to change the RAT when data conenction is active. 1355 @test_tracker_info(uuid="eb5f0180-b70d-436f-8fcb-60c59307cc43") 1356 @TelephonyBaseTest.tel_test_wrap 1357 def test_change_rat_during_active_wifi_tethering_3g_to_lte(self): 1358 """WiFi Tethering test: Change Cellular Data RAT generation from 3G to LTE, 1359 during active WiFi Tethering. 1360 1361 1. DUT in 3G mode, idle. 1362 2. DUT start 2.4G WiFi Tethering 1363 3. PhoneB disable data, connect to DUT's softAP 1364 4. Verily Internet access on DUT and PhoneB 1365 5. Change DUT Cellular Data RAT generation from 3G to LTE. 1366 6. Verify both DUT and PhoneB have Internet access. 1367 1368 Returns: 1369 True if success. 1370 False if failed. 1371 """ 1372 if not test_setup_tethering(self.log, self.provider, self.clients, RAT_3G): 1373 self.log.error("Verify 3G Internet access failed.") 1374 return False 1375 try: 1376 if not wifi_tethering_setup_teardown( 1377 self.log, 1378 self.provider, [self.clients[0]], 1379 ap_band=WIFI_CONFIG_APBAND_2G, 1380 check_interval=10, 1381 check_iteration=2, 1382 do_cleanup=False): 1383 self.log.error("WiFi Tethering failed.") 1384 return False 1385 1386 if not self.provider.droid.wifiIsApEnabled(): 1387 self.log.error("Provider WiFi tethering stopped.") 1388 return False 1389 1390 self.log.info("Provider change RAT from 3G to 4G.") 1391 if not ensure_network_generation( 1392 self.log, 1393 self.provider, 1394 RAT_4G, 1395 voice_or_data=NETWORK_SERVICE_DATA, 1396 toggle_apm_after_setting=False): 1397 self.log.error("Provider failed to reselect to 4G.") 1398 return False 1399 time.sleep(WAIT_TIME_DATA_STATUS_CHANGE_DURING_WIFI_TETHERING) 1400 if not verify_internet_connection(self.log, self.provider): 1401 self.provider.log.error("Data not available on Provider.") 1402 return False 1403 if not self.provider.droid.wifiIsApEnabled(): 1404 self.provider.log.error("Provider WiFi tethering stopped.") 1405 return False 1406 if not tethering_check_internet_connection( 1407 self.log, self.provider, [self.clients[0]], 10, 5): 1408 return False 1409 finally: 1410 if not wifi_tethering_cleanup(self.log, self.provider, [self.clients[0]]): 1411 return False 1412 return True 1413 1414 @test_tracker_info(uuid="12a6c910-fa96-4d9b-99a5-8391fea33732") 1415 @TelephonyBaseTest.tel_test_wrap 1416 def test_toggle_apm_during_active_wifi_tethering(self): 1417 """WiFi Tethering test: Toggle APM during active WiFi Tethering 1418 1419 1. DUT in LTE mode, idle. 1420 2. DUT start 2.4G WiFi Tethering 1421 3. PhoneB disable data, connect to DUT's softAP 1422 4. Verify Internet access on DUT and PhoneB 1423 5. DUT toggle APM on, verify WiFi tethering stopped, PhoneB lost WiFi connection. 1424 6. DUT toggle APM off, verify PhoneA have cellular data and Internet connection. 1425 1426 Returns: 1427 True if success. 1428 False if failed. 1429 """ 1430 if not test_setup_tethering(self.log, self.provider, self.clients, RAT_4G): 1431 self.log.error("Verify 4G Internet access failed.") 1432 return False 1433 try: 1434 ssid = rand_ascii_str(10) 1435 if not wifi_tethering_setup_teardown( 1436 self.log, 1437 self.provider, [self.clients[0]], 1438 ap_band=WIFI_CONFIG_APBAND_2G, 1439 check_interval=10, 1440 check_iteration=2, 1441 do_cleanup=False, 1442 ssid=ssid): 1443 self.log.error("WiFi Tethering failed.") 1444 return False 1445 1446 if not verify_toggle_apm_tethering_internet_connection(self.log, 1447 self.provider, 1448 self.clients, 1449 ssid): 1450 return False 1451 finally: 1452 self.clients[0].droid.telephonyToggleDataConnection(True) 1453 wifi_reset(self.log, self.clients[0]) 1454 return True 1455 1456 @test_tracker_info(uuid="037e80fc-6eab-4cd1-846a-b9780a1d502d") 1457 @TelephonyBaseTest.tel_test_wrap 1458 def test_tethering_entitlement_check(self): 1459 """Tethering Entitlement Check Test 1460 1461 Get tethering entitlement check result. 1462 1463 Returns: 1464 True if entitlement check returns True. 1465 """ 1466 return verify_tethering_entitlement_check(self.log, 1467 self.provider) 1468 1469 @test_tracker_info(uuid="4972826e-39ea-42f7-aae0-06fe3aa9ecc6") 1470 @TelephonyBaseTest.tel_test_wrap 1471 def test_tethering_4g_to_2gwifi_stress(self): 1472 """Stress Test LTE to WiFI 2.4G Tethering 1473 1474 This is a stress test for "test_tethering_4g_to_2gwifi". 1475 Default MINIMUM_SUCCESS_RATE is set to 95%. 1476 1477 Returns: 1478 True stress pass rate is higher than MINIMUM_SUCCESS_RATE. 1479 False otherwise. 1480 """ 1481 def precondition(): 1482 return ensure_phones_default_state(self.log, self.android_devices) 1483 1484 def test_case(): 1485 return test_wifi_tethering(self.log, 1486 self.provider, 1487 self.clients, 1488 self.clients, 1489 RAT_4G, 1490 WIFI_CONFIG_APBAND_2G, 1491 check_interval=10, 1492 check_iteration=10) 1493 return run_stress_test(self.log, self.stress_test_number, precondition, test_case) 1494 1495 @test_tracker_info(uuid="54e85aed-09e3-42e2-bb33-bca1005d93ab") 1496 @TelephonyBaseTest.tel_test_wrap 1497 def test_tethering_wifi_ssid_quotes(self): 1498 """WiFi Tethering test: SSID name have quotes. 1499 1. Set SSID name have double quotes. 1500 2. Start LTE to WiFi (2.4G) tethering. 1501 3. Verify tethering. 1502 1503 Returns: 1504 True if success. 1505 False if failed. 1506 """ 1507 ssid = "\"" + rand_ascii_str(10) + "\"" 1508 self.log.info( 1509 "Starting WiFi Tethering test with ssid: {}".format(ssid)) 1510 1511 return test_wifi_tethering(self.log, 1512 self.provider, 1513 self.clients, 1514 self.clients, 1515 None, 1516 WIFI_CONFIG_APBAND_2G, 1517 check_interval=10, 1518 check_iteration=10, 1519 ssid=ssid) 1520 1521 @test_tracker_info(uuid="320326da-bf32-444d-81f9-f781c55dbc99") 1522 @TelephonyBaseTest.tel_test_wrap 1523 def test_tethering_wifi_password_escaping_characters(self): 1524 """WiFi Tethering test: password have escaping characters. 1525 1. Set password have escaping characters. 1526 e.g.: '"DQ=/{Yqq;M=(^_3HzRvhOiL8S%`]w&l<Qp8qH)bs<4E9v_q=HLr^)}w$blA0Kg' 1527 2. Start LTE to WiFi (2.4G) tethering. 1528 3. Verify tethering. 1529 1530 Returns: 1531 True if success. 1532 False if failed. 1533 """ 1534 if not test_setup_tethering(self.log, self.provider, self.clients, None): 1535 self.log.error("Verify Internet access failed.") 1536 return False 1537 1538 password = TETHERING_PASSWORD_HAS_ESCAPE 1539 self.log.info( 1540 "Starting WiFi Tethering test with password: {}".format(password)) 1541 1542 return wifi_tethering_setup_teardown( 1543 self.log, 1544 self.provider, 1545 self.clients, 1546 ap_band=WIFI_CONFIG_APBAND_2G, 1547 check_interval=10, 1548 check_iteration=10, 1549 password=password) 1550 1551 @test_tracker_info(uuid="617c7e71-f166-465f-bfd3-b5a3a40cc0d4") 1552 @TelephonyBaseTest.tel_test_wrap 1553 def test_tethering_wifi_ssid(self): 1554 """WiFi Tethering test: start WiFi tethering with all kinds of SSIDs. 1555 1556 For each listed SSID, start WiFi tethering on DUT, client connect WiFi, 1557 then tear down WiFi tethering. 1558 1559 Returns: 1560 True if WiFi tethering succeed on all SSIDs. 1561 False if failed. 1562 """ 1563 if not test_setup_tethering(self.log, self.provider, self.clients, RAT_4G): 1564 self.log.error("Setup Failed.") 1565 return False 1566 ssid_list = TETHERING_SPECIAL_SSID_LIST 1567 fail_list = {} 1568 self.number_of_devices = 2 1569 for ssid in ssid_list: 1570 password = rand_ascii_str(8) 1571 self.log.info("SSID: <{}>, Password: <{}>".format(ssid, password)) 1572 if not test_start_wifi_tethering_connect_teardown(self.log, 1573 self.provider, 1574 self.clients[0], 1575 ssid, 1576 password): 1577 fail_list[ssid] = password 1578 1579 if len(fail_list) > 0: 1580 self.log.error("Failed cases: {}".format(fail_list)) 1581 return False 1582 else: 1583 return True 1584 1585 @test_tracker_info(uuid="9a5b5a34-b5cf-451d-94c4-8a64d456dfe5") 1586 @TelephonyBaseTest.tel_test_wrap 1587 def test_tethering_wifi_password(self): 1588 """WiFi Tethering test: start WiFi tethering with all kinds of passwords. 1589 1590 For each listed password, start WiFi tethering on DUT, client connect WiFi, 1591 then tear down WiFi tethering. 1592 1593 Returns: 1594 True if WiFi tethering succeed on all passwords. 1595 False if failed. 1596 """ 1597 if not test_setup_tethering(self.log, self.provider, self.clients, RAT_4G): 1598 self.log.error("Setup Failed.") 1599 return False 1600 password_list = TETHERING_SPECIAL_PASSWORD_LIST 1601 fail_list = {} 1602 self.number_of_devices = 2 1603 for password in password_list: 1604 ssid = rand_ascii_str(8) 1605 self.log.info("SSID: <{}>, Password: <{}>".format(ssid, password)) 1606 if not test_start_wifi_tethering_connect_teardown(self.log, 1607 self.provider, 1608 self.clients[0], 1609 ssid, 1610 password): 1611 fail_list[ssid] = password 1612 1613 if len(fail_list) > 0: 1614 self.log.error("Failed cases: {}".format(fail_list)) 1615 return False 1616 else: 1617 return True 1618 1619 @test_tracker_info(uuid="216bdb8c-edbf-4ff8-8750-a0861ab44df6") 1620 @TelephonyBaseTest.tel_test_wrap 1621 def test_tethering_wifi_volte_call(self): 1622 """WiFi Tethering test: VoLTE call during WiFi tethering 1623 1. Start LTE to WiFi (2.4G) tethering. 1624 2. Verify tethering. 1625 3. Make outgoing VoLTE call on tethering provider. 1626 4. Verify tethering still works. 1627 5. Make incoming VoLTE call on tethering provider. 1628 6. Verify tethering still works. 1629 1630 Returns: 1631 True if success. 1632 False if failed. 1633 """ 1634 return test_tethering_wifi_and_voice_call(self.log, self.provider, self.clients, 1635 RAT_4G, phone_setup_volte, is_phone_in_call_volte) 1636 1637 @test_tracker_info(uuid="bcd430cc-6d33-47d1-825d-aae9f248addc") 1638 @TelephonyBaseTest.tel_test_wrap 1639 def test_tethering_wifi_csfb_call(self): 1640 """WiFi Tethering test: CSFB call during WiFi tethering 1641 1. Start LTE to WiFi (2.4G) tethering. 1642 2. Verify tethering. 1643 3. Make outgoing CSFB call on tethering provider. 1644 4. Verify tethering still works. 1645 5. Make incoming CSFB call on tethering provider. 1646 6. Verify tethering still works. 1647 1648 Returns: 1649 True if success. 1650 False if failed. 1651 """ 1652 return test_tethering_wifi_and_voice_call(self.log, self.provider, self.clients, 1653 RAT_4G, phone_setup_csfb, is_phone_in_call_csfb) 1654 1655 @test_tracker_info(uuid="19e0df23-6819-4c69-bfda-eea9cce802d8") 1656 @TelephonyBaseTest.tel_test_wrap 1657 def test_tethering_wifi_3g_call(self): 1658 """WiFi Tethering test: 3G call during WiFi tethering 1659 1. Start 3G to WiFi (2.4G) tethering. 1660 2. Verify tethering. 1661 3. Make outgoing CS call on tethering provider. 1662 4. Verify tethering still works. 1663 5. Make incoming CS call on tethering provider. 1664 6. Verify tethering still works. 1665 1666 Returns: 1667 True if success. 1668 False if failed. 1669 """ 1670 return test_tethering_wifi_and_voice_call(self.log, self.provider, self.clients, 1671 RAT_3G, phone_setup_voice_3g, is_phone_in_call_3g) 1672 1673 @test_tracker_info(uuid="4acd98b5-fdef-4736-969f-3fa953990a58") 1674 @TelephonyBaseTest.tel_test_wrap 1675 def test_tethering_wifi_no_password(self): 1676 """WiFi Tethering test: Start WiFi tethering with no password 1677 1678 1. DUT is idle. 1679 2. DUT start 2.4G WiFi Tethering, with no WiFi password. 1680 3. PhoneB disable data, connect to DUT's softAP 1681 4. Verify Internet access on DUT and PhoneB 1682 1683 Returns: 1684 True if success. 1685 False if failed. 1686 """ 1687 if not test_setup_tethering(self.log, self.provider, self.clients, None): 1688 self.log.error("Verify Internet access failed.") 1689 return False 1690 1691 return wifi_tethering_setup_teardown( 1692 self.log, 1693 self.provider, [self.clients[0]], 1694 ap_band=WIFI_CONFIG_APBAND_2G, 1695 check_interval=10, 1696 check_iteration=10, 1697 password="") 1698 1699 @test_tracker_info(uuid="86ad1680-bfb8-457e-8b4d-23321cb3f223") 1700 @TelephonyBaseTest.tel_test_wrap 1701 def test_tethering_wifi_reboot(self): 1702 """WiFi Tethering test: Start WiFi tethering then Reboot device 1703 1704 1. DUT is idle. 1705 2. DUT start 2.4G WiFi Tethering. 1706 3. PhoneB disable data, connect to DUT's softAP 1707 4. Verify Internet access on DUT and PhoneB 1708 5. Reboot DUT 1709 6. After DUT reboot, verify tethering is stopped. 1710 1711 Returns: 1712 True if success. 1713 False if failed. 1714 """ 1715 try: 1716 if not test_wifi_tethering(self.log, 1717 self.provider, 1718 self.clients, 1719 [self.clients[0]], 1720 None, 1721 WIFI_CONFIG_APBAND_2G, 1722 check_interval=10, 1723 check_iteration=2, 1724 do_cleanup=False): 1725 return False 1726 1727 if not verify_wifi_tethering_when_reboot(self.log, 1728 self.provider): 1729 return False 1730 1731 finally: 1732 if not wifi_tethering_cleanup(self.log, self.provider, 1733 self.clients): 1734 return False 1735 1736 return True 1737 1738 @test_tracker_info(uuid="5cf04ca2-dfde-43d6-be74-78b9abdf6c26") 1739 @TelephonyBaseTest.tel_test_wrap 1740 def test_connect_wifi_start_tethering_wifi_reboot(self): 1741 """WiFi Tethering test: WiFI connected, then start WiFi tethering, 1742 then reboot device. 1743 1744 Initial Condition: DUT in 4G mode, idle, DUT connect to WiFi. 1745 1. DUT start 2.4G WiFi Tethering. 1746 2. PhoneB disable data, connect to DUT's softAP 1747 3. Verify Internet access on DUT and PhoneB 1748 4. Reboot DUT 1749 5. After DUT reboot, verify tethering is stopped. DUT is able to connect 1750 to previous WiFi AP. 1751 1752 Returns: 1753 True if success. 1754 False if failed. 1755 """ 1756 1757 # Ensure provider connecting to wifi network. 1758 def setup_provider_internet_connection(): 1759 return setup_device_internet_connection(self.log, 1760 self.provider, 1761 self.wifi_network_ssid, 1762 self.wifi_network_pass) 1763 1764 # wait for provider connecting to wifi network and verify 1765 # internet connection is working. 1766 def wait_and_verify_internet_connection(): 1767 return wait_and_verify_device_internet_connection(self.log, 1768 self.provider) 1769 1770 try: 1771 if not test_wifi_tethering(self.log, 1772 self.provider, 1773 self.clients, 1774 [self.clients[0]], 1775 None, 1776 WIFI_CONFIG_APBAND_2G, 1777 check_interval=10, 1778 check_iteration=2, 1779 do_cleanup=False, 1780 pre_teardown_func=setup_provider_internet_connection): 1781 return False 1782 1783 if not verify_wifi_tethering_when_reboot(self.log, 1784 self.provider, 1785 post_reboot_func=wait_and_verify_internet_connection): 1786 return False 1787 1788 finally: 1789 if not wifi_tethering_cleanup(self.log, 1790 self.provider, 1791 self.clients): 1792 return False 1793 return True 1794 1795 @test_tracker_info(uuid="e0621997-c5bd-4137-afa6-b43406e9c713") 1796 @TelephonyBaseTest.tel_test_wrap 1797 def test_connect_wifi_reboot_start_tethering_wifi(self): 1798 """WiFi Tethering test: DUT connected to WiFi, then reboot, 1799 After reboot, start WiFi tethering, verify tethering actually works. 1800 1801 Initial Condition: Device set to 4G mode, idle, DUT connect to WiFi. 1802 1. Verify Internet is working on DUT (by WiFi). 1803 2. Reboot DUT. 1804 3. DUT start 2.4G WiFi Tethering. 1805 4. PhoneB disable data, connect to DUT's softAP 1806 5. Verify Internet access on DUT and PhoneB 1807 1808 Returns: 1809 True if success. 1810 False if failed. 1811 """ 1812 1813 # Ensure provider connecting to wifi network and then reboot. 1814 def setup_provider_internet_connect_then_reboot(): 1815 return setup_device_internet_connection_then_reboot(self.log, 1816 self.provider, 1817 self.wifi_network_ssid, 1818 self.wifi_network_pass) 1819 return test_wifi_tethering(self.log, 1820 self.provider, 1821 self.clients, 1822 [self.clients[0]], 1823 None, 1824 WIFI_CONFIG_APBAND_2G, 1825 check_interval=10, 1826 check_iteration=2, 1827 pre_teardown_func=setup_provider_internet_connect_then_reboot) 1828 1829 @test_tracker_info(uuid="89a849ef-e2ed-4bf2-ac31-81d34aba672a") 1830 @TelephonyBaseTest.tel_test_wrap 1831 def test_tethering_wifi_screen_off_enable_doze_mode(self): 1832 """WiFi Tethering test: Start WiFi tethering, then turn off DUT's screen, 1833 then enable doze mode, verify internet connection. 1834 1835 1. Start WiFi tethering on DUT. 1836 2. PhoneB disable data, and connect to DUT's softAP 1837 3. Verify Internet access on DUT and PhoneB 1838 4. Turn off DUT's screen. Wait for 1 minute and 1839 verify Internet access on Client PhoneB. 1840 5. Enable doze mode on DUT. Wait for 1 minute and 1841 verify Internet access on Client PhoneB. 1842 6. Disable doze mode and turn off wifi tethering on DUT. 1843 1844 Returns: 1845 True if success. 1846 False if failed. 1847 """ 1848 try: 1849 if not test_wifi_tethering(self.log, 1850 self.provider, 1851 self.clients, 1852 [self.clients[0]], 1853 None, 1854 WIFI_CONFIG_APBAND_2G, 1855 check_interval=10, 1856 check_iteration=2, 1857 do_cleanup=False): 1858 return False 1859 if not verify_internet_connection_in_doze_mode(self.log, 1860 self.provider, 1861 self.clients[0]): 1862 return False 1863 1864 finally: 1865 if not wifi_tethering_cleanup(self.log, 1866 self.provider, 1867 [self.clients[0]]): 1868 return False 1869 return True 1870 1871 @test_tracker_info(uuid="695eef18-f759-4b41-8ad3-1fb329ee4b1b") 1872 @TelephonyBaseTest.tel_test_wrap 1873 def test_msim_switch_data_sim_2g(self): 1874 """Switch Data SIM on 2G network. 1875 1876 Steps: 1877 1. Data on default Data SIM. 1878 2. Switch Data to another SIM. Make sure data is still available. 1879 3. Switch Data back to previous SIM. Make sure data is still available. 1880 1881 Expected Results: 1882 1. Verify Data on Cell 1883 2. Verify Data on Wifi 1884 1885 Returns: 1886 True if success. 1887 False if failed. 1888 """ 1889 ad = self.android_devices[0] 1890 current_data_sub_id = ad.droid.subscriptionGetDefaultDataSubId() 1891 current_sim_slot_index = get_slot_index_from_subid( 1892 self.log, ad, current_data_sub_id) 1893 if current_sim_slot_index == SIM1_SLOT_INDEX: 1894 next_sim_slot_index = SIM2_SLOT_INDEX 1895 else: 1896 next_sim_slot_index = SIM1_SLOT_INDEX 1897 next_data_sub_id = get_subid_from_slot_index(self.log, ad, 1898 next_sim_slot_index) 1899 self.log.info("Current Data is on subId: {}, SIM slot: {}".format( 1900 current_data_sub_id, current_sim_slot_index)) 1901 if not ensure_network_generation_for_subscription( 1902 self.log, 1903 ad, 1904 ad.droid.subscriptionGetDefaultDataSubId(), 1905 GEN_2G, 1906 voice_or_data=NETWORK_SERVICE_DATA): 1907 self.log.error("Device data does not attach to 2G.") 1908 return False 1909 if not verify_internet_connection(self.log, ad): 1910 self.log.error("No Internet access on default Data SIM.") 1911 return False 1912 1913 self.log.info("Change Data to subId: {}, SIM slot: {}".format( 1914 next_data_sub_id, next_sim_slot_index)) 1915 if not change_data_sim_and_verify_data(self.log, ad, 1916 next_sim_slot_index): 1917 self.log.error("Failed to change data SIM.") 1918 return False 1919 1920 next_data_sub_id = current_data_sub_id 1921 next_sim_slot_index = current_sim_slot_index 1922 self.log.info("Change Data back to subId: {}, SIM slot: {}".format( 1923 next_data_sub_id, next_sim_slot_index)) 1924 if not change_data_sim_and_verify_data(self.log, ad, 1925 next_sim_slot_index): 1926 self.log.error("Failed to change data SIM.") 1927 return False 1928 1929 return True 1930 1931 1932 @test_tracker_info(uuid="9b8e92da-0ae1-472c-a72a-f6427e5405ce") 1933 @TelephonyBaseTest.tel_test_wrap 1934 def test_wifi_connect_disconnect_4g(self): 1935 """Perform multiple connects and disconnects from WiFi and verify that 1936 data switches between WiFi and Cell. 1937 1938 Steps: 1939 1. DUT Cellular Data is on 4G. Reset Wifi on DUT 1940 2. Connect DUT to a WiFi AP 1941 3. Repeat steps 1-2, alternately disconnecting and disabling wifi 1942 1943 Expected Results: 1944 1. Verify Data on Cell 1945 2. Verify Data on Wifi 1946 1947 Returns: 1948 True if success. 1949 False if failed. 1950 """ 1951 1952 ad = self.android_devices[0] 1953 if not ensure_network_generation_for_subscription( 1954 self.log, ad, ad.droid.subscriptionGetDefaultDataSubId(), 1955 GEN_4G, MAX_WAIT_TIME_NW_SELECTION, NETWORK_SERVICE_DATA): 1956 self.log.error("Device {} failed to reselect in {}s.".format( 1957 ad.serial, MAX_WAIT_TIME_NW_SELECTION)) 1958 return False 1959 return test_wifi_connect_disconnect(self.log, ad, self.wifi_network_ssid, self.wifi_network_pass) 1960 1961 @test_tracker_info(uuid="09893b1f-a4a2-49d3-8027-c2c91cb8742e") 1962 @TelephonyBaseTest.tel_test_wrap 1963 def test_wifi_connect_disconnect_3g(self): 1964 """Perform multiple connects and disconnects from WiFi and verify that 1965 data switches between WiFi and Cell. 1966 1967 Steps: 1968 1. DUT Cellular Data is on 3G. Reset Wifi on DUT 1969 2. Connect DUT to a WiFi AP 1970 3. Repeat steps 1-2, alternately disconnecting and disabling wifi 1971 1972 Expected Results: 1973 1. Verify Data on Cell 1974 2. Verify Data on Wifi 1975 1976 Returns: 1977 True if success. 1978 False if failed. 1979 """ 1980 1981 ad = self.android_devices[0] 1982 if not ensure_network_generation_for_subscription( 1983 self.log, ad, ad.droid.subscriptionGetDefaultDataSubId(), 1984 GEN_3G, MAX_WAIT_TIME_NW_SELECTION, NETWORK_SERVICE_DATA): 1985 self.log.error("Device {} failed to reselect in {}s.".format( 1986 ad.serial, MAX_WAIT_TIME_NW_SELECTION)) 1987 return False 1988 return test_wifi_connect_disconnect(self.log, ad, self.wifi_network_ssid, self.wifi_network_pass) 1989 1990 @test_tracker_info(uuid="0f095ca4-ce05-458f-9670-49a69f8c8270") 1991 @TelephonyBaseTest.tel_test_wrap 1992 def test_wifi_connect_disconnect_2g(self): 1993 """Perform multiple connects and disconnects from WiFi and verify that 1994 data switches between WiFi and Cell. 1995 1996 Steps: 1997 1. DUT Cellular Data is on 2G. Reset Wifi on DUT 1998 2. Connect DUT to a WiFi AP 1999 3. Repeat steps 1-2, alternately disconnecting and disabling wifi 2000 2001 Expected Results: 2002 1. Verify Data on Cell 2003 2. Verify Data on Wifi 2004 2005 Returns: 2006 True if success. 2007 False if failed. 2008 """ 2009 ad = self.android_devices[0] 2010 if not ensure_network_generation_for_subscription( 2011 self.log, ad, ad.droid.subscriptionGetDefaultDataSubId(), 2012 GEN_2G, MAX_WAIT_TIME_NW_SELECTION, NETWORK_SERVICE_DATA): 2013 self.log.error("Device {} failed to reselect in {}s.".format( 2014 ad.serial, MAX_WAIT_TIME_NW_SELECTION)) 2015 return False 2016 return test_wifi_connect_disconnect(self.log, ad, self.wifi_network_ssid, self.wifi_network_pass) 2017 2018 def _test_wifi_tethering_enabled_add_voice_call( 2019 self, network_generation, voice_call_direction, 2020 is_data_available_during_call): 2021 """Tethering enabled + voice call. 2022 2023 Steps: 2024 1. DUT data is on <network_generation>. Start WiFi Tethering. 2025 2. PhoneB connect to DUT's softAP 2026 3. DUT make a MO/MT (<voice_call_direction>) phone call. 2027 4. DUT end phone call. 2028 2029 Expected Results: 2030 1. DUT is able to start WiFi tethering. 2031 2. PhoneB connected to DUT's softAP and able to browse Internet. 2032 3. DUT WiFi tethering is still on. Phone call works OK. 2033 If is_data_available_during_call is True, then PhoneB still has 2034 Internet access. 2035 Else, then Data is suspend, PhoneB has no Internet access. 2036 4. WiFi Tethering still on, voice call stopped, and PhoneB have Internet 2037 access. 2038 2039 Returns: 2040 True if success. 2041 False if failed. 2042 """ 2043 if not test_setup_tethering(self.log, self.provider, self.clients, network_generation): 2044 self.log.error("Verify Internet access failed.") 2045 return False 2046 try: 2047 # Start WiFi Tethering 2048 if not wifi_tethering_setup_teardown( 2049 self.log, 2050 self.provider, [self.clients[0]], 2051 ap_band=WIFI_CONFIG_APBAND_2G, 2052 check_interval=10, 2053 check_iteration=2, 2054 do_cleanup=False): 2055 self.log.error("WiFi Tethering failed.") 2056 return False 2057 2058 if not self.provider.droid.wifiIsApEnabled(): 2059 self.log.error("Provider WiFi tethering stopped.") 2060 return False 2061 2062 # Make a voice call 2063 if voice_call_direction == DIRECTION_MOBILE_ORIGINATED: 2064 ad_caller = self.provider 2065 ad_callee = self.clients[0] 2066 else: 2067 ad_caller = self.clients[0] 2068 ad_callee = self.provider 2069 if not call_setup_teardown(self.log, ad_caller, ad_callee, None, 2070 None, None): 2071 self.log.error("Failed to Establish {} Voice Call".format( 2072 voice_call_direction)) 2073 return False 2074 2075 # Tethering should still be on. 2076 if not self.provider.droid.wifiIsApEnabled(): 2077 self.provider.log.error("Provider WiFi tethering stopped.") 2078 return False 2079 if not is_data_available_during_call: 2080 if verify_internet_connection( 2081 self.log, self.clients[0], retry=0): 2082 self.clients[0].log.error( 2083 "Client should not have Internet Access.") 2084 return False 2085 else: 2086 if not verify_internet_connection(self.log, self.clients[0]): 2087 self.clients[0].error( 2088 "Client should have Internet Access.") 2089 return False 2090 2091 # Hangup call. Client should have data. 2092 if not hangup_call(self.log, self.provider): 2093 self.provider.log.error("Failed to hang up call") 2094 return False 2095 if not self.provider.droid.wifiIsApEnabled(): 2096 self.provider.log.error("Provider WiFi tethering stopped.") 2097 return False 2098 if not verify_internet_connection(self.log, self.clients[0]): 2099 self.clients[0].log.error( 2100 "Client should have Internet Access.") 2101 return False 2102 finally: 2103 self.clients[0].droid.telephonyToggleDataConnection(True) 2104 wifi_reset(self.log, self.clients[0]) 2105 if self.provider.droid.wifiIsApEnabled(): 2106 stop_wifi_tethering(self.log, self.provider) 2107 return True 2108 2109 @test_tracker_info(uuid="4d7a68c6-5eae-4242-a6e6-668f830caec3") 2110 @TelephonyBaseTest.tel_test_wrap 2111 def test_wifi_tethering_enabled_add_mo_voice_call_2g_dsds(self): 2112 """Tethering enabled + voice call 2113 2114 Steps: 2115 1. DUT is DSDS device, Data on 2G. Start WiFi Tethering on <Data SIM> 2116 2. PhoneB connect to DUT's softAP 2117 3. DUT make a mo phone call on <Voice SIM> 2118 4. DUT end phone call. 2119 2120 Expected Results: 2121 1. DUT is able to start WiFi tethering. 2122 2. PhoneB connected to DUT's softAP and able to browse Internet. 2123 3. DUT WiFi tethering is still on. Phone call works OK. Data is suspend, 2124 PhoneB still connected to DUT's softAP, but no data available. 2125 4. DUT data resumes, and PhoneB have Internet access. 2126 2127 Returns: 2128 True if success. 2129 False if failed. 2130 """ 2131 2132 return self._test_wifi_tethering_enabled_add_voice_call( 2133 GEN_2G, DIRECTION_MOBILE_ORIGINATED, False) 2134 2135 @test_tracker_info(uuid="de720069-a46c-4a6f-ae80-60b9349c8528") 2136 @TelephonyBaseTest.tel_test_wrap 2137 def test_wifi_tethering_enabled_add_mt_voice_call_2g_dsds(self): 2138 """Tethering enabled + voice call 2139 2140 Steps: 2141 1. DUT is DSDS device, Data on 2G. Start WiFi Tethering on <Data SIM> 2142 2. PhoneB connect to DUT's softAP 2143 3. DUT make a mt phone call on <Voice SIM> 2144 4. DUT end phone call. 2145 2146 Expected Results: 2147 1. DUT is able to start WiFi tethering. 2148 2. PhoneB connected to DUT's softAP and able to browse Internet. 2149 3. DUT WiFi tethering is still on. Phone call works OK. Data is suspend, 2150 PhoneB still connected to DUT's softAP, but no data available. 2151 4. DUT data resumes, and PhoneB have Internet access. 2152 2153 Returns: 2154 True if success. 2155 False if failed. 2156 """ 2157 2158 return self._test_wifi_tethering_enabled_add_voice_call( 2159 GEN_2G, DIRECTION_MOBILE_TERMINATED, False) 2160 2161 @test_tracker_info(uuid="fad169c0-8ae6-45d2-98ba-3fb60466ff0b") 2162 @TelephonyBaseTest.tel_test_wrap 2163 def test_wifi_tethering_msim_switch_data_sim(self): 2164 """Tethering enabled + switch data SIM. 2165 2166 Steps: 2167 1. Start WiFi Tethering on <Default Data SIM> 2168 2. PhoneB connect to DUT's softAP 2169 3. DUT change Default Data SIM. 2170 2171 Expected Results: 2172 1. DUT is able to start WiFi tethering. 2173 2. PhoneB connected to DUT's softAP and able to browse Internet. 2174 3. DUT Data changed to 2nd SIM, WiFi tethering should continues, 2175 PhoneB should have Internet access. 2176 2177 Returns: 2178 True if success. 2179 False if failed. 2180 """ 2181 current_data_sub_id = self.provider.droid.subscriptionGetDefaultDataSubId( 2182 ) 2183 current_sim_slot_index = get_slot_index_from_subid( 2184 self.log, self.provider, current_data_sub_id) 2185 self.provider.log.info("Current Data is on subId: %s, SIM slot: %s", 2186 current_data_sub_id, current_sim_slot_index) 2187 if not test_setup_tethering(self.log, self.provider, self.clients, None): 2188 self.log.error("Verify Internet access failed.") 2189 return False 2190 try: 2191 # Start WiFi Tethering 2192 if not wifi_tethering_setup_teardown( 2193 self.log, 2194 self.provider, [self.clients[0]], 2195 ap_band=WIFI_CONFIG_APBAND_2G, 2196 check_interval=10, 2197 check_iteration=2, 2198 do_cleanup=False): 2199 self.log.error("WiFi Tethering failed.") 2200 return False 2201 for i in range(0, 2): 2202 next_sim_slot_index = \ 2203 {SIM1_SLOT_INDEX : SIM2_SLOT_INDEX, 2204 SIM2_SLOT_INDEX : SIM1_SLOT_INDEX}[current_sim_slot_index] 2205 self.log.info( 2206 "Change Data to SIM slot: {}".format(next_sim_slot_index)) 2207 if not change_data_sim_and_verify_data(self.log, self.provider, 2208 next_sim_slot_index): 2209 self.provider.log.error("Failed to change data SIM.") 2210 return False 2211 current_sim_slot_index = next_sim_slot_index 2212 if not verify_internet_connection(self.log, self.clients[0]): 2213 self.clients[0].log.error( 2214 "Client should have Internet Access.") 2215 return False 2216 finally: 2217 self.clients[0].droid.telephonyToggleDataConnection(True) 2218 wifi_reset(self.log, self.clients[0]) 2219 if self.provider.droid.wifiIsApEnabled(): 2220 stop_wifi_tethering(self.log, self.provider) 2221 return True 2222 2223 @test_tracker_info(uuid="8bb9383f-ddf9-400c-a831-c9462bae6b47") 2224 @TelephonyBaseTest.tel_test_wrap 2225 def test_msim_cell_data_switch_to_wifi_switch_data_sim_2g(self): 2226 """Switch Data SIM on 2G network. 2227 2228 Steps: 2229 1. Data on default Data SIM. 2230 2. Turn on WiFi, then data should be on WiFi. 2231 3. Switch Data to another SIM. Disable WiFi. 2232 2233 Expected Results: 2234 1. Verify Data on Cell 2235 2. Verify Data on WiFi 2236 3. After WiFi disabled, Cell Data is available on 2nd SIM. 2237 2238 Returns: 2239 True if success. 2240 False if failed. 2241 """ 2242 ad = self.android_devices[0] 2243 current_data_sub_id = ad.droid.subscriptionGetDefaultDataSubId() 2244 current_sim_slot_index = get_slot_index_from_subid( 2245 self.log, ad, current_data_sub_id) 2246 if current_sim_slot_index == SIM1_SLOT_INDEX: 2247 next_sim_slot_index = SIM2_SLOT_INDEX 2248 else: 2249 next_sim_slot_index = SIM1_SLOT_INDEX 2250 next_data_sub_id = get_subid_from_slot_index(self.log, ad, 2251 next_sim_slot_index) 2252 self.log.info("Current Data is on subId: {}, SIM slot: {}".format( 2253 current_data_sub_id, current_sim_slot_index)) 2254 if not ensure_network_generation_for_subscription( 2255 self.log, 2256 ad, 2257 ad.droid.subscriptionGetDefaultDataSubId(), 2258 GEN_2G, 2259 voice_or_data=NETWORK_SERVICE_DATA): 2260 self.log.error("Device data does not attach to 2G.") 2261 return False 2262 if not verify_internet_connection(self.log, ad): 2263 self.log.error("No Internet access on default Data SIM.") 2264 return False 2265 2266 self.log.info("Connect to WiFi and verify Internet access.") 2267 if not ensure_wifi_connected(self.log, ad, self.wifi_network_ssid, 2268 self.wifi_network_pass): 2269 self.log.error("WiFi connect fail.") 2270 return False 2271 if (not wait_for_wifi_data_connection(self.log, ad, True) 2272 or not verify_internet_connection(self.log, ad)): 2273 self.log.error("Data is not on WiFi") 2274 return False 2275 2276 try: 2277 self.log.info( 2278 "Change Data SIM, Disable WiFi and verify Internet access.") 2279 set_subid_for_data(ad, next_data_sub_id) 2280 wifi_toggle_state(self.log, ad, False) 2281 if not wait_for_data_attach_for_subscription( 2282 self.log, ad, next_data_sub_id, 2283 MAX_WAIT_TIME_NW_SELECTION): 2284 self.log.error("Failed to attach data on subId:{}".format( 2285 next_data_sub_id)) 2286 return False 2287 if not verify_internet_connection(self.log, ad): 2288 self.log.error("No Internet access after changing Data SIM.") 2289 return False 2290 2291 finally: 2292 self.log.info("Change Data SIM back.") 2293 set_subid_for_data(ad, current_data_sub_id) 2294 2295 return True 2296 2297 @test_tracker_info(uuid="ef03eff7-ddd3-48e9-8f67-5e271e14048b") 2298 @TelephonyBaseTest.tel_test_wrap 2299 def test_vzw_embms_services(self): 2300 ad = self.android_devices[0] 2301 # Install App and Push config 2302 self.log.info("Pushing embms config and apk to the Android device.") 2303 android_embms_path = "/sdcard/mobitv" 2304 embms_path = self.user_params.get("embms_path", "embms_path") 2305 if isinstance(embms_path, list): 2306 embms_path = embms_path[0] 2307 ad.adb.shell("mkdir /sdcard/mobitv") 2308 dcafile = os.path.join(embms_path, "dca.config") 2309 apkfile = os.path.join(embms_path, "VzwDCA.apk") 2310 ad.adb.push("%s %s" % (dcafile, android_embms_path)) 2311 ad.adb.install("%s" % apkfile) 2312 2313 # Co-ordinates Mapping 2314 lcd_density = ad.adb.shell("getprop ro.sf.lcd_density") 2315 ad.log.debug("lcd_density %s" % lcd_density) 2316 if lcd_density in ["420", "440"]: 2317 agree_y_axis = 1000 2318 else: 2319 agree_y_axis = 1300 2320 2321 # Screen ON needed to open the VZW App 2322 if "ON" in \ 2323 ad.adb.shell( 2324 "dumpsys power | grep 'Display Power: state' | cut -d '=' -f2"): 2325 ad.log.info("Screen already ON") 2326 ad.adb.shell("input keyevent 82") 2327 else: 2328 ad.log.info("Screen OFF, turning ON") 2329 ad.adb.shell("input keyevent 26") 2330 ad.adb.shell("input keyevent 82") 2331 2332 try: 2333 # Check if app is installed 2334 if ad.is_apk_installed("com.mobitv.vzwdca"): 2335 ad.log.info("VZWDCA App is successfully installed") 2336 else: 2337 ad.log.error("VZWDCA App is not installed") 2338 return False 2339 2340 # Grant Permissions, Start, Agree, Register 2341 for cmd in ("pm grant com.mobitv.vzwdca " 2342 "android.permission.READ_EXTERNAL_STORAGE", 2343 "pm grant com.mobitv.vzwdca " 2344 "android.permission.WRITE_EXTERNAL_STORAGE", 2345 "am start -a android.intent.action.VIEW -n " 2346 "com.mobitv.vzwdca/.DcaActivity", 2347 "input tap 500 %d" % agree_y_axis, "input keyevent 61", 2348 "input keyevent 61", "input keyevent 61", 2349 "input keyevent 61", "input keyevent 61", 2350 "input keyevent 66"): 2351 time.sleep(1) 2352 ad.log.info(cmd) 2353 ad.adb.shell(cmd) 2354 2355 # Check Reg-DeReg 2356 time.sleep(5) 2357 if ad.is_apk_running("com.qualcomm.ltebc_vzw"): 2358 ad.log.info("EMBMS Registered successfully") 2359 ad.adb.shell("input keyevent 61") 2360 time.sleep(1) 2361 ad.adb.shell("input keyevent 66") 2362 time.sleep(1) 2363 if not ad.is_apk_running("com.qualcomm.ltebc_vzw"): 2364 ad.log.info("EMBMS De-Registered successfully") 2365 return True 2366 else: 2367 ad.log.error("EMBMS De-Registeration Failed") 2368 return False 2369 else: 2370 ad.log.error("EMBMS Registeration Failed") 2371 return False 2372 finally: 2373 ad.log.info("Force Close the VZW App") 2374 ad.adb.shell("am force-stop com.mobitv.vzwdca") 2375 2376 @test_tracker_info(uuid="8a8cd773-77f5-4802-85ac-1a654bb4743c") 2377 @TelephonyBaseTest.tel_test_wrap 2378 def test_disable_data_on_non_active_data_sim(self): 2379 """Switch Data SIM on 2G network. 2380 2381 Steps: 2382 1. Data on default Data SIM. 2383 2. Disable data on non-active Data SIM. 2384 2385 Expected Results: 2386 1. Verify Data Status on Default Data SIM and non-active Data SIM. 2387 1. Verify Data Status on Default Data SIM and non-active Data SIM. 2388 2389 Returns: 2390 True if success. 2391 False if failed. 2392 """ 2393 ad = self.android_devices[0] 2394 current_data_sub_id = ad.droid.subscriptionGetDefaultDataSubId() 2395 current_sim_slot_index = get_slot_index_from_subid( 2396 self.log, ad, current_data_sub_id) 2397 if current_sim_slot_index == SIM1_SLOT_INDEX: 2398 non_active_sim_slot_index = SIM2_SLOT_INDEX 2399 else: 2400 non_active_sim_slot_index = SIM1_SLOT_INDEX 2401 non_active_sub_id = get_subid_from_slot_index( 2402 self.log, ad, non_active_sim_slot_index) 2403 self.log.info("Current Data is on subId: {}, SIM slot: {}".format( 2404 current_data_sub_id, current_sim_slot_index)) 2405 2406 if not ensure_network_generation_for_subscription( 2407 self.log, 2408 ad, 2409 ad.droid.subscriptionGetDefaultDataSubId(), 2410 GEN_2G, 2411 voice_or_data=NETWORK_SERVICE_DATA): 2412 self.log.error("Device data does not attach to 2G.") 2413 return False 2414 if not verify_internet_connection(self.log, ad): 2415 self.log.error("No Internet access on default Data SIM.") 2416 return False 2417 2418 if ad.droid.telephonyGetDataConnectionState() != DATA_STATE_CONNECTED: 2419 self.log.error("Data Connection State should be connected.") 2420 return False 2421 # TODO: Check Data state for non-active subId. 2422 2423 try: 2424 self.log.info("Disable Data on Non-Active Sub ID") 2425 ad.droid.telephonyToggleDataConnectionForSubscription( 2426 non_active_sub_id, False) 2427 # TODO: Check Data state for non-active subId. 2428 if ad.droid.telephonyGetDataConnectionState( 2429 ) != DATA_STATE_CONNECTED: 2430 self.log.error("Data Connection State should be connected.") 2431 return False 2432 finally: 2433 self.log.info("Enable Data on Non-Active Sub ID") 2434 ad.droid.telephonyToggleDataConnectionForSubscription( 2435 non_active_sub_id, True) 2436 return True 2437 2438 def file_download_stress(self): 2439 failure = 0 2440 total_count = 0 2441 self.result_info = collections.defaultdict(int) 2442 dut = self.android_devices[0] 2443 self.max_sleep_time = int(self.user_params.get("max_sleep_time", 1200)) 2444 #file_names = ["5MB", "10MB", "20MB", "50MB", "200MB", "512MB", "1GB"] 2445 file_names = ["5MB", "10MB", "20MB", "50MB", "200MB", "512MB"] 2446 while total_count < self.stress_test_number: 2447 total_count += 1 2448 try: 2449 dut.log.info(dict(self.result_info)) 2450 selection = random.randrange(0, len(file_names)) 2451 file_name = file_names[selection] 2452 self.result_info["Total %s file download" % file_name] += 1 2453 if not active_file_download_test(self.log, dut, file_name): 2454 self.result_info["%s file download failure" % 2455 file_name] += 1 2456 failure += 1 2457 dut.take_bug_report("%s_failure_%s" % (self.test_name, 2458 failure), 2459 time.strftime("%m-%d-%Y-%H-%M-%S")) 2460 self.dut.droid.goToSleepNow() 2461 time.sleep(random.randrange(0, self.max_sleep_time)) 2462 except Exception as e: 2463 self.log.error("Exception error %s", str(e)) 2464 self.result_info["Exception Errors"] += 1 2465 dut.log.info("File download test failure: %s/%s", failure, 2466 total_count) 2467 if failure / total_count > 0.1: 2468 dut.log.error("File download test failure: %s/%s", failure, 2469 total_count) 2470 return False 2471 return True 2472 2473 @test_tracker_info(uuid="5381a6fa-6771-4b00-a0d6-4a3891a6dba8") 2474 @TelephonyBaseTest.tel_test_wrap 2475 def test_file_download_stress_default(self): 2476 """File download stress test 2477 2478 Steps: 2479 1. Download a file random picked. 2480 2. Device sleep for sometime and Repeat 1. 2481 2482 Expected Results: 2483 Total download failure rate is less than 10%. 2484 2485 Returns: 2486 True if success. 2487 False if failed. 2488 """ 2489 return self.file_download_stress() 2490 2491 @test_tracker_info(uuid="c9970955-123b-467c-afbb-95ec8f99e9b7") 2492 def test_file_download_with_mobile_data_usage_limit_set(self): 2493 """ Steps: 2494 2495 1. Set the data usage limit to current data usage + 9MB 2496 2. Download 5MB file from internet. 2497 3. The first file download should succeed 2498 4. The second file download should fail 2499 2500 """ 2501 dut = self.android_devices[0] 2502 ensure_phones_default_state(self.log, [dut]) 2503 subscriber_id = dut.droid.telephonyGetSubscriberId() 2504 old_data_usage = get_mobile_data_usage(dut, subscriber_id) 2505 2506 # set data usage limit to current usage limit + 10MB 2507 data_limit = old_data_usage + 9 * 1000 * 1000 2508 set_mobile_data_usage_limit(dut, data_limit, subscriber_id) 2509 2510 # download file - size 5MB twice 2511 try: 2512 for _ in range(2): 2513 if not active_file_download_test(self.log, dut, "5MB", "curl"): 2514 if get_mobile_data_usage( 2515 dut, subscriber_id) + 5 * 1000 * 1000 < data_limit: 2516 dut.log.error( 2517 "Fail to download file when mobile data usage is" 2518 " below data usage limit") 2519 return False 2520 else: 2521 dut.log.info( 2522 "Download fails as expected due to data limit reached" 2523 ) 2524 else: 2525 if get_mobile_data_usage(dut, subscriber_id) < data_limit: 2526 dut.log.info( 2527 "Download file succeed when mobile data usage is" 2528 " below data usage limit") 2529 else: 2530 dut.log.error( 2531 "Download should fail due to data limit reached") 2532 return False 2533 return True 2534 finally: 2535 remove_mobile_data_usage_limit(dut, subscriber_id) 2536 2537 2538 def _test_data_stall_detection_recovery(self, nw_type="cellular", 2539 validation_type="detection"): 2540 dut = self.android_devices[0] 2541 try: 2542 cmd = ('ss -l -p -n | grep "tcp.*droid_script" | tr -s " " ' 2543 '| cut -d " " -f 5 | sed s/.*://g') 2544 sl4a_port = dut.adb.shell(cmd) 2545 ensure_phones_default_state(self.log, [dut]) 2546 if nw_type == "wifi": 2547 if not ensure_wifi_connected(self.log, dut, 2548 self.wifi_network_ssid, self.wifi_network_pass): 2549 return False 2550 2551 if not test_data_browsing_success_using_sl4a(self.log, dut): 2552 dut.log.error("Browsing failed before the test, aborting!") 2553 return False 2554 2555 begin_time = get_device_epoch_time(dut) 2556 break_internet_except_sl4a_port(dut, sl4a_port) 2557 2558 if not test_data_browsing_failure_using_sl4a(self.log, dut): 2559 dut.log.error("Browsing success even after breaking internet, "\ 2560 "aborting!") 2561 return False 2562 2563 if not check_data_stall_detection(dut): 2564 dut.log.error("NetworkMonitor unable to detect Data Stall") 2565 2566 if not check_network_validation_fail(dut, begin_time): 2567 dut.log.error("Unable to detect NW validation fail") 2568 return False 2569 2570 if validation_type == "recovery": 2571 if not check_data_stall_recovery(dut, begin_time): 2572 dut.log.error("Recovery was not triggerred") 2573 return False 2574 2575 resume_internet_with_sl4a_port(dut, sl4a_port) 2576 time.sleep(10) 2577 2578 if not test_data_browsing_success_using_sl4a(self.log, dut): 2579 dut.log.error("Browsing failed after resuming internet") 2580 return False 2581 return True 2582 finally: 2583 resume_internet_with_sl4a_port(dut, sl4a_port) 2584 2585 2586 def _test_airplane_mode_stress(self): 2587 ad = self.android_devices[0] 2588 total_iteration = self.stress_test_number 2589 fail_count = collections.defaultdict(int) 2590 current_iteration = 1 2591 for i in range(1, total_iteration + 1): 2592 msg = "Airplane mode test Iteration: <%s> / <%s>" % (i, total_iteration) 2593 self.log.info(msg) 2594 if not airplane_mode_test(self.log, ad): 2595 fail_count["apm_run"] += 1 2596 ad.log.error(">----Iteration : %d/%d failed.----<", 2597 i, total_iteration) 2598 ad.log.info(">----Iteration : %d/%d succeeded.----<", 2599 i, total_iteration) 2600 current_iteration += 1 2601 test_result = True 2602 for failure, count in fail_count.items(): 2603 if count: 2604 ad.log.error("%s: %s %s failures in %s iterations", 2605 self.test_name, count, failure, 2606 total_iteration) 2607 test_result = False 2608 return test_result 2609 2610 2611 @test_tracker_info(uuid="3a82728f-18b5-4a35-9eab-4e6cf55271d9") 2612 @TelephonyBaseTest.tel_test_wrap 2613 def test_apm_toggle_stress(self): 2614 """ Test airplane mode toggle 2615 2616 1. Start with airplane mode off 2617 2. Toggle airplane mode on 2618 3. Toggle airplane mode off 2619 4. Repeat above steps 2620 2621 Returns: 2622 True if pass; False if fail. 2623 """ 2624 return self._test_airplane_mode_stress() 2625 2626 2627 @test_tracker_info(uuid="fda33416-698a-408f-8ddc-b5cde13b1f83") 2628 @TelephonyBaseTest.tel_test_wrap 2629 def test_data_stall_detection_cellular(self): 2630 """ Data Stall Detection Testing 2631 2632 1. Ensure device is camped, browsing working fine 2633 2. Break Internet access, browsing should fail 2634 3. Check for Data Stall Detection 2635 2636 """ 2637 return self._test_data_stall_detection_recovery(nw_type="cellular") 2638 2639 2640 @test_tracker_info(uuid="a57891d6-7892-46c7-8bca-23cd2cca8552") 2641 @TelephonyBaseTest.tel_test_wrap 2642 def test_data_stall_detection_wifi(self): 2643 """ Data Stall Detection Testing 2644 2645 1. Ensure device is connected to WiFi, browsing working fine 2646 2. Break Internet access, browsing should fail 2647 3. Check for Data Stall Detection 2648 2649 """ 2650 return self._test_data_stall_detection_recovery(nw_type="wifi") 2651 2652 2653 @test_tracker_info(uuid="16d3f123-cac3-45a9-a2e5-c01bab7044d4") 2654 @TelephonyBaseTest.tel_test_wrap 2655 def test_data_stall_recovery_cellular(self): 2656 """ Data Stall Recovery Testing 2657 2658 1. Ensure device is camped, browsing working fine 2659 2. Break Internet access, browsing should fail 2660 3. Check for Data Stall Detection 2661 4. Check for Data Stall Recovery 2662 2663 """ 2664 return self._test_data_stall_detection_recovery(nw_type="cellular", 2665 validation_type="recovery") 2666 2667 @test_tracker_info(uuid="d705d653-c810-42eb-bd07-3313f99be2fa") 2668 @TelephonyBaseTest.tel_test_wrap 2669 def test_browsing_4g(self): 2670 ad = self.android_devices[0] 2671 self.log.info("Connect to LTE and verify internet connection.") 2672 if not phone_setup_4g(self.log, ad): 2673 return False 2674 if not verify_internet_connection(self.log, ad): 2675 return False 2676 2677 return browsing_test(self.log, self.android_devices[0]) 2678 2679 @test_tracker_info(uuid="71088cb1-5ccb-4d3a-8e6a-03fac9bf31cc") 2680 @TelephonyBaseTest.tel_test_wrap 2681 def test_browsing_wifi(self): 2682 ad = self.android_devices[0] 2683 self.log.info("Connect to Wi-Fi and verify internet connection.") 2684 if not ensure_wifi_connected(self.log, ad, self.wifi_network_ssid, 2685 self.wifi_network_pass): 2686 return False 2687 if not wait_for_wifi_data_connection(self.log, ad, True): 2688 return False 2689 if not verify_internet_connection(self.log, ad): 2690 return False 2691 2692 return browsing_test(self.log, self.android_devices[0], wifi_ssid=self.wifi_network_ssid) 2693 2694 def _test_sync_time_from_network(self, ad, data_on=True): 2695 """ Verifies time recovered by nitz service 2696 2697 1. Toggle mobile data 2698 2. Toggle off network time synchronization 2699 3. Change device time to FAKE_DATE_TIME: Jan,2,2019 03:04:05 2700 4. Toggle on network time synchronization 2701 5. Verify the year is changed back. 2702 6. Recover mobile data 2703 2704 Args: 2705 ad: android device object 2706 data_on: conditional mobile data on or off 2707 2708 Returns: 2709 True if pass; False if fail. 2710 """ 2711 if not(data_on): 2712 ad.log.info("Disable mobile data.") 2713 ad.droid.telephonyToggleDataConnection(False) 2714 set_time_sync_from_network(ad, "disable") 2715 ad.log.info("Set device time to Jan,2,2019 03:04:05") 2716 datetime_handle(ad, 'set', set_datetime_value = FAKE_DATE_TIME) 2717 datetime_before_sync = datetime_handle(ad, 'get') 2718 ad.log.info("Got before sync datetime from device: %s", 2719 datetime_before_sync) 2720 device_year = datetime_handle(ad, 'get', get_year = True) 2721 2722 if (device_year != FAKE_YEAR): 2723 raise signals.TestSkip("Set device time failed, skip test.") 2724 set_time_sync_from_network(ad, "enable") 2725 datetime_after_sync = datetime_handle(ad, "get") 2726 ad.log.info("Got after sync datetime from device: %s", 2727 datetime_after_sync) 2728 device_year = datetime_handle(ad, "get", get_year = True) 2729 2730 if not(data_on): 2731 ad.log.info("Enabling mobile data.") 2732 ad.droid.telephonyToggleDataConnection(True) 2733 2734 if (device_year != FAKE_YEAR): 2735 self.record_data({ 2736 "Test Name": "test_sync_time_from_network", 2737 "sponge_properties": { 2738 "result": "pass", 2739 }, 2740 }) 2741 return True 2742 else: 2743 return False 2744 2745 @test_tracker_info(uuid="1017b655-5d79-44d2-86ff-675c69aec26b") 2746 @TelephonyBaseTest.tel_test_wrap 2747 def test_sync_time_from_network(self): 2748 """ Test device time recovered by nitz service 2749 2750 1. Toggle off network time synchronization 2751 2. Change device time to FAKE_DATE_TIME. 2752 3. Toggle on network time synchronization 2753 4. Verify the year is changed back. 2754 2755 """ 2756 ad = self.android_devices[0] 2757 wifi_toggle_state(ad.log, ad, False) 2758 return self._test_sync_time_from_network(ad) 2759 2760 @test_tracker_info(uuid="46d170c6-a632-4124-889b-96caa0e641da") 2761 @TelephonyBaseTest.tel_test_wrap 2762 def test_sync_time_from_network_data_off(self): 2763 """ Test device time recovered by nitz service 2764 2765 1. Toggle off mobile data 2766 2. Toggle off network time synchronization 2767 3. Change device time to FAKE_DATE_TIME. 2768 4. Toggle on network time synchronization 2769 5. Verify the year is changed back. 2770 2771 """ 2772 ad = self.android_devices[0] 2773 wifi_toggle_state(ad.log, ad, False) 2774 return self._test_sync_time_from_network(ad, data_on=False) 2775 2776 @test_tracker_info(uuid="2d739779-3beb-4e6e-8396-84f28e626379") 2777 @TelephonyBaseTest.tel_test_wrap 2778 def test_reboot_4g(self): 2779 ad = self.android_devices[0] 2780 self.log.info("Connect to LTE and verify internet connection.") 2781 if not phone_setup_4g(self.log, ad): 2782 return False 2783 if not verify_internet_connection(self.log, ad): 2784 return False 2785 2786 return reboot_test(self.log, ad) 2787 2788 @test_tracker_info(uuid="5ce671f7-c2a4-46aa-a9f2-e5571c144fad") 2789 @TelephonyBaseTest.tel_test_wrap 2790 def test_reboot_3g(self): 2791 ad = self.android_devices[0] 2792 self.log.info("Connect to 3G and verify internet connection.") 2793 if not phone_setup_3g(self.log, ad): 2794 return False 2795 if not verify_internet_connection(self.log, ad): 2796 return False 2797 2798 return reboot_test(self.log, ad) 2799 2800 @test_tracker_info(uuid="9e094f0e-7bef-479e-a5fa-a6bfa95289a5") 2801 @TelephonyBaseTest.tel_test_wrap 2802 def test_reboot_wifi(self): 2803 ad = self.android_devices[0] 2804 self.log.info("Connect to Wi-Fi and verify internet connection.") 2805 if not ensure_wifi_connected(self.log, ad, self.wifi_network_ssid, 2806 self.wifi_network_pass): 2807 return False 2808 if not wait_for_wifi_data_connection(self.log, ad, True): 2809 return False 2810 if not verify_internet_connection(self.log, ad): 2811 return False 2812 2813 return reboot_test(self.log, ad, wifi_ssid=self.wifi_network_ssid) 2814 2815 """ Tests End """ 2816