def __init__(self, tc_name, global_config): """ Constructor """ # Call LiveBTBase init function LiveNfcBase.__init__(self, tc_name, global_config) UECmdTestTool.__init__(self, self.get_name(), self._logger, self._device) self.__fcts2test = list() self.__robot_fcts2test = list() self.__secure_element_fcts2test = list() self.__use_robot = str( self._tc_parameters.get_param_value("USE_ROBOT")) if self.__use_robot.lower() in ["1", "true", "yes", "ok"]: self.__use_robot = True else: self.__use_robot = False self.__use_secure_element = str( self._tc_parameters.get_param_value("USE_SECURE_ELEMENT")) if self.__use_secure_element.lower() in ["1", "true", "yes", "ok"]: self._secure_element = str( self._tc_parameters.get_param_value("SECURE_ELEMENT")) self.__use_secure_element = True else: self.__use_secure_element = False self.__start_time = time.time()
def run_test(self): """ Execute the test """ LiveNfcBase.run_test(self) # enable Beam NFC self._nfc_api.enable_nfc_beam() time.sleep(self._wait_btwn_cmd) # Compare beam status to the one desired is_beam_on = self._nfc_api.get_nfc_beam_status() if not is_beam_on: msg = "Unable to turn beam on" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) # disable Beam NFC self._nfc_api.disable_nfc_beam() time.sleep(self._wait_btwn_cmd) # Compare beam status to the one desired is_beam_on = self._nfc_api.get_nfc_beam_status() if is_beam_on: msg = "Unable to turn beam off" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) return Global.SUCCESS, "No errors"
def __init__(self, tc_name, global_config): """ Constructor """ LiveNfcBase.__init__(self, tc_name, global_config) # Get "Beam control check" from test case xml file (set ON, set OFF) self._beam_checked = self._get_beam_check_config()
def run_test(self): """ Execute the test """ LiveNfcBase.run_test(self) self._nfc_api.exchange_apdu_using_scapi(self._channel, self._reader, self._apdu_case, self._data_length, self._loop) return Global.SUCCESS, "No errors"
def __init__(self, tc_name, global_config): """ Constructor """ LiveNfcBase.__init__(self, tc_name, global_config) # Get URI name from TC parameters self.__uri = self._tc_parameters.get_param_value("URI") # Get UECmdLayer self._system_api = self._device.get_uecmd("System") self._key_event_api = self._device.get_uecmd("KeyEvent")
def set_up(self): """ Execute the test """ LiveNfcBase.set_up(self) # Get device logger instance self._device_logger = self._device.get_device_logger() # Add trigger messages to the device logger self._device_logger.add_trigger_message(self.__uri) self._device_logger.add_trigger_message( "android.nfc.action.NDEF_DISCOVERED") return Global.SUCCESS, "No errors"
def run_test(self): """ Execute the test """ # Call LiveNfcBase base run_test function LiveNfcBase.run_test(self) # Check every EUCmd for fct2test in self.__fcts2test + self.__robot_fcts2test + self.__secure_element_fcts2test: self._check_uecmd(fct2test) time.sleep(self._wait_btwn_cmd) # Raise an Exception in case of all tests do not pass self._compute_general_verdict() return Global.SUCCESS, "All UECmds OK"
def run_test(self): """ Execute the test """ LiveNfcBase.run_test(self) msg = "reading NFC tag successfully done : %s" % self.__uri verdict = Global.SUCCESS # Check for resolver activity if self._system_api.check_Activity("ResolverActivity"): count = 0 while self._system_api.check_Activity( "ResolverActivity") and count < 2: self._key_event_api.enter() time.sleep(self._wait_btwn_cmd) count += 1 if not self._system_api.check_Activity("ResolverActivity"): # Start to search the nfc tag discovering in the logcat log ndef_discovered = self._device_logger.get_message_triggered_status( "android.nfc.action.NDEF_DISCOVERED") uri_check = self._device_logger.get_message_triggered_status( self.__uri) self._key_event_api.home() if not ndef_discovered: msg = "NDEF discovering failure" verdict = Global.FAILURE if ndef_discovered and not uri_check: msg = "Bad NFC tag discovered expected : %s" % self.__uri verdict = Global.FAILURE else: msg = "Can't go over the 'choose application' pop-up" verdict = Global.FAILURE else: msg = "No tag discovered" verdict = Global.FAILURE return verdict, msg
def __init__(self, tc_name, global_config): """ Constructor """ LiveNfcBase.__init__(self, tc_name, global_config) # Get channel to use from test case xml file self._channel = \ str(self._tc_parameters.get_param_value("CHANNEL")) # Get reader to use from test case xml file self._reader = \ str(self._tc_parameters.get_param_value("READER")) # Get APDU case to use from test case xml file self._apdu_case = \ str(self._tc_parameters.get_param_value("APDU_CASE")) # Get data length to use from test case xml file self._data_length = \ int(self._tc_parameters.get_param_value("DATA_LENGTH")) # Get the number of commands to send to stress the system self._loop = \ int(self._tc_parameters.get_param_value("LOOP"))
def run_test(self): """ Execute the test """ LiveNfcBase.run_test(self) # enable NFC self._nfc_api.nfc_enable() time.sleep(self._wait_btwn_cmd) # If Beam to be checked if self._beam_used and self._beam_checked: is_beam_on = self._nfc_api.get_nfc_beam_status() # Compare beam status to the one set at the begining if is_beam_on != self._beam_wished_value: msg = "Unexpected result! Read beam value is %s instead of %s" % ( str(is_beam_on), str(self._beam_wished_value)) self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) # disable NFC self._nfc_api.nfc_disable() time.sleep(self._wait_btwn_cmd) # If Beam to be checked if self._beam_used and self._beam_checked: is_beam_on = self._nfc_api.get_nfc_beam_status() # Compare beam status to the one set at the begining if is_beam_on != self._beam_wished_value: msg = "Unexpected result! Read beam value is %s instead of %s" % ( str(is_beam_on), str(self._beam_wished_value)) self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) return Global.SUCCESS, "No errors"
def set_up(self): """ Initialize the test """ LiveNfcBase.set_up(self) UECmdTestTool.set_up(self, self.tc_order) self.__use_robot = str_to_bool(str(self.__use_robot)) """ List of tests to perform. Each test is described as followed: [Label to print in the secondary report, UECmd to test, parameter(s) for the UECmd to test, Depends on the test names in the list] """ nfc_api = self._nfc_api self.__fcts2test = [{ self._FCT: nfc_api.exchange_apdu_using_scapi, self._PARMS: ["BASIC", "SMX", "4", 255, 1] }, { self._FCT: nfc_api.get_nfc_beam_status }, { self._FCT: nfc_api.enable_nfc_beam }, { self._FCT: nfc_api.disable_nfc_beam }, { self._FCT: nfc_api.force_nfc_state, self._PARMS: ["1"] }, { self._FCT: nfc_api.nfc_touch_to_beam, self._PARMS: ["1024x768", "10"] }, { self._FCT: nfc_api.get_nfc_status }, { self._FCT: nfc_api.nfc_disable }, { self._FCT: nfc_api.nfc_enable }, { self._FCT: nfc_api.check_nfc_crash, self._PARMS: [self.__start_time] }, { self._FCT: nfc_api.set_default_nfc_p2p_configuration, self._DEP: ["nfc_enable"] }, { self._FCT: nfc_api.set_nfc_p2p_configuration, self._PARMS: ["passive", "target", "106"], self._DEP: ["nfc_enable"] }] if self.__use_robot is True: self.__robot_fcts2test = [{ self._FCT: nfc_api.read_nfc_tag }, { self._FCT: nfc_api.write_nfc_tag, self._PARMS: ["RTD_TEXT", "RANDOM"] }] if self.__use_secure_element is True: self.__secure_element_fcts2test = [{ self._FCT: nfc_api.select_secure_element, self._PARMS: [self._secure_element] }] return Global.SUCCESS, "No errors"
def __init__(self, tc_name, global_config): """ Constructor """ LiveNfcBase.__init__(self, tc_name, global_config)