def set_up(self): """ Initialize the test """ LabNfcBase.set_up(self) self._reader_x = self._nfc_robot_param.get_param_value( "ExternalReaderX") self._reader_y = self._nfc_robot_param.get_param_value( "ExternalReaderY") self._reader_up = self._nfc_robot_param.get_param_value( "ExternalReaderUp") self._reader_down = self._nfc_robot_param.get_param_value( "ExternalReaderDown") if self._secure_element not in ["EMBEDDED", "UICC"]: msg = "Unknown Secure element" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if self._secure_element == "EMBEDDED": self._logger.info("Try to select embedded secure element") self._nfc_api.select_secure_element("com.nxp.smart_mx.ID") else: self._logger.info("Try to select UICC secure element") self._nfc_api.select_secure_element("com.nxp.uicc.ID") # Place DUT in front of reader self._robot_positioning(self._reader_x, self._reader_y, "null", "null") return Global.SUCCESS, "No errors"
def run_test(self): """ Execute the test """ LabNfcBase.run_test(self) # Increase the iteration index self._current_iteration_num += 1 if self._data_to_write == self._RANDOM_VALUE: self._logger.info("Generate random string") value_to_compare = generate_random_string(10) else: value_to_compare = self._data_to_write self._write_read_action(value_to_compare, True) if self._should_erase: self._write_read_action(self._EMPTY_VALUE) # If Beam to be checked if self._beam_used and self._beam_checked: read_nfc_beam_status = self._nfc_api.get_nfc_beam_status() # Compare beam status to the one desired if read_nfc_beam_status != self._beam_wished_value: msg = "Unexpected result! Read beam value is %s instead of %s" % ( str(read_nfc_beam_status), str(self._beam_wished_value)) self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) return Global.SUCCESS, "No errors"
def tear_down(self): """ End and dispose the test """ UseCaseBase.tear_down(self) # restore default P2P configuration self._nfc_api.set_default_nfc_p2p_configuration() LabNfcBase.tear_down(self) # In case of failure, restore robot initial position self._robot_positioning("null", "null", self._antenna_up, "null") if self._direction == "SEND": # delete contact self._contacts_api.contact_delete( self._nfc_tool.CONTACT_EXPECTED_BY_EMULATOR) # check contact is removed contact_count = self._contacts_api.check_contact_in_list( self._nfc_tool.CONTACT_EXPECTED_BY_EMULATOR) if contact_count is not "0": self._logger.error("Contact has not been removed!") raise DeviceException(DeviceException.OPERATION_FAILED, "Error deleting contact") return Global.SUCCESS, "No errors"
def run_test(self): """ Execute the test """ LabNfcBase.run_test(self) self._logger.info("Select following secure element :" + self._se_selection_sequence) time.sleep(self._wait_btwn_cmd) seqlist = self._se_selection_sequence.strip().split(";") for switch in seqlist: if switch.upper() == "EMBEDDED": self._logger.info("Try to select embedded secure element") self._nfc_api.select_secure_element("com.nxp.smart_mx.ID") time.sleep(self._wait_btwn_cmd) self._check_connection_with_reader() elif switch.upper() == "UICC": self._logger.info("Try to select SIM card secure element") self._nfc_api.select_secure_element("com.nxp.uicc.ID") time.sleep(self._wait_btwn_cmd) self._check_connection_with_reader() elif switch.upper() in ("DISABLED", "NONE"): self._logger.info("Disabled Smartcard") self._nfc_api.select_secure_element("DISABLED") time.sleep(self._wait_btwn_cmd) else: msg = switch.upper() + "is trying to be set as secure element. It is not a possible value!" \ + "You must use DISABLED, UICC or EMBEDDED in test case xml file" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) return Global.SUCCESS, "No errors"
def run_test(self): LabNfcBase.run_test(self) if self.__is_max_z: # try to find the higher field point in the center of device higher_z = self.__found_max_Z() if higher_z is None: # something is wrong msg = "No field found on Z axe, test ending" self.__result_file_handler.write(msg) else: msg = "Higher field point on Z axe is %f\n" % float( abs(self.__max_Z - higher_z)) self.__result_file_handler.write(msg) # Build the field for y in range(-self.__starting_Y, self.__starting_Y, self.__resolution): for x in range(-self.__starting_X, self.__starting_X, self.__resolution): is_field_on = self.__is_read_ok(x, y, self.__max_Z) self.__add_point_to_file(x, y, self.__max_Z, is_field_on) return Global.SUCCESS, "No errors"
def tear_down(self): """ End and dispose the test """ self.__result_file_handler.close() LabNfcBase.tear_down(self) return Global.SUCCESS, "No errors"
def run_test(self): """ Execute the test """ LabNfcBase.run_test(self) self._mp_manager.run_script(self._script) return Global.SUCCESS, "No errors"
def __init__(self, tc_name, global_config): """ Constructor """ LabNfcBase.__init__(self, tc_name, global_config) # Instantiate the Secondary Report object self._secondary_report = SecondaryTestReport( self._device.get_report_tree().get_report_path()) # status for the test setup self.__flight_mode_status = self._tc_parameters.get_param_value( "FLIGHT_MODE_STATUS", "APM_NONE") # Get UECmdLayer self._phone_system_api = self._device.get_uecmd("PhoneSystem") self._networking_api = self._device.get_uecmd("Networking") self._appmgmt_api = self._phone_ref.get_uecmd("AppMgmt") # Get tag to manage from test case xml file self._tag_type = str(self._tc_parameters.get_param_value("TAG_TYPE")) # Get RTD to write in tag from test case xml file self._record_type_description = str( self._tc_parameters.get_param_value("RTD_TYPE")) # Get DATA to write in tag from test case xml file self._data_to_write = str(self._tc_parameters.get_param_value("DATA")) # Get DATA to write in tag from test case xml file self._should_erase = str_to_bool_ex( self._tc_parameters.get_param_value("ERASE")) if self._should_erase is None: self._should_erase = False # Get NFC Tags application package name self._tag_app = str(self._dut_config.get("TagsAppPackageName")) # Get Browsers application package name (need to disable in order to be able to read URI tags) self._browser_app = str(self._dut_config.get("BrowserAppPackageName")) self._chrome_app = str(self._dut_config.get("ChromeAppPackageName")) self._nfc_robot_param = global_config.benchConfig.get_parameters( "NFC_ROBOT1") # Get "Beam control check" from test case xml file (set ON, set OFF) self._beam_checked = self._get_beam_config() # Initialize up down robot values self._tag_up = "0" self._tag_down = "0" self._read_max_duration = "5" self._write_max_duration = "5" # Measure read time self._read_time_list = list() self._current_iteration_num = 0
def tear_down(self): """ End and dispose the test """ LabNfcBase.tear_down(self) # Put DUT away from the reader self._robot_positioning("null", "null", self._reader_up, "null") return Global.SUCCESS, "No errors"
def tear_down(self): """ End and dispose the test """ LabNfcBase.tear_down(self) # Remove DUT from antenna self._robot_positioning("null", "null", self._pcd_antenna_up, "null") self._mp_manager.release() return Global.SUCCESS, "No errors"
def run_test(self): """ Execute the test """ LabNfcBase.run_test(self) if self._direction == "RECEIVE": self.__nfc_p2p_receive_contact() else: self.__nfc_p2p_send_contact() return Global.SUCCESS, "No errors"
def __init__(self, tc_name, global_config): LabNfcBase.__init__(self, tc_name, global_config) # starting height self.__starting_Z = self._tc_parameters.get_param_value("STARTING_Z") if self.__starting_Z is None: self.__starting_Z = 0 else: self.__starting_Z = int(self.__starting_Z) # ending height self.__max_Z = self._tc_parameters.get_param_value("MAX_Z") if self.__max_Z is None: self.__max_Z = 0 else: self.__max_Z = int(self.__max_Z) # test max Z or not self.__is_max_z = str_to_bool( self._tc_parameters.get_param_value("FOUND_MAX_Z")) # position of the testing square self.__right_up_corner_position = str( self._tc_parameters.get_param_value("RIGHT_UP_CORNER")).split("x") self.__starting_X = int(self.__right_up_corner_position[0]) self.__starting_Y = int(self.__right_up_corner_position[1]) # get the resolution self.__resolution = int( self._tc_parameters.get_param_value("RESOLUTION")) # output file self.__result_file_name = self._tc_parameters.get_param_value( "RESULT_FILE_NAME") self.__result_file_handler = open( os.path.join(self._saving_directory, self.__result_file_name), 'w') # get the antenna position nfc_antenna_position = self._device.get_config("NfcAntennaPosition", "").split(',') if len(nfc_antenna_position) == 2 and is_number( nfc_antenna_position[0]) and is_number( nfc_antenna_position[1]): self._x_antenna = int(nfc_antenna_position[0]) self._y_antenna = int(nfc_antenna_position[1]) else: self._x_antenna = 0 self._y_antenna = 0
def __init__(self, tc_name, global_config): """ Constructor """ LabNfcBase.__init__(self, tc_name, global_config) # Get the NFC tool equipment self._nfc_tool = self._em.get_nfc_tool("NFC_TOOL3") # Get DUT state from test case xml file self._dut_state = \ str(self._tc_parameters.get_param_value("DUT_STATE")) # Get Secure element to communicate with from test case xml file self._secure_element = \ str(self._tc_parameters.get_param_value("SECURE_ELEMENT")) # Get protocol type to use from test case xml file self._protocol_type = \ str(self._tc_parameters.get_param_value("PROTOCOL_TYPE")) # Get APDU case to use from test case xml file self._apdu_case = \ str(self._tc_parameters.get_param_value("APDU_CASE")) # Get bitrate to use from test case xml file self._bitrate = \ str(self._tc_parameters.get_param_value("BITRATE")) # Get data length to use from test case xml file self._data_length = \ str(self._tc_parameters.get_param_value("DATA_LENGTH")) # Get the number of commands to send to stress the system self._loop = \ str(self._tc_parameters.get_param_value("LOOP")) self._phone_system_api = self._device.get_uecmd("PhoneSystem") self._nfc_robot_param = global_config.benchConfig.get_parameters( "NFC_ROBOT1") self._reader_x = "0" self._reader_y = "0" self._reader_up = "0" self._reader_down = "0"
def set_up(self): LabNfcBase.set_up(self) # dont need to check if BEAM activated because of the parameters # self._Device is DUT # self._phone_ref is the reference phone # disable "Tags" and browsers built-in apps # In DUT self._appmgmt_api.app_enable_disable(self._tag_app, False) self._appmgmt_api.app_enable_disable(self._browser_app, False) self._appmgmt_api.app_enable_disable(self._chrome_app, False) # in phone ref self._appmgmt_api.app_enable_disable(self._tag_app, False) self._appmgmt_api.app_enable_disable(self._browser_app, False) self._appmgmt_api.app_enable_disable(self._chrome_app, False) self.__size_of_file = 0 # file have to be in both device, and get its size file_exist, result = self._file_api_dut.exist( posixpath.join(self._device.multimedia_path, self.__file_to_share)) if file_exist: size = self._file_api_dut.size( posixpath.join(self._device.multimedia_path, self.__file_to_share)) self.__size_of_file = size else: msg = "File to transfert missing on DUT " raise AcsConfigException(AcsConfigException.FILE_NOT_FOUND, msg) size = 0 file_exist, result = self._file_api_ref.exist( posixpath.join(self._device.multimedia_path, self.__file_to_share)) if file_exist: size = self._file_api_ref.size( posixpath.join(self._device.multimedia_path, self.__file_to_share)) if size != self.__size_of_file: msg = "File to share are different size on DUT and reference phone" raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) else: msg = "File to transfert missing on reference phone " raise AcsConfigException(AcsConfigException.FILE_NOT_FOUND, msg) return Global.SUCCESS, "No errors"
def set_up(self): """ Initialize the test """ LabNfcBase.set_up(self) self._reader_x = self._nfc_robot_param.get_param_value( "ExternalReaderX") self._reader_y = self._nfc_robot_param.get_param_value( "ExternalReaderY") self._reader_up = self._nfc_robot_param.get_param_value( "ExternalReaderUp") self._reader_down = self._nfc_robot_param.get_param_value( "ExternalReaderDown") # Place DUT in front of reader self._robot_positioning(self._reader_x, self._reader_y, "null", "null") return Global.SUCCESS, "No errors"
def __init__(self, tc_name, global_config): """ Constructor """ LabNfcBase.__init__(self, tc_name, global_config) self._reader_x = "0" self._reader_y = "0" self._reader_up = "0" self._reader_down = "0" self._nfc_robot_param = global_config.benchConfig.get_parameters( "NFC_ROBOT1") # Get Secure element to communicate with from test case xml file self._secure_element = self._tc_parameters.get_param_value( "SECURE_ELEMENT", "").upper() self._gpshell = self._em.get_nfc_tool("NFC_TOOL1")
def __init__(self, tc_name, global_config): """ Constructor """ LabNfcBase.__init__(self, tc_name, global_config) self._nfc_robot_param = global_config.benchConfig.get_parameters( "NFC_ROBOT1") # Read SE_SELECTION_SEQUENCE from test case xml file self._se_selection_sequence = \ str(self._tc_parameters.get_param_value("SE_SELECTION_SEQUENCE")) self._gpshell = self._em.get_nfc_tool("NFC_TOOL1") self._reader_x = "0" self._reader_y = "0" self._reader_up = "0" self._reader_down = "0"
def tear_down(self): """ End and dispose the test """ LabNfcBase.tear_down(self) # if flight mode is activate if self._networking_api.get_flight_mode(): self._networking_api.set_flight_mode(0) # In case of failure, restore robot initial position self._robot_positioning("null", "null", self._tag_up, "null") # enable "Tags" and browser built-in apps self._appmgmt_api.app_enable_disable(self._tag_app, True) self._appmgmt_api.app_enable_disable(self._browser_app, True) self._appmgmt_api.app_enable_disable(self._chrome_app, True) return Global.SUCCESS, "No errors"
def tear_down(self): """ End and dispose the test """ UseCaseBase.tear_down(self) # In case of failure, restore robot initial position self._robot_positioning("null", "null", self._reader_up, "null") # Put DUT in initial state if self._dut_state == "SCREEN_OFF": self._logger.info("Switch on the screen") self._io_card.press_power_button(0.1) elif self._dut_state == "PHONE_OFF": self._logger.info("Switch on the phone") self._device.switch_on() LabNfcBase.tear_down(self) return Global.SUCCESS, "No errors"
def set_up(self): """ Initialize the test """ LabNfcBase.set_up(self) self._pcd_antenna_x = self._nfc_robot_param.get_param_value( "PcdAntennaX") self._pcd_antenna_y = self._nfc_robot_param.get_param_value( "PcdAntennaY") self._pcd_antenna_up = self._nfc_robot_param.get_param_value( "PcdAntennaUp") self._pcd_antenna_down = self._nfc_robot_param.get_param_value( "PcdAntennaDown") # Check NFC tool in use is the NFC emulator if self._mp_manager.get_model() != "MP_MANAGER": raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "MP Manager must be used!") if self._secure_element not in ["EMBEDDED", "UICC"]: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "Unknown Secure element") if self._secure_element == "EMBEDDED": self._logger.info("Try to select embedded secure element") self._nfc_api.select_secure_element("com.nxp.smart_mx.ID") else: self._logger.info("Try to select UICC secure element") self._nfc_api.select_secure_element("com.nxp.uicc.ID") self._robot_positioning(self._pcd_antenna_x, self._pcd_antenna_y, "null", "null") # Put DUT on antenna self._robot_positioning("null", "null", self._pcd_antenna_down, "null") self._mp_manager.init() return Global.SUCCESS, "No errors"
def run_test(self): """ Execute the test """ LabNfcBase.run_test(self) # Put DUT on reader self._robot_positioning("null", "null", self._reader_down, "null") # Run program that sends APDU result = self._nfc_tool.exchange_apdu(self._protocol_type, self._bitrate, self._data_length, self._apdu_case, self._loop) # Remove DUT from reader self._robot_positioning("null", "null", self._reader_up, "null") if not result: raise DeviceException(DeviceException.OPERATION_FAILED, "Error during apdu exchange test") return Global.SUCCESS, "No errors"
def __init__(self, tc_name, global_config): """ Constructor """ LabNfcBase.__init__(self, tc_name, global_config) self._pcd_antenna_x = "0" self._pcd_antenna_y = "0" self._pcd_antenna_up = "0" self._pcd_antenna_down = "0" # Get PhoneSystem UECmdLayer self._phone_system_api = self._device.get_uecmd("PhoneSystem") # Get ContentOperate UECmdLayer self._contacts_api = self._device.get_uecmd("Contacts") self._screen_resolution = "" # Create NFC tool self._nfc_tool = self._em.get_nfc_tool("NFC_TOOL2") # Read P2P role from test case xml file self._role = \ str(self._tc_parameters.get_param_value("ROLE")) # Read P2P mode from test case xml file self._mode = \ str(self._tc_parameters.get_param_value("MODE")) # Read P2P bitrate from test case xml file self._bitrate = \ str(self._tc_parameters.get_param_value("BITRATE")) # Read P2P direction from test case xml file self._direction = \ str(self._tc_parameters.get_param_value("DIRECTION")) self._nfc_robot_param = global_config.benchConfig.get_parameters( "NFC_ROBOT1")
def __init__(self, tc_name, global_config): """ Constructor """ LabNfcBase.__init__(self, tc_name, global_config) self._pcd_antenna_x = "0" self._pcd_antenna_y = "0" self._pcd_antenna_up = "0" self._pcd_antenna_down = "0" # Create NFC software self._mp_manager = self._em.get_nfc_tool("NFC_TOOL4") # Get Secure element to communicate with from test case xml file self._secure_element = \ str(self._tc_parameters.get_param_value("SECURE_ELEMENT")) # Read script name from test case xml file self._script = str(self._tc_parameters.get_param_value("SCRIPT")) self._nfc_robot_param = global_config.benchConfig.get_parameters( "NFC_ROBOT1")
def set_up(self): LabNfcBase.set_up(self) self._robot_positioning('0', '0', '0', "null") return Global.SUCCESS, "No errors"
def set_up(self): """ Initialize the test """ LabNfcBase.set_up(self) # Check NFC tool in use is the NFC emulator if self._nfc_tool.get_model() != "NFC_EMULATOR": raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "NFC emulator must be used!") self._role = self._role.upper() self._mode = self._mode.upper() self._direction = self._direction.upper() # check parameter validity if self._role not in ["INITIATOR", "TARGET"]: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "Unknown P2P role") if self._mode not in ["ACTIVE", "PASSIVE"]: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "Unknown P2P mode") if self._bitrate not in ["106", "212", "424"]: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "Invalid bitrate") if self._direction not in ["SEND", "RECEIVE"]: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "Unknown P2P communication direction") if self._mode == "PASSIVE" and self._role == "INITIATOR": self._antenna_x = int( self._nfc_robot_param.get_param_value("PiccAntennaX")) self._antenna_y = int( self._nfc_robot_param.get_param_value("PiccAntennaY")) self._antenna_up = int( self._nfc_robot_param.get_param_value("PiccAntennaUp")) self._antenna_down = int( self._nfc_robot_param.get_param_value("PiccAntennaDown")) else: self._antenna_x = int( self._nfc_robot_param.get_param_value("PcdAntennaX")) self._antenna_y = int( self._nfc_robot_param.get_param_value("PcdAntennaY")) self._antenna_up = int( self._nfc_robot_param.get_param_value("PcdAntennaUp")) self._antenna_down = int( self._nfc_robot_param.get_param_value("PcdAntennaDown")) self._robot_positioning(self._antenna_x, self._antenna_y, "null", "null") # set P2P configuration self._nfc_api.set_nfc_p2p_configuration(self._mode, self._role, self._bitrate) self._screen_resolution = self._phone_system_api.get_screen_resolution( ) if self._direction == "RECEIVE": self._contacts_api.contact_all_delete() else: self._contacts_api.contact_insert( self._nfc_tool.CONTACT_EXPECTED_BY_EMULATOR) return Global.SUCCESS, "No errors"
def __init__(self, tc_name, global_config): LabNfcBase.__init__(self, tc_name, global_config) # second phone init self._phone_ref = DeviceManager().get_device( LabNfcDualPhoneBeamTransfert.REF_PHONE) self._phone_ref.connect_board() # Check if we have the ref phone available if self._phone_ref is not None: if not self._phone_ref.is_available(): DeviceManager().boot_device( LabNfcDualPhoneBeamTransfert.REF_PHONE) self._nfc_api_phone_ref = self._phone_ref.get_uecmd( "LocalConnectivity") # get PhoneSystem uecmd instance for the ref phone self._phonesystem_api_dut = self._device.get_uecmd("PhoneSystem") self._phonesystem_api_ref = self._phone_ref.get_uecmd("PhoneSystem") self._appmgmt_api = self._phone_ref.get_uecmd("AppMgmt") # get file uecmd instance self._file_api_dut = self._device.get_uecmd("File") self._file_api_ref = self._phone_ref.get_uecmd("File") # Get NFC Tags application package name self._tag_app = str(self._dut_config.get("TagsAppPackageName")) # Get Browsers application package name (need to disable in order to be able to read URI tags) self._browser_app = str(self._dut_config.get("BrowserAppPackageName")) self._chrome_app = str(self._dut_config.get("ChromeAppPackageName")) # force phone 2 state unlock and display on # for the DUT this is made in LiveNfcBase class self._phonesystem_api_ref.display_on() self._phonesystem_api_ref.set_phone_lock(0) self._nfc_api_phone_ref.force_nfc_state(1) # BE careful here we have to be sure that the file is here (setup embbeded) self.__file_to_share = str( self._tc_parameters.get_param_value("FILE_TO_SHARE")) self.__beam_duration = int( self._tc_parameters.get_param_value("BEAM_DURATION")) self.__direction = str( self._tc_parameters.get_param_value("DIRECTION")).upper() self._nfc_robot_param = global_config.benchConfig.get_parameters( "NFC_ROBOT1") self._beam_path = self._tc_parameters.get_param_value("BEAM_PATH") # get ref phone position self.__ref_phone_position = self._tc_parameters.get_param_value( "REF_PHONE_POSITION") self._tag_up = self._nfc_robot_param.get_param_value( self.__ref_phone_position + "Up") self._tag_down = self._nfc_robot_param.get_param_value( self.__ref_phone_position + "Down") self._tag_X = self._nfc_robot_param.get_param_value( self.__ref_phone_position + "X") # get the antenna position antenna_position = self._device.get_config("NfcAntennaPosition") self._tag_Y = str( int( self._nfc_robot_param.get_param_value( self.__ref_phone_position + "Y")) + int(antenna_position.split(",")[1]))
def tear_down(self): # move robot to start position self._robot_positioning(self._tag_X, self._tag_Y, self._tag_up, 'null') LabNfcBase.tear_down(self) return Global.SUCCESS, "No errors"
def run_test(self): LabNfcBase.run_test(self) # Put DUT away from the reader self._robot_positioning("null", "null", self._reader_up, "null") # Enable NFC self._nfc_api.nfc_enable() # Put DUT on reader self._robot_positioning("null", "null", self._reader_down, "null") # Check external reader detects the device if not self._gpshell.check_reader_connection(): msg = "Error: DUT with NFC ON over the reader -"\ + " NFC on but reader cannot detect/connect it" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) self._logger.info("DUT with NFC ON over the reader - Detected: Ok") # Put DUT away from the reader self._robot_positioning("null", "null", self._reader_up, "null") # Disable NFC self._nfc_api.nfc_disable() # Put DUT on reader self._robot_positioning("null", "null", self._reader_down, "null") # Check external reader cannot detect the device if self._gpshell.check_reader_connection(): msg = "Error: DUT with NFC OFF over the reader -"\ + " NFC on but reader cannot detect/connect it" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) self._logger.info( "DUT with NFC OFF over the reader - Not Detected: Ok") # Put DUT away from the reader self._robot_positioning("null", "null", self._reader_up, "null") # Switch off the phone self._device.switch_off() # Put DUT on reader self._robot_positioning("null", "null", self._reader_down, "null") # Check external reader cannot detect the device if self._gpshell.check_reader_connection(): msg = "Error: DUT with Power OFF over the reader -" \ + " NFC on but reader cannot detect/connect it" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) self._logger.info( "DUT with Power OFF over the reader - Not Detected: Ok") # Put DUT away from the reader self._robot_positioning("null", "null", self._reader_up, "null") # Switch on the phone error_code, error_msg = self._device.switch_on() if error_code != Global.SUCCESS: msg = "Error: DUT switch On [" + error_code + "] " + error_msg self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) # Put DUT on reader self._robot_positioning("null", "null", self._reader_down, "null") # Check external reader cannot detect the device if self._gpshell.check_reader_connection(): msg = "Error: DUT with Power ON over the reader -" \ + " NFC on but reader cannot detect/connect it" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) self._logger.info("DUT with Power ON (and NFC OFF) over the reader -" + " Not Detected: Ok") return Global.SUCCESS, "No errors"
def set_up(self): """ Initialize the test """ LabNfcBase.set_up(self) # air plane mode status if self.__flight_mode_status is not "APM_NONE": if self.__flight_mode_status == "APM_ONOFF_NFC_OFF": self._nfc_api.nfc_disable() self._logger.info("Turn flight mode ON") self._networking_api.set_flight_mode(1) if not self._networking_api.get_flight_mode(): msg = "Unable to activate flight mode" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) if self.__flight_mode_status == "APM_NFC_ON": self._logger.info("Activate NFC after turning flight mode ON") self._nfc_api.nfc_enable() if self.__flight_mode_status == "APM_ONOFF_NFC_ON": #reactivate self._logger.info("Turn flight mode OFF") self._networking_api.set_flight_mode(0) if self._record_type_description not in ("RTD_TEXT", "RTD_SP", "RTD_URI"): msg = "Set wrong RTD type. Could only be RTD_TEXT, RTD_SP or RTD_URI. " msg += "Read Value: " + self._data_to_write self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) # Get the time in seconds during which the Robot presents the NFC tag to the DUT self._read_max_duration = self._nfc_robot_param.get_param_value( "NfcReadTime", self._read_max_duration) self._write_max_duration = self._nfc_robot_param.get_param_value( "NfcWriteTime", self._write_max_duration) # Get the TAG coordinates if self._tag_type == "TOPAZ": tag_x = self._nfc_robot_param.get_param_value("TopazX") tag_y = self._nfc_robot_param.get_param_value("TopazY") self._tag_up = self._nfc_robot_param.get_param_value("TopazUp") self._tag_down = self._nfc_robot_param.get_param_value("TopazDown") elif self._tag_type == "MIFARE_ULTRALIGHT": tag_x = self._nfc_robot_param.get_param_value("MifareUltralightX") tag_y = self._nfc_robot_param.get_param_value("MifareUltralightY") self._tag_up = self._nfc_robot_param.get_param_value( "MifareUltralightUp") self._tag_down = self._nfc_robot_param.get_param_value( "MifareUltralightDown") elif self._tag_type == "MULC": tag_x = self._nfc_robot_param.get_param_value("MifareUltralightCX") tag_y = self._nfc_robot_param.get_param_value("MifareUltralightCY") self._tag_up = self._nfc_robot_param.get_param_value( "MifareUltralightCUp") self._tag_down = self._nfc_robot_param.get_param_value( "MifareUltralightCDown") elif self._tag_type == "FELICA": tag_x = self._nfc_robot_param.get_param_value("FelicaX") tag_y = self._nfc_robot_param.get_param_value("FelicaY") self._tag_up = self._nfc_robot_param.get_param_value("FelicaUp") self._tag_down = self._nfc_robot_param.get_param_value( "FelicaDown") elif self._tag_type == "DESFIRE_A": tag_x = self._nfc_robot_param.get_param_value("DesfireX") tag_y = self._nfc_robot_param.get_param_value("DesfireY") self._tag_up = self._nfc_robot_param.get_param_value("DesfireUp") self._tag_down = self._nfc_robot_param.get_param_value( "DesfireDown") elif self._tag_type == "TYPE4_B": tag_x = self._nfc_robot_param.get_param_value("Type4BX") tag_y = self._nfc_robot_param.get_param_value("Type4BY") self._tag_up = self._nfc_robot_param.get_param_value("Type4BUp") self._tag_down = self._nfc_robot_param.get_param_value( "Type4BDown") elif self._tag_type == "MIFARE_CLASSIC": tag_x = self._nfc_robot_param.get_param_value("MifareClassicX") tag_y = self._nfc_robot_param.get_param_value("MifareClassicY") self._tag_up = self._nfc_robot_param.get_param_value( "MifareClassicUp") self._tag_down = self._nfc_robot_param.get_param_value( "MifareClassicDown") elif self._tag_type == "MIFARE4K": tag_x = self._nfc_robot_param.get_param_value("MifareClassic4KX") tag_y = self._nfc_robot_param.get_param_value("MifareClassic4KY") self._tag_up = self._nfc_robot_param.get_param_value( "MifareClassic4KUp") self._tag_down = self._nfc_robot_param.get_param_value( "MifareClassic4KDown") elif self._tag_type == "LIBRARY_TAG": tag_x = self._nfc_robot_param.get_param_value("LibraryX") tag_y = self._nfc_robot_param.get_param_value("LibraryY") self._tag_up = self._nfc_robot_param.get_param_value("LibraryUp") self._tag_down = self._nfc_robot_param.get_param_value( "LibraryDown") elif self._tag_type == "CENTER": tag_x = self._nfc_robot_param.get_param_value("CenterX") tag_y = self._nfc_robot_param.get_param_value("CenterY") self._tag_up = self._nfc_robot_param.get_param_value("CenterUp") self._tag_down = self._nfc_robot_param.get_param_value( "CenterDown") else: msg = "Unknown tag type! Read value: " + self._tag_type self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) # disable "Tags" and browsers built-in apps if self._tag_app in ["None", ""]: msg = "NFC not available on this device!" self._logger.error(msg) raise AcsConfigException(AcsConfigException.FEATURE_NOT_AVAILABLE, msg) self._appmgmt_api.app_enable_disable(self._tag_app, False) self._appmgmt_api.app_enable_disable(self._browser_app, False) self._appmgmt_api.app_enable_disable(self._chrome_app, False) self._robot_positioning(tag_x, tag_y, "null", "null") return Global.SUCCESS, "No errors"
def set_up(self): """ Initialize the test """ LabNfcBase.set_up(self) # check parameter validity if self._dut_state not in ["UNLOCKED", "SCREEN_OFF", "PHONE_OFF"]: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "Unknown DUT's state") if self._secure_element not in ["EMBEDDED", "UICC"]: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "Unknown Secure element") if self._protocol_type not in ["A", "a", "B", "b"]: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "Unknown Protocol type") if self._apdu_case not in ["1", "2", "3", "4", "ALL"]: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "Unknown APDU case") if self._bitrate not in ["106", "212", "424"]: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "Invalid bitrate") if not self._data_length.isdigit() or int( self._data_length) < 1 or int(self._data_length) > 256: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "Invalid data length") self._data_length = int(self._data_length) if not self._loop.isdigit(): raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "Invalid loop parameter") self._loop = int(self._loop) if self._secure_element == "EMBEDDED": self._logger.info("Try to select embedded secure element") self._nfc_api.select_secure_element("com.nxp.smart_mx.ID") else: self._logger.info("Try to select UICC secure element") self._nfc_api.select_secure_element("com.nxp.uicc.ID") # put DUT in expected state : unlocked, screen off, phone off if self._dut_state == "SCREEN_OFF": self._logger.info("Switch off the screen") if self._phone_system_api.get_screen_status(): self._io_card.press_power_button(0.1) if self._phone_system_api.get_screen_status(): msg = "Screen should be switched off" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) elif self._dut_state == "PHONE_OFF": self._logger.info("Switch off the phone") self._device.hard_shutdown(False) # Check NFC tool in use and get target coordinates accordingly if self._nfc_tool.get_model() == "GPSHELL": self._reader_x = self._nfc_robot_param.get_param_value( "ExternalReaderX") self._reader_y = self._nfc_robot_param.get_param_value( "ExternalReaderY") self._reader_up = self._nfc_robot_param.get_param_value( "ExternalReaderUp") self._reader_down = self._nfc_robot_param.get_param_value( "ExternalReaderDown") elif self._nfc_tool.get_model() == "NFC_EMULATOR": self._reader_x = self._nfc_robot_param.get_param_value( "PcdAntennaX") self._reader_y = self._nfc_robot_param.get_param_value( "PcdAntennaY") self._reader_up = self._nfc_robot_param.get_param_value( "PcdAntennaUp") self._reader_down = self._nfc_robot_param.get_param_value( "PcdAntennaDown") else: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "Invalid NFC tool") # place DUT in front of reader self._robot_positioning(self._reader_x, self._reader_y, "null", "null") return Global.SUCCESS, "No errors"