def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) multimedia_path = self._device.multimedia_path address = self._pars.bdaddr # Split the file names and strip each of them file_list = split_and_strip(self._pars.files, Constants.FILE_NAME_SEPARATOR) fullpath_filenames, file_size = self._process_files( multimedia_path, file_list, False) self._api.bt_opp_clean_notification_list() self._save_file_size_if_needed(file_size, context) self._save_file_chksum_if_needed(multimedia_path, file_list, context) # Request for the First transfer to be registered self._api.bt_opp_send_file(fullpath_filenames, address)
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) cmd = "sdptool browse " + self._pars.name output = self._device.run_cmd(cmd, 20) control_string = "Browsing " + self._pars.name if self._pars.check_string and self._pars.check_string != "": if "'" in self._pars.check_string: if self._pars.check_string.replace("'", "\"") in output[1]: self.ts_verdict_msg = "VERDICT: The searched service is correctly found by the sdptool: {0}".format(self._pars.check_string) self._logger.debug(self.ts_verdict_msg) elif "Version" in self._pars.check_string: search1, search2 = self._pars.check_string.split("Version") if re.search(search1 + ".+" + search2, output[1]): self.ts_verdict_msg = "VERDICT: The searched service is correctly found by the sdptool: {0}".format(self._pars.check_string) self._logger.debug(self.ts_verdict_msg) else: self.ts_verdict_msg = "VERDICT: The sdptool did not find the given service listed for this device" raise DeviceException(DeviceException.OPERATION_FAILED, self.ts_verdict_msg) elif (not self._pars.check_string or self._pars.check_string == "") and control_string in output[1]: self.ts_verdict_msg = "VERDICT: The service list is correctly found by the sdptool: {0}".format(output[1]) self._logger.debug(self.ts_verdict_msg) else: self.ts_verdict_msg = "VERDICT: The sdptool did not find any services listed for this device" raise DeviceException(DeviceException.OPERATION_FAILED, self.ts_verdict_msg) self._logger.debug(self.ts_verdict_msg)
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) power = str(self._pars.power).lower() # # Get the power sequence (it might just be one single operation) power_sequence = split_and_strip(power, self.STR_SEPARATOR) for current in power_sequence: assert current in [TestConst.STR_ON, TestConst.STR_OFF], \ "passed value (%s) is invalid at this stage" % current self._logger.info("Power %s the Bluetooth adapters" % current) self._api.set_bt_power(current) state_bt = self._api.get_bt_power_status() if (current == TestConst.STR_ON) and (state_bt != str( BT_STATE.STATE_ON)): self._raise_device_exception("set BT ON failure") if (current == TestConst.STR_OFF) and (state_bt != str( BT_STATE.STATE_OFF)): self._raise_device_exception("set BT OFF failure")
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ BtBase.run(self, context) assert self._pars.must_find in [True, False], \ "MUST_FIND (%s) value should have been checked by the framework" % self._pars.must_find try: device_found = self._api.bt_find_device(self._pars.device_to_find) if not device_found and self._pars.must_find is True: msg = "Device %s not found" % self._pars.device_to_find self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) elif device_found and self._pars.must_find is False: msg = "Device %s found" % self._pars.device_to_find self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) except DeviceException as acs_exception: if self._pars.must_find is None: self._logger.debug("Error/Timeout on scan devices") else: raise
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) bd_address = str(self._pars.bdaddr) class_to_browse = str(self._pars.class_to_browse) # Because optional if class_to_browse is None: class_to_browse = "" self._logger.info("Browse service class '{0}' on device {1}".format( class_to_browse, bd_address)) status, bt_dev = self._api.bt_service_browsing( bd_address=bd_address, class_to_browse=class_to_browse) if bt_dev is not None and isinstance(bt_dev, BluetoothDevice): context.set_nested_info([self._pars.save_as, "ADDRESS"], bt_dev.address) context.set_nested_info([self._pars.save_as, "NAME"], bt_dev.name) context.set_nested_info([self._pars.save_as, "BONDED"], bt_dev.bonded) context.set_nested_info([self._pars.save_as, "INTERFACE"], bt_dev.interface) # format list a test step parameter style uuids_list_step_style = TestStepParameters.LIST_KEYWORD.join( bt_dev.uuids) context.set_nested_info([self._pars.save_as, "UUID"], uuids_list_step_style)
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) power = str(self._pars.power).lower() # # Get the power sequence (it might just be one single operation) power_sequence = split_and_strip(power, self.STR_SEPARATOR) for current in power_sequence: assert current in [TestConst.STR_ON, TestConst.STR_OFF], \ "passed value (%s) is invalid at this stage" % current self._logger.info("Power %s the Bluetooth tethering" % current) self._api.set_bt_tethering_power(current) if current == TestConst.STR_ON and self._api.get_bt_tethering_power( ) != True: self._raise_device_exception("set BT tethering ON failure") if current == TestConst.STR_OFF and self._api.get_bt_tethering_power( ) != False: self._raise_device_exception("set BT tethering OFF failure")
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) self._api.bt_opp_clean_notification_list() self._remove_files_if_needed()
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) # # Get the BT address and post it in the context address = self._api.get_bt_adapter_address() context.set_info(self._pars.save_as, address)
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) if self._bt_ui_actions.bt_refresh_scan_ui(): self._bt_ui_actions.bt_wait_for_scan_end() self._bt_ui_actions.bt_look_for_device_in_list( self._pars.device_name_to_find)
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) profile = self._pars.profile if profile == self._PBAP_PROFILE: self._bt_ui_actions.bt_pbap_allow_contact_sharing( self._pars.fail_if_already, self._pars.must_exist)
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ BtBase.run(self, context) self._bt_obj = BluetoothConnectivity(self._device, 15) self._phone2 = DeviceManager().get_device( BtFindDeviceBypass.STR_PHONE2) self._bt_api2 = self._phone2.get_uecmd( BtFindDeviceBypass.STR_LOCAL_CONN) assert self._pars.must_find in [True, False], \ "MUST_FIND (%s) value should have been checked by the framework" % self._pars.must_find self._bt_obj.search_for_device_until_found(self._api, self._bt_api2, self._pars.device_to_find, self._pars.must_find)
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) if self._pars.timeout is None: self._pars.timeout = 0 # Start Opp server if self._pars.status == "enable": self._api.bt_start_opp_server() if self._pars.status == "disable": self._api.bt_stop_opp_server()
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) self._bt_ui_actions._bt_open_pairing_menu(self._pars.device_name) if self._pars.enable is None or self._pars.enable is True: self._enable() else: self._disable() self._bt_ui_actions._bt_dismiss_pairing_menu(self._pars.enable)
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) if self._pars.mode is None: self._pars.mode = Constants.DISCOVERABLE_BOTH if self._pars.timeout is None: self._pars.timeout = 0 # # Does it make sense to have mode default = both? self._api.set_bt_discoverable(self._pars.mode, int(self._pars.timeout))
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) if self._pars.timeout is not None: timeout = self._pars.timeout else: timeout = self.DEFAULT_TIMEOUT # Split the file names and strip each of them file_list = split_and_strip(self._pars.files, Constants.FILE_NAME_SEPARATOR) self._api.bt_opp_cancel_send()
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) # Collects pairing arguments defaulting the non passed ones config = PairingConfig(self._pars) # Pair the DUT with the device pair_result = self._api.pair_to_device(config.address, config.reconnect, config.accept, config.pincode, config.passkey) if pair_result[0] == BT_BOND_STATE.BOND_NONE: if config.accept: self._raise_device_exception("Pairing with device failed") else: return_msg = "Pairing with device rejected" self._ts_verdict_msg = return_msg self._logger.info(return_msg) return if pair_result[0] == BT_BOND_STATE.BOND_BONDED: if config.accept: return_msg = "Pairing with device succeeded" self._ts_verdict_msg = return_msg self._logger.info(return_msg) return else: self._raise_device_exception( "Pairing with device succeeded but it should not") self._raise_device_exception( "Unknown bond state returned by the device")
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ BtBase.run(self, context) assert self._pars.must_find in [True, False], \ "MUST_FIND (%s) value should have been checked by the framework" % self._pars.must_find all_devices_to_find = self._pars.devices_to_find.split(',') devices_found = self._api.bt_find_multi_devices(all_devices_to_find, self._pars.tries) if not devices_found and self._pars.must_find is True: msg = "At list one device is not found" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) elif devices_found and self._pars.must_find is False: msg = "At list one device is not found and it shouldn't" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg)
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) # Get the BT power status and post it in the context power_status = self._api.get_bt_power_status() if power_status == str(BT_STATE.STATE_ON): power_status = TestConst.STR_ON if power_status == str(BT_STATE.STATE_OFF): power_status = TestConst.STR_OFF context.set_info(self._pars.save_as, power_status) self.ts_verdict_msg = "VERDICT: %s stored as {0}".format( power_status) % self._pars.save_as self._logger.debug(self.ts_verdict_msg)
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) if self._pars.timeout is not None: timeout = self._pars.timeout else: timeout = self.DEFAULT_TIMEOUT # Split the file names and strip each of them file_list = split_and_strip(self._pars.files, Constants.FILE_NAME_SEPARATOR) if self._pars.expected_state == self._STATUS_ACCEPTED: if not opp_accept_file(self._api, file_list[0], timeout): msg = "remote device has not accepted the file on time" raise DeviceException(DeviceException.OPERATION_FAILED, msg) elif self._pars.expected_state == self._STATUS_CANCELED: if not opp_check_file_cancelled(self._api, file_list[0], timeout): msg = "remote device has not canceled the file on time" raise DeviceException(DeviceException.OPERATION_FAILED, msg) elif self._pars.expected_state == self._STATUS_WAITING_ACCEPT: if not opp_check_file_waiting_accept(self._api, file_list[0], timeout): if not opp_accept_file(self._api, file_list[0], timeout): msg = "remote device has not initiated the transfer on time" raise DeviceException(DeviceException.OPERATION_FAILED, msg) elif self._pars.expected_state == self._STATUS_NONE: if not opp_check_status_none(self._api, timeout): msg = "remote device has a status different than none for a type it should not consider" raise DeviceException(DeviceException.OPERATION_FAILED, msg)
def run(self, context): """ Runs the test step. The Accept command is implicitly included in the bt_opp_check_service command :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) if self._pars.timeout is not None: timeout = self._pars.timeout else: timeout = self.DEFAULT_TIMEOUT # Split the file names and strip each of them file_list = split_and_strip(self._pars.files, Constants.FILE_NAME_SEPARATOR) if not opp_accept_file(self._api, file_list[0], timeout): msg = "remote device has not accepted the file on time" raise DeviceException(DeviceException.OPERATION_FAILED, msg)
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) if self._pars.timeout is not None: timeout = self._pars.timeout else: timeout = self.DEFAULT_TIMEOUT # Split the file names and strip each of them file_list = split_and_strip(self._pars.files, Constants.FILE_NAME_SEPARATOR) self._api.bt_opp_reject_file() if not opp_check_file_cancelled(self._api, file_list[0], timeout): msg = "remote device has not rejected the file on time" raise DeviceException(DeviceException.OPERATION_FAILED, msg)
def _do_run(self, context): """ Executes the run logic """ BtBase.run(self, context) self._setup_timeout_value() self._logger.info( "File transfer is supposed to complete in %d seconds" % self._time_out) file_names = split_and_strip(self._pars.files, Constants.FILE_NAME_SEPARATOR) self._num_expected_files = len(file_names) self._logger.info("Expect to receive %d files" % self._num_expected_files) self._reach_expected_state() self._save_file_size_if_needed(context) self._save_file_chksum_if_needed(None, file_names, context) self._validate_throughput_if_needed()