def power_voice_call_test(self): """ Measures power during a voice call. Measurement step in this test. Starts the voice call and initiates power measurement. Pass or fail is decided with a threshold value. """ # Initiate the voice call initiate_call(self.log, self.dut, "+11112223333") # Wait for the callbox to pick up time.sleep(self.CALL_SETTLING_TIME) # Mute the call self.dut.droid.telecomCallMute() # Turn of screen self.dut.droid.goToSleepNow() # Measure power result = self.collect_power_data() # End the call hangup_call(self.log, self.dut) # Check if power measurement is within the required values self.pass_fail_check(result.average_current)
def route_audio_from_hf_to_speaker(self): """Route audio from HF to primary device inbuilt speakers and vice_versa. Steps: 1. Initiate call from HF. 2. Toggle audio from HF to speaker and vice-versa from N iterations. 3. Hangup call from primary device. Returns: True if successful, False otherwise. """ if not self.audio_receiver.press_initiate_call(): self.log.error("Failed to initiate call.") return False for i in range(self.iterations): self.log.info("DUT speaker iteration = {}".format(i)) if not set_audio_route(self.log, self.pri_ad, AUDIO_ROUTE_SPEAKER): self.log.error("Failed switching to primary device speaker.") hangup_call(self.log, self.pri_ad) return False time.sleep(2) if not set_audio_route(self.log, self.pri_ad, AUDIO_ROUTE_BLUETOOTH): self.log.error("Failed switching to bluetooth headset.") hangup_call(self.log, self.pri_ad) return False if not hangup_call(self.log, self.pri_ad): self.log.error("Failed to hang up the call.") return False return True
def multi_call_audio_routing(self, pri_dut, sec_dut, ter_dut): self.log.info( "Test 2 incomming calls scenario to phone, then test audio routing." ) input("Press enter to execute this testcase...") if not self.setup_multi_call(sec_dut, ter_dut, pri_dut): return False input("Press enter to switch to earpiece...") self.log.info("Switching to earpiece.") set_audio_route(self.log, pri_dut, AUDIO_ROUTE_EARPIECE) time.sleep(self.short_timeout) if get_audio_route(self.log, pri_dut) != AUDIO_ROUTE_EARPIECE: self.log.error( "Audio Route not set to {}".format(AUDIO_ROUTE_EARPIECE)) return False input("Press enter to switch to Bluetooth...") self.log.info("Switching to Bluetooth...") set_audio_route(self.log, pri_dut, AUDIO_ROUTE_BLUETOOTH) time.sleep(self.short_timeout) if get_audio_route(self.log, pri_dut) != AUDIO_ROUTE_BLUETOOTH: self.log.error( "Audio Route not set to {}".format(AUDIO_ROUTE_BLUETOOTH)) return False input("Press enter to hangup call 1...") if not hangup_call(self.log, sec_dut): self.log.error("Failed to hangup call") return False input("Press enter to hangup call 2...") if not hangup_call(self.log, ter_dut): self.log.error("Failed to hangup call") return False return True
def power_volte_call_test(self): """ Measures power during a VoLTE call. Measurement step in this test. Starts the voice call and initiates power measurement. Pass or fail is decided with a threshold value. """ # Initiate the voice call self.anritsu.ims_cscf_call_action( anritsu_utils.DEFAULT_IMS_VIRTUAL_NETWORK_ID, md8475a.ImsCscfCall.MAKE.value) # Wait for the call to be started time.sleep(self.CALL_INITIATING_TIME) # Pickup the call self.dut.adb.shell('input keyevent KEYCODE_CALL') # Mute the call self.dut.droid.telecomCallMute() # Turn of screen self.dut.droid.goToSleepNow() # Measure power self.collect_power_data() # End the call hangup_call(self.log, self.dut) # Check if power measurement is within the required values self.pass_fail_check()
def _power_test(self, phone_check_func_after_power_test=None, **kwargs): # Test passing criteria can be defined in test config file with the # maximum mA allowed for the test case in "pass_criteria"->test_name # field. By default it will set to 999. pass_criteria = self._get_pass_criteria(self.test_name) bug_report = True active_call = kwargs.get('active_call') average_current = 0 result = None self.log.info("Test %s: %s" % (self.test_name, kwargs)) if active_call: sample_rate = ACTIVE_CALL_TEST_SAMPLING_RATE sample_time = ACTIVE_CALL_TEST_SAMPLE_TIME offset_time = ACTIVE_CALL_TEST_OFFSET_TIME else: sample_rate = IDLE_TEST_SAMPLING_RATE sample_time = IDLE_TEST_SAMPLE_TIME offset_time = IDLE_TEST_OFFSET_TIME try: if not self._test_setup(**kwargs): self.log.error("DUT Failed to Set Up Properly.") return False if ((phone_check_func_after_power_test is not None) and (not phone_check_func_after_power_test( self.log, self.android_devices[0]))): self.log.error( "Phone is not in correct status before power test.") return False result = self.mon.measure_power(sample_rate, sample_time, self.test_id, offset_time) average_current = result.average_current if ((phone_check_func_after_power_test is not None) and (not phone_check_func_after_power_test( self.log, self.android_devices[0]))): self.log.error( "Phone is not in correct status after power test.") return False if active_call: if not verify_incall_state( self.log, [self.android_devices[0], self.android_devices[1]], True): self.log.error("Call drop during power test.") return False else: hangup_call(self.log, self.android_devices[1]) if (average_current <= pass_criteria): bug_report = False return True finally: self._save_logs_for_power_test(result, bug_report) self.log.info("{} Result: {} mA, pass criteria: {} mA".format( self.test_id, average_current, pass_criteria))
def multi_incomming_call(self, pri_dut, sec_dut, ter_dut): self.log.info("Test 2 incomming calls scenario to phone.") input("Press enter to execute this testcase...") if not self.setup_multi_call(sec_dut, ter_dut, pri_dut): return False input("Press enter to hangup call 1...") if not hangup_call(self.log, sec_dut): self.log.error("Failed to hangup call") return False input("Press enter to hangup call 2...") if not hangup_call(self.log, ter_dut): self.log.error("Failed to hangup call") return False return True
def call_from_sec_ad_to_pri_ad_and_change_volume(self): """Initiates the call from secondary device and accepts the call from HF connected to primary device. Steps: 1. Initiate call from secondary device to primary device. 2. Accept the call from HF. 3. Hangup the call from primary device. Returns: True if successful, False otherwise. """ if not initiate_call(self.log, self.sec_ad, self.ag_phone_number): self.log.error("Failed to initiate call") return False time.sleep(5) # Wait until initiate call. if not self.audio_receiver.press_accept_call(): self.log.error("Failed to answer call from HF.") return False self.audio_receiver.press_volume_up() time.sleep(2) #Wait until volume changes. self.audio_receiver.press_volume_down() time.sleep(self.iperf["duration"]) if not hangup_call(self.log, self.pri_ad): self.log.error("Failed to hangup call.") return False return True
def outgoing_call_hsp_disabled_then_enabled_during_call( self, pri_dut, sec_dut): self.log.info( "Test outgoing call hsp disabled then enable during call.") input("Press enter to execute this testcase...") outgoing_num = get_phone_number(self.log, sec_dut) if not pri_dut.droid.bluetoothHspDisconnect(self.target_mac_address): self.log.error("Failed to disconnect HSP service...") return False time.sleep(self.short_timeout) if len(pri_dut.droid.bluetoothHspGetConnectedDevices()) != 0: self.log.error("Failed to disconnect from HSP service") return False if not initiate_call(self.log, pri_dut, outgoing_num): self.log.error("Failed to initiate call") return False time.sleep(default_timeout) pri_dut.droid.bluetoothConnectBonded(self.target_mac_address) time.sleep(self.short_timeout) test_result = True if len(pri_dut.droid.bluetoothHspGetConnectedDevices()) != 1: self.log.error("Failed to reconnect to HSP service...") return if not hangup_call(self.log, pri_dut): self.log.error("Failed to hangup call") return False return test_result
def initiate_call_when_a2dp_streaming_on(self): """Initiates HFP call when a2dp is streaming, then check for call is present or not. Disconnect a2dp profile and then connect HFP profile and answer the call from reference device. Returns: True if successful, False otherwise. """ if not self.play_music_and_connect_wifi(): return False if not initiate_call(self.log, self.pri_ad, self.re_phone_number): self.log.error("Failed to initiate call") return False if wait_for_dialing(self.log, self.pri_ad): self.pri_ad.droid.bluetoothDisconnectConnectedProfile( self.audio_receiver.mac_address, [BtEnum.BluetoothProfile.A2DP.value]) if not connect_dev_to_headset( self.pri_ad, self.audio_receiver.mac_address, [BtEnum.BluetoothProfile.HEADSET.value]): return False if not wait_and_answer_call(self.log, self.sec_ad): self.log.error("Failed to answer call in second device") return False time.sleep(self.iperf["duration"]) if not hangup_call(self.log, self.pri_ad): self.log.error("Failed to hangup call") return False return True
def test_smoke_wfc_call_sms(self): ads = self.android_devices sms_idle_result = False sms_incall_result = False call_result = False self.log.info("--------start test_smoke_wfc_call_sms--------") for ad in [ads[0], ads[1]]: if not ad.droid.imsIsWfcEnabledByPlatform(): self.log.info("WFC not supported by platform.") return True try: ensure_phones_default_state(self.log, ads) tasks = [(phone_setup_iwlan, (self.log, ads[0], True, WFC_MODE_WIFI_PREFERRED, self.wifi_network_ssid, self.wifi_network_pass)), (phone_setup_iwlan, (self.log, ads[1], True, WFC_MODE_WIFI_PREFERRED, self.wifi_network_ssid, self.wifi_network_pass))] if not multithread_func(self.log, tasks): self.log.error("Phone Failed to Set Up WiFI Calling.") return False self.log.info("1. Verify SMS in idle.") if sms_send_receive_verify(self.log, ads[0], ads[1], [rand_ascii_str(50)]): sms_idle_result = True self.log.info("2. Setup WiFi Call.") if not call_setup_teardown( self.log, ads[0], ads[1], ad_hangup=None, verify_caller_func=is_phone_in_call_iwlan, verify_callee_func=is_phone_in_call_iwlan): self.log.error("Setup WiFi Call Failed.") self.log.info("sms_idle_result:{}".format(sms_idle_result)) return False self.log.info("3. Verify SMS in call.") if sms_send_receive_verify(self.log, ads[0], ads[1], [rand_ascii_str(51)]): sms_incall_result = True self.log.info("4. Verify Call not drop and hangup.") if (is_phone_in_call_iwlan(self.log, ads[0]) and is_phone_in_call_iwlan(self.log, ads[1]) and hangup_call(self.log, ads[0])): call_result = True return (call_result and sms_idle_result and sms_incall_result) finally: self.log.info( "Summary for test run. Testbed:<{}>. <WFC> SMS idle: {}, " "SMS in call: {}, Voice Call: {}".format( getattr(self, Config.ikey_testbed_name.value), sms_idle_result, sms_incall_result, call_result))
def check_incall_data(self): if verify_internet_connection_by_ping(self.log, self.dut): self.internet_connection_check_method = verify_internet_connection_by_ping elif verify_http_connection(self.log, self.dut): self.internet_connection_check_method = verify_http_connection else: self.dut.log.error("Data test failed") raise signals.TestFailure("Data check failed") if self.single_phone_test: if not initiate_call( self.log, self.dut, self.call_server_number) and wait_for_in_call_active( self.dut, 60, 3): self._take_bug_report(self.test_name, self.begin_time) raise signals.TestFailure("Unable to make phone call") else: if not call_setup_teardown( self.log, self.dut, self.android_devices[1], ad_hangup=None): self._take_bug_report(self.test_name, self.begin_time) raise signals.TestFailure("Unable to make phone call") voice_rat = self.dut.droid.telephonyGetCurrentVoiceNetworkType() data_rat = self.dut.droid.telephonyGetCurrentDataNetworkType() self.dut.log.info("Voice in RAT %s, Data in RAT %s", voice_rat, data_rat) try: if is_rat_svd_capable(voice_rat.upper()) and is_rat_svd_capable( data_rat.upper()): self.dut.log.info("Capable for simultaneous voice and data") if not self.internet_connection_check_method( self.log, self.dut): self.dut.log.error("Incall data check failed") raise signals.TestFailure("Incall data check failed") else: return True else: self.dut.log.info( "Not capable for simultaneous voice and data") return False hangup_call(self.log, self.dut) finally: for ad in self.android_devices: if ad.droid.telecomIsInCall(): hangup_call(self.log, ad)
def multi_call_swap_multiple_times(self, pri_dut, sec_dut, ter_dut): self.log.info( "Test 2 incomming calls scenario to phone, then test audio routing." ) input("Press enter to execute this testcase...") if not self.setup_multi_call(sec_dut, ter_dut, pri_dut): return False input("Press enter to swap active calls...") calls = pri_dut.droid.telecomCallGetCallIds() if not swap_calls(self.log, [pri_dut, sec_dut, ter_dut], calls[0], calls[1], 5): return False input("Press enter to hangup call 1...") if not hangup_call(self.log, sec_dut): self.log.error("Failed to hangup call") return False input("Press enter to hangup call 2...") if not hangup_call(self.log, ter_dut): self.log.error("Failed to hangup call") return False return True
def initiate_disconnect_call_dut(pri_ad, sec_ad, duration, callee_number): """Initiates call and disconnect call on primary device. Steps: 1. Initiate call from DUT. 2. Wait for dialing state at DUT and wait for ringing at secondary device. 3. Accepts call from secondary device. 4. Wait for call active state at primary and secondary device. 5. Sleeps until given duration. 6. Disconnect call from primary device. 7. Wait for call is not present state. Args: pri_ad: An android device to disconnect call. sec_ad: An android device accepting call. duration: Duration of call in seconds. callee_number: Secondary device's phone number. Returns: True if successful, False otherwise. """ if not initiate_call(logging, pri_ad, callee_number): pri_ad.log.error("Failed to initiate call") return False time.sleep(2) flag = True flag &= wait_for_dialing(logging, pri_ad) flag &= wait_for_ringing(logging, sec_ad) if not flag: pri_ad.log.error("Outgoing call did not get established") return False if not wait_and_answer_call(logging, sec_ad): pri_ad.log.error("Failed to answer call in second device.") return False # Wait for AG, RE to go into an Active state. if not wait_for_active(logging, pri_ad): pri_ad.log.error("AG not in Active state.") return False if not wait_for_active(logging, sec_ad): pri_ad.log.error("RE not in Active state.") return False time.sleep(duration) if not hangup_call(logging, pri_ad): pri_ad.log.error("Failed to hangup call.") return False flag = True flag &= wait_for_not_in_call(logging, pri_ad) flag &= wait_for_not_in_call(logging, sec_ad) return flag
def multi_call_join_conference_call(self, pri_dut, sec_dut, ter_dut): self.log.info( "Test 2 incomming calls scenario to phone then join the calls.") input("Press enter to execute this testcase...") if not self.setup_multi_call(sec_dut, ter_dut, pri_dut): return False input("Press enter to join active calls...") calls = pri_dut.droid.telecomCallGetCallIds() pri_dut.droid.telecomCallJoinCallsInConf(calls[0], calls[1]) time.sleep(WAIT_TIME_IN_CALL) if num_active_calls(self.log, pri_dut) != 4: self.log.error("Total number of call ids in {} is not 4.".format( pri_dut.serial)) return False input("Press enter to hangup call 1...") if not hangup_call(self.log, sec_dut): self.log.error("Failed to hangup call") return False input("Press enter to hangup call 2...") if not hangup_call(self.log, ter_dut): self.log.error("Failed to hangup call") return False return True
def outgoing_multi_call_join_conference_call(self, pri_dut, sec_dut, ter_dut): self.log.info( "Test 2 outgoing calls scenario from phone then join the calls.") input("Press enter to execute this testcase...") outgoing_num = get_phone_number(self.log, sec_dut) if not initiate_call(self.log, pri_dut, outgoing_num): self.log.error("Failed to initiate call") return False if not wait_and_answer_call(self.log, sec_dut): self.log.error("Failed to answer call.") return False time.sleep(self.short_timeout) outgoing_num = get_phone_number(self.log, ter_dut) if not initiate_call(self.log, pri_dut, outgoing_num): self.log.error("Failed to initiate call") return False if not wait_and_answer_call(self.log, ter_dut): self.log.error("Failed to answer call.") return False input("Press enter to join active calls...") calls = pri_dut.droid.telecomCallGetCallIds() pri_dut.droid.telecomCallJoinCallsInConf(calls[0], calls[1]) time.sleep(WAIT_TIME_IN_CALL) if num_active_calls(self.log, pri_dut) != 4: self.log.error("Total number of call ids in {} is not 4.".format( pri_dut.serial)) return False input("Press enter to hangup call 1...") if not hangup_call(self.log, sec_dut): self.log.error("Failed to hangup call") return False input("Press enter to hangup call 2...") if not hangup_call(self.log, ter_dut): self.log.error("Failed to hangup call") return False return True
def initiate_call_from_hf_disconnect_from_ag(self): """Initiates call from HF and disconnect call from ag for multiple iterations. Returns: True if successful, False otherwise. """ for i in range(self.iterations): if not self.audio_receiver.press_initiate_call(): self.log.error("Failed to initiate call.") return False time.sleep(5) #Wait time for intiating call. if not hangup_call(self.log, self.pri_ad): self.log.error("Failed to hang up the call.") return False return True
def initiate_disconnect_from_hf(audio_receiver, pri_ad, sec_ad, duration): """Initiates call and disconnect call on primary device. Steps: 1. Initiate call from HF. 2. Wait for dialing state at DUT and wait for ringing at secondary device. 3. Accepts call from secondary device. 4. Wait for call active state at primary and secondary device. 5. Sleeps until given duration. 6. Disconnect call from primary device. 7. Wait for call is not present state. Args: audio_receiver: An relay device object. pri_ad: An android device to disconnect call. sec_ad: An android device accepting call. duration: Duration of call in seconds. Returns: True if successful, False otherwise. """ audio_receiver.press_initiate_call() time.sleep(2) flag = True flag &= wait_for_dialing(logging, pri_ad) flag &= wait_for_ringing(logging, sec_ad) if not flag: pri_ad.log.error("Outgoing call did not get established") return False if not wait_and_answer_call(logging, sec_ad): pri_ad.log.error("Failed to answer call in second device.") return False if not wait_for_active(logging, pri_ad): pri_ad.log.error("AG not in Active state.") return False if not wait_for_active(logging, sec_ad): pri_ad.log.error("RE not in Active state.") return False time.sleep(duration) if not hangup_call(logging, pri_ad): pri_ad.log.error("Failed to hangup call.") return False flag = True flag &= wait_for_not_in_call(logging, pri_ad) flag &= wait_for_not_in_call(logging, sec_ad) return flag
def outgoing_call_private_number(self, pri_dut, ter_dut): self.log.info( "Test outgoing call scenario from phone to private number") input("Press enter to execute this testcase...") outgoing_num = "*67" + get_phone_number(self.log, ter_dut) if not initiate_call(self.log, pri_dut, outgoing_num): self.log.error("Failed to initiate call") return False if not wait_and_answer_call(self.log, ter_dut): self.log.error("Failed to answer call.") return False time.sleep(self.short_timeout) input("Press enter to hangup call...") if not hangup_call(self.log, pri_dut): self.log.error("Failed to hangup call") return False return True
def incomming_call_unknown_contact(self, pri_dut, ter_dut): self.log.info( "Test incomming call scenario to phone from unknown contact") input("Press enter to execute this testcase...") outgoing_num = get_phone_number(self.log, pri_dut) if not initiate_call(self.log, ter_dut, outgoing_num): self.log.error("Failed to initiate call") return False if not wait_and_answer_call(self.log, pri_dut): self.log.error("Failed to answer call.") return False time.sleep(self.short_timeout) input("Press enter to hangup call...") if not hangup_call(self.log, ter_dut): self.log.error("Failed to hangup call") return False return True
def call_audio_routes(self, pri_dut, sec_dut): self.log.info("Test various audio routes scenario from phone.") input("Press enter to execute this testcase...") outgoing_num = get_phone_number(self.log, sec_dut) if not initiate_call(self.log, pri_dut, outgoing_num): self.log.error("Failed to initiate call") return False if not wait_and_answer_call(self.log, sec_dut): self.log.error("Failed to answer call.") return False time.sleep(self.short_timeout) call_id = pri_dut.droid.telecomCallGetCallIds()[0] pri_dut.droid.telecomCallPlayDtmfTone(call_id, "9") input("Press enter to switch to speaker...") self.log.info("Switching to speaker.") set_audio_route(self.log, pri_dut, AUDIO_ROUTE_SPEAKER) time.sleep(self.short_timeout) if get_audio_route(self.log, pri_dut) != AUDIO_ROUTE_SPEAKER: self.log.error( "Audio Route not set to {}".format(AUDIO_ROUTE_SPEAKER)) return False input("Press enter to switch to earpiece...") self.log.info("Switching to earpiece.") set_audio_route(self.log, pri_dut, AUDIO_ROUTE_EARPIECE) time.sleep(self.short_timeout) if get_audio_route(self.log, pri_dut) != AUDIO_ROUTE_EARPIECE: self.log.error( "Audio Route not set to {}".format(AUDIO_ROUTE_EARPIECE)) return False input("Press enter to switch to Bluetooth...") self.log.info("Switching to Bluetooth...") set_audio_route(self.log, pri_dut, AUDIO_ROUTE_BLUETOOTH) time.sleep(self.short_timeout) if get_audio_route(self.log, pri_dut) != AUDIO_ROUTE_BLUETOOTH: self.log.error( "Audio Route not set to {}".format(AUDIO_ROUTE_BLUETOOTH)) return False input("Press enter to hangup call...") self.log.info("Hanging up call...") pri_dut.droid.telecomCallStopDtmfTone(call_id) if not hangup_call(self.log, pri_dut): self.log.error("Failed to hangup call") return False return True
def outgoing_call_multiple_iterations(self, pri_dut, sec_dut): iteration_count = 3 self.log.info( "Test outgoing call scenario from phone {} times from known contact" .format(iteration_count)) input("Press enter to execute this testcase...") outgoing_num = get_phone_number(self.log, sec_dut) for _ in range(iteration_count): if not initiate_call(self.log, pri_dut, outgoing_num): self.log.error("Failed to initiate call") return False if not wait_and_answer_call(self.log, sec_dut): self.log.error("Failed to answer call.") return False time.sleep(self.short_timeout) if not hangup_call(self.log, pri_dut): self.log.error("Failed to hangup call") return False return True
def call_from_sec_ad_to_pri_ad(self): """Initiates the call from secondary device and accepts the call from HF. Steps: 1. Initiate call from secondary device to primary device. 2. Accept the call from HF. 3. Hangup the call from primary device. Returns: True if successful, False otherwise. """ if not initiate_call(self.log, self.sec_ad, self.ag_phone_number): self.log.error("Failed to initiate call") return False if not self.audio_receiver.press_accept_call(): self.log.error("Failed to answer call from HF.") return False if not hangup_call(self.log, self.pri_ad): self.log.error("Failed to hangup call.") return False return False
def sms_during_incomming_call(self, pri_dut, sec_dut): self.log.info( "Test incomming call scenario to phone from unknown contact") input("Press enter to execute this testcase...") outgoing_num = get_phone_number(self.log, pri_dut) if not initiate_call(self.log, sec_dut, outgoing_num): self.log.error("Failed to initiate call") return False if not wait_and_answer_call(self.log, pri_dut): self.log.error("Failed to answer call.") return False time.sleep(self.short_timeout) msg = [rand_ascii_str(10)] if not sms_send_receive_verify(self.log, sec_dut, pri_dut, msg): return False else: self.log.info("Successfully sent sms. Please verify on carkit.") input("Press enter to hangup call...") if not hangup_call(self.log, sec_dut): self.log.error("Failed to hangup call") return False return True
def test_internet_access_during_video_call(self): """ Test Internet access during VT<->VT call. Make Sure PhoneA is in LTE mode (with Video Calling). Make Sure PhoneB is in LTE mode (with Video Calling). Call from PhoneA to PhoneB as Bi-Directional Video, Accept on PhoneB as video call. Verify PhoneA have Internet access. Hang up on PhoneA. Returns: True if pass; False if fail. """ ads = self.android_devices tasks = [(phone_setup_video, (self.log, ads[0])), (phone_setup_video, (self.log, ads[1]))] if not multithread_func(self.log, tasks): self.log.error("Phone Failed to Set Up Properly.") return False self.log.info("Step1: Make MO VT call.") if not video_call_setup_teardown( self.log, ads[0], ads[1], None, video_state=VT_STATE_BIDIRECTIONAL, verify_caller_func=is_phone_in_call_video_bidirectional, verify_callee_func=is_phone_in_call_video_bidirectional): self.log.error("Failed to setup+teardown a call") return False self.log.info("Step2: Verify Internet on PhoneA.") if not verify_http_connection(self.log, ads[0]): self.log.error("Verify Internet on PhoneA failed.") return False return hangup_call(self.log, ads[0])
def multi_call_join_conference_call_audio_routes(self, pri_dut, sec_dut, ter_dut): self.log.info( "Test 2 incomming calls scenario to phone then join the calls, then test different audio routes." ) input("Press enter to execute this testcase...") if not self.setup_multi_call(sec_dut, ter_dut, pri_dut): return False input("Press enter to join active calls...") calls = pri_dut.droid.telecomCallGetCallIds() pri_dut.droid.telecomCallJoinCallsInConf(calls[0], calls[1]) time.sleep(WAIT_TIME_IN_CALL) if num_active_calls(self.log, pri_dut) != 4: self.log.error("Total number of call ids in {} is not 4.".format( pri_dut.serial)) return False input("Press enter to switch to phone speaker...") self.log.info("Switching to earpiece.") set_audio_route(self.log, pri_dut, AUDIO_ROUTE_EARPIECE) time.sleep(self.short_timeout) if get_audio_route(self.log, pri_dut) != AUDIO_ROUTE_EARPIECE: self.log.error( "Audio Route not set to {}".format(AUDIO_ROUTE_EARPIECE)) return False input("Press enter to switch to Bluetooth...") self.log.info("Switching to Bluetooth...") set_audio_route(self.log, pri_dut, AUDIO_ROUTE_BLUETOOTH) time.sleep(self.short_timeout) if get_audio_route(self.log, pri_dut) != AUDIO_ROUTE_BLUETOOTH: self.log.error( "Audio Route not set to {}".format(AUDIO_ROUTE_BLUETOOTH)) return False input("Press enter to hangup conf call...") if not hangup_call(self.log, pri_dut): self.log.error("Failed to hangup call") return False return True
def outgoing_call_a2dp_play_before_and_after(self, pri_dut, sec_dut): self.log.info( "Test outgoing call scenario while playing music. Music should resume after call." ) pri_dut.adb.shell(KEYCODE_EVENT_PREVIOUS) input( "Press enter to execute this testcase when music is in a play state..." ) outgoing_num = get_phone_number(self.log, sec_dut) if not initiate_call(self.log, pri_dut, outgoing_num): self.log.error("Failed to initiate call") return False if not wait_and_answer_call(self.log, sec_dut): self.log.error("Failed to answer call.") return False time.sleep(self.short_timeout) input("Press enter to hangup call...") if not hangup_call(self.log, pri_dut): self.log.error("Failed to hangup call") return False input("Press enter when music continues to play.") self.log.info("Pausing Music...") pri_dut.adb.shell(KEYCODE_EVENT_PLAY_PAUSE) return True
def test_smoke_volte_call_data_sms(self): try: ads = self.android_devices sms_idle_result = False sms_incall_result = False data_idle_result = False data_incall_result = False call_result = False self.log.info( "--------start test_smoke_volte_call_data_sms--------") ensure_phones_default_state(self.log, ads) tasks = [(phone_setup_volte, (self.log, ads[0])), (phone_setup_volte, (self.log, ads[1]))] if not multithread_func(self.log, tasks): self.log.error("Phone Failed to Set Up VoLTE.") return False # This is to reduce call fail in VoLTE mode. # TODO: b/26338170 remove sleep, use proper API to check DUT status. time.sleep(10) self.log.info("1. SMS in LTE idle.") sms_idle_result = sms_send_receive_verify(self.log, ads[0], ads[1], [rand_ascii_str(50)]) self.log.info("2. Data in LTE idle.") if (wait_for_cell_data_connection(self.log, ads[0], True) and verify_http_connection(self.log, ads[0])): data_idle_result = True self.log.info("3. Setup VoLTE Call.") if not call_setup_teardown( self.log, ads[0], ads[1], ad_hangup=None, verify_caller_func=is_phone_in_call_volte, verify_callee_func=is_phone_in_call_volte, wait_time_in_call=WAIT_TIME_IN_CALL_FOR_IMS): self.log.error("Setup VoLTE Call Failed.") return False self.log.info("4. Verify SMS in call.") sms_incall_result = sms_send_receive_verify( self.log, ads[0], ads[1], [rand_ascii_str(51)]) self.log.info("5. Verify Data in call.") if (wait_for_cell_data_connection(self.log, ads[0], True) and verify_http_connection(self.log, ads[0])): data_incall_result = True self.log.info("6. Verify Call not drop and hangup.") if (is_phone_in_call_volte(self.log, ads[0]) and is_phone_in_call_volte(self.log, ads[1]) and hangup_call(self.log, ads[0])): call_result = True return (sms_idle_result and data_idle_result and call_result and sms_incall_result and data_incall_result) finally: self.log.info( "Summary for test run. Testbed:<{}>. <VoLTE> SMS idle: {}, " "Data idle: {}, SMS in call: {}, Data in call: {}, " "Voice Call: {}".format( getattr(self, Config.ikey_testbed_name.value), sms_idle_result, data_idle_result, sms_incall_result, data_incall_result, call_result))
def test_smoke_3g_call_data_sms(self): try: ads = self.android_devices sms_idle_result = False sms_incall_result = False data_idle_result = False data_incall_result = False call_result = False self.log.info("--------start test_smoke_3g_call_data_sms--------") ensure_phones_default_state(self.log, ads) tasks = [(phone_setup_voice_3g, (self.log, ads[0])), (phone_setup_voice_3g, (self.log, ads[1]))] if not multithread_func(self.log, tasks): self.log.error("Phone Failed to Set Up 3G.") return False self.log.info("1. SMS in 3G idle.") sms_idle_result = sms_send_receive_verify(self.log, ads[0], ads[1], [rand_ascii_str(50)]) self.log.info("2. Data in 3G idle.") if (wait_for_cell_data_connection(self.log, ads[0], True) and verify_http_connection(self.log, ads[0])): data_idle_result = True self.log.info("3. Setup 3G Call.") if not call_setup_teardown(self.log, ads[0], ads[1], ad_hangup=None, verify_caller_func=is_phone_in_call_3g, verify_callee_func=is_phone_in_call_3g): self.log.error("Setup 3G Call Failed.") return False self.log.info("4. Verify SMS in call.") sms_incall_result = sms_send_receive_verify( self.log, ads[0], ads[1], [rand_ascii_str(51)]) self.log.info("5. Verify Data in call.") if is_rat_svd_capable( get_network_rat(self.log, ads[0], NETWORK_SERVICE_VOICE)): if (wait_for_cell_data_connection(self.log, ads[0], True) and verify_http_connection(self.log, ads[0])): data_incall_result = True else: self.log.info("Data in call not supported on current RAT." "Skip Data verification.") data_incall_result = SKIP self.log.info("6. Verify Call not drop and hangup.") if (is_phone_in_call_3g(self.log, ads[0]) and is_phone_in_call_3g(self.log, ads[1]) and hangup_call(self.log, ads[0])): call_result = True return (sms_idle_result and data_idle_result and call_result and sms_incall_result and ((data_incall_result is True) or (data_incall_result == SKIP))) finally: self.log.info( "Summary for test run. Testbed:<{}>. <3G> SMS idle: {}, " "Data idle: {}, SMS in call: {}, Data in call: {}, " "Voice Call: {}".format( getattr(self, Config.ikey_testbed_name.value), sms_idle_result, data_idle_result, sms_incall_result, data_incall_result, call_result))
def volte_modechange_volte_test(self): failure = 0 total_count = 0 sub_id = self.dut.droid.subscriptionGetDefaultSubId() while time.time() < self.finishing_time: total_count += 1 try: self.dut.log.info(dict(self.result_info)) self.result_info["Total Calls"] += 1 duration = random.randrange(self.min_phone_call_duration, self.max_phone_call_duration) # Current Voice RAT self.dut.log.info("Current Voice RAT is %s", get_current_voice_rat(self.log, self.dut)) self.dut.log.info("Make call to %s with call duration %s", self.call_server_number, duration) if not initiate_call(self.log, self.dut, self.call_server_number): self.dut.log.error("Initiate phone call to %s failed.", self.call_server_number) self.result_info["Call initiation failure"] += 1 failure += 1 self._take_bug_report("%s_call_initiation_failure" % self.test_name, time.strftime("%m-%d-%Y-%H-%M-%S")) continue elapse_time = 0 interval = min(5, duration) while elapse_time < duration: interval = min(duration - elapse_time, interval) time.sleep(interval) elapse_time += interval if not is_phone_in_call_volte(self.log, self.dut): self.dut.log.error("Call not VoLTE") self.result_info["Call not VoLTE"] += 1 failure += 1 self._take_bug_report( "%s_not_in_volte" % self.test_name, time.strftime("%m-%d-%Y-%H-%M-%S")) break else: self.dut.log.info("DUT is in VoLTE call") else: hangup_call(self.log, self.dut) self.dut.log.info("VoLTE test succeed.") # ModePref change to non-LTE network_preference_list = [ NETWORK_MODE_TDSCDMA_GSM_WCDMA, NETWORK_MODE_WCDMA_ONLY, NETWORK_MODE_GLOBAL, NETWORK_MODE_CDMA, NETWORK_MODE_GSM_ONLY ] network_preference = random.choice(network_preference_list) set_preferred_network_mode_pref(self.dut.log, self.dut, sub_id, network_preference) time.sleep(WAIT_TIME_AFTER_MODE_CHANGE) self.dut.log.info( "Current Voice RAT is %s", get_current_voice_rat(self.log, self.dut)) # ModePref change back to with LTE set_preferred_network_mode_pref( self.dut.log, self.dut, sub_id, NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA) time.sleep(WAIT_TIME_AFTER_MODE_CHANGE) except IGNORE_EXCEPTIONS as e: self.log.error("Exception error %s", str(e)) self.result_info["Exception Errors"] += 1 if self.result_info["Exception Errors"] > EXCEPTION_TOLERANCE: self.finishing_time = time.time() raise except Exception as e: self.finishing_time = time.time() raise self.dut.log.info("VoLTE test failure: %s/%s", failure, total_count) if failure: return "VoLTE test failure: %s/%s" % (failure, total_count) else: return ""
def call_test(self): failure = 0 total_count = 0 while time.time() < self.finishing_time: total_count += 1 try: self.dut.log.info(dict(self.result_info)) self.result_info["Total Calls"] += 1 duration = random.randrange(self.min_phone_call_duration, self.max_phone_call_duration) # Current Voice RAT self.dut.log.info("Current Voice RAT is %s", get_current_voice_rat(self.log, self.dut)) self.dut.log.info("Make call to %s with call duration %s", self.call_server_number, duration) if not initiate_call(self.log, self.dut, self.call_server_number): self.dut.log.error("Initiate phone call to %s failed.", self.call_server_number) self.result_info["Call initiation failure"] += 1 failure += 1 self._take_bug_report("%s_call_initiation_failure" % self.test_name, time.strftime("%m-%d-%Y-%H-%M-%S")) continue elapse_time = 0 interval = min(60, duration) while elapse_time < duration: interval = min(duration - elapse_time, interval) time.sleep(interval) elapse_time += interval if not is_phone_in_call(self.log, self.dut): self.dut.log.error("Call droped.") self.result_info["Call drop"] += 1 failure += 1 self._take_bug_report( "%s_call_drop" % self.test_name, time.strftime("%m-%d-%Y-%H-%M-%S")) break else: self.dut.log.info("DUT is in call") else: hangup_call(self.log, self.dut) self.dut.log.info("Call test succeed.") ensure_phone_idle(self.log, self.dut) self.dut.droid.goToSleepNow() time.sleep(random.randrange(0, self.max_sleep_time)) except IGNORE_EXCEPTIONS as e: self.log.error("Exception error %s", str(e)) self.result_info["Exception Errors"] += 1 if self.result_info["Exception Errors"] > EXCEPTION_TOLERANCE: self.finishing_time = time.time() raise except Exception as e: self.finishing_time = time.time() raise self.dut.log.info("Call test failure: %s/%s", failure, total_count) if failure: return "Call test failure: %s/%s" % (failure, total_count) else: return ""