Skip to content
Snippets Groups Projects
Commit ba4cc8fd authored by Ben's avatar Ben
Browse files

BumbleBluetoothTests: Add tests for first match and match lost

These tests currently expect silent failure because offloaded
filtering is not yet supported in Rootcanal.

Bug: 296143555
Test: atest BumbleBluetoothTests:android.bluetooth.LeScanningTest
Change-Id: I58e3371a17f21aabf2c1a08573096fb311643623
parent 78b8efbd
No related branches found
No related tags found
No related merge requests found
......@@ -19,6 +19,8 @@ package android.bluetooth;
import static com.google.common.io.BaseEncoding.base16;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.after;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.timeout;
......@@ -122,6 +124,50 @@ public class LeScanningTest {
assertThat(results.get(0).getDevice().getAddress()).isEqualTo(TEST_ADDRESS_RANDOM_STATIC);
}
@Test
public void startBleScan_withCallbackTypeFirstMatchSilentlyFails() {
advertiseWithBumble(TEST_UUID_STRING, OwnAddressType.PUBLIC);
ScanSettings scanSettings =
new ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
.setCallbackType(ScanSettings.CALLBACK_TYPE_FIRST_MATCH)
.build();
ScanFilter scanFilter =
new ScanFilter.Builder()
.setServiceUuid(ParcelUuid.fromString(TEST_UUID_STRING))
.build();
ScanCallback mockScanCallback = mock(ScanCallback.class);
mLeScanner.startScan(List.of(scanFilter), scanSettings, mockScanCallback);
verify(mockScanCallback, after(TIMEOUT_SCANNING_MS).never()).onScanFailed(anyInt());
mLeScanner.stopScan(mockScanCallback);
}
@Test
public void startBleScan_withCallbackTypeMatchLostSilentlyFails() {
advertiseWithBumble(TEST_UUID_STRING, OwnAddressType.PUBLIC);
ScanSettings scanSettings =
new ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
.setCallbackType(ScanSettings.CALLBACK_TYPE_MATCH_LOST)
.build();
ScanFilter scanFilter =
new ScanFilter.Builder()
.setServiceUuid(ParcelUuid.fromString(TEST_UUID_STRING))
.build();
ScanCallback mockScanCallback = mock(ScanCallback.class);
mLeScanner.startScan(List.of(scanFilter), scanSettings, mockScanCallback);
verify(mockScanCallback, after(TIMEOUT_SCANNING_MS).never()).onScanFailed(anyInt());
mLeScanner.stopScan(mockScanCallback);
}
@Test
public void startBleScan_withPendingIntentAndDynamicReceiverAndCallbackTypeAllMatches() {
BroadcastReceiver mockReceiver = mock(BroadcastReceiver.class);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment