def run_test(self): """ Execute the test """ # Call UseCase base run_test function LiveBTBase.run_test(self) start = time.time() while (start + self._duration) > time.time(): self._bt_api.set_bt_power(1) time.sleep(self._wait_btwn_cmd) self._check_bt_wifi_state(str(BT_STATE.STATE_ON), 0) self._networking_api.set_wifi_power(1) time.sleep(self._wait_btwn_cmd) self._check_bt_wifi_state(str(BT_STATE.STATE_ON), 1) self._bt_api.set_bt_power(0) time.sleep(self._wait_btwn_cmd) self._check_bt_wifi_state(str(BT_STATE.STATE_OFF), 1) self._networking_api.set_wifi_power(0) time.sleep(self._wait_btwn_cmd) self._check_bt_wifi_state(str(BT_STATE.STATE_OFF), 0) return Global.SUCCESS, "No errors"
def run_test(self): """ Execute the test """ # Call UseCase base run_test function LiveBTBase.run_test(self) # Switch flight mode self._networking_api.set_flight_mode(1) time.sleep( LabBTAndWiFiReconnectionAfterFlightMode.WAIT_TIME_IN_FLIGHT_MODE) self._networking_api.set_flight_mode(0) time.sleep(LabBTAndWiFiReconnectionAfterFlightMode. WAIT_BT_WIFI_AUTO_RECONNECTION) # Check BT connection bt_state = self._bt_api.get_bt_connection_state( self._bt_headset.get_bdaddress(), BtProfile.A2DP) if bt_state != BtConState.d[BtConState.CONNECTED]: msg = "Error BT reconnection - State %s" % str(bt_state) self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) # Check WiFi connection packet_loss = self._networking_api.ping(self._wifi_ip, 16, 16) if packet_loss.value > LabBTAndWiFiReconnectionAfterFlightMode.MAX_PING_PACKET_LOST: msg = "Error WiFi reconnection - Ping %s fail with %s lost" % self._wifi_ip % packet_loss self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) return Global.SUCCESS, "No errors"
def run_test(self): """ Execute the test """ # Call UseCase base run_test function LiveBTBase.run_test(self) time.sleep(self._wait_btwn_cmd) # begin bluetooth turn on off sequence self._logger.info("bluetooth turn on off sequence is :" + self._turn_bluetooth_sequence) time.sleep(self._wait_btwn_cmd) seqlist = self._turn_bluetooth_sequence.strip().split() for switch in seqlist: if switch.lower() in ("on", "1", 1): self._logger.info("try to turn on bluetooth") self._bt_api.set_bt_power("1") time.sleep(self._wait_btwn_cmd) elif switch.lower() in ("off", "0", 0): self._logger.info("try to turn off bluetooth ") self._bt_api.set_bt_power("0") time.sleep(self._wait_btwn_cmd) else: self._error.Code = Global.FAILURE self._error.Msg = \ "input wrong sequence , failed ." \ + "alter your sequence in test case xml file" return self._error.Code, self._error.Msg
def run_test(self): """ As of right now, at the beginning of the RUN part, we have connected the 2 phones in a PAN-NAP way and we are also connected to the internet. """ LiveBTBase.run_test(self) # Handle External connection (WIFI or CELLULAR) self._bluetooth_connectivity_obj.handle_external_connection(self._connection_to_share, self._networking_api, self.__global_config, self._wifi_access_point) time.sleep(self._wait_btwn_cmd) #turn airplane mode ON self._networking_api.set_flight_mode(1) time.sleep(BluetoothPanAirplane.WAIT_TIME_IN_FLIGHT_MODE) #check BT, BT Tethering and Wifi are deactivated #check BT status is OFF time.sleep(self._wait_btwn_cmd) bt_power_air_on = self._bt_api.get_bt_power_status() if bt_power_air_on != str(BT_STATE.STATE_OFF): msg = "After setting Airplane mode to ON, Bluetooth is still ON. Expected state is OFF." \ "the actual state is: " + bt_power_air_on raise DeviceException(DeviceException.OPERATION_FAILED, msg) #check BT tethering is turned off if self._bt_api.get_bt_tethering_power_status() != str(BT_STATE.STATE_OFF): msg = "After setting Airplane mode to ON, Bluetooth TETHERING is still ON. Expected state is OFF." raise DeviceException(DeviceException.OPERATION_FAILED, msg) #check Wifi status is OFF if self._networking_api.get_wifi_power_status == 1: msg = "After setting Airplane mode to ON, WIFI is still ON. Expected state is OFF." raise DeviceException(DeviceException.OPERATION_FAILED, msg) #turn airplane mode OFF self._networking_api.set_flight_mode(0) time.sleep(BluetoothPanAirplane.WAIT_TIME_IN_FLIGHT_MODE) #check BT, BT Tethering and Wifi are reactivated #check BT status is ON time.sleep(self._wait_btwn_cmd) #locally initialize phone for PAN - turn tethering ON self._bt_api.set_bt_tethering_power("on") bt_power_air_off = self._bt_api.get_bt_power_status() if bt_power_air_off != str(BT_STATE.STATE_ON): msg = "After setting Airplane mode to OFF, Bluetooth is still OFF. Expected state is ON." \ "the actual state is: " + bt_power_air_off raise DeviceException(DeviceException.OPERATION_FAILED, msg) #check BT tethering is turned ON if self._bt_api.get_bt_tethering_power_status() != str(BT_STATE.STATE_ON): msg = "After setting Airplane mode to OFF, Bluetooth TETHERING is still OFF. Expected state is ON." raise DeviceException(DeviceException.OPERATION_FAILED, msg) #check Wifi status is ON if self._networking_api.get_wifi_power_status == 1: msg = "After setting Airplane mode to OFF, WIFI is still OFF. Expected state is ON." raise DeviceException(DeviceException.OPERATION_FAILED, msg) return Global.SUCCESS, "Usecase successful"
def run_test(self): """ Execute the test """ # Call UseCase base run_test function LiveBTBase.run_test(self) # Configure threads if self._wifi_activity == "WIFI_WEB_BROWSING": self._thread_wifi_activity = ThreadWebBrowsing(self._queue, self._networking_api, self._duration, self._wifi_url) elif self._wifi_activity == "WIFI_FTP_DOWNLOAD": self._thread_wifi_activity = ThreadDownloadFileFromFTP(self._queue, self._networking_api, self._server_ip_address, self._username, self._password, self._ftp_remote_file, self._ftp_path, str(self._device.get_ftpdir_path()), self._timeout) else: msg = "Unknown WIFI_ACTIVITY : %s" % self._wifi_activity self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if self._a2dp_activity == "A2DP_CHECK_AUDIO": self._thread_a2dp_activity = ThreadA2DPCheckMusic(self._queue, BtAudioState.PLAYING, self._duration, self._bt_api, self._bt_headset_addr) elif self._a2dp_activity == "A2DP_SWITCH_VOLUME": self._thread_a2dp_activity = ThreadA2DPSwitchVolume(self._queue, self._duration, self._bt_api, self._bt_headset) elif self._a2dp_activity == "A2DP_SWITCH_SONG": self._thread_a2dp_activity = ThreadA2DPSwitchSong(self._queue, self._duration, self._bt_api, self._bt_headset) elif self._a2dp_activity == "A2DP_SWITCH_PLAYING": self._thread_a2dp_activity = ThreadA2DPSwitchPlaying(self._queue, BtAudioState.PLAYING, self._duration, 1.0, self._bt_api, self._bt_headset) else: msg = "Unknown A2DP_ACTIVITY : %s" % self._a2dp_activity self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) # Launch threads self._thread_wifi_activity.start() self._thread_a2dp_activity.start() time.sleep(self._wait_btwn_cmd) # This function waits all threads are dead or timeout is over before finish self._exception_reader(self._queue, [self._thread_wifi_activity, self._thread_a2dp_activity]) return Global.SUCCESS, "No errors"
def run_test(self): """ Execute the test """ # Call UseCase base run_test function LiveBTBase.run_test(self) time.sleep(self._wait_btwn_cmd) # begin APM turn on off sequence self._logger.info("Airplane mode sequence is :" + self._turn_apm_sequence) time.sleep(self._wait_btwn_cmd) self._turn_apm_sequence = self._turn_apm_sequence.lower() seqlist = self._turn_apm_sequence.strip().split() # pylint: disable=E1101 for switch in seqlist: if switch.lower() in ("flight", "on", "1"): self._logger.info("try to set airplane mode to flight mode") self._networking_api.set_flight_mode(1) # CHeck BT is switched off if not self._bt_api.bt_power_state_reached( str(BT_STATE.STATE_OFF), self._bt_getmode_timeout): msg = "set BT OFF failure" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) elif switch.lower() in ("normal", "off", "0"): self._logger.info("try to set airplane mode to normal mode") self._networking_api.set_flight_mode(0) # CHeck BT is coming back to power state before flight mode if not self._bt_api.bt_power_state_reached( self._initial_bt_state, self._bt_getmode_timeout): msg = "switch BT back to previous state failure" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) else: msg = "input wrong sequence, failed. " \ + "Alter your sequence in test case xml file" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) return Global.SUCCESS, "No errors"
def run_test(self): """ Execute the test """ # pylint: disable=E1101 # Call UseCase base run_test function LiveBTBase.run_test(self) self._connect_profile() self._raise_error_if_already_playing() self._start_media_player() try: self._do_run_test() finally: self._bt_api.stop_a2dp_media_player() self._disconnect_profile() return Global.SUCCESS, "No errors"
def run_test(self): """ Execute the test """ # Call UseCase base run_test function LiveBTBase.run_test(self) self._logger.info("bluetooth tethering turn on off sequence is :" + self._turn_bt_tethering_sequence) # begin bluetooth tethering turn on off sequence seqlist = self._turn_bt_tethering_sequence.split() for switch in seqlist: if switch in ("ON", "1"): # Turn ON BT Tethering self._logger.info("try to turn on bluetooth tethering") self._bt_api.set_bt_tethering_power("1") time.sleep(self._wait_btwn_cmd) # Check BT interface activation by ACS_Agent if self._bt_initial_state == False and \ self._bt_api.get_bt_power_status() != "STATE_ON": msg = "BT interface has not been activated" \ + " while BT tethering activation" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) elif switch in ("OFF", "0"): # Turn OFF BT Tethering self._logger.info("try to turn off bluetooth tethering") self._bt_api.set_bt_tethering_power("0") time.sleep(self._wait_btwn_cmd) else: msg = "Wrong input sequence. " \ + "Change your sequence in test case xml file: " \ + self._turn_bt_tethering_sequence self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) return Global.SUCCESS, "No errors"
def run_test(self): """ Execute the test """ # Call UseCase base run_test function LiveBTBase.run_test(self) # Configure BT Scan self._thread_bt_scan = ThreadScanBTRemoteDevice(self._queue, self._bt_api, self._ref_bt_addr, self._duration) # Configure A2DP check music self._thread_headset_check_music = ThreadA2DPCheckMusic(self._queue, BtAudioState.PLAYING, self._duration, self._bt_api, self._bt_headset_addr) # Launch threads self._thread_headset_check_music.start() self._thread_bt_scan.start() time.sleep(self._wait_btwn_cmd) self._exception_reader(self._queue, [self._thread_bt_scan, self._thread_headset_check_music]) return Global.SUCCESS, "No errors"
def run_test(self): """ Execute the test """ LiveBTBase.run_test(self) time.sleep(self._wait_btwn_cmd) # Split to create a list of BD-ADDR in case of multiple search bd_addr_list = self._device_to_search.strip().split(";") for bdaddr in bd_addr_list: # Remove leading and trailing whitespace bdaddr = str(bdaddr).strip() # start scan , and find specific device self._logger.info("Looking for " + bdaddr) if not self._bt_api.bt_find_device(bdaddr): msg = "Device %s not found" % bdaddr self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) return Global.SUCCESS, "No errors"