Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_packages_modules_Bluetooth
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LMODroid
platform_packages_modules_Bluetooth
Commits
5bcb8455
Commit
5bcb8455
authored
1 year ago
by
Ben Lawson
Committed by
Gerrit Code Review
1 year ago
Browse files
Options
Downloads
Plain Diff
Merge "BumbleBluetoothTests: Add too many scans test" into main
parents
9a682318
4025af40
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
framework/tests/bumble/src/android/bluetooth/LeScanningTest.java
+42
-4
42 additions, 4 deletions
...rk/tests/bumble/src/android/bluetooth/LeScanningTest.java
with
42 additions
and
4 deletions
framework/tests/bumble/src/android/bluetooth/LeScanningTest.java
+
42
−
4
View file @
5bcb8455
...
...
@@ -22,7 +22,9 @@ 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
.
eq
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
never
;
import
static
org
.
mockito
.
Mockito
.
timeout
;
import
static
org
.
mockito
.
Mockito
.
verify
;
...
...
@@ -53,6 +55,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Stream
;
import
pandora.HostProto
;
import
pandora.HostProto.AdvertiseRequest
;
...
...
@@ -64,8 +67,7 @@ public class LeScanningTest {
private
static
final
String
TAG
=
"LeScanningTest"
;
private
static
final
int
TIMEOUT_SCANNING_MS
=
2000
;
@Rule
public
final
AdoptShellPermissionsRule
mPermissionRule
=
new
AdoptShellPermissionsRule
();
@Rule
public
final
AdoptShellPermissionsRule
mPermissionRule
=
new
AdoptShellPermissionsRule
();
@Rule
public
final
PandoraDevice
mBumble
=
new
PandoraDevice
();
...
...
@@ -208,8 +210,7 @@ public class LeScanningTest {
List
<
ScanResult
>
results
=
intent
.
getValue
()
.
getParcelableArrayListExtra
(
BluetoothLeScanner
.
EXTRA_LIST_SCAN_RESULT
,
ScanResult
.
class
);
BluetoothLeScanner
.
EXTRA_LIST_SCAN_RESULT
,
ScanResult
.
class
);
assertThat
(
results
).
isNotEmpty
();
assertThat
(
results
.
get
(
0
).
getScanRecord
().
getServiceUuids
()).
isNotEmpty
();
assertThat
(
results
.
get
(
0
).
getScanRecord
().
getServiceUuids
().
get
(
0
))
...
...
@@ -252,6 +253,43 @@ public class LeScanningTest {
.
containsExactly
(
ParcelUuid
.
fromString
(
TEST_UUID_STRING
));
}
@Test
public
void
startBleScan_oneTooManyScansFails
()
{
final
int
maxNumScans
=
32
;
advertiseWithBumble
(
TEST_UUID_STRING
,
OwnAddressType
.
PUBLIC
);
ScanSettings
scanSettings
=
new
ScanSettings
.
Builder
()
.
setScanMode
(
ScanSettings
.
SCAN_MODE_LOW_LATENCY
)
.
setCallbackType
(
ScanSettings
.
CALLBACK_TYPE_ALL_MATCHES
)
.
build
();
ScanFilter
scanFilter
=
new
ScanFilter
.
Builder
()
.
setServiceUuid
(
ParcelUuid
.
fromString
(
TEST_UUID_STRING
))
.
build
();
List
<
ScanCallback
>
scanCallbacks
=
Stream
.
generate
(()
->
mock
(
ScanCallback
.
class
)).
limit
(
maxNumScans
).
toList
();
for
(
ScanCallback
mockScanCallback
:
scanCallbacks
)
{
mLeScanner
.
startScan
(
List
.
of
(
scanFilter
),
scanSettings
,
mockScanCallback
);
}
// This last scan should fail
ScanCallback
lastMockScanCallback
=
mock
(
ScanCallback
.
class
);
mLeScanner
.
startScan
(
List
.
of
(
scanFilter
),
scanSettings
,
lastMockScanCallback
);
// We expect an error only for the last scan, which was over the maximum active scans limit.
for
(
ScanCallback
mockScanCallback
:
scanCallbacks
)
{
verify
(
mockScanCallback
,
timeout
(
TIMEOUT_SCANNING_MS
).
atLeast
(
1
))
.
onScanResult
(
eq
(
ScanSettings
.
CALLBACK_TYPE_ALL_MATCHES
),
any
());
verify
(
mockScanCallback
,
never
()).
onScanFailed
(
anyInt
());
mLeScanner
.
stopScan
(
mockScanCallback
);
}
verify
(
lastMockScanCallback
,
timeout
(
TIMEOUT_SCANNING_MS
))
.
onScanFailed
(
eq
(
ScanCallback
.
SCAN_FAILED_APPLICATION_REGISTRATION_FAILED
));
mLeScanner
.
stopScan
(
lastMockScanCallback
);
}
private
List
<
ScanResult
>
startScanning
(
ScanFilter
scanFilter
,
int
callbackType
)
{
CompletableFuture
<
List
<
ScanResult
>>
future
=
new
CompletableFuture
<>();
List
<
ScanResult
>
scanResults
=
new
ArrayList
<>();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment