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