def test_a2dp_streaming_toggle_screen_state_with_fping(self): """Starts fping along with a2dp streaming. This test is to start fping with traffic between host machine and android device and test the functional behaviour of a2dp streaming when screen turned on or off. Steps: 1. Start fping. 2. Start media play on android device and check for music streaming. 3. Start screen on/off of android device multiple times. Returns: True if successful, False otherwise. Test Id: Bt_CoEx_080 """ tasks = [(start_fping, (self.pri_ad, self.iperf["duration"], self.fping_drop_tolerance)), (music_play_and_check, (self.pri_ad, self.audio_receiver.mac_address, self.music_file_to_play, self.iperf["duration"])), (toggle_screen_state, (self.pri_ad, self.iterations))] if not multithread_func(self.log, tasks): return False return True
def test_hfp_call_toggle_screen_state_with_fping(self): """Starts fping with hfp call connection. This test is to start fping between host machine and android device and test the functional behaviour of hfp call when toggling the screen state. Steps: 1. Start fping from AP backend. 1. Initiate call from primary device headset to secondary device. Returns: True if successful, False otherwise. Test Id: Bt_CoEx_081 """ tasks = [(start_fping, (self.pri_ad, self.iperf["duration"], self.fping_drop_tolerance)), (initiate_disconnect_from_hf, ( self.audio_receiver, self.pri_ad, self.sec_ad, self.iperf["duration"])), (toggle_screen_state, (self.pri_ad, self.iterations))] if not multithread_func(self.log, tasks): return False return True
def test_bluetooth_discovery_with_fping(self): """Starts fping, along with bluetooth discovery. This test is to start fping between host machine and android device and test functional behaviour of bluetooth discovery. Steps: 1. Start fping on background. 2. Enable bluetooth. 3. Start bluetooth discovery. 4. Repeat step 3 for n iterations. Returns: True if successful, False otherwise. Test Id: Bt_CoEx_071 """ tasks = [(start_fping, (self.pri_ad, self.iperf["duration"], self.fping_params)), (perform_classic_discovery, (self.pri_ad, self.iperf["duration"], self.json_file, self.dev_list))] if not multithread_func(self.log, tasks): return False return True
def test_connect_disconnect_headset_toggle_screen_state_with_fping(self): """Starts fping along with connection and disconnection of the headset. This test is to start fping between host machine and android device and test the functional behaviour of connection and disconnection of the paired headset when screen is off and on. Steps: 1. Start fping. 2. Connect bluetooth headset. 4. Disconnect bluetooth headset. 5. Screen on/off. Returns: True if successful, False otherwise. Test Id: Bt_CoEx_079 """ tasks = [(start_fping, (self.pri_ad, self.iperf["duration"], self.fping_drop_tolerance)), (self.connect_disconnect_headset, ()), (toggle_screen_state, (self.pri_ad, self.iterations))] if not multithread_func(self.log, tasks): return False return True
def initiate_call_from_hf_bt_discovery_with_iperf(self): """Wrapper function to start iperf, initiate call and perform classic discovery. """ self.run_iperf_and_get_result() tasks = [(initiate_disconnect_from_hf, ( self.audio_receiver, self.pri_ad, self.sec_ad, self.iperf["duration"])), (perform_classic_discovery, (self.pri_ad,))] if not multithread_func(self.log, tasks): return False return self.teardown_result()
def music_streaming_avrcp_controls_with_iperf(self): """Wrapper function to start iperf traffic, music streaming and avrcp controls. """ self.run_iperf_and_get_result() tasks = [(music_play_and_check, (self.pri_ad, self.adapter_mac_address, self.music_file_to_play, self.iperf["duration"])), (avrcp_actions, (self.device_id, self.bus))] if not multithread_func(self.log, tasks): return False return self.teardown_result()
def music_streaming_with_iperf(self): """Wrapper function to start iperf traffic and music streaming.""" tasks = [(self.audio.capture_audio, (self.audio_params["record_duration"], self.current_test_name)), (music_play_and_check, (self.pri_ad, self.audio_receiver.mac_address, self.music_file_to_play, self.audio_params["music_play_time"])), (self.run_iperf_and_get_result, ())] if not multithread_func(self.log, tasks): return False return self.teardown_result()
def music_streaming_discovery_avrcp_controls_with_iperf(self): """Wrapper function to start iperf traffic, music streaming, bluetooth discovery and avrcp controls. """ tasks = [(self.audio.capture_audio, (self.audio_params["record_duration"], self.current_test_name)), (music_play_and_check, (self.pri_ad, self.audio_receiver.mac_address, self.music_file_to_play, self.audio_params["duration"])), (self.run_iperf_and_get_result, ()), (perform_classic_discovery, (self.pri_ad, self.iperf["duration"])), (self.avrcp_actions, ())] if not multithread_func(self.log, tasks): return False return self.teardown_result()
def ble_with_multiprofile_connection(self): """Wrapper function to check ble connection along with a2dp streaming and hfp call connection with iperf. """ if not connect_ble(self.pri_ad, self.sec_ad): self.log.error("Failed to connect BLE device") return False if not music_play_and_check_via_app(self.pri_ad, self.audio_receiver.mac_address): self.log.error("Failed to stream music file") return False tasks = [(self.run_iperf_and_get_result, ()), (initiate_disconnect_from_hf, (self.audio_receiver, self.pri_ad, self.sec_ad, self.iperf["duration"]))] if not multithread_func(self.log, tasks): return False return self.teardown_result()
def set_attenuation_and_run_iperf(self, called_func=None): """Sets attenuation and runs iperf for Attenuation max value. Args: called_func : Function object to run. Returns: True if Pass False if Fail """ self.iperf_received = [] for atten in self.attenuation_range: self.log.info("Setting attenuation = {}".format(atten)) for i in range(self.num_atten): self.attenuators[i].set_atten(atten) if not wifi_connection_check(self.pri_ad, self.network["SSID"]): return False time.sleep(5) # Time for attenuation to set. if called_func: if not multithread_func(self.log, called_func): return False else: self.run_iperf_and_get_result() if "a2dp_streaming" in self.current_test_name: if not collect_bluetooth_manager_dumpsys_logs( self.pri_ad, self.current_test_name): return False self.teardown_result() for i in range(self.num_atten): self.attenuators[i].set_atten(0) for received in self.received: iperf_value = str(received).strip("Mb/s") if iperf_value == "Iperf Failed": self.iperf_received.append(0) else: self.iperf_received.append(float(iperf_value)) self.rvr["test_name"] = self.current_test_name self.rvr["attenuation"] = list(self.attenuation_range) self.rvr["throughput_received"] = self.iperf_received self.rvr["fixed_attenuation"] = ( self.test_params["fixed_attenuation"][str(self.network["channel"])]) return True
def test_a2dp_streaming_with_fping(self): """Starts fping along with a2dp streaming. This test is to start fping between host machine and android device and test the functional behaviour of music streaming to a2dp headset. Steps: 1. Start fping. 1. Start media play on android device and check for music streaming. Returns: True if successful, False otherwise. Test Id: Bt_CoEx_077 """ tasks = [(start_fping, (self.pri_ad, self.iperf["duration"], self.fping_drop_tolerance)), (self.music_play_and_check, ( self.pri_ad, self.audio_receiver.mac_address, self.music_file_to_play, self.iperf["duration"]))] if not multithread_func(self.log, tasks): return False return True
def test_connect_disconnect_headset_with_fping(self): """Starts fping, along with connection and disconnection of headset. This test is to start fping between host machine and android device with connection and disconnection of paired headset. Steps: 1. Start fping. 2. Enable bluetooth 3. Connect bluetooth headset. 4. Disconnect bluetooth headset. Returns: True if successful, False otherwise. Test Id: Bt_CoEx_076 """ tasks = [(start_fping, (self.pri_ad, self.iperf["duration"], self.fping_drop_tolerance)), (self.connect_disconnect_headset, ())] if not multithread_func(self.log, tasks): return False return True
def test_toogle_bluetooth_with_fping(self): """Starts fping, while toggling bluetooth. This test is to start fping between host machine and android device while toggling bluetooth. Steps: 1. Start fping on background. 2. Enable bluetooth. 3. Disable bluetooth. 4. Repeat steps 3 and 4 for n iterations. Returns: True if successful, False otherwise. Test Id: Bt_CoEx_070 """ tasks = [(start_fping, (self.pri_ad, self.iperf["duration"], self.fping_params)), (toggle_bluetooth, (self.pri_ad, self.iperf["duration"]))] if not multithread_func(self.log, tasks): return False return True
def rvr_throughput(self, bt_atten, called_func=None): """Sets attenuation and runs the function passed. Args: bt_atten: Bluetooth attenuation. called_func: Functions object to run parallely. Returns: Throughput, a2dp_drops and True/False. """ self.iperf_received = [] self.iperf_variables.received = [] self.a2dp_dropped_list = [] self.rvr["bt_attenuation"].append(bt_atten) self.rvr[bt_atten]["audio_artifacts"] = {} self.rvr[bt_atten]["attenuation"] = [] self.rvr["bt_gap_analysis"][bt_atten] = {} for atten in self.wifi_atten_range: tag = '{}_{}'.format(bt_atten, atten) self.rvr[bt_atten]["attenuation"].append( atten + self.rvr[bt_atten]["fixed_attenuation"]) self.log.info('Setting wifi attenuation to: {} dB'.format(atten)) for i in range(self.num_atten - 1): self.attenuators[i].set_atten(atten) if not wifi_connection_check(self.pri_ad, self.network["SSID"]): self.iperf_received.append(0) return self.iperf_received, self.a2dp_dropped_list, False time.sleep(5) # Time for attenuation to set. begin_time = get_current_epoch_time() if self.a2dp_streaming: self.audio.start() if called_func: if not multithread_func(self.log, called_func): self.iperf_received.append( float( str(self.iperf_variables.received[-1]).strip( "Mb/s"))) return self.iperf_received, self.a2dp_dropped_list, False else: self.run_iperf_and_get_result() adb_rssi_poll_results = self.pri_ad.search_logcat( RSSI_POLL_RESULTS, begin_time) adb_rssi_results = self.pri_ad.search_logcat( RSSI_RESULTS, begin_time) if adb_rssi_results: self.log.debug(adb_rssi_poll_results) self.log.debug(adb_rssi_results[-1]) self.log.info('Android device: {}'.format( (adb_rssi_results[-1]['log_message']).split(',')[5])) if self.a2dp_streaming: self.path = self.audio.stop() analysis_path = AudioCaptureResult( self.path).audio_quality_analysis(self.audio_params) with open(analysis_path) as f: self.rvr[bt_atten]["audio_artifacts"][atten] = f.readline() content = json.loads( self.rvr[bt_atten]["audio_artifacts"][atten]) self.rvr["bt_gap_analysis"][bt_atten][atten] = {} for idx, data in enumerate(content["quality_result"]): if data['artifacts']['delay_during_playback']: self.rvr["bt_gap_analysis"][bt_atten][atten][idx] = ( data['artifacts']['delay_during_playback']) self.rvr["bt_range"].append(bt_atten) else: self.rvr["bt_gap_analysis"][bt_atten][atten][idx] = 0 file_path = collect_bluetooth_manager_dumpsys_logs( self.pri_ad, self.current_test_name) self.a2dp_dropped_list.append( self.a2dp_dumpsys.parse(file_path)) self.iperf_received.append( float(str(self.iperf_variables.throughput[-1]).strip("Mb/s"))) for i in range(self.num_atten - 1): self.attenuators[i].set_atten(0) return self.iperf_received, self.a2dp_dropped_list, True