def test_scan_with_peer_set_non_discoverable(self): """Test Bluetooth scan with peer set to non discoverable. Steps: 1. Set peer device to a unique device name. 2. Set peer device to be non-discoverable. 3. Perform a BT Scan with primary dut with enough time to gather results. Expected Result: Verify there are no results that match the unique device name in step 1. Returns: signals.TestPass if no errors signals.TestFailure if there are any errors during the test. TAGS: BR/EDR, BT Priority: 1 """ local_name = generate_id_by_size(10) self.sec_dut.btc_lib.setName(local_name) self.sec_dut.btc_lib.setDiscoverable(False) self.pri_dut.btc_lib.requestDiscovery(True) time.sleep(self.scan_timeout_seconds) self.pri_dut.btc_lib.requestDiscovery(False) discovered_devices = self.pri_dut.btc_lib.getKnownRemoteDevices() for device in discovered_devices.get("result").values(): discoverd_name = device.get("name") if discoverd_name is not None and discoverd_name is local_name: raise signals.TestFailure( "Found peer unexpectedly: {}.".format(device)) raise signals.TestPass("Successfully didn't find peer device.")
def _orchestrate_single_connect_disconnect(self): adv_name = generate_id_by_size(10) adv_data = { "name": adv_name, "appearance": None, "service_data": None, "tx_power_level": None, "service_uuids": None, "manufacturer_data": None, "uris": None, } scan_response = None connectable = True self.fuchsia_server_dut.ble_lib.bleStartBleAdvertising( adv_data, scan_response, self.ble_advertise_interval, connectable) device = le_scan_for_device_by_name(self.fuchsia_client_dut, self.log, adv_name, self.scan_timeout_seconds) if device is None: raise signals.TestFailure("Scanner unable to find advertisement.") connect_result = self.fuchsia_client_dut.gattc_lib.bleConnectToPeripheral( device["id"]) if connect_result.get("error") is not None: raise signals.TestFailure( self.gatt_connect_err_message.format( connect_result.get("error"))) self.log.info("Connection Successful...") disconnect_result = self.fuchsia_client_dut.gattc_lib.bleDisconnectPeripheral( device["id"]) if disconnect_result.get("error") is not None: raise signals.TestFailure( self.gatt_disconnect_err_message.format( connect_result.get("error"))) self.log.info("Disconnection Successful...") self.fuchsia_server_dut.ble_lib.bleStopBleAdvertising()
def test_two_devices_set_get_name(self): test_name = generate_id_by_size(4) for n in self.native_devices: d = n.droid d.BtBinderSetName(test_name) name = d.BtBinderGetName() if name != test_name: return False return True
def test_binder_set_name_get_name(self): test_name = generate_id_by_size(4) result = self.droid.BtBinderSetName(test_name) if not result: return False name = self.droid.BtBinderGetName() if test_name != name: return False return True
def test_scan_with_peer_set_discoverable(self): """Test Bluetooth scan with peer set to discoverable. Steps: 1. Set peer device to a unique device name. 2. Set peer device to be discoverable. 3. Perform a BT Scan with primary dut with enough time to gather results. Expected Result: Verify there is a result that match the unique device name in step 1. Returns: signals.TestPass if no errors signals.TestFailure if there are any errors during the test. TAGS: BR/EDR, BT Priority: 1 """ local_name = generate_id_by_size(10) self.log.info("Setting local peer name to: {}".format(local_name)) self.sec_dut.btc_lib.setName(local_name) self.sec_dut.btc_lib.setDiscoverable(True) self.pri_dut.btc_lib.requestDiscovery(True) end_time = time.time() + self.scan_timeout_seconds poll_timeout = 10 while time.time() < end_time: discovered_devices = self.pri_dut.btc_lib.getKnownRemoteDevices() for device in discovered_devices.get("result").values(): self.log.info(device) discoverd_name = device.get("name") if discoverd_name is not None and discoverd_name in local_name: self.pri_dut.btc_lib.requestDiscovery(False) raise signals.TestPass("Successfully found peer device.") time.sleep(poll_timeout) self.pri_dut.btc_lib.requestDiscovery(False) raise signals.TestFailure("Unable to find peer device.")