def run_test(self): """ Execute the test """ # Call UseCase base run_test function LiveDualPhoneBTBase.run_test(self) # Set screen always on and unlock phone (Since LLP , DUT need to be unlocked to be visible) self._phone_system_api.set_phone_screen_lock_on("on") self._phone_system_api.set_phone_lock(0) if self._dis_mode in ("on", "1"): self._bt_api.\ set_bt_discoverable('both', 0) elif self._dis_mode in ("off", "0"): self._bt_api.\ set_bt_discoverable('none', 0) else: msg = "Set wrong dis_mode. could only be on(1) or off(0)" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) # Remove pairing from DEVICE_BT_ADDRESS time.sleep(self._wait_btwn_cmd) if (self._dis_mode in ("on", "1") and not self._bt_api2.bt_find_device(self._phone1_addr)) or \ (self._dis_mode in ("off", "0") and self._bt_api2.bt_find_device(self._phone1_addr)): msg = "phone in wrong discoverable mode" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) return Global.SUCCESS, "No errors"
def run_test(self): """ Execute the test """ LiveDualPhoneBTBase.run_test(self) # If necessary, remove the file on the destination device self._receiver_api.bt_opp_init(self._filename) # Clean the notification list self._receiver_api.bt_opp_clean_notification_list() self._sender_api.bt_opp_clean_notification_list() # Request for the First transfer to be registered self._logger.info("Start sending file %s" % self._fullpath_filename) self._sender_api.bt_opp_send_file(self._fullpath_filename, self._receiver_add) # Wait for the transfer First to started self._wait_for_transfer("downloading", self._receiver_api, self._sender_add, self.TIME_OUT) # Cancel the transfer self._logger.info("Cancel file transfer") self._sender_api.bt_opp_cancel_send() # Wait for the transfer state to be cancelled self._wait_for_transfer("cancelled", self._receiver_api, self._sender_add, self.TIME_OUT) # Send the file again self._logger.info("Start sending file %s again" % self._fullpath_filename) self._sender_api.bt_opp_send_file(self._fullpath_filename, self._receiver_add) # Wait for the transfer to be complete self._wait_for_transfer("downloaded", self._receiver_api, self._sender_add, self._timeout) # bt_opp_get_files_checksum wants a list, but there's only one file # so put it into a list file_list = [self._filename] source_path = self._multimedia_path1 if self._direction.upper() == "UL" \ else self._multimedia_path2 source_files = self._sender_api.bt_opp_get_files_checksum( source_path, file_list) dest_files = self._receiver_api.bt_opp_get_files_checksum( None, file_list) # Check the file matches on the RX phone self._logger.info("Compare file checksum on sender and receiver") if not source_files == dest_files: msg = "The file hasn't been received or it doesn't match the sent one" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) return Global.SUCCESS, "No errors"
def run_test(self): """ Execute the test """ # Call LiveDualPhoneBTBase base run_test function LiveDualPhoneBTBase.run_test(self) # Check every EUCmd for fct2test in self._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 """ # Call UseCase base run_test function LiveDualPhoneBTBase.run_test(self) # BT Tethering Connection if not self._lola_test: connect_to_nap(self._panu_api, self._nap_api, self._nap_addr, self._who_restarts_bt, self._wait_btwn_cmd) else: self._logger.info("Sleeping 60 seconds") time.sleep(60) # Check connection with ping command packet_loss = self._panu_net_api.ping(self._server_to_ping, self._packet_size, self._packet_count) msg = "Measured Packet Loss: %.0f%s (Target: %.0f%s)" \ % (packet_loss.value, packet_loss.units, self._target_packet_loss_rate, packet_loss.units) self._logger.info(msg) if packet_loss.value > self._target_packet_loss_rate: msg = "Ping packet loss is not acceptable [%s]" \ % str(packet_loss.value) self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) # BT Tethering Disconnection if not self._lola_test: self.__disconnect() return (Global.SUCCESS, "BT Tethering ping %s OK" % self._server_to_ping)
def run_test(self): """ Execute the test """ LiveDualPhoneBTBase.run_test(self) # Flush bt scanned devices list. # Doing so makes sure if the DUT is in the list is because it's been found now self._bt_api2.flush_bt_scanned_devices() if self._discov_mode in ("on", "1"): # step 1: Enable discoverable mode start_time = int(time.time()) self._bt_api.set_bt_discoverable('both', self._discov_timeout) start_time2 = math.ceil(time.time()) delta_time = 1 if self._discov_timeout != 0: self._logger.info( "Start waiting for the end of %d sec timeout" % self._discov_timeout) # step 2: time < timeout, Check DUT is visible by 2nd phone while delta_time < self._discov_timeout: time.sleep(1) if not delta_time % 20: self._logger.info( "timeout in %d sec" % int(self._discov_timeout - delta_time)) if ((not delta_time % 50) and (delta_time < self._discov_timeout) and (not self._bt_api2.bt_find_device(self._phone1_addr))): msg = "DUT is not visible" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) delta_time = math.ceil(time.time() - start_time) # step 3: time > timeout, Check DUT no more visible delta_time = int(time.time() - start_time2) while delta_time < self._discov_timeout: time.sleep(1) delta_time = math.ceil(time.time() - start_time2) # Before scanning again (and expecting not to find the device) # flush bt scanned devices list. # Doing so makes sure if the DUT is in the list is because it's been found now self._bt_api2.flush_bt_scanned_devices() if self._bt_api2.bt_find_device(self._phone1_addr): msg = "DUT is still visible" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) else: # Set screen always on and unlock phone (Since LLP , DUT need to be unlocked to be visible) self._phone_system_api.set_phone_screen_lock_on("on") self._phone_system_api.set_phone_lock(0) max_time = 300 self._logger.info("timeout is to never") self._logger.info("Start waiting for %d sec" % max_time) # timeout = 0 equals never timeout # step 2: time < 5min, Check DUT is visible by 2nd phone while int(delta_time) < max_time: time.sleep(1) delta_time = int(time.time() - start_time) if not int(delta_time) % 20: self._logger.info("end of wait = %d sec" % int(max_time - delta_time)) if ((not delta_time % 50) and (not self._bt_api2.bt_find_device(self._phone1_addr))): msg = "DUT is not visible" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) # Before scanning again (and expecting to find the device) # flush bt scanned devices list. # Doing so makes sure if the DUT is in the list is because it's been found now self._bt_api2.flush_bt_scanned_devices() # step 3: Check after 5minutes that DUT is still visible if not self._bt_api2.bt_find_device(self._phone1_addr): msg = "DUT is not visible" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) elif self._discov_mode in ("off", "0"): self._bt_api.set_bt_discoverable('none', 0) time.sleep(self._wait_btwn_cmd) if self._bt_api2.bt_find_device(self._phone1_addr): msg = "phone in wrong discoverable mode" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) return Global.SUCCESS, "No errors"
def run_test(self): """ Execute the test """ LiveDualPhoneBTBase.run_test(self) # If necessary, remove the file on the destination device self._file_cleanup() # Clean the notification list self._receiver_api.bt_opp_clean_notification_list() self._sender_api.bt_opp_clean_notification_list() # Request for the First transfer to be registered self._sender_api.bt_opp_send_file(self._fullpath_filenames, self._receiver_add) # Process the bidirectional transfer if self._is_bidirectional: # Wait for the transfer start self._wait_for_transfer("downloading", self._receiver_api, self._sender_add, True, self._timeout1) # Request for the second transfer to be registered self._receiver_api.bt_opp_send_file(self._fp_filename_other_dir, self._sender_add) # Wait for the transfer First to complete self._wait_for_transfer("downloaded", self._receiver_api, self._sender_add, False, self._timeout1) # Process the bidirectional transfer if self._is_bidirectional: # Wait for the second transfer to complete self._wait_for_transfer("downloaded", self._sender_api, self._receiver_add, False, self._timeout2) self._logger.info( "Compare files' checksum on RX phone with the sent ones") self._check_files_checksum( self._sender_api, self._multimedia_path1, self._receiver_api, "Received files on RX phone are different from Sent ones" " (or don't exist)") if self._is_bidirectional in ["1", "yes", "true"]: self._logger.info( "Compare files' checksum on TX phone with the sent ones") self._check_files_checksum( self._receiver_api, self._multimedia_path2, self._sender_api, "Received files on TX phone are different from Sent ones" " (or don't exist)") # Throughput measurement if self._tp_enable: # Compare average throughput with Threshold self._compare_tp_threshold() # Reset self._tp_meas value in case of multiple b2bIteration. self._reset_tp_meas(self._file_list, self._direction, self._is_bidirectional) return Global.SUCCESS, "No errors"
def run_test(self): """ Execute the test """ # Call UseCase base run_test function LiveDualPhoneBTBase.run_test(self) # pair two phones device_found = False # Prepare remote device to respond to pairing request self._bt_api2.wait_for_pairing(self._phone1_addr, 1, 1) time.sleep(self._wait_btwn_cmd) # pair two devices self._bt_api.pair_to_device(self._phone2_addr, 1) time.sleep(self._wait_btwn_cmd) list_paired_devices = \ self._bt_api.list_paired_device() for element in list_paired_devices: if str(element.address).upper() == str(self._phone2_addr).upper(): device_found = True if not device_found: msg = "Connect to device %s failed" % self._phone2_addr self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) # connect and send message self._logger.info("Message to send is : " + self._message) time.sleep(self._wait_btwn_cmd) if self._direction == self.STR_SEND: self._logger.info("Start receiving msg") self._bt_api2.bt_receive_msg() time.sleep(self._wait_btwn_cmd) self._logger.info("Start sending msg") self._bt_api.bt_send_msg(self._phone2_addr, self._message) elif self._direction == self.STR_RECEIVE: self._logger.info("Start receiving msg") self._bt_api.bt_receive_msg() time.sleep(self._wait_btwn_cmd) self._logger.info("Start sending msg") self._bt_api2.bt_send_msg(self._phone1_addr, self._message) # check message time.sleep(self._wait_btwn_cmd) self._logger.info("Start checking msg") if self._direction == self.STR_SEND: self._bt_api2.bt_check_msg(self._message) else: self._bt_api.bt_check_msg(self._message) self._logger.info("Message received successfully") # Unpair both devices time.sleep(self._wait_btwn_cmd) self._logger.info("Unpair both devices") self._bt_api.unpair_bt_device(self._phone2_addr) self._bt_api2.unpair_bt_device(self._phone1_addr) time.sleep(self._wait_btwn_cmd) return (Global.SUCCESS, "Pairing to device %s success" % self._phone2_addr)