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 Smoke Test 18 """ 19 20 import time 21 from acts.keys import Config 22 from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest 23 from acts.test_utils.tel.tel_data_utils import airplane_mode_test 24 from acts.test_utils.tel.tel_data_utils import wifi_cell_switching 25 from acts.test_utils.tel.tel_data_utils import wifi_tethering_setup_teardown 26 from acts.test_utils.tel.tel_defines import GEN_4G 27 from acts.test_utils.tel.tel_defines import MAX_WAIT_TIME_TETHERING_ENTITLEMENT_CHECK 28 from acts.test_utils.tel.tel_defines import TETHERING_MODE_WIFI 29 from acts.test_utils.tel.tel_defines import NETWORK_SERVICE_VOICE 30 from acts.test_utils.tel.tel_defines import WAIT_TIME_IN_CALL_FOR_IMS 31 from acts.test_utils.tel.tel_defines import WFC_MODE_WIFI_PREFERRED 32 from acts.test_utils.tel.tel_lookup_tables import is_rat_svd_capable 33 from acts.test_utils.tel.tel_test_utils import WifiUtils 34 from acts.test_utils.tel.tel_test_utils import call_setup_teardown 35 from acts.test_utils.tel.tel_test_utils import ensure_phones_default_state 36 from acts.test_utils.tel.tel_test_utils import get_network_rat 37 from acts.test_utils.tel.tel_test_utils import hangup_call 38 from acts.test_utils.tel.tel_test_utils import multithread_func 39 from acts.test_utils.tel.tel_test_utils import sms_send_receive_verify 40 from acts.test_utils.tel.tel_test_utils import verify_http_connection 41 from acts.test_utils.tel.tel_test_utils import wait_for_cell_data_connection 42 from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_3g 43 from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_csfb 44 from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_iwlan 45 from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_volte 46 from acts.test_utils.tel.tel_voice_utils import phone_setup_voice_3g 47 from acts.test_utils.tel.tel_voice_utils import phone_setup_csfb 48 from acts.test_utils.tel.tel_voice_utils import phone_setup_iwlan 49 from acts.test_utils.tel.tel_voice_utils import phone_setup_volte 50 from acts.utils import load_config 51 from acts.utils import rand_ascii_str 52 53 SKIP = 'Skip' 54 55 class TelLiveSmokeTest(TelephonyBaseTest): 56 def __init__(self, controllers): 57 TelephonyBaseTest.__init__(self, controllers) 58 self.tests = ( 59 "test_smoke_volte_call_data_sms", 60 "test_smoke_csfb_3g_call_data_sms", 61 "test_smoke_3g_call_data_sms", 62 "test_smoke_wfc_call_sms", 63 "test_smoke_data_airplane_mode_network_switch_tethering" 64 ) 65 66 self.simconf = load_config(self.user_params["sim_conf_file"]) 67 68 self.wifi_network_ssid = self.user_params["wifi_network_ssid"] 69 try: 70 self.wifi_network_pass = self.user_params["wifi_network_pass"] 71 except KeyError: 72 self.wifi_network_pass = None 73 74 """ Tests Begin """ 75 @TelephonyBaseTest.tel_test_wrap 76 def test_smoke_volte_call_data_sms(self): 77 try: 78 ads = self.android_devices 79 sms_idle_result = False 80 sms_incall_result = False 81 data_idle_result = False 82 data_incall_result = False 83 call_result = False 84 85 self.log.info("--------start test_smoke_volte_call_data_sms--------") 86 ensure_phones_default_state(self.log, ads) 87 tasks = [(phone_setup_volte, (self.log, ads[0])), 88 (phone_setup_volte, (self.log, ads[1]))] 89 if not multithread_func(self.log, tasks): 90 self.log.error("Phone Failed to Set Up VoLTE.") 91 return False 92 93 # This is to reduce call fail in VoLTE mode. 94 # TODO: b/26338170 remove sleep, use proper API to check DUT status. 95 time.sleep(10) 96 97 self.log.info("1. SMS in LTE idle.") 98 sms_idle_result = sms_send_receive_verify(self.log, ads[0], ads[1], 99 [rand_ascii_str(50)]) 100 101 self.log.info("2. Data in LTE idle.") 102 if (wait_for_cell_data_connection(self.log, ads[0], True) and 103 verify_http_connection(self.log, ads[0])): 104 data_idle_result = True 105 106 self.log.info("3. Setup VoLTE Call.") 107 if not call_setup_teardown( 108 self.log, 109 ads[0], 110 ads[1], 111 ad_hangup=None, 112 verify_caller_func=is_phone_in_call_volte, 113 verify_callee_func=is_phone_in_call_volte, 114 wait_time_in_call=WAIT_TIME_IN_CALL_FOR_IMS): 115 self.log.error("Setup VoLTE Call Failed.") 116 return False 117 118 self.log.info("4. Verify SMS in call.") 119 sms_incall_result = sms_send_receive_verify(self.log, ads[0], ads[1], 120 [rand_ascii_str(51)]) 121 122 self.log.info("5. Verify Data in call.") 123 if (wait_for_cell_data_connection(self.log, ads[0], True) and 124 verify_http_connection(self.log, ads[0])): 125 data_incall_result = True 126 127 self.log.info("6. Verify Call not drop and hangup.") 128 if (is_phone_in_call_volte(self.log, ads[0]) and 129 is_phone_in_call_volte(self.log, ads[1]) and 130 hangup_call(self.log, ads[0])): 131 call_result = True 132 133 return (sms_idle_result and data_idle_result and call_result and 134 sms_incall_result and data_incall_result) 135 finally: 136 self.log.info( 137 "Summary for test run. Testbed:<{}>. <VoLTE> SMS idle: {}, " 138 "Data idle: {}, SMS in call: {}, Data in call: {}, " 139 "Voice Call: {}".format( 140 getattr(self, Config.ikey_testbed_name.value), 141 sms_idle_result, data_idle_result, 142 sms_incall_result, data_incall_result, 143 call_result)) 144 145 @TelephonyBaseTest.tel_test_wrap 146 def test_smoke_csfb_3g_call_data_sms(self): 147 try: 148 ads = self.android_devices 149 sms_idle_result = False 150 sms_incall_result = False 151 data_idle_result = False 152 data_incall_result = False 153 call_result = False 154 155 self.log.info("--------start test_smoke_csfb_3g_call_data_sms--------") 156 ensure_phones_default_state(self.log, ads) 157 tasks = [(phone_setup_csfb, (self.log, ads[0])), 158 (phone_setup_csfb, (self.log, ads[1]))] 159 if not multithread_func(self.log, tasks): 160 self.log.error("Phone Failed to Set Up CSFB_3G.") 161 return False 162 163 # This is to reduce SMS send failure in CSFB mode. 164 # TODO: b/26338170 remove sleep, use proper API to check DUT status. 165 time.sleep(10) 166 167 self.log.info("1. SMS in LTE idle (no IMS).") 168 sms_idle_result = sms_send_receive_verify(self.log, ads[0], ads[1], 169 [rand_ascii_str(50)]) 170 171 self.log.info("2. Data in LTE idle (no IMS).") 172 if (wait_for_cell_data_connection(self.log, ads[0], True) and 173 verify_http_connection(self.log, ads[0])): 174 data_idle_result = True 175 176 self.log.info("3. Setup CSFB_3G Call.") 177 if not call_setup_teardown(self.log, 178 ads[0], 179 ads[1], 180 ad_hangup=None, 181 verify_caller_func=is_phone_in_call_csfb, 182 verify_callee_func=is_phone_in_call_csfb): 183 self.log.error("Setup CSFB_3G Call Failed.") 184 return False 185 186 self.log.info("4. Verify SMS in call.") 187 sms_incall_result = sms_send_receive_verify(self.log, ads[0], ads[1], 188 [rand_ascii_str(51)]) 189 190 self.log.info("5. Verify Data in call.") 191 if is_rat_svd_capable(get_network_rat(self.log, ads[0], 192 NETWORK_SERVICE_VOICE)): 193 if (wait_for_cell_data_connection(self.log, ads[0], True) and 194 verify_http_connection(self.log, ads[0])): 195 data_incall_result = True 196 else: 197 self.log.info("Data in call not supported on current RAT." 198 "Skip Data verification.") 199 data_incall_result = SKIP 200 201 self.log.info("6. Verify Call not drop and hangup.") 202 if (is_phone_in_call_csfb(self.log, ads[0]) and 203 is_phone_in_call_csfb(self.log, ads[1]) and 204 hangup_call(self.log, ads[0])): 205 call_result = True 206 207 return (sms_idle_result and data_idle_result and call_result and 208 sms_incall_result and ((data_incall_result is True) or 209 (data_incall_result == SKIP))) 210 finally: 211 self.log.info( 212 "Summary for test run. Testbed:<{}>. <3G+CSFB> SMS idle: {}, " 213 "Data idle: {}, SMS in call: {}, Data in call: {}, " 214 "Voice Call: {}".format( 215 getattr(self, Config.ikey_testbed_name.value), 216 sms_idle_result, data_idle_result, 217 sms_incall_result, data_incall_result, 218 call_result)) 219 220 @TelephonyBaseTest.tel_test_wrap 221 def test_smoke_3g_call_data_sms(self): 222 try: 223 ads = self.android_devices 224 sms_idle_result = False 225 sms_incall_result = False 226 data_idle_result = False 227 data_incall_result = False 228 call_result = False 229 230 self.log.info("--------start test_smoke_3g_call_data_sms--------") 231 ensure_phones_default_state(self.log, ads) 232 tasks = [(phone_setup_voice_3g, (self.log, ads[0])), 233 (phone_setup_voice_3g, (self.log, ads[1]))] 234 if not multithread_func(self.log, tasks): 235 self.log.error("Phone Failed to Set Up 3G.") 236 return False 237 self.log.info("1. SMS in 3G idle.") 238 sms_idle_result = sms_send_receive_verify(self.log, ads[0], ads[1], 239 [rand_ascii_str(50)]) 240 241 self.log.info("2. Data in 3G idle.") 242 if (wait_for_cell_data_connection(self.log, ads[0], True) and 243 verify_http_connection(self.log, ads[0])): 244 data_idle_result = True 245 246 self.log.info("3. Setup 3G Call.") 247 if not call_setup_teardown(self.log, 248 ads[0], 249 ads[1], 250 ad_hangup=None, 251 verify_caller_func=is_phone_in_call_3g, 252 verify_callee_func=is_phone_in_call_3g): 253 self.log.error("Setup 3G Call Failed.") 254 return False 255 256 self.log.info("4. Verify SMS in call.") 257 sms_incall_result = sms_send_receive_verify(self.log, ads[0], ads[1], 258 [rand_ascii_str(51)]) 259 260 self.log.info("5. Verify Data in call.") 261 if is_rat_svd_capable(get_network_rat(self.log, ads[0], 262 NETWORK_SERVICE_VOICE)): 263 if (wait_for_cell_data_connection(self.log, ads[0], True) and 264 verify_http_connection(self.log, ads[0])): 265 data_incall_result = True 266 else: 267 self.log.info("Data in call not supported on current RAT." 268 "Skip Data verification.") 269 data_incall_result = SKIP 270 271 self.log.info("6. Verify Call not drop and hangup.") 272 if (is_phone_in_call_3g(self.log, ads[0]) and 273 is_phone_in_call_3g(self.log, ads[1]) and 274 hangup_call(self.log, ads[0])): 275 call_result = True 276 277 return (sms_idle_result and data_idle_result and call_result and 278 sms_incall_result and ((data_incall_result is True) or 279 (data_incall_result == SKIP))) 280 finally: 281 self.log.info( 282 "Summary for test run. Testbed:<{}>. <3G> SMS idle: {}, " 283 "Data idle: {}, SMS in call: {}, Data in call: {}, " 284 "Voice Call: {}".format( 285 getattr(self, Config.ikey_testbed_name.value), 286 sms_idle_result, data_idle_result, 287 sms_incall_result, data_incall_result, 288 call_result)) 289 290 @TelephonyBaseTest.tel_test_wrap 291 def test_smoke_wfc_call_sms(self): 292 ads = self.android_devices 293 sms_idle_result = False 294 sms_incall_result = False 295 call_result = False 296 297 self.log.info("--------start test_smoke_wfc_call_sms--------") 298 for ad in [ads[0], ads[1]]: 299 if not ad.droid.imsIsWfcEnabledByPlatform(): 300 self.log.info("WFC not supported by platform.") 301 return True 302 try: 303 ensure_phones_default_state(self.log, ads) 304 tasks = [(phone_setup_iwlan, 305 (self.log, ads[0], True, WFC_MODE_WIFI_PREFERRED, 306 self.wifi_network_ssid, self.wifi_network_pass)), 307 (phone_setup_iwlan, 308 (self.log, ads[1], True, WFC_MODE_WIFI_PREFERRED, 309 self.wifi_network_ssid, self.wifi_network_pass))] 310 if not multithread_func(self.log, tasks): 311 self.log.error("Phone Failed to Set Up WiFI Calling.") 312 return False 313 314 self.log.info("1. Verify SMS in idle.") 315 if sms_send_receive_verify(self.log, ads[0], ads[1], 316 [rand_ascii_str(50)]): 317 sms_idle_result = True 318 319 self.log.info("2. Setup WiFi Call.") 320 if not call_setup_teardown(self.log, 321 ads[0], 322 ads[1], 323 ad_hangup=None, 324 verify_caller_func=is_phone_in_call_iwlan, 325 verify_callee_func=is_phone_in_call_iwlan): 326 self.log.error("Setup WiFi Call Failed.") 327 self.log.info("sms_idle_result:{}".format(sms_idle_result)) 328 return False 329 330 self.log.info("3. Verify SMS in call.") 331 if sms_send_receive_verify(self.log, ads[0], ads[1], 332 [rand_ascii_str(51)]): 333 sms_incall_result = True 334 335 self.log.info("4. Verify Call not drop and hangup.") 336 if (is_phone_in_call_iwlan(self.log, ads[0]) and 337 is_phone_in_call_iwlan(self.log, ads[1]) and 338 hangup_call(self.log, ads[0])): 339 call_result = True 340 341 return (call_result and sms_idle_result and sms_incall_result) 342 finally: 343 self.log.info( 344 "Summary for test run. Testbed:<{}>. <WFC> SMS idle: {}, " 345 "SMS in call: {}, Voice Call: {}".format( 346 getattr(self, Config.ikey_testbed_name.value), 347 sms_idle_result, sms_incall_result, 348 call_result)) 349 350 @TelephonyBaseTest.tel_test_wrap 351 def test_smoke_data_airplane_mode_network_switch_tethering(self): 352 try: 353 ads = self.android_devices 354 apm_result = False 355 nw_switch_result = False 356 tethering_result = False 357 358 self.log.info("--------start test_smoke_data_airplane_mode_network" 359 "_switch_tethering--------") 360 ensure_phones_default_state(self.log, ads) 361 self.log.info("1. Verify toggle airplane mode.") 362 apm_result = airplane_mode_test(self.log, ads[0]) 363 self.log.info("2. Verify LTE-WiFi network switch.") 364 nw_switch_result = wifi_cell_switching(self.log, ads[0], 365 self.wifi_network_ssid, 366 self.wifi_network_pass, GEN_4G) 367 if ads[0].droid.carrierConfigIsTetheringModeAllowed( 368 TETHERING_MODE_WIFI, MAX_WAIT_TIME_TETHERING_ENTITLEMENT_CHECK): 369 self.log.info("3. Verify WiFi Tethering.") 370 if ads[0].droid.wifiIsApEnabled(): 371 WifiUtils.stop_wifi_tethering(self.log, ads[0]) 372 tethering_result = wifi_tethering_setup_teardown( 373 self.log, 374 ads[0], 375 [ads[1]], 376 ap_band=WifiUtils.WIFI_CONFIG_APBAND_2G, 377 check_interval=10, 378 check_iteration=4) 379 # check_interval=10, check_iteration=4: in this Smoke test, 380 # check tethering connection for 4 times, each time delay 10s, 381 # to provide a reasonable check_time (10*4=40s) and also reduce test 382 # execution time. In regular test, check_iteration is set to 10. 383 else: 384 self.log.info("3. Skip WiFi Tethering." 385 "Tethering not allowed on SIM.") 386 tethering_result = SKIP 387 388 return (apm_result and nw_switch_result and 389 ((tethering_result is True) or (tethering_result == SKIP))) 390 finally: 391 self.log.info( 392 "Summary for test run. Testbed:<{}>. <Data> Airplane Mode: {}, " 393 "WiFi-Cell Network Switch: {}, Tethering: {}".format( 394 getattr(self, Config.ikey_testbed_name.value), 395 apm_result, nw_switch_result, tethering_result)) 396 397 """ Tests End """ 398