class LiveDsdsFtpSms(UseCaseBase): """ Use Case Live SMS loopback class. """ def __init__(self, tc_name, global_config): UseCaseBase.__init__(self, tc_name, global_config) self.awake = False self._test_timeout=10 self._call_setup_time = 15 self.d = Device(self._device.retrieve_serial_number()) self._registration_timeout = \ int(self._dut_config.get("registrationTimeout")) self._phone_number = str(self._device.get_phone_number()) self._destination_number = \ str(self._tc_parameters.get_param_value("DESTINATION_NUMBER")) self._message = \ str(self._tc_parameters.get_param_value("MESSAGE_CONTENT", "")) self._phone = DeviceManager().get_device("PHONE1") self._phone2 = DeviceManager().get_device("PHONE2") self._phone_number2 = str(self._phone2.get_phone_number()) self._default_sim = self._tc_parameters.get_param_value("DEFAULT_SIM") self._network_pref = self._tc_parameters.get_param_value("PREFERRED_NETWORK_TYPE", None) if self._network_pref: self._network_pref = self._network_pref.upper() self._initial_pref_network = None #Parameter to download or upload self._direction = self._tc_parameters.get_param_value("DIRECTION") self._server_name = \ self._tc_parameters.get_param_value("SERVER_NAME", "LAB_SERVER") self._callduration = \ int(self._tc_parameters.get_param_value("CALL_DURATION")) self._sms_transfer_timeout= \ int(self._tc_parameters.get_param_value("SMS_TRANSFER_TIMEOUT")) # Get FTP server parameters self._server = \ global_config.benchConfig.get_parameters(self._server_name) self._server_ip_address = self._server.get_param_value("IP") self._username = self._server.get_param_value("username") self._password = self._server.get_param_value("password") if self._server.has_parameter("ftp_path"): self._ftp_path = self._server.get_param_value("ftp_path") else: self._ftp_path = "" #The file need to download self._dlfilename = os.path.join( self._ftp_path, self._tc_parameters.get_param_value("DL_FILE", "")) #Max time for file transfer self._xfer_timeout = \ int(self._tc_parameters.get_param_value("XFER_TIMEOUT")) # The base name of the file we download self._ftp_file_basename = self._tc_parameters.get_param_value("BASENAME") self._sms_api = self._device.get_uecmd("SmsMessaging") self._sms_api2 = self._phone2.get_uecmd("SmsMessaging") self._mms_api = self._device.get_uecmd("MmsMessaging") self._sms_api2 = self._phone2.get_uecmd("SmsMessaging") #self._voice_call_api2 = self._phone2.get_uecmd("VoiceCall") self._networking_api = self._device.get_uecmd("Networking") self._phone_system_api = self._device.get_uecmd("PhoneSystem") #self._phone_system_api2 = self._phone2.get_uecmd("PhoneSystem") self._ftp_api = self._device.get_uecmd("Ftp") self._modem_api = self._device.get_uecmd("Modem") self._phonesystem_api = self._device.get_uecmd("PhoneSystem") #self._phone_system_api2 = self._phone2.get_uecmd("PhoneSystem") self._networking_api = self._device.get_uecmd("Networking") #self._voice_call_api2 = self._phone2.get_uecmd("VoiceCall") #self._networking_api2 = self._phone2.get_uecmd("Networking") self._voicecall_api = self._phone.get_uecmd("VoiceCall") if self._phone2 is not None: self._voice_call_api2 = self._phone2.get_uecmd("VoiceCall") self._networking_api2 = self._phone2.get_uecmd("Networking") self._phone_system_api2 = self._phone2.get_uecmd("PhoneSystem") #-------------------------------------------------------------------------------------- def set_up(self): """ Setup for the test case """ # Call set_up of use case base UseCaseBase.set_up(self) # Check if we have the second phone available if self._phone2 is None: # We are using this multi UC with only one phone error_msg = \ "This use case requires two phones to be executed !" self._logger.error(error_msg) raise AcsConfigException(AcsConfigException.INVALID_BENCH_CONFIG, error_msg) self._sms_api.delete_all_sms() # Boot the other phone (the DUT is already booted) if not self._phone2.is_available(): DeviceManager().boot_device("PHONE2") if self._default_sim == "SIM2": #Setting the sim to Default (verdict,msg)=self._setDefaultSecondSim() else: (verdict,msg)=self._setDefaultSim() time.sleep(10) self._absolute_path_on_dut = "".join([ self._device.multimedia_path, self._ftp_file_basename]) # Delete the FTP download file on the DUT self._delete_file_if_exists(self._absolute_path_on_dut) # Disable flight mode self._networking_api.set_flight_mode("off") time.sleep(self._wait_btwn_cmd) time.sleep(self._wait_btwn_cmd) # There is a preferred network to set, backup initial, then set configured one if self._network_pref is not None: self._initial_pref_network = self._dut_config.get("defaultPreferredNetwork") time.sleep(self._wait_btwn_cmd) if self._networking_api.is_preferred_network_type_valid(self._network_pref): # Setting the DUT preferred network type to the one specified # in the TC. self._networking_api.set_preferred_network_type(self._network_pref) time.sleep(self._wait_btwn_cmd) # Check the DUT is camped on a compatible network with the selected # preferred network. self._modem_api.check_rat_with_pref_network(self._network_pref, self._registration_timeout) time.sleep(self._wait_btwn_cmd) else: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "Unknown network type: %s" % self._network_pref) return verdict,msg #-------------------------------------------------------------------------------------- def run_test(self): """ Execute the test """ #Call UseCase base run function UseCaseBase.run_test(self) queue = Queue.Queue() #creating empty list to append the threads threads=[] #creating empty list to append the return value from the threads result=[] try: #creating thread object to trigger to the _ftpdownloads method thread_ftp=Thread(target = self._ftpdownload,args=[queue]) thread_ftp.setName("Thread1") #to start the thread object thread_ftp.start() time.sleep(10) #creating thread object to trigger to the _smssendreceive method thread_sms=Thread(target = self._sendsms,args=[queue]) thread_sms.setName("Thread2") #to start the thread object thread_sms.start() except Exception as inst: self._logger.info(inst) raise AcsConfigException(AcsConfigException.OPERATION_FAILED, "Exception: %s" % inst) return Global.FAILURE,"Error" #appending the thread object into the empty list threads.append(thread_ftp) #appending the thread object into the empty list threads.append(thread_sms) for thread_id in threads: #to make the thread wait for the other thread does not complete thread_id.join() #appending the return value to the list result.append(queue.get()) #checking the return value is SUCCESS if result[0]==Global.SUCCESS: self._logger("successfull") if result[1]==Global.SUCCESS: self._logger("succssfully") return Global.SUCCESS, "SUCCESSFULL" else: return Global.FAILURE," not send done." else: return Global.FAILURE,"not done" #--------------------------------------------------------------------------------------------- def _ftpdownload(self,queue): """ Execute the web browsing """ #creating the lock lock=threading.Lock() lock.acquire() try: self._logger.info("inside _ftpdownload function") #Thread no self._logger.info(current_thread()) #checking the pdp status pdp_context_status = self._networking_api._get_pdp_context_status() if pdp_context_status in ("0", "2"): self._networking_api.activate_pdp_context() time.sleep(self._wait_btwn_cmd) if self._direction == "DL": self._logger.info("FTP transfer " + str(self._direction) + " for " + str(self._dlfilename) + "...") # Uecmd to do ftp and storing the result result = self._networking_api.\ ftp_xfer(self._uecmd_types.XFER_DIRECTIONS.DL, # pylint: disable=E1101 self._server_ip_address, self._username, self._password, self._dlfilename, self._xfer_timeout, self._device.multimedia_path) else: self._error.Code =Global.FAILURE self._error.Msg = "%s is not a known xfer direction" % self._direction self._logger.info(self._error.Msg) queue.put(self._error.Code) except Exception as inst: self._error.Code = Global.FAILURE queue.put(self._error.Code) self._logger.info(inst) raise AcsConfigException(AcsConfigException.OPERATION_FAILED, "Exception : %s" % inst) finally: #lock is released lock.release() self.awake = True #giving the return value into queue queue.put(Global.SUCCESS) #--------------------------------------------------------------------------------------------- def _sendsms(self,queue): lock = threading.Lock() lock.acquire() try: result_verdict=Global.FAILURE self._logger.info("inside the lock of msg") #thread no self._logger.info(current_thread()) #to delete all sms self._sms_api.delete_all_sms() self._sms_api2.delete_all_sms() time.sleep(5) sms_sent = SmsMessage(self._message, self._destination_number) # register on intent to receive incoming sms self._sms_api.register_for_sms_reception() # Send SMS to equipment using SMS parameters : # - SMS_TEXT # - DESTINATION_NUMBER self._sms_api2.send_sms(self._destination_number,self._message) # Get received sms sms_received = self._sms_api.wait_for_incoming_sms(self._sms_transfer_timeout) # Compare sent and received SMS (Text, # Destination number) self._logger.info(sms_received) (result_verdict, result_message) = \ compute_sms_equals_dual_phone(sms_sent, sms_received) self._logger.info(result_message) queue.put(result_verdict) except Exception as inst: self._logger.info(inst) raise AcsConfigException(AcsConfigException.OPERATION_FAILED, "Exception: %s" % inst) finally: #release of the lock lock.release() print(self.awake) if self.awake==True: result_verdict=Global.FAILURE #giving the return value into queue queue.put(result_verdict) #-------------------------------------------------------------------------------------------------- def _setDefaultSim(self): self._device.run_cmd("adb shell input keyevent 82",self._test_timeout, force_execution=True) time.sleep(8) #To pop up the dialog box for selecting the sim statusintent=self._voicecall_api.get_sim_select(dialog=3,sim=0) self._logger.info(statusintent) #To check dailog is reached or not if statusintent == {}: err_msg=" The option dialog is not reached" raise DeviceException(DeviceException.OPERATION_SET_ERROR, err_msg) return Global.FAILURE,err_msg #Waiting for the dailog box if self.d(resourceId='android:id/title_template').wait.exists( timeout=5000): #clicking the default sim self.d(resourceId='android:id/button1').click() self._logger.info("Default sim is selected") return Global.SUCCESS,"Default sim is selected" else: err_msg="Dialog is not opening" raise DeviceException(DeviceException.OPERATION_SET_ERROR, err_msg) return Global.FAILURE,err_msg #------------------------------------------------------------------------------------------------- def _setDefaultSecondSim(self): self._device.run_cmd("adb shell input keyevent 82",self._test_timeout, force_execution=True) time.sleep(8) #To pop up the dialog box for selecting the sim statusintent=self._voicecall_api.get_sim_select(dialog=3,sim=1) self._logger.info(statusintent) #To check dailog is reached or not if statusintent == {}: err_msg=" The option dialog is not reached" raise DeviceException(DeviceException.OPERATION_SET_ERROR, err_msg) return Global.FAILURE,err_msg #Waiting for the dailog box if self.d(resourceId='android:id/title_template').wait.exists( timeout=5000): #clicking the default sim self.d(resourceId='android:id/button1').click() self._logger.info("Default sim is selected") return Global.SUCCESS,"Default sim is selected" else: err_msg="Dialog is not opening" raise DeviceException(DeviceException.OPERATION_SET_ERROR, err_msg) return Global.FAILURE,err_msg #------------------------------------------------------------------------------------------------- def _delete_file_if_exists(self, file_path, fail_on_error=True): """ Deletes the given file on DUT if it exists. :type file_path: str :param file_path: the absolute path of the file to delete. :type fail_on_error: bool :param fail_on_error: [optional] a boolean indicating whether we want to raise an exception on error or not. Defaults to C{True}. """ # Force file path to a str value file_path = str(file_path) rm_cmd = "adb shell rm %s" % file_path # We go on only if the file exists on the DUT if not self._phone_system_api.check_file_exist_from_shell(file_path): self._logger.debug("No such file to delete.") return # We try to delete the file try: # Run the command to remove the file, we give it 10 seconds to run self._logger.debug("Deleting file %s." % file_path) (exit_status, _output) = internal_shell_exec(rm_cmd, 10) except (KeyboardInterrupt, SystemExit): raise # We want to trap any kind of error/exception so # we use an empty exception clause and disable the # corresponding Pylint warning. # pylint: disable=W0702 except: exit_status = Global.FAILURE traceback.print_exc() # Check the status of the command execution if exit_status != Global.SUCCESS: # Build an error message error_message = "Command execution failed (command: '%s')." % rm_cmd # Handle the error case as expected if fail_on_error: # If we have to fail, raise an exception raise DeviceException(DeviceException.OPERATION_FAILED, error_message) else: # Otherwise simply log a warning self._logger.warning(error_message) # We double-check that the file has been deleted if self._phone_system_api.check_file_exist_from_shell(file_path): # Build an error message error_message = "File deletion failed (file: '%s')." % file_path # Handle the error case as expected if fail_on_error: # If we have to fail, raise an exception raise DeviceException(DeviceException.OPERATION_FAILED, error_message) else: # Otherwise simply log a warning self._logger.warning(error_message) else: self._logger.info("File %s deleted successfully." % file_path)
class LiveLteImsVcDualBase(LiveLteImsReg): """ This test case requires a Com4Innov cell to work. Because of this constraint some values that should have been given as parameters are actually hard-coded. That is to be changed if this test ever has to be executed in a different environment. """ def __init__(self, tc_name, global_config): """ Initializes this instance. """ # Call inherited initializer LiveLteImsReg.__init__(self, tc_name, global_config) # Read the call direction parameter self._call_direction = str( self._tc_parameters.get_param_value("CALL_DIRECTION", "MO")) # Read the call release parameter self._call_release_direction = str( self._tc_parameters.get_param_value("CALL_RELEASE", "MR")) # Read the call type parameter self._call_type = self._tc_parameters.get_param_value("CALL_TYPE", "") # Retrieve call duration parameter self._callduration = \ int(self._tc_parameters.get_param_value("CALL_DURATION", 15)) # Read the parameter for call on hold/resume procedure self._check_on_hold_resume_procedure = str_to_bool( self._tc_parameters.get_param_value("CHECK_CALL_ON_HOLD_RESUME", "False")) # Read the call option parameter for remote party self._remote_party_action = \ self._tc_parameters.get_param_value("REMOTE_PARTY_ACTION", "") # Initialize some attributes to store various phone numbers self._phone_no_main_dut = None self._phone_no_secondary_dut = None # Read the phone number parameter from TC's XML self._phone_number = self._tc_parameters.get_param_value( "PHONE_NUMBER") # If Phone number is not specified in TC XML, try to retrieve it from bench config if self._phone_number is None: # Retrieve the numbers for each phone used, from bench config file self._phone_no_main_dut = \ self._retrive_parameter_bench_config(global_config, "PhoneNumberDut1") self._phone_no_secondary_dut = \ self._retrive_parameter_bench_config(global_config, "PhoneNumberDut2") if self._ims_reg_operation == "CHECK_ONLY": self._perform_ims_registration = False else: self._perform_ims_registration = True # Read the ftp transfer parameter self._ftp_transfer = str_to_bool( self._tc_parameters.get_param_value("FTP_TRANSFER", "False")) if self._ftp_transfer is True: # Retrieve the parameters needed for FTP data transfer self._retrieve_ftp_parameters(global_config) # Instantiate the FTP UE commands for main device self._ftp_api = self._device.get_uecmd("Ftp") else: # Initialize the FTP parameters self._ftp_api = None self._server = None self._server_ip_v4_address = None self._server_ip_v6_address = None self._username = None self._password = None self._ftp_path = None self._ftp_direction = None self._ftp_filename = None self._dl_ftp_filename = None self._ftp_ip_version = None self._ip_address = None self._xfer_timeout = None # Read callSetupTimeout from Phone_Catalog.xml self._call_setup_time = \ int(self._dut_config.get("callSetupTimeout")) # Instantiate UE categories for first device self._voice_call_api = self._device.get_uecmd("VoiceCall") self._networking_api = self._device.get_uecmd("Networking") self._file_system_api = self._device.get_uecmd("File") self._phone_system_api = self._device.get_uecmd("PhoneSystem") # Load instance of the PHONE2 self._remote_phone = DeviceManager().get_device("PHONE2") self._remote_dut_config = DeviceManager().get_device_config("PHONE2") # Instantiate UE categories for second device if self._remote_phone is not None: self._voice_call_api2 = self._remote_phone.get_uecmd("VoiceCall") self._networking_api2 = self._remote_phone.get_uecmd("Networking") self._phone_system_api2 = self._remote_phone.get_uecmd( "PhoneSystem") else: self._voice_call_api2 = None self._networking_api2 = None self._phone_system_api2 = None #------------------------------------------------------------------------------ def set_up(self): """ Initializes the test. """ # Call the inherited set_up method # Ugly temporary solution before implementing something # better using test steps. if self._perform_ims_registration: # Call inherited setup method self._logger.info("Performing IMS registration step as requested.") LiveLteImsReg.set_up(self) else: # Call the base setup method in order to be # compliant with ACS framework self._logger.info( "Skipping IMS registration step (assumed to be done).") UseCaseBase.set_up(self) if self._perform_ims_registration is None: # But raise an exception message = "Invalid parameter value for IMS_REGISTRATION_OPERATION" raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, message) # Simply perform a IMS registration check self._networking_api.check_ims_registration_before_timeout(10) # Check the call duration parameter if not self._callduration: message = "%s '%s' %s '%s'" % ( "Invalid parameter value (or missing parameter)", str(self._callduration), "for parameter", "CALL_DURATION") raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, message) # We arbitrarily set a minimum allowed value for call duration if self._callduration < 15: message = "%s '%s' %s '%s'. %s." % ( "Invalid parameter value ", str( self._callduration), "for parameter", "CALL_DURATION", "The value should be set to 15 at the minimum") raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, message) # Check the call type parameter if self._call_type not in ("IR92", "IR94_AUDIO", "IR94_RX", "IR94_TX", "IR94_BIDIRECTIONAL"): message = "%s '%s' %s '%s'" % ( "Invalid parameter value (or missing parameter)", str(self._call_type), "for parameter", "CALL_TYPE") raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, message) # Check the call type parameter if self._call_direction not in ("MO", "MT"): message = "%s '%s' %s '%s'" % ( "Invalid parameter value (or missing parameter)", str(self._call_direction), "for parameter", "CALL_DIRECTION") raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, message) # Check the call type parameter if self._call_release_direction not in ("MR", "NR"): message = "%s '%s' %s '%s'" % ("Invalid parameter value", str(self._call_release_direction), "for parameter", "CALL_RELEASE") raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, message) # Check if we have the second phone available if self._remote_phone is None: # We are using this multi UC with only one phone message = \ "This use case requires two phones to be executed !" self._logger.error(message) raise AcsConfigException(AcsConfigException.INVALID_BENCH_CONFIG, message) # Boot the other phone (the DUT is already booted) if not self._remote_phone.is_available(): DeviceManager().boot_device("PHONE2") # Disable Flight Mode for the secondary DUT (robustness) self._networking_api2.set_flight_mode("off") # Set up is done correctly return (Global.SUCCESS, "No errors") #------------------------------------------------------------------------------ def run_test(self): """ Runs the test. """ # Call inherited run_test method which will ensure IMS registration # Ugly temporary solution before implementing something # better using test steps. if self._perform_ims_registration: LiveLteImsReg.run_test(self) else: UseCaseBase.run_test(self) # Check registration for secondary DUT self._check_registration_second_dut() # Release any previous call (Robustness) self._logger.info("Releasing any ongoing calls") self._voice_call_api.release() self._voice_call_api2.release() # Return the test result return (Global.SUCCESS, "No error.") #------------------------------------------------------------------------------ def tear_down(self): """ Disposes this test. """ # Call the inherited tear_down method # Ugly temporary solution before implementing something # better using test steps. if self._perform_ims_registration: LiveLteImsReg.tear_down(self) else: UseCaseBase.tear_down(self) # End of tear_down return (Global.SUCCESS, "No errors") def _retrieve_ftp_parameters(self, global_config): """ Read and set the FTP parameters from bench config and TC's .XML files. """ # Get FTP server parameters from bench config file self._server = \ global_config.benchConfig.get_parameters("LAB_LTE_IMS_SERVER") self._server_ip_v4_address = self._server.get_param_value("IP4") self._server_ip_v6_address = self._server.get_param_value("IP6") self._username = self._server.get_param_value("username") self._password = self._server.get_param_value("password") if self._server.has_parameter("ftp_path"): self._ftp_path = self._server.get_param_value("ftp_path") else: self._ftp_path = "" # Read the the direction parameter name from TC's xml file self._ftp_direction = self._tc_parameters.get_param_value( "FTP_DIRECTION") # Read the ftp file name from TC's xml if self._ftp_direction == "DL": self._ftp_filename = os.path.join( self._ftp_path, self._tc_parameters.get_param_value("DL_FILENAME", "")) self._ftp_filename = self._ftp_filename.replace('\\', '/') self._dl_ftp_filename = None elif self._ftp_direction == "UL": # Read the UL_FILENAME value from TC's xml self._ftp_filename = os.path.join( self._ftp_path, self._tc_parameters.get_param_value("UL_FILENAME", "")) self._ftp_filename = self._ftp_filename.replace('\\', '/') self._dl_ftp_filename = None elif self._ftp_direction == "BOTH": self._dl_ftp_filename = os.path.join( self._ftp_path, self._tc_parameters.get_param_value("DL_FILENAME", "")) self._dl_ftp_filename = self._dl_ftp_filename.replace('\\', '/') # Read the UL_FILE value from TC's xml self._ftp_filename = os.path.join( self._ftp_path, self._tc_parameters.get_param_value("UL_FILENAME", "")) self._ftp_filename = self._ftp_filename.replace('\\', '/') # Read the the ip_version from TC's xml self._ftp_ip_version = self._tc_parameters.get_param_value( "FTP_IP_VERSION", "IPV4") # Selecting the IPV6 address of the FTP server, according to # the TC parameter value. if self._ftp_ip_version == "IPV6": if self._server_ip_v6_address is not None: # If Protocol is IPV6 use IPV6 address. log_msg = "Using IPV6 address to connect to the FTP server." self._logger.info(log_msg) self._ip_address = self._server_ip_v6_address else: # If IPV6 address is not present in the BenchConfig. msg = "The IPV6 parameter is missing from the Bench Config!" raise AcsConfigException( AcsConfigException.INVALID_BENCH_CONFIG, msg) else: self._ip_address = self._server_ip_v4_address # Read the XFER_TIMEOUT from UseCase xml Parameter self._xfer_timeout = self._tc_parameters.get_param_value( "XFER_TIMEOUT") if self._xfer_timeout is not None and str( self._xfer_timeout).isdigit(): self._xfer_timeout = int(self._xfer_timeout) else: self._xfer_timeout = None def _check_ftp_parameters(self): """ Check the parameters related with FTP data transfer :raise AcsConfigException: in case any parameter is incorrect """ # Check the call type parameter if self._ftp_direction not in ("DL", "UL", "BOTH"): message = "%s '%s' %s '%s'" % ( "Invalid parameter value (or missing parameter)", str(self._ftp_direction), "for parameter", "FTP_DIRECTION") raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, message) if self._xfer_timeout is None: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "XFER_TIMEOUT should be int") def _check_registration_second_dut(self): """ Check if secondary DUT is registered or not to NW :raise DeviceException: in case 2nd DUT not registered """ in_service_status = ImsRegistrationStatus.in_service() reg_status = ImsRegistrationStatus( self._networking_api2.get_ims_registration_status()) # If not registered if reg_status != in_service_status: self._logger.warning( "The secondary DUT is NOT registered! Airplane on/off will be performed!" ) self._networking_api2.set_flight_mode("on") # Wait 10 seconds time.sleep(10) self._networking_api2.set_flight_mode("off") # Wait 10 seconds time.sleep(10) try: self._networking_api2.check_ims_registration_before_timeout(60) except DeviceException: message = "Secondary DUT still not registered after airplane on/off !" raise DeviceException(DeviceException.TIMEOUT_REACHED, message)
class LabAudioAPxCalibrationVOIP(UseCaseBase): """ AudioComms calibration APx class. """ def __init__(self, tc_name, global_config): """ Constructor """ # Call UseCaseBase Init function UseCaseBase.__init__(self, tc_name, global_config) # Create APx self._audio_analyzer = self._em.get_audio_analyzer("AudioAnalyzer") # Check if IO card is used self._use_io_card = str_to_bool( global_config.campaignConfig.get("isIoCardUsed")) # Create Whs if self._use_io_card: self._wired_headset = self._em.get_wired_headset("WiredHeadset") # Initialization of the test type self._test_type = "calibration" # Initialization of test result in uplink self._result_verdict_ul = Global.FAILURE # Initialization of test result in downlink self._result_verdict_dl = Global.FAILURE # Initialization of test result self._result_verdict_final = Global.FAILURE # Call Stream Volume self._call_stream_volume = 70 # Initialization of the verdict comment self._verdict_comment = "APx Calibration fail" # Read registrationTimeout from Device_Catalog.xml self._registration_timeout = \ int(self._dut_config.get("registrationTimeout")) # Read callSetupTimeout from Device_Catalog.xml self._call_setup_time = \ int(self._dut_config.get("callSetupTimeout")) # Read accessories type from test case xml file (str) self._acc_type = str(self._tc_parameters.get_param_value("ACC_TYPE")) # Call Stream Volume in percent self._call_stream_volume_dut = \ int(self._tc_parameters.get_param_value("CALL_VOLUME_DUT")) # Call Stream Volume in percent self._call_stream_volume_ref = \ int(self._tc_parameters.get_param_value("CALL_VOLUME_REF")) # Read Audio Analyzer parameters from bench config xml file (str) self._audio_analyser = global_config.benchConfig.\ get_parameters("AudioAnalyzer") self._bt_remote_addr = self._audio_analyser.get_param_value( "Bt_mac_addr") # Read dut sip address from test case xml file (str) self._dut_sip_address = \ str(self._tc_parameters.get_param_value("DUT_SIP_ADDRESS")) # Read ref phone sip address from test case xml file (str) self._peer_sip_address = \ str(self._tc_parameters.get_param_value("PEER_SIP_ADDRESS")) # Instantiate generic UECmd for voiceCall Ucs self._networking_api = self._device.get_uecmd("Networking") self._sip_call_api = self._device.get_uecmd("SipCall") self._phonesystem_api = self._device.get_uecmd("PhoneSystem") self._system_api = self._device.get_uecmd("System") if self._acc_type.find("BLUETOOTH") != -1: # Get UECmdLayer self._bt_api = self._device.get_uecmd("LocalConnectivity") # Get dut bt address self._dut_bt_address = self._bt_api.get_bt_adapter_address() else: self._dut_bt_address = "None" # Load instance of the PHONE2 self._phone2 = DeviceManager().get_device("PHONE2") if self._phone2 is not None: if not self._phone2.is_available(): self._phone2.switch_on(simple_switch_mode=True) self._voice_call_api2 = self._phone2.get_uecmd("VoiceCall") self._system_api2 = self._phone2.get_uecmd("System") # Instantiate the instances of member class variables self._sip_call_api2 = None self._networking_api2 = None self._phone_calling = None self._phone_receiving = None self._phone_releasing = None self._calling_phone_number = None def set_up(self): """ Set up the test configuration """ # Call UseCaseBase Setup function UseCaseBase.set_up(self) if self._phone2 is not None: self._networking_api2 = self._phone2.get_uecmd("Networking") self._sip_call_api2 = self._phone2.get_uecmd("SipCall") else: error_msg = \ "This test case requires two phones to be executed !" self._logger.error(error_msg) raise AcsConfigException(AcsConfigException.INVALID_BENCH_CONFIG, error_msg) # APx Initialization if self._audio_analyzer.initialization(self._device.get_phone_model(), self._test_type) != 0: error_msg = \ "APX Initialization Failed !" self._logger.error(error_msg) raise TestEquipmentException( TestEquipmentException.OPERATION_FAILED, error_msg) # Setup phone type ( calling, receiving, releasing phone) self._phone_calling = self._sip_call_api self._phone_receiving = self._sip_call_api2 self._calling_phone_number = self._peer_sip_address self._phone_releasing = self._sip_call_api2 # Start Sip Service self._phone_calling.initialize_sipcall_module() self._phone_receiving.initialize_sipcall_module() # Setup Sip Account self._sip_call_api.initialize_local_profile(self._dut_sip_address) self._sip_call_api2.initialize_local_profile(self._peer_sip_address) return Global.SUCCESS, "No errors" def run_test(self): """ Execute the test """ # Call UseCaseBase run_test function UseCaseBase.run_test(self) self._phone_calling.wait_for_state( self._uecmd_types.SIP_CALL_STATE.READY_TO_CALL, self._call_setup_time) self._phone_receiving.wait_for_state( self._uecmd_types.SIP_CALL_STATE.READY_TO_CALL, self._call_setup_time) # Dial using PHONE_NUMBER parameter self._phone_calling.dial(self._calling_phone_number) self._phone_receiving.wait_for_state( self._uecmd_types.SIP_CALL_STATE.INCOMING_CALL, self._call_setup_time) self._phone_receiving.answer() # Phone1 & 2 : Check voice call is active self._phone_calling.wait_for_state( self._uecmd_types.SIP_CALL_STATE.IN_CALL, self._call_setup_time) self._phone_receiving.wait_for_state( self._uecmd_types.SIP_CALL_STATE.IN_CALL, self._call_setup_time) # Configure Audio output to acc_type given with the test_case except in Bluetooth test case if self._acc_type.find("BLUETOOTH") != -1: if self._audio_analyzer.connect_bt(self._acc_type, self._dut_bt_address) != 0: error_msg = \ "Connect Bluetooth failed !" self._logger.error(error_msg) raise DeviceException(DeviceException.OPERATION_FAILED, error_msg) # Configure Audio output to acc_type given with the test_case if self._acc_type == "EARPIECE": self._sip_call_api.switch_to_earpiece() if self._use_io_card: self._wired_headset.unplug_whs() self._wired_headset.unplug_headphone() time.sleep(self._wait_btwn_cmd) elif self._acc_type == "HEADSET": self._sip_call_api.switch_to_earpiece() if self._use_io_card: self._wired_headset.unplug_headphone() self._wired_headset.plug_whs() time.sleep(self._wait_btwn_cmd) elif self._acc_type == "HEADPHONE": self._sip_call_api.switch_to_earpiece() if self._use_io_card: self._wired_headset.unplug_whs() self._wired_headset.plug_headphone() time.sleep(self._wait_btwn_cmd) elif self._acc_type == "SPEAKER": self._sip_call_api.switch_to_speaker() time.sleep(self._wait_btwn_cmd) elif self._acc_type == "BLUETOOTHHSP" or self._acc_type == "BLUETOOTHHFP": self._sip_call_api.switch_to_bluetooth() elif self._acc_type == "BLUETOOTHA2DP": self._sip_call_api.switch_to_bluetooth() else: self._logger.error("Unknown accessories") raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "Unknown accessories") time.sleep(self._wait_btwn_cmd) if self._acc_type.find("BLUETOOTH") == -1: # Set Voice Call Volume self._system_api.adjust_specified_stream_volume( "VoiceCall", self._call_stream_volume_dut) else: # Set Voice Call Volume self._system_api.adjust_specified_stream_volume( "Bluetooth", self._call_stream_volume_dut) self._system_api2.adjust_specified_stream_volume( "VoiceCall", self._call_stream_volume_ref) # Launch Apx Calibration test on Uplink apx_result = self._audio_analyzer.calibration( self._device.get_phone_model(), "VOIP", self._acc_type, "UL", self._dut_bt_address) if apx_result == 0: self._result_verdict_ul = Global.SUCCESS self._verdict_comment = "APx Calibration success in UL" else: self._result_verdict_ul = Global.FAILURE self._verdict_comment = "APx Calibration fail in UL" # Launch Apx Calibration test on Downlink apx_result = self._audio_analyzer.calibration( self._device.get_phone_model(), "VOIP", self._acc_type, "DL", self._dut_bt_address) if apx_result == 0: self._result_verdict_dl = Global.SUCCESS self._verdict_comment += " and APx Calibration success in DL" else: self._result_verdict_dl = Global.FAILURE self._verdict_comment += " and APx Calibration fail in DL" # Compute final verdict if self._result_verdict_ul == Global.FAILURE or \ self._result_verdict_dl == Global.FAILURE: self._result_verdict_final = Global.FAILURE else: self._result_verdict_final = Global.SUCCESS # RELEASE THE CALL # Phone1 & 2 : Check call is still active self._phone_calling.wait_for_state( self._uecmd_types.SIP_CALL_STATE.IN_CALL, self._call_setup_time) self._phone_receiving.wait_for_state( self._uecmd_types.SIP_CALL_STATE.IN_CALL, self._call_setup_time) self._phone_releasing.release() self._phone_releasing.wait_for_state( self._uecmd_types.SIP_CALL_STATE.READY_TO_CALL, self._call_setup_time) self._phone_receiving.wait_for_state( self._uecmd_types.SIP_CALL_STATE.READY_TO_CALL, self._call_setup_time) return self._result_verdict_final, self._verdict_comment def tear_down(self): """ End and dispose the test """ # Call LabAudioQualityBase run_test function UseCaseBase.tear_down(self) if self._acc_type == "HEADSET": if self._use_io_card: self._wired_headset.unplug_whs() elif self._acc_type == "HEADPHONE": if self._use_io_card: self._wired_headset.unplug_headphone() # Stop Sip Service if self._sip_call_api is not None: self._sip_call_api.clean_sipcall_module() if self._sip_call_api2 is not None: self._sip_call_api2.clean_sipcall_module() return Global.SUCCESS, "No errors"
class LiveWifiTetheringBase(UseCaseBase): """ Live Wifi Tethering base Test class. """ _CHECK_CONNECTION_TIMEOUT = 20 def __init__(self, tc_name, global_config): """ Constructor """ UseCaseBase.__init__(self, tc_name, global_config) # Get FTP server parameters self._wifi_server = global_config.benchConfig.get_parameters( "WIFI_SERVER") self._ftp_ip_address = self._wifi_server.get_param_value("IP") self._ftp_username = self._wifi_server.get_param_value("username") self._ftp_password = self._wifi_server.get_param_value("password") if self._wifi_server.has_parameter("ftp_path"): self._ftp_path = self._wifi_server.get_param_value("ftp_path") else: self._ftp_path = "" # Get host spot configuration according HOTSPOT_SSID self._hotspot_ssid = \ str(self._tc_parameters.get_param_value("HOTSPOT_SSID")) # Get host spot configuration according HOTSPOT_SECURITY self._hotspot_security = \ str(self._tc_parameters.get_param_value("HOTSPOT_SECURITY")) # Get host spot configuration according HOTSPOT_PASSWORD self._hotspot_passphrase = \ str(self._tc_parameters.get_param_value("HOTSPOT_PASSWORD")) # Get host spot configuration according HOTSPOT_STANDARD self._hotspot_standard = \ self._tc_parameters.get_param_value("HOTSPOT_STANDARD") # Get flight mode configuration according FLIGHT_MODE self._flight_mode = \ str(self._tc_parameters.get_param_value("FLIGHT_MODE")) self._flight_mode = str_to_bool_ex(self._flight_mode) # Get Data connection mode self._is_pdp_context_activated = \ str(self._tc_parameters.get_param_value("IS_PDP_CONTEXT_ACTIVATED")) self._is_pdp_context_activated = str_to_bool_ex( self._is_pdp_context_activated) # Default is True if self._is_pdp_context_activated == None: self._is_pdp_context_activated = True # Get the optional DUT wrong passphrase to test connection failure self._wrong_passphrase = self._tc_parameters. \ get_param_value("WIFI_PASSPHRASE") # Get computer type self._computer = self._tc_parameters.get_param_value("COMPUTER") if self._computer == "": self._computer = None # empty computer: use second DUT # Get UECmdLayer self._networking_api = self._device.get_uecmd("Networking") # Load computer equipment if self._computer is not None: self._computer = self._em.get_computer(self._computer) self._wifi_interface = self._computer.get_wifi_interface() if self._wifi_interface == "": self._wifi_interface = None else: self._wifi_interface = None # Get PHONE2 self._phone2 = None self._networking_api2 = None if self._computer is None: self._phone2 = DeviceManager().get_device("PHONE2") if self._phone2 is not None: self._networking_api2 = self._phone2.get_uecmd("Networking") # init original wifi power status for phone1 self._original_wifi_power_status = 0 # init original flight mode for phone1 self._original_flight_mode = 0 self._interface_ip = None self._hotspot_ext_interface = \ str(self._dut_config.get("hotspotExtInterface")) # Set BT prerequisite (set ON, set OFF or nothing) for FIT BT/WIFI tests self._bt_fit_used, self._bt_wished_value = self._get_bt_fit_config() # BT initial state self._bt_initial_state = 'STATE_ON' # Instantiate generic UECmd self._localconnectivity_api = self._device.get_uecmd( "LocalConnectivity") # MAC Address of the STA device that will be connected to the softAP self._client_mac_address = "" #------------------------------------------------------------------------------ def set_up(self): """ Initialize the test """ # pylint: disable=E1101 # run setup inherit from UseCaseBase UseCaseBase.set_up(self) # Check if we have second wifi interface or second phone available if (self._computer is None or self._wifi_interface is None) \ and self._phone2 is None: msg = "Cannot run that use case without a remote PC or with only one phone configured." self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) # If Bt to be (de-)activated for FIT tests if self._bt_fit_used: self._bt_initial_state = self._localconnectivity_api.get_bt_power_status( ) # if Bt is not at the wished value, set it to the correct one. if self._bt_initial_state != self._bt_wished_value: self._localconnectivity_api.set_bt_power(self._bt_wished_value) time.sleep(self._wait_btwn_cmd) # store original wifi power status time.sleep(self._wait_btwn_cmd) self._original_wifi_power_status = \ self._networking_api.get_wifi_power_status() # store original flight mode time.sleep(self._wait_btwn_cmd) self._original_flight_mode = self._networking_api.get_flight_mode() # Enable/Disable flight mode time.sleep(self._wait_btwn_cmd) self._networking_api.set_flight_mode(self._flight_mode) # Enable Cellular Data connection if self._flight_mode == False and self._is_pdp_context_activated: time.sleep(self._wait_btwn_cmd) self._networking_api.activate_pdp_context() # disable wifi for Phone1 time.sleep(self._wait_btwn_cmd) self._networking_api.set_wifi_power("off") # enable Portable wifi hotspot for Phone1 time.sleep(self._wait_btwn_cmd) self._networking_api.set_wifi_hotspot("on", self._hotspot_ssid, self._hotspot_security, self._hotspot_passphrase) if self._wrong_passphrase in (None, "", "NONE", "None"): passphrase = self._hotspot_passphrase wrong_passphrase = False else: passphrase = self._wrong_passphrase wrong_passphrase = True if self._computer is not None: try: self._interface_ip = \ self._computer.wifi_connect(self._wifi_interface, self._hotspot_standard, self._hotspot_ssid, self._hotspot_security, passphrase) if wrong_passphrase: msg = "Connection successful with wrong passphrase." self._logger.error(msg) raise TestEquipmentException( TestEquipmentException.OPERATION_FAILED, msg) except TestEquipmentException as exc: # ignore the exception if the connection fails with a wrong passphrase if not wrong_passphrase: raise elif not "Could not get IP address" in str(exc) \ and not "Could not associate device" in str(exc): raise # Retrieve the MAC address of the COMPUTER time.sleep(self._wait_btwn_cmd) self._client_mac_address = self._computer.get_interface_mac_addr( self._wifi_interface) self._client_mac_address.lower() elif self._phone2 is not None: # Boot the other phone (the DUT is already booted) if not self._phone2.is_available(): DeviceManager().boot_device("PHONE2") # set wifi power on for Phone2 time.sleep(self._wait_btwn_cmd) self._networking_api2.set_wifi_power("on") # set auto connect state off for Phone2 time.sleep(self._wait_btwn_cmd) self._networking_api2.\ set_autoconnect_mode("all", self._uecmd_types.AUTO_CONNECT_STATE.off) # disconnect all wifi for Phone2 time.sleep(self._wait_btwn_cmd) self._networking_api2.wifi_disconnect_all() # set passphrase for Phone2 self._networking_api2.set_wificonfiguration( self._hotspot_ssid, passphrase, self._hotspot_security) # connect hotspot from Phone1 for Phone2 time.sleep(self._wait_btwn_cmd) try: self._networking_api2.wifi_connect(self._hotspot_ssid) if wrong_passphrase: msg = "Connection successful with wrong passphrase." self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) except AcsBaseException as exc: # ignore the exception if the connection fails with a wrong passphrase if not wrong_passphrase: raise elif not "timeout" in str(exc): raise # Retrieve the MAC address of the PHONE2 time.sleep(self._wait_btwn_cmd) self._client_mac_address = self._networking_api2.get_interface_mac_addr( ).lower() else: msg = "Cannot run that use case without a remote PC or with only one phone configured." self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) return Global.SUCCESS, "No error" #------------------------------------------------------------------------------ def tear_down(self): """ End and dispose the test """ UseCaseBase.tear_down(self) status = Global.SUCCESS msg = "No error" if self._computer is not None: self._computer.wifi_disconnect(self._wifi_interface) elif self._phone2 is not None: # disconnect from hotspot for Phone2 time.sleep(self._wait_btwn_cmd) self._networking_api2.\ wifi_disconnect(self._hotspot_ssid) time.sleep(self._wait_btwn_cmd) self._networking_api2.wifi_remove_config(self._hotspot_ssid) # set wifi power off for phone2 time.sleep(self._wait_btwn_cmd) self._networking_api2.set_wifi_power("off") # disable Portable wifi hotspot for Phone1 time.sleep(self._wait_btwn_cmd) self._networking_api.set_wifi_hotspot("off") # restore original flight mode if str_to_bool_ex(self._original_flight_mode) != str_to_bool_ex( self._flight_mode): time.sleep(self._wait_btwn_cmd) self._networking_api.set_flight_mode(self._original_flight_mode) # restore original wifi power status time.sleep(self._wait_btwn_cmd) self._networking_api.set_wifi_power(self._original_wifi_power_status) # If Bt to be (de-)activated for FIT tests if self._bt_fit_used: bt_final_status = self._localconnectivity_api.get_bt_power_status() # if Bt is not at the initial value, set it to the correct one. if bt_final_status != self._bt_initial_state: # restore Bt in initial state self._localconnectivity_api.set_bt_power( self._bt_initial_state) time.sleep(self._wait_btwn_cmd) return status, msg #------------------------------------------------------------------------------ def _get_bt_fit_config(self): """ Get BT configuration for FIT BT/WIFI tests :rtype: list of 2 elements (boolean, str) :return: true if BT/WIFI FIT is used, Bluetooth state ON or OFF for the test to be run """ # Read WHILE_BLUETOOTH_ON parameter (named for retro-compatibility) # from test case xml file for FIT tests param_while_bt_on = \ str(self._tc_parameters.get_param_value("WHILE_BLUETOOTH_ON")) if param_while_bt_on.lower() in ["1", "on", "true", "yes"]: bt_fit_used = True bt_wished_value = 'STATE_ON' elif param_while_bt_on.lower() in ["0", "off", "false", "no"]: bt_fit_used = True bt_wished_value = 'STATE_OFF' else: bt_fit_used = False bt_wished_value = 'STATE_OFF' return bt_fit_used, bt_wished_value
class LiveDualPhoneVcBase(UseCaseBase): """ Live Voice Call base class. """ def __init__(self, tc_name, global_config): """ Constructor """ # Call init of use case base UseCaseBase.__init__(self, tc_name, global_config) # Get Test Cases Parameters self._callduration = \ int(self._tc_parameters.get_param_value("CALL_DURATION")) # Read callSetupTimeout from Phone_Catalog.xml self._call_setup_time = \ int(self._dut_config.get("callSetupTimeout")) # Get UECmdLayer self._voice_call_api = self._device.get_uecmd("VoiceCall") self._networking_api = self._device.get_uecmd("Networking") # Load instance of the PHONE2 self._phone2 = DeviceManager().get_device("PHONE2") if self._phone2 is not None: self._voice_call_api2 = self._phone2.get_uecmd("VoiceCall") self._networking_api2 = self._phone2.get_uecmd("Networking") else: self._voice_call_api2 = None self._networking_api2 = None # Instantiate the instances for phone caller, receiver and releaser self._caller_phone = None self._receiver_phone = None self._releaser_phone = None #------------------------------------------------------------------------------ def set_up(self): """ Initialize the test """ # Call set_up of use case base UseCaseBase.set_up(self) # Check if we have the second phone available if self._phone2 is None: # We are using this multi UC with only one phone error_msg = \ "This use case requires two phones to be executed !" self._logger.error(error_msg) raise AcsConfigException(AcsConfigException.INVALID_BENCH_CONFIG, error_msg) # Boot the other phone (the DUT is already booted) if not self._phone2.is_available(): DeviceManager().boot_device("PHONE2") # Disable flight mode self._networking_api.set_flight_mode("off") self._networking_api2.set_flight_mode("off") return Global.SUCCESS, "No errors" #------------------------------------------------------------------------------ def run_test(self): """ Execute the test """ # pylint: disable-msg=E1101 # This to avoid pylint warnings due to enum class VOICE_CALL_STATE # Call init of use case base UseCaseBase.run_test(self) # Release any previous call (Robustness) time.sleep(self._wait_btwn_cmd) self._voice_call_api.release() self._voice_call_api2.release() # ESTABLISH THE CALL # Phone1 : Dial time.sleep(self._wait_btwn_cmd) self._caller_phone.dial(self._phone_number, False) # Phone2 : Wait for state incoming before callSetupTimeout seconds self._receiver_phone.wait_for_state( self._uecmd_types.VOICE_CALL_STATE.INCOMING, self._call_setup_time) # Phone2 : Answer call self._receiver_phone.answer() # Phone1 & 2 : Check voice call is active self._voice_call_api.wait_for_state( self._uecmd_types.VOICE_CALL_STATE.ACTIVE, self._call_setup_time) self._voice_call_api2.wait_for_state( self._uecmd_types.VOICE_CALL_STATE.ACTIVE, self._call_setup_time) # WAIT FOR CALL DURATION self._logger.info("Wait for call duration: " + str(self._callduration) + "s...") time.sleep(self._callduration) # RELEASE THE CALL # Phone1 & 2 : Check call is still active self._voice_call_api.check_state( self._uecmd_types.VOICE_CALL_STATE.ACTIVE) self._voice_call_api2.check_state( self._uecmd_types.VOICE_CALL_STATE.ACTIVE) # Phone1 : Release the call time.sleep(self._wait_btwn_cmd) self._releaser_phone.release() # Phone1 & 2 : Check call is idle self._voice_call_api.wait_for_state( self._uecmd_types.VOICE_CALL_STATE.NOCALL, self._call_setup_time) self._voice_call_api2.wait_for_state( self._uecmd_types.VOICE_CALL_STATE.NOCALL, self._call_setup_time) # pylint: enable=E1101 return Global.SUCCESS, "No errors"
class LiveDualPhoneBTBase(LiveBTBase): """ Live BT Test base class. """ # Constants STR_PHONE_2 = "PHONE2" def __init__(self, tc_name, global_config): """ Constructor """ LiveBTBase.__init__(self, tc_name, global_config) # Get PHONE2 self._phone2 = DeviceManager().get_device(self.STR_PHONE_2) # Check if we have the second phone available if self._phone2 is not None: if not self._phone2.is_available(): DeviceManager().boot_device(self.STR_PHONE_2) self._bt_api2 = self._phone2.get_uecmd("LocalConnectivity") # Get PHONE2 networking interface self._networking_api2 = self._phone2.get_uecmd("Networking") # Get BT device parameters self._dut2_config = DeviceManager().get_device_config(self.STR_PHONE_2) self._phone_system_api = self._device.get_uecmd("PhoneSystem") # Initialize phones address self._phone1_addr = "" self._phone2_addr = "" self._original_flight_mode2 = 0 #------------------------------------------------------------------------------ def set_up(self): """ Initialize the test """ LiveBTBase.set_up(self) if self._phone2 is None: msg = "PHONE2 is not specified in the bench configuration" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_BENCH_CONFIG, msg) # Get original phone mode self._original_flight_mode2 = self._networking_api2.get_flight_mode() # Flight mode if self._use_flightmode != self._original_flight_mode2: self._networking_api2.set_flight_mode(self._use_flightmode) self._logger.info("Reset phone Bluetooth adapter") self._bt_api2.bt_reset_device() # Get phones address self._phone1_addr = self._bt_api.get_bt_adapter_address() self._phone2_addr = self._bt_api2.get_bt_adapter_address() return Global.SUCCESS, "No errors" #------------------------------------------------------------------------------ def tear_down(self): """ End and dispose the test """ LiveBTBase.tear_down(self) time.sleep(self._wait_btwn_cmd) # Recover to initial flight mode self._logger.info("Set PHONE2 to original flight mode") self._networking_api2.set_flight_mode(self._original_flight_mode2) time.sleep(self._wait_btwn_cmd) self._logger.info("Close phone 2 adapter devices") self._bt_api2.set_bt_power("off") time.sleep(self._wait_btwn_cmd) return Global.SUCCESS, "No errors" def _establish_bt_pairing(self, pairing_initiator): """ Establish bluetooth pairing procedure :type pairing_initiator: String :param pairing_initiator: PHONE1 or PHONE2 the device that requests for pairing first """ # Defines BT pairing roles if pairing_initiator == "PHONE2": paired_api = self._bt_api paired_addr = self._phone1_addr requester_api = self._bt_api2 requester_addr = self._phone2_addr else: paired_api = self._bt_api2 paired_addr = self._phone2_addr requester_api = self._bt_api requester_addr = self._phone1_addr establish_bt_pairing(requester_api, requester_addr, paired_api, paired_addr, self._wait_btwn_cmd)
class LiveDualPhoneSms(UseCaseBase): """ Live Dual Phone SMS test. """ def __init__(self, tc_name, global_config): """ Constructor """ UseCaseBase.__init__(self, tc_name, global_config) # Get TC Parameters self._service_center_addr = \ self._tc_parameters.get_param_value("SERVICE_CENTER_ADDRESS") self._destination = \ str(self._tc_parameters.get_param_value("DESTINATION_NUMBER")) self._message = self._tc_parameters.get_param_value("MESSAGE_CONTENT") self._data_coding_sheme = \ self._tc_parameters.get_param_value("DATA_CODING_SCHEME") self._sms_transfer_timeout = \ int(self._tc_parameters.get_param_value("SMS_TRANSFER_TIMEOUT")) dcs = DataCodingScheme(self._data_coding_sheme) dcs.decode() # Get number of bits per character setted in DCS self._nb_bits_per_char = dcs.compute_character_size() character_set = dcs.get_character_set() if character_set == "7BITS": self._content_type = "CTEX" else: self._content_type = "CDAT" # Phone1 & 2 : Get ue command for Phone self._msg_api = self._device.get_uecmd("SmsMessaging") self._networking_api = self._device.get_uecmd("Networking") self._phone2 = DeviceManager().get_device("PHONE2") if self._phone2 is not None: self._msg_api2 = self._phone2.get_uecmd("SmsMessaging") self._networking_api2 = self._phone2.get_uecmd("Networking") if self._destination.upper() == "[PHONE_NUMBER]": self._destination = str(self._phone2.get_phone_number()) #------------------------------------------------------------------------------ def set_up(self): """ Initialize the test """ UseCaseBase.set_up(self) # Check if we have the second phone available if self._phone2 is None: # We are using this multi UC with only one phone return (Global.FAILURE, "Cannot run that use case with only one phone configured.") # Boot the other phone (the DUT is already booted) DeviceManager().boot_device("PHONE2") # Disable flight mode on Phone 1 & 2 self._networking_api.set_flight_mode("off") self._networking_api2.set_flight_mode("off") self._msg_api.set_service_center_address(self._service_center_addr) return Global.SUCCESS, "No errors" #----------------------------------------------------------------------------- def run_test(self): """ Execute the test """ UseCaseBase.run_test(self) # Clear old SMS (Non blocking for this test if function isn't # implemented on CDK) time.sleep(self._wait_btwn_cmd) self._logger.info("Clearing all sms...") self._msg_api2.delete_all_sms() # Calculate how many SMS will be sent to equipment time.sleep(self._wait_btwn_cmd) self._logger.info("Computing sms segments...") nb_segments = \ compute_sms_segments(self._message, self._nb_bits_per_char) # Phone2 : Wait for the sms # retrieve instance in order to get sent messages time.sleep(self._wait_btwn_cmd) # register on intent to receive incoming sms self._msg_api2.register_for_sms_reception() # Phone1: Check SMS delivery status OK before timeout using # SMS_TRANSFER_TIMEOUT value and number of SMS to be received # (Non blocking for this test if function isn't implemented on CDK) time.sleep(self._wait_btwn_cmd) self._logger.info("Sending sms from DUT...") self._msg_api.send_sms(self._destination, self._message) # Phone2: get sms received time.sleep(self._wait_btwn_cmd) self._logger.info("Assembling received sms...") sms_received = self._msg_api2.wait_for_incoming_sms( self._sms_transfer_timeout) if sms_received.message == self._message: result_code = Global.SUCCESS result_message = "Sms text received and sms text sent are equal" result_message += " (sent:{%s}, received:{%s})." % (str( self._message), str(sms_received.message)) self._logger.info(result_message) else: result_code = Global.FAILURE result_message = "Sms text received and sms text sent aren't equal" result_message += " (sent:{%s}, received:{%s})." % (str( self._message), str(sms_received.message)) self._logger.error(result_message) return result_code, result_message #------------------------------------------------------------------------------ def tear_down(self): """ End and dispose the test """ UseCaseBase.tear_down(self) # Phone2: Switch off the phone self._phone2.switch_off() return Global.SUCCESS, "No errors"
class LabAudioAPxCalibrationCSV(UseCaseBase): """ AudioComms calibration APx class. """ def __init__(self, tc_name, global_config): """ Constructor """ # Call UseCaseBase Init function UseCaseBase.__init__(self, tc_name, global_config) # Create APx self._audio_analyzer = self._em.get_audio_analyzer("AudioAnalyzer") # Check if IO card is used self._use_io_card = str_to_bool( global_config.campaignConfig.get("isIoCardUsed")) # Create Whs if self._use_io_card: self._wired_headset = self._em.get_wired_headset("WiredHeadset") # Initialization of the test type self._test_type = "calibration" # Initialization of test result in uplink self._result_verdict_ul = Global.FAILURE # Initialization of test result in downlink self._result_verdict_dl = Global.FAILURE # Initialization of test result self._result_verdict_final = Global.FAILURE # Call Stream Volume self._call_stream_volume = 70 # Initialization of the verdict comment self._verdict_comment = "APx Calibration fail" # Read registrationTimeout from Device_Catalog.xml self._registration_timeout = \ int(self._dut_config.get("registrationTimeout")) # Read callSetupTimeout from Device_Catalog.xml self._call_setup_time = \ int(self._dut_config.get("callSetupTimeout")) # Read accessories type from test case xml file (str) self._acc_type = str(self._tc_parameters.get_param_value("ACC_TYPE")) # Call Stream Volume in percent self._call_stream_volume_dut = \ int(self._tc_parameters.get_param_value("CALL_VOLUME_DUT")) # Call Stream Volume in percent self._call_stream_volume_ref = \ int(self._tc_parameters.get_param_value("CALL_VOLUME_REF")) # Read Audio Analyzer parameters from bench config xml file (str) self._audio_analyser = global_config.benchConfig.\ get_parameters("AudioAnalyzer") self._bt_remote_addr = self._audio_analyser.get_param_value( "Bt_mac_addr") # Instantiate generic UECmd for voiceCall Ucs self._voice_call_api = self._device.get_uecmd("VoiceCall") self._phonesystem_api = self._device.get_uecmd("PhoneSystem") self._phonemodem_api = self._device.get_uecmd("Modem") self._system_api = self._device.get_uecmd("System") if self._acc_type.find("BLUETOOTH") != -1: # Get UECmdLayer self._bt_api = self._device.get_uecmd("LocalConnectivity") # Get dut bt address self._dut_bt_address = self._bt_api.get_bt_adapter_address() else: self._dut_bt_address = "None" # Load instance of the PHONE2 self._phone2 = DeviceManager().get_device("PHONE2") if self._phone2 is not None: if not self._phone2.is_available(): self._phone2.switch_on(simple_switch_mode=True) self._voice_call_api2 = self._phone2.get_uecmd("VoiceCall") self._system_api2 = self._phone2.get_uecmd("System") else: self._voice_call_api2 = None self._system_api2 = None # Setup phone type ( calling, receiving, releasing phone) self._phone_calling = self._voice_call_api self._phone_receiving = self._voice_call_api2 self._calling_phone_number = self._phone2.get_phone_number() self._phone_releasing = self._voice_call_api2 def set_up(self): """ Set up the test configuration """ # Call UseCaseBase Setup function UseCaseBase.set_up(self) # Check if we have the second phone available if self._phone2 is None: # We are using this multi UC with only one phone error_msg = \ "This test case requires two phones to be executed !" self._logger.error(error_msg) raise AcsConfigException(AcsConfigException.INVALID_BENCH_CONFIG, error_msg) # APx Initialization if self._audio_analyzer.initialization(self._device.get_phone_model(), self._test_type) != 0: error_msg = \ "APX Initialization Failed !" self._logger.error(error_msg) raise TestEquipmentException( TestEquipmentException.OPERATION_FAILED, error_msg) # Release any previous call (Robustness) self._voice_call_api.release() self._voice_call_api2.release() return Global.SUCCESS, "No errors" def run_test(self): """ Execute the test """ # Call UseCaseBase run_test function UseCaseBase.run_test(self) if self._acc_type == "HEADSET": if self._use_io_card: self._wired_headset.unplug_headphone() self._wired_headset.plug_whs() elif self._acc_type == "HEADPHONE": if self._use_io_card: self._wired_headset.unplug_whs() self._wired_headset.plug_headphone() # Dial using PHONE_NUMBER parameter self._phone_calling.dial(self._calling_phone_number) time.sleep(self._wait_btwn_cmd) # Wait for state "active" before callSetupTimeout seconds self._phone_receiving.wait_for_state( self._uecmd_types.VOICE_CALL_STATE.INCOMING, self._call_setup_time) # Answer call self._phone_receiving.answer() # Phone1 & 2 : Check voice call is active self._phone_calling.wait_for_state( self._uecmd_types.VOICE_CALL_STATE.ACTIVE, self._call_setup_time) self._phone_receiving.wait_for_state( self._uecmd_types.VOICE_CALL_STATE.ACTIVE, self._call_setup_time) # Configure Audio output to acc_type given with the test_case if self._acc_type == "EARPIECE": if self._use_io_card: self._wired_headset.unplug_whs() self._wired_headset.unplug_headphone() elif self._acc_type == "SPEAKER": # Switch to Speaker, nothing to do in Earpiece # Bluetooth already done with connect Bluetooth function above self._phonesystem_api.switch_audio_output(self._acc_type.lower()) time.sleep(self._wait_btwn_cmd) elif self._acc_type.find("BLUETOOTH") != -1: if self._audio_analyzer.connect_bt(self._acc_type, self._dut_bt_address) != 0: error_msg = \ "Connect Bluetooth failed !" self._logger.error(error_msg) raise DeviceException(DeviceException.OPERATION_FAILED, error_msg) if self._acc_type.find("BLUETOOTH") == -1: # Set Voice Call Volume self._system_api.adjust_specified_stream_volume( "VoiceCall", self._call_stream_volume_dut) else: # Set Voice Call Volume self._system_api.adjust_specified_stream_volume( "Bluetooth", self._call_stream_volume_dut) self._system_api2.adjust_specified_stream_volume( "VoiceCall", self._call_stream_volume_ref) # Launch Apx Calibration test on Uplink apx_result = self._audio_analyzer.calibration( self._device.get_phone_model(), "3G", self._acc_type, "UL", self._dut_bt_address) if apx_result == 0: self._result_verdict_ul = Global.SUCCESS self._verdict_comment = "APx Calibration success in UL" else: self._result_verdict_ul = Global.FAILURE self._verdict_comment = "APx Calibration fail in UL" # Launch Apx Calibration test on Downlink apx_result = self._audio_analyzer.calibration( self._device.get_phone_model(), "3G", self._acc_type, "DL", self._dut_bt_address) if apx_result == 0: self._result_verdict_dl = Global.SUCCESS self._verdict_comment += " and APx Calibration success in DL" else: self._result_verdict_dl = Global.FAILURE self._verdict_comment += " and APx Calibration fail in DL" # Compute final verdict if self._result_verdict_ul == Global.FAILURE or \ self._result_verdict_dl == Global.FAILURE: self._result_verdict_final = Global.FAILURE else: self._result_verdict_final = Global.SUCCESS # RELEASE THE CALL # Phone1 & 2 : Check call is still active self._phone_calling.check_state( self._uecmd_types.VOICE_CALL_STATE.ACTIVE) self._phone_receiving.check_state( self._uecmd_types.VOICE_CALL_STATE.ACTIVE) # Hang up call self._phone_releasing.release() # Phone1 & 2 : Check call is idle self._phone_calling.wait_for_state( self._uecmd_types.VOICE_CALL_STATE.NOCALL, self._call_setup_time) self._phone_receiving.wait_for_state( self._uecmd_types.VOICE_CALL_STATE.NOCALL, self._call_setup_time) return self._result_verdict_final, self._verdict_comment def tear_down(self): """ End and dispose the test """ # Call UseCaseBase tear_down function UseCaseBase.tear_down(self) if self._acc_type == "HEADSET": if self._use_io_card: self._wired_headset.unplug_whs() elif self._acc_type == "HEADPHONE": if self._use_io_card: self._wired_headset.unplug_headphone() # Release any previous call (Robustness) self._voice_call_api.release() self._voice_call_api2.release() # Reset Voice Call Volume at 70% if self._system_api is not None: self._system_api.adjust_specified_stream_volume("VoiceCall", 70) if self._system_api2 is not None: self._system_api2.adjust_specified_stream_volume("VoiceCall", 70) return Global.SUCCESS, "No errors"
class LiveSystemSleepResidencyMeasurement(SystemSleepBase): """ Sleep mode residency measurement class. """ def __init__(self, tc_name, global_config): """ Constructor :type tc_name: BaseConf :param tc_name: Configuration of the usecase :type global_config: Dictionary :param global_config: Global configuration of the campaign """ # Call UseCase base constructor self._device = DeviceManager().get_device("PHONE1") self.__adbConnectionTimeout = self._device.get_config( "adbConnectTimeout", 30, float) self._device_uptime_begin = None self._sleep_duration = None # If the device was disconnected before due to an error # we must reconnect it explicitly at the beginning of the test # else some commands will not be executed and the test will be blocked self._system_api = self._device.get_uecmd("System") return_code = self._system_api.wait_for_device( self.__adbConnectionTimeout) if not return_code: time.sleep(30) if not self._device.is_available(): self._device.connect_board() # Call SystemSleepBase base Init function SystemSleepBase.__init__(self, tc_name, global_config) self._report_tree = global_config.campaignConfig.get( "campaignReportTree") self._sysdebug_apis = self._device.get_uecmd("SysDebug") self._tc_name = os.path.basename(self.get_name()) self._tc_date = "" attributes = {"id": self._tc_name, "date": self._tc_date} self.__results = PnPResults(self._report_tree, self._dut_config.get("Name"), self._failure_file, None, attributes) def run_test(self): """ Execute the test """ sysdbg_modules_config = self._tc_parameters.get_param_value( "SYSDEBUG_MODULES") self._sysdebug_apis.init(sysdbg_modules_config) sleep_parameter = self._tc_parameters.get_param_value("SLEEP_DURATION") if sleep_parameter is not None and sleep_parameter != "" and sleep_parameter.isdigit( ): self._sleep_duration = int(sleep_parameter) # Call live sleep use case base SystemSleepBase.run_test(self) self._tc_date = time.strftime("%Y-%m-%d %H:%M:%S") self.__results.update({"date": self._tc_date}) while not self._sysdebug_apis.synchronize(): time.sleep(10) adbConnectTimeout = self._device.get_config("adbConnectTimeout", 10, float) usbReplugRetries = self._device.get_config("usbReplugRetries", 1, int) if self._io_card is not None: self._device.disconnect_board() self._sysdebug_apis.reset() # will clear mid_pmu_states self._residency_api.clear( self._sleep_duration) # will also clear mid_pmu_states # but this is needed to do the fetch on this instance self._io_card.usb_host_pc_connector(False) # Unplug wall charger only if it is AC_CHGR if self._device.get_default_wall_charger( ) == self._io_card.AC_CHGR: self._io_card.wall_charger_connector(False) # Update device uptime updated, self._device_uptime_begin = self._device._update_device_up_state( 0) if not updated: self._device_uptime_begin = None if self._sleep_duration: self._logger.info( "Wait for %s s before measurement (sleep duration before %s)" % (str(self._sleep_duration), self._sleep_mode)) time.sleep(self._sleep_duration) self._sysdebug_apis.start() self._logger.info("Wait for %s s to enter in %s" % (str(self._duration), self._sleep_mode)) time.sleep(self._duration) self._sysdebug_apis.stop() residency_spent = 0 ret_code = None if self._io_card is not None: for cnt in range(0, usbReplugRetries + 1): self._logger.debug("Loop Iteration: %d" % cnt) # plug wall charger only if it is AC_CHGR if self._device.get_default_wall_charger( ) == self._io_card.AC_CHGR: self._io_card.wall_charger_connector(True) self._io_card.usb_host_pc_connector(True) self._logger.debug("Wait for device %s seconds" % self.__adbConnectionTimeout) ret_code = self._system_api.wait_for_device( self.__adbConnectionTimeout) self._logger.debug("Wait for device return code: %s" % ret_code) if not ret_code: if cnt < usbReplugRetries: self._logger.warning( "timeout on wait-for-device, trying to unplug/replug (try %s/%s)" % (str(cnt + 1), str(usbReplugRetries))) self._io_card.usb_host_pc_connector(False) # Unplug wall charger only if it is AC_CHGR if self._device.get_default_wall_charger( ) == self._io_card.AC_CHGR: self._io_card.wall_charger_connector(False) time.sleep(10) continue residency_spent = self._residency_api.get_value( "residency", self._sleep_mode_api.get_sleep_mode()) self._sysdebug_apis.fetch() self._device.connect_board() self._logger.debug("device retrieved after %s tries" % str(cnt + 1)) break if not ret_code: raise DeviceException( DeviceException.OPERATION_FAILED, "Could not retrieve the device after %s plug/unplug cycles" % str(usbReplugRetries)) if residency_spent is None: raise DeviceException( DeviceException.INVALID_PARAMETER, "There is no %s sleep mode for this device model" % self._sleep_mode_api.get_sleep_mode()) # Get device uptime and raise an exception if the device rebooted if self._device_uptime_begin: updated, uptime = self._device._update_device_up_state( self._device_uptime_begin) if updated and not self._device.is_up: self._logger.warning( "the device uptime was %s before the measurement, %s now !" % (str(self._device_uptime_begin), str(uptime))) raise DeviceException( DeviceException.OPERATION_FAILED, "Device rebooted during the measurement") sysreport = self._sysdebug_apis.report() self.__results.append(sysreport) self.__results.write() return self._residency_verdict(residency_spent)
class LabAudioQualityAccessoriesChangeBase(UseCaseBase): """ AudioComms Audio CSV Call Accessories Change class. """ def __init__(self, tc_name, global_config): """ Constructor """ # Call UseCaseBase Init function UseCaseBase.__init__(self, tc_name, global_config) # Create Audio Analyzer self._audio_analyzer = self._em.get_audio_analyzer("AudioAnalyzer") # Check if IO card is used self._use_io_card = str_to_bool( global_config.campaignConfig.get("isIoCardUsed")) # Create Whs if self._use_io_card: self._wired_headset = self._em.get_wired_headset("WiredHeadset") # Initialization of the test type self._test_type = "audioquality" # Initialization of accessories type self._acc_type = "None" self._previous_acc_type = "None" # Initialization of audio_analyzer_result saved self._audio_analyzer_result_save = 0 self._audio_analyzer_result_ul = 0 self._audio_analyzer_result_dl = 0 # Initialization of failed transition saved self._failed_transition_audio_pb = "" self._failed_transition_no_audio = "" # Initialization of _dut_bt_address self._dut_bt_address = "None" # Initialization of test result self._result_verdict = Global.SUCCESS # Initialization of the verdict comment self._verdict_comment = "Audio Quality test fail" # Read registrationTimeout from Device_Catalog.xml self._registration_timeout = \ int(self._dut_config.get("registrationTimeout")) # Read callSetupTimeout from Device_Catalog.xml self._call_setup_time = \ int(self._dut_config.get("callSetupTimeout")) # Read call origin type from test case xml file (str) self._call_origin_type = str( self._tc_parameters.get_param_value("CALL_ORIGIN_TYPE")) # Read accessories list from test case xml file (str) self._acc_list = str(self._tc_parameters.get_param_value("ACC_LIST")) # Split the accessories list, accessories separated by ',' self._acc_list = self._acc_list.strip('[] ') self._acc_list_split = self._acc_list.split(',') self._acc_list_split.reverse() # Read accessories active list from test case xml file (str) self._acc_active_list = str( self._tc_parameters.get_param_value("ACC_ACTIVE_LIST")) # Split the accessories active list, accessories separated by ',' self._acc_active_list = self._acc_active_list.strip('[] ') self._acc_active_list_split = self._acc_active_list.split(',') self._acc_active_list_split.reverse() # Call Stream Volume in percent self._call_stream_volume_dut_list = \ str(self._tc_parameters.get_param_value("CALL_VOLUME_DUT_LIST")) # Split the accessories list, accessories separated by ',' self._call_stream_volume_dut_list = self._call_stream_volume_dut_list.strip( '[] ') self._call_volume_dut_list_split = self._call_stream_volume_dut_list.split( ',') self._call_volume_dut_list_split.reverse() # Call Stream Volume in percent self._call_stream_volume_ref_list = \ str(self._tc_parameters.get_param_value("CALL_VOLUME_REF_LIST")) # Split the accessories list, accessories separated by ',' self._call_stream_volume_ref_list = self._call_stream_volume_ref_list.strip( '[] ') self._call_volume_ref_list_split = self._call_stream_volume_ref_list.split( ',') self._call_volume_ref_list_split.reverse() # Read call end type from test case xml file (str) self._call_end_type = str( self._tc_parameters.get_param_value("CALL_END_TYPE")) # Read call type from test case xml file (str) self._call_type = str(self._tc_parameters.get_param_value("CALL_TYPE")) # Read test call direction type from test case xml file (s tring) self._signal_tested_direction = \ str(self._tc_parameters.get_param_value("SIGNAL_TESTED_DIRECTION")) # Read duration type from test case xml file (int) if self._tc_parameters.get_param_value("DURATION"): self._call_duration = int( self._tc_parameters.get_param_value("DURATION")) else: # Call duration by default self._call_duration = 5 # Read Audio Analyzer parameters from bench config xml file (str) self._audio_analyzer_node = global_config.benchConfig.\ get_parameters("AudioAnalyzer") self._bt_remote_addr = self._audio_analyzer_node.get_param_value( "Bt_mac_addr") # Instantiate generic UECmd for voiceCall Ucs self._system_api = self._device.get_uecmd("System") self._networking_api = self._device.get_uecmd("Networking") # Bluetooth present in the list accessories if self._acc_list.count("BLUETOOTH") > 0: # Get UECmdLayer self._bt_api = self._device.get_uecmd("LocalConnectivity") # Load instance of the PHONE2 self._phone2 = DeviceManager().get_device("PHONE2") self._system_api2 = None self._acc_swap_type = self._tc_parameters.get_param_value( "ACC_SWAP_TYPE", 'Default') # Copy of accessories list self._temp_acc_list_split = None # Copy of volume list / active accessory list self._temp_call_volume_dut_list_split = None self._temp_call_volume_ref_list_split = None self._temp_acc_active_list_split = None def set_up(self): """ Set up the test configuration """ # Call UseCaseBase Setup function UseCaseBase.set_up(self) # Check if we have the second phone available if self._phone2 is not None: if not self._phone2.is_available(): self._phone2.switch_on(simple_switch_mode=True) self._system_api2 = self._phone2.get_uecmd("System") else: # We are using this multi UC with only one phone error_msg = \ "This test case requires two phones to be executed !" self._logger.error(error_msg) raise AcsConfigException(AcsConfigException.INVALID_BENCH_CONFIG, error_msg) # Swap 2G 3G or 4G. if self._call_type == "2G": self._networking_api.set_preferred_network_type( PreferredNetwork.GSM_ONLY) elif self._call_type == "3G": self._networking_api.set_preferred_network_type( PreferredNetwork.WCDMA_ONLY) elif self._call_type == "4G": self._networking_api.set_preferred_network_type( PreferredNetwork.LTE_ONLY) else: if self._call_type not in "VOIP": msg = "wrong value of parameter CALL TYPE" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) # Audio Analyzer Initialization if self._audio_analyzer.initialization(self._device.get_phone_model(), self._test_type) != 0: error_msg = \ "Audio Analyzer Initialization Failed !" self._logger.error(error_msg) raise TestEquipmentException( TestEquipmentException.OPERATION_FAILED, error_msg) if self._acc_list.count("BLUETOOTH") > 0: # Get dut bt address self._dut_bt_address = self._bt_api.get_bt_adapter_address() # Push the first Bluetooth accessories in first l_bluetooth_acc_position = 0 for i in self._acc_list_split: if i.find("BLUETOOTH") != -1: # Initialization of _acc_type with the bluetooth accessories self._acc_type = i self._acc_list_split.insert(len(self._acc_list_split), i) self._acc_active_list_split.insert( len(self._acc_active_list_split), self._acc_active_list_split[l_bluetooth_acc_position]) self._call_volume_ref_list_split.insert( len(self._call_volume_ref_list_split), self. _call_volume_ref_list_split[l_bluetooth_acc_position]) self._call_volume_dut_list_split.insert( len(self._call_volume_dut_list_split), self. _call_volume_dut_list_split[l_bluetooth_acc_position]) break l_bluetooth_acc_position += 1 # Connect Bluetooth device if self._audio_analyzer.connect_bt(self._acc_type, self._dut_bt_address) != 0: error_msg = \ "Connect Bluetooth failed !" self._logger.error(error_msg) raise DeviceException(DeviceException.OPERATION_FAILED, error_msg) return Global.SUCCESS, "No errors" def tear_down(self): """ End and dispose the test """ # Call UseCaseBase tear_down function UseCaseBase.tear_down(self) # Reset Voice Call Volume at 50% if self._system_api is not None: self._system_api.adjust_specified_stream_volume("VoiceCall", 70) if self._system_api2 is not None: self._system_api2.adjust_specified_stream_volume("VoiceCall", 70) return Global.SUCCESS, "No errors" def _compute_test_verdict_(self, audio_analyzer_result_ul, audio_analyzer_result_dl): """ Computes the test verdict for audio accessory change :type audio_analyzer_result_dl: int :param audio_analyzer_result_dl: result value for the DL audio test given by the audio analyzer :type audio_analyzer_result_ul: int :param audio_analyzer_result_ul: result value for the UL audio test given by the audio analyzer :return: None """ if self._audio_analyzer_result_save == 3: self._result_verdict = Global.BLOCKED elif self._audio_analyzer_result_save == 2: if (audio_analyzer_result_ul == 3) or (audio_analyzer_result_dl == 3): self._result_verdict = Global.BLOCKED self._failed_transition_no_audio = self._failed_transition_no_audio + ", " + \ self._previous_acc_type + " => " + self._acc_type self._audio_analyzer_result_save = 3 elif (audio_analyzer_result_ul == 2) or (audio_analyzer_result_dl == 2): self._result_verdict = Global.FAILURE self._failed_transition_no_audio = self._failed_transition_no_audio + ", " + \ self._previous_acc_type + " => " + self._acc_type self._audio_analyzer_result_save = 2 elif self._audio_analyzer_result_save == 1: if (audio_analyzer_result_ul == 3) or (audio_analyzer_result_dl == 3): self._result_verdict = Global.BLOCKED self._failed_transition_no_audio = self._failed_transition_no_audio + ", " + \ self._previous_acc_type + " => " + self._acc_type self._audio_analyzer_result_save = 3 elif (audio_analyzer_result_ul == 2) or (audio_analyzer_result_dl == 2): self._result_verdict = Global.FAILURE self._failed_transition_no_audio = self._failed_transition_no_audio + ", " + \ self._previous_acc_type + " => " + self._acc_type self._audio_analyzer_result_save = 2 elif (audio_analyzer_result_ul == 1) or (audio_analyzer_result_dl == 1): self._result_verdict = Global.FAILURE self._failed_transition_audio_pb = self._failed_transition_audio_pb + ", " + \ self._previous_acc_type + " => " + self._acc_type elif self._audio_analyzer_result_save == 0: if (audio_analyzer_result_ul == 3) or (audio_analyzer_result_dl == 3): self._result_verdict = Global.BLOCKED self._failed_transition_no_audio = self._failed_transition_no_audio + ", " + \ self._previous_acc_type + " => " + self._acc_type self._audio_analyzer_result_save = 3 elif (audio_analyzer_result_ul == 2) or (audio_analyzer_result_dl == 2): self._result_verdict = Global.FAILURE self._failed_transition_no_audio = self._failed_transition_no_audio + ", " + \ self._previous_acc_type + " => " + self._acc_type self._audio_analyzer_result_save = 2 elif (audio_analyzer_result_ul == 1) or (audio_analyzer_result_dl == 1): self._result_verdict = Global.FAILURE self._failed_transition_audio_pb = self._failed_transition_audio_pb + ", " + \ self._previous_acc_type + " => " + self._acc_type self._audio_analyzer_result_save = 1 else: self._audio_analyzer_result_save = 0 self._result_verdict = Global.SUCCESS # Now, the verdict comment will be updated, according to the outcome of the audio test if self._audio_analyzer_result_save == 0: self._verdict_comment = ( "Audio Quality test success: in %s with " "a %s call with %s accessories sequence" % (self._signal_tested_direction, self._call_type, str(self._tc_parameters.get_param_value("ACC_LIST")))) elif self._audio_analyzer_result_save == 1: self._verdict_comment = ( "Audio Quality test fail: Audio Analyzer quality audio " "problems detected in %s with a %s call with " "%s accessories sequence" % (self._signal_tested_direction, self._call_type, self._failed_transition_audio_pb)) elif self._audio_analyzer_result_save == 2: self._verdict_comment = ( "Audio Quality test fail: No audio signal in %s with " "a %s call with %s accessories sequence" % (self._signal_tested_direction, self._call_type, self._failed_transition_no_audio)) elif self._audio_analyzer_result_save == 3: self._verdict_comment = ( "Audio Quality test fail: Exception in executable in %s with " "a %s call with %s accessories sequence" % (self._signal_tested_direction, self._call_type, self._failed_transition_no_audio)) else: self._verdict_comment = ( "Audio Quality test fail: Audio Analyzer problems detected " "in %s with a %s call" % (self._signal_tested_direction, self._call_type))
class LabWifiDirectBase(UseCaseBase): """ Lab Wifi Direct class. """ DEFAULT_REGULATORY_DOMAIN = "US" def __init__(self, tc_name, global_config): """ Constructor """ UseCaseBase.__init__(self, tc_name, global_config) self._device1_name = self._tc_parameters.get_param_value( "DEVICE1_NAME", "") self._device2_name = self._tc_parameters.get_param_value( "DEVICE2_NAME", "") # Get P2p interface name self._device1_p2pinterface = str(self._dut_config.get("p2pInterface")) self._device1_supplicant = None self._device1_client = None self._device1_mac = None self._device2_supplicant = None self._device2_client = None self._device2_mac = None self._phone2 = None self._networking2_api = None self._device2_p2pinterface = None if self._device2_name.startswith("PHONE"): self.dut_config2 = DeviceManager().get_device_config("PHONE2") self._device2_p2pinterface = str( self.dut_config2.get("p2pInterface")) # Get Device 2 Instance self._phone2 = DeviceManager().get_device(self._device2_name) self._networking2_api = self._phone2.get_uecmd("Networking") self._networking_api = self._device.get_uecmd("Networking") self._dut1_wlan_iface = str(self._dut_config.get("wlanInterface")) self._dut2_wlan_iface = str(self.dut_config2.get("wlanInterface")) def set_up(self): """ Initialize the test """ UseCaseBase.set_up(self) self.__check_tc_parameters() if self._phone2 is not None and not self._phone2.is_available(): DeviceManager().boot_device(self._device2_name) # set wifi On on the DUT to allow regulatory domain to change self._networking_api.set_wifi_power("on") if self._networking2_api is not None: self._networking2_api.set_wifi_power("on") # set the regulatory domain self._networking_api.set_regulatorydomain( LabWifiDirectBase.DEFAULT_REGULATORY_DOMAIN, self._dut1_wlan_iface) if self._networking2_api is not None: self._networking2_api.set_regulatorydomain( LabWifiDirectBase.DEFAULT_REGULATORY_DOMAIN, self._dut2_wlan_iface) # set wifi Off on the DUT self._networking_api.set_wifi_power("off") if self._networking2_api is not None: self._networking2_api.set_wifi_power("off") return Global.SUCCESS, "No error" #------------------------------------------------------------------------------ def _get_supplicant_instance(self, device_name): """ Get the p2p supplicant instance for the device :rtype: UECmd Object or Equipement Object :return: The p2p supplicant instance for the device """ device_instance = self.__get_device_instance(device_name) if device_name.startswith("PHONE"): return device_instance.get_uecmd("P2PSupplicantCLI") if device_name.startswith("COMPUTER"): return device_instance.get_p2p("P2pSupplicant") msg = "device not found " + device_name self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) def _get_client_instance(self, device_name): """ return the p2p client instance for the device """ device_instance = self.__get_device_instance(device_name) if device_name.startswith("PHONE"): return device_instance.get_uecmd("P2PClientCLI") if device_name.startswith("COMPUTER"): return device_instance.get_p2p("P2pClient") msg = "device not found " + device_name self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) def __get_device_instance(self, device_name): """ retrieve the device instance """ if device_name.startswith("COMPUTER"): return self._em if device_name == "PHONE1": return self._device if device_name.startswith("PHONE"): if not self._phone2.is_available(): DeviceManager().boot_device(device_name) return self._phone2 msg = "device not found " + device_name self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) def __check_tc_parameters(self): """ Checks all TC parameters """ if not self._device1_name: msg = "undefined device name 1." self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if not self._device2_name: msg = "undefined device name 2." self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)