Skip to content

Commit

Permalink
Update test for added AddressType property
Browse files Browse the repository at this point in the history
  • Loading branch information
weliem committed Dec 30, 2021
1 parent 7e89650 commit bec733c
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class BluetoothCentralManagerTest {
private static final String DUMMY_MAC_ADDRESS_PATH_HTS = "/org/bluez/hci0/dev_" + DUMMY_MAC_ADDRESS_HTS.replace(":", "_");
private static final String DUMMY_PERIPHERAL_NAME_HTS = "Taidoc 1241";

private static final String PUBLIC_ADDRESS = "public";

@BeforeEach
void setup() {
}
Expand Down Expand Up @@ -196,6 +198,7 @@ void When_scanning_unfiltered_and_a_PropertiesChanged_signal_comes_in_then_onDis
when(bluezAdapter.getPath(DUMMY_MAC_ADDRESS_BLP)).thenReturn(DUMMY_MAC_ADDRESS_PATH_BLP);
when(bluezAdapter.getBluezDeviceByPath(DUMMY_MAC_ADDRESS_PATH_BLP)).thenReturn(bluezDevice);
when(bluezDevice.getAddress()).thenReturn(DUMMY_MAC_ADDRESS_BLP);
when(bluezDevice.getAddressType()).thenReturn(PUBLIC_ADDRESS);
when(bluezDevice.getName()).thenReturn(DUMMY_PERIPHERAL_NAME_BLP);
when(bluezDevice.getUuids()).thenReturn(Collections.singletonList(BLP_SERVICE_UUID));
BluetoothCentralManager central = startUnfilteredScan();
Expand Down Expand Up @@ -295,6 +298,7 @@ void When_scanning_for_service_and_a_matching_PropertiesChanged_signal_comes_in_
when(bluezAdapter.getPath(DUMMY_MAC_ADDRESS_BLP)).thenReturn(DUMMY_MAC_ADDRESS_PATH_BLP);
when(bluezAdapter.getBluezDeviceByPath(DUMMY_MAC_ADDRESS_PATH_BLP)).thenReturn(bluezDevice);
when(bluezDevice.getAddress()).thenReturn(DUMMY_MAC_ADDRESS_BLP);
when(bluezDevice.getAddressType()).thenReturn(PUBLIC_ADDRESS);
when(bluezDevice.getName()).thenReturn(DUMMY_PERIPHERAL_NAME_BLP);
when(bluezDevice.getUuids()).thenReturn(Collections.singletonList(BLP_SERVICE_UUID));
BluetoothCentralManager central = startScanWithServices(BLP_SERVICE_UUID);
Expand Down Expand Up @@ -334,7 +338,6 @@ void When_scanning_for_service_and_a_non_matching_InterFaceAdded_signal_comes_in
@Test
void When_scanning_for_service_and_a_non_matching_PropertiesChanged_signal_comes_in_then_onDiscoveredPeripheral_is_not_called() throws InterruptedException, DBusException {
// Given
when(bluezAdapter.getPath(DUMMY_MAC_ADDRESS_BLP)).thenReturn(DUMMY_MAC_ADDRESS_PATH_BLP);
when(bluezAdapter.getBluezDeviceByPath(DUMMY_MAC_ADDRESS_PATH_BLP)).thenReturn(bluezDevice);
when(bluezDevice.getAddress()).thenReturn(DUMMY_MAC_ADDRESS_BLP);
when(bluezDevice.getName()).thenReturn(DUMMY_PERIPHERAL_NAME_BLP);
Expand Down Expand Up @@ -420,6 +423,7 @@ void When_scanning_for_address_and_a_matching_PropertiesChanged_signal_comes_in_
when(bluezAdapter.getPath(DUMMY_MAC_ADDRESS_BLP)).thenReturn(DUMMY_MAC_ADDRESS_PATH_BLP);
when(bluezAdapter.getBluezDeviceByPath(DUMMY_MAC_ADDRESS_PATH_BLP)).thenReturn(bluezDevice);
when(bluezDevice.getAddress()).thenReturn(DUMMY_MAC_ADDRESS_BLP);
when(bluezDevice.getAddressType()).thenReturn(PUBLIC_ADDRESS);
when(bluezDevice.getName()).thenReturn(DUMMY_PERIPHERAL_NAME_BLP);
when(bluezDevice.getUuids()).thenReturn(Collections.singletonList(BLP_SERVICE_UUID));
BluetoothCentralManager central = startScanWithAddress(DUMMY_MAC_ADDRESS_BLP);
Expand Down Expand Up @@ -461,7 +465,6 @@ void When_scanning_for_address_and_a_non_matching_InterfaceAdded_signal_comes_in
@Test
void When_scanning_for_address_and_a_non_matching_PropertiesChanged_signal_comes_in_then_onDiscoveredPeripheral_is_not_called() throws InterruptedException, DBusException {
// Given
when(bluezAdapter.getPath(DUMMY_MAC_ADDRESS_BLP)).thenReturn(DUMMY_MAC_ADDRESS_PATH_BLP);
when(bluezAdapter.getBluezDeviceByPath(DUMMY_MAC_ADDRESS_PATH_BLP)).thenReturn(bluezDevice);
when(bluezDevice.getAddress()).thenReturn(DUMMY_MAC_ADDRESS_BLP);
when(bluezDevice.getName()).thenReturn(DUMMY_PERIPHERAL_NAME_BLP);
Expand Down Expand Up @@ -547,6 +550,7 @@ void When_scanning_for_names_and_a_matching_PropertiesChanged_signal_comes_in_th
when(bluezAdapter.getPath(DUMMY_MAC_ADDRESS_BLP)).thenReturn(DUMMY_MAC_ADDRESS_PATH_BLP);
when(bluezAdapter.getBluezDeviceByPath(DUMMY_MAC_ADDRESS_PATH_BLP)).thenReturn(bluezDevice);
when(bluezDevice.getAddress()).thenReturn(DUMMY_MAC_ADDRESS_BLP);
when(bluezDevice.getAddressType()).thenReturn(PUBLIC_ADDRESS);
when(bluezDevice.getName()).thenReturn(DUMMY_PERIPHERAL_NAME_BLP);
when(bluezDevice.getUuids()).thenReturn(Collections.singletonList(BLP_SERVICE_UUID));
BluetoothCentralManager central = startScanWithNames(DUMMY_PERIPHERAL_NAME_BLP);
Expand All @@ -572,7 +576,6 @@ void When_scanning_for_names_and_a_matching_PropertiesChanged_signal_comes_in_th
void When_scanning_for_names_and_non_matching_InterfaceAdded_signal_comes_in_then_onDiscoveredPeripheral_is_not_called() throws InterruptedException, DBusException {
// Given
when(bluezAdapter.getPath(DUMMY_MAC_ADDRESS_HTS)).thenReturn(DUMMY_MAC_ADDRESS_PATH_HTS);
when(bluezAdapter.getBluezDeviceByPath(DUMMY_MAC_ADDRESS_PATH_HTS)).thenReturn(bluezDeviceHts);
BluetoothCentralManager central = startScanWithNames(DUMMY_PERIPHERAL_NAME_BLP);

// When
Expand All @@ -586,7 +589,7 @@ void When_scanning_for_names_and_non_matching_InterfaceAdded_signal_comes_in_the
@Test
void When_scanning_for_names_and_a_non_matching_PropertiesChanged_signal_comes_in_then_onDiscoveredPeripheral_is_not_called() throws InterruptedException, DBusException {
// Given
when(bluezAdapter.getPath(DUMMY_MAC_ADDRESS_BLP)).thenReturn(DUMMY_MAC_ADDRESS_PATH_BLP);
// when(bluezAdapter.getPath(DUMMY_MAC_ADDRESS_BLP)).thenReturn(DUMMY_MAC_ADDRESS_PATH_BLP);
when(bluezAdapter.getBluezDeviceByPath(DUMMY_MAC_ADDRESS_PATH_BLP)).thenReturn(bluezDevice);
when(bluezDevice.getAddress()).thenReturn(DUMMY_MAC_ADDRESS_BLP);
when(bluezDevice.getName()).thenReturn("Something else");
Expand Down Expand Up @@ -743,6 +746,7 @@ void Given_an_autoConnect_is_issued_when_the_peripheral_is_seen_then_a_connect_i
when(bluezAdapter.getPath(DUMMY_MAC_ADDRESS_BLP)).thenReturn(DUMMY_MAC_ADDRESS_PATH_BLP);
when(bluezAdapter.getBluezDeviceByPath(DUMMY_MAC_ADDRESS_PATH_BLP)).thenReturn(bluezDevice);
when(bluezDevice.getAddress()).thenReturn(DUMMY_MAC_ADDRESS_BLP);
when(bluezDevice.getAddressType()).thenReturn(PUBLIC_ADDRESS);
when(bluezDevice.getName()).thenReturn("Something else");
when(bluezDevice.getUuids()).thenReturn(Collections.singletonList(BLP_SERVICE_UUID));
BluetoothPeripheral peripheral = central.getPeripheral(DUMMY_MAC_ADDRESS_BLP);
Expand Down Expand Up @@ -916,6 +920,7 @@ private ObjectManager.InterfacesAdded getInterfacesAddedNewBlpDevice() throws DB
Map<String, Variant<?>> interfaceMap = new HashMap<>();

interfaceMap.put(PROPERTY_ADDRESS, new Variant<>(DUMMY_MAC_ADDRESS_BLP));
interfaceMap.put(PROPERTY_ADDRESS_TYPE, new Variant<>(PUBLIC_ADDRESS));
interfaceMap.put(PROPERTY_NAME, new Variant<>(DUMMY_PERIPHERAL_NAME_BLP));
interfaceMap.put(PROPERTY_CONNECTED, new Variant<>(false));
interfaceMap.put(PROPERTY_SERVICES_RESOLVED, new Variant<>(false));
Expand Down Expand Up @@ -950,6 +955,7 @@ private ObjectManager.InterfacesAdded getInterfacesAddedNewHtsDevice() throws DB
Map<String, Variant<?>> interfaceMap = new HashMap<>();

interfaceMap.put(PROPERTY_ADDRESS, new Variant<>(DUMMY_MAC_ADDRESS_HTS));
interfaceMap.put(PROPERTY_ADDRESS_TYPE, new Variant<>(PUBLIC_ADDRESS));
interfaceMap.put(PROPERTY_NAME, new Variant<>(DUMMY_PERIPHERAL_NAME_HTS));
interfaceMap.put(PROPERTY_CONNECTED, new Variant<>(false));
interfaceMap.put(PROPERTY_SERVICES_RESOLVED, new Variant<>(false));
Expand Down

0 comments on commit bec733c

Please sign in to comment.