def tear_down(self): """ End and dispose the test """ # Call LiveMessagingBase tear_down function. LiveMessagingBase.tear_down(self) # Delete all MMS and SMS. self._mms_api.delete_all_messages() # Kill the messaging application. self._kill_messaging_app() # set initial sleep timeout self._phonesystem_api.set_screen_timeout(self._initial_sleep_timeout_value) time.sleep(self._wait_btwn_cmd) # Lock the screen. self._phonesystem_api.set_phone_lock("on") self._phonesystem_api.display_off() # If at start data was deactivated, go back to this state. if self._initial_pdp_context_status == "2": # Then deactivate PDP context status self._networking_api.deactivate_pdp_context() time.sleep(self._wait_btwn_cmd) return Global.SUCCESS, "No errors"
def __init__(self, tc_name, global_config): """ Constructor """ # Call UseCase base Init function LiveMessagingBase.__init__(self, tc_name, global_config) # Read SMS_TRANSFER_TIMEOUT from xml UseCase parameter file self._sms_transfer_timeout = \ int(self._tc_parameters.get_param_value("SMS_TRANSFER_TIMEOUT")) # Get FTP server parameters from bench config file self._server = \ global_config.benchConfig.get_parameters("LIVE_FTP_SERVER") self._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 get_param_value output is casted to a str # None will be "None" if self._username in ("None", ""): self._logger.info("FTP user not indicated, using 'anonymous'") self._username = str("anonymous") # The get_param_value, output is casted to a str # None will be "None" if self._password in ("None", ""): self._logger.info( "FTP user's password not indicated, using 'none'") self._password = str("none") # Read the ftp DL file name from TC's xml 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 # The base name of the file we download self._ftp_file_basename = self._tc_parameters.get_param_value( "BASENAME") # Some attributes needed to add robustness to FTP operations # The absolute file path on the DUT self._absolute_path_on_dut = None # Get UECmdLayer for Data Use Cases self._networking_api = self._device.get_uecmd("Networking") self._phone_system_api = self._device.get_uecmd("PhoneSystem") self._ftp_api = self._device.get_uecmd("Ftp")
def __init__(self, tc_name, global_config): """ Constructor """ # Call UseCase base Init function LiveMessagingBase.__init__(self, tc_name, global_config) # Read SMS_TRANSFER_TIMEOUT from xml UseCase parameter file self._sms_transfer_timeout = \ int(self._tc_parameters.get_param_value("SMS_TRANSFER_TIMEOUT"))
def set_up(self): """ Setting up the test Setup: Checking some FTP parameters """ LiveMessagingBase.set_up(self) # Compute the file name on DUT self._absolute_path_on_dut = "".join( [self._device.multimedia_path, self._ftp_file_basename]) # Delete the FTP downloaded file on the DUT self._delete_file_if_exists(self._absolute_path_on_dut) return Global.SUCCESS, "No error"
def run_test(self): """ Execute the test """ # Call UseCase base Run function LiveMessagingBase.run_test(self) # Send SMS to equipment using SMS parameters : # - SMS_TEXT # - DESTINATION_NUMBER # check_delivery parameter set to TRUE time.sleep(self._wait_btwn_cmd) self._sms_api.send_sms(self._destination_number, self._message, check_delivery=True) return Global.SUCCESS, "No errors"
def __init__(self, tc_name, global_config): """ Constructor """ # Call LiveMessagingBase init function. LiveMessagingBase.__init__(self, tc_name, global_config) # Retrieve the repeat count self._repeat_count = 0 repeat_count = self._tc_parameters.get_param_value("REPEAT_COUNT","0") if repeat_count and repeat_count.isdigit(): self._repeat_count = int(repeat_count) # Retrieve the mms_type parameters. self._mms_type = self._tc_parameters.get_param_value("MMS_TYPE") # Retrieve the MMS subject. self._mms_subject = self._tc_parameters.get_param_value("MMS_SUBJECT") if self._mms_type == "text": self._attachment_file = None else: self._multimedia_path = self._device.multimedia_path # Retrieve the path of the MMS attachment. self._attachment_file = os.path.join( self._multimedia_path, self._tc_parameters.get_param_value("ATTACHED_FILE")) # Retrieve the time that the test should wait to receive the MMS. self._send_mms_timeout = \ int(self._tc_parameters.get_param_value("SENT_MMS_TIMEOUT")) self._received_mms_timeout = \ int(self._tc_parameters.get_param_value("RECEIVED_MMS_TIMEOUT")) # Retrieve System API in order to wake up the phone screen. self._phonesystem_api = self._device.get_uecmd("PhoneSystem") self._system_api = self._device.get_uecmd("System") self._modem_api = self._device.get_uecmd("Modem") self._initial_pdp_context_status = None self._initial_sleep_timeout_value = None
def set_up(self): """ Setting up the test """ # Call LiveMessagingBase set_up function. LiveMessagingBase.set_up(self) # Backup the initial pdp context status # pylint: disable=W0212 self._initial_pdp_context_status = \ self._networking_api._get_pdp_context_status() # pylint: enable=W0212 # If deactivated, activate it if self._initial_pdp_context_status == "2": # Then deactivate PDP context status self._networking_api.activate_pdp_context(check=False) time.sleep(self._wait_btwn_cmd) # Check registration state is connected using # registrationTimeout from Device_Catalog.xml (Non blocking # for this test if function isn't implemented on CDK) self._modem_api.check_cdk_registration_bfor_timeout(self._registration_timeout) # store initial Sleep Timeout value self._initial_sleep_timeout_value = self._phonesystem_api.get_screen_timeout() time.sleep(self._wait_btwn_cmd) # If the MMS type picture check if the file exist. if self._mms_type.lower() == "picture": # Checks if the attachment file exist. self._phonesystem_api.check_file_exist(self._attachment_file) # Kill the messaging application. self._kill_messaging_app() # set sleep timeout to 30 second self._phonesystem_api.set_screen_timeout(30) time.sleep(self._wait_btwn_cmd) return Global.SUCCESS, "No error"
def tear_down(self): """ End and dispose the test """ LiveMessagingBase.tear_down(self) time.sleep(self._wait_btwn_cmd) # Delete remaining FTP transfered files from DUT self._delete_file_if_exists(self._absolute_path_on_dut) # Stop the ftp transfer if was not stopped succesfully self._ftp_api.stop_ftp(self._dl_id) # Disable cellular data self._logger.info("Deactivate PDP Context") self._networking_api.deactivate_pdp_context() time.sleep(self._wait_btwn_cmd) return Global.SUCCESS, "No errors"
def run_test(self): """ Execute the test """ # Call UseCase base Run function LiveMessagingBase.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._sms_api.delete_all_sms() # Enable cellular data self._logger.info("Activate PDP Context") self._networking_api.activate_pdp_context() time.sleep(self._wait_btwn_cmd) sms_sent = SmsMessage(self._message, self._destination_number) # Start the FTP data transfer self._dl_id = self._launch_ftp_data_transfer() # Check the status of the FTP connection status = self._ftp_api.get_ftp_status(self._dl_id) # If the transfer is not working some exceptions if str(status) <> "transferring": # If the transfer is not established raised an exception if str(status) in ("notrunning", "transfer failed"): message = "FTP transfer failed / not started: %s" % str(status) raise DeviceException(DeviceException.CONNECTION_LOST, message) # If the transfer status is 'connecting' # additionally wait for the connection to be established elif str(status) == "connecting": self._logger.info( "FTP transfer not started yet. STATUS is CONNECTING") time.sleep(self._wait_btwn_cmd) if str(status) == "connecting": message = "FTP transfer status is CONNECTING for a too long time" raise DeviceException(DeviceException.CONNECTION_LOST, message) # If the FTP data transfer is finished already # the transferred file length chosen is too short else: message = "FTP transfer finished before SMS has been sent" self._logger.error(message) raise AcsConfigException( AcsConfigException.INVALID_TEST_CASE_FILE, message) # If the FTP data transfer is on going start the SMS sending procedures # If the FTP data transfer status is "transferring" else: # 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_api.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) (result_verdict, result_message) = \ compute_sms_equals(sms_sent, sms_received) self._logger.info(result_message) final_transfer_status = str( self._ftp_api.get_ftp_status(self._dl_id)) while final_transfer_status <> "transfer successful": if str(final_transfer_status) in ("transfer successful", "transferring"): time.sleep(self._wait_btwn_cmd) else: message = "FTP transfer failed after SMS sent: %s" % str( final_transfer_status) raise DeviceException(DeviceException.CONNECTION_LOST, message) final_transfer_status = str( self._ftp_api.get_ftp_status(self._dl_id)) if final_transfer_status == "transfer successful": message = "FTP transfer finished successfully" self._logger.info(message) result_message = result_message + ". " + message return result_verdict, result_message
def run_test(self): """ Execute the test """ # Initializing some local variables. time_to_receive_mms = None time_to_send_mms = None time_waited = 0 # Max number of iteration done while waiting for the screen to turn off. # Used to prevent endless loops. max_time_waited = 200 # Call LiveMessagingBase run_test function. LiveMessagingBase.run_test(self) # Clear all SMS and MMS. self._mms_api.delete_all_messages() # Wait for the screen to turn off. while self._phonesystem_api.get_screen_status() \ and time_waited < max_time_waited: time.sleep(5) time_waited += 5 self._logger.info("Waited %s seconds for the screen to turn off." % time_waited) # Checks if the screen turned off before a fixed timeout. if time_waited >= max_time_waited: raise DeviceException(DeviceException.TIMEOUT_REACHED, "The screen did not turned off in %s." % max_time_waited) # Wake up the phone screen. time.sleep(self._wait_btwn_cmd) self._logger.info("Turning the screen on.") self._phonesystem_api.set_phone_lock("off") self._phonesystem_api.wake_screen() self._phonesystem_api.set_phone_lock(0) # register on intent to receive incoming mms self._mms_api.register_for_mms_reception() # Build the MMS. time.sleep(self._wait_btwn_cmd) self._mms_api.send_mms(self._mms_type, self._destination_number, self._mms_subject, self._message, self._attachment_file, self._repeat_count) time.sleep(self._wait_btwn_cmd) # Waiting for the MMS to be send. sent_time = self._mms_api.check_mms_sent(self._destination_number, self._send_mms_timeout) # Waiting on incoming message. reception_date = self._mms_api.wait_for_incoming_mms(self._received_mms_timeout, self._destination_number) # Logging the time taken to receive the MMS. time_to_receive_mms = float(reception_date) - float(sent_time) self._logger.info("The MMS has been received in %s seconds." % time_to_receive_mms) # Compare the sent and received MMS. self._mms_api.request_remote_send_received_mms_compare(self._mms_type) return (Global.SUCCESS, "MMS sent in %s secs and received in %s secs" % (self._mms_api.time_to_send_mms, time_to_receive_mms))