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
e863465d
Commit
e863465d
authored
1 year ago
by
Treehugger Robot
Committed by
Gerrit Code Review
1 year ago
Browse files
Options
Downloads
Plain Diff
Merge "SystemServer: Parametrized Flag testing" into main
parents
ad33b578
441fbfe9
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
service/tests/src/com/android/server/bluetooth/BluetoothManagerServiceTest.java
+69
-5
69 additions, 5 deletions
...android/server/bluetooth/BluetoothManagerServiceTest.java
with
69 additions
and
5 deletions
service/tests/src/com/android/server/bluetooth/BluetoothManagerServiceTest.java
+
69
−
5
View file @
e863465d
...
...
@@ -30,6 +30,8 @@ import static com.android.server.bluetooth.BluetoothManagerService.MESSAGE_TIMEO
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
static
org
.
junit
.
runners
.
Parameterized
.
Parameter
;
import
static
org
.
junit
.
runners
.
Parameterized
.
Parameters
;
import
static
org
.
mockito
.
ArgumentMatchers
.
anyBoolean
;
import
static
org
.
mockito
.
ArgumentMatchers
.
eq
;
import
static
org
.
mockito
.
Mockito
.
any
;
...
...
@@ -58,23 +60,30 @@ import android.os.test.TestLooper;
import
android.provider.Settings
;
import
androidx.test.platform.app.InstrumentationRegistry
;
import
androidx.test.runner.AndroidJUnit4
;
import
com.android.bluetooth.flags.FakeFeatureFlagsImpl
;
import
com.android.bluetooth.flags.Flags
;
import
com.google.common.collect.Lists
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.Parameterized
;
import
org.mockito.ArgumentCaptor
;
import
org.mockito.Mock
;
import
org.mockito.MockitoAnnotations
;
import
org.mockito.Spy
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.IntStream
;
import
java.util.stream.Stream
;
@RunWith
(
AndroidJUnit4
.
class
)
@RunWith
(
Parameterized
.
class
)
public
class
BluetoothManagerServiceTest
{
private
static
final
String
TAG
=
BluetoothManagerServiceTest
.
class
.
getSimpleName
();
private
static
final
int
STATE_BLE_TURNING_ON
=
14
;
// can't find the symbol because hidden api
...
...
@@ -98,6 +107,63 @@ public class BluetoothManagerServiceTest {
@Mock
AdapterBinder
mAdapterBinder
;
private
FakeFeatureFlagsImpl
mFakeFlagsImpl
;
@Parameter
public
FlagsValue
mFlagsValue
;
static
class
FlagsValue
{
final
Map
<
String
,
Boolean
>
mFlagsValue
;
FlagsValue
(
Map
<
String
,
Boolean
>
flagsValue
)
{
mFlagsValue
=
flagsValue
;
}
private
static
String
formatFlag
(
String
key
)
{
return
key
.
substring
(
key
.
lastIndexOf
(
"."
)
+
1
);
}
@Override
public
String
toString
()
{
return
mFlagsValue
.
entrySet
().
stream
()
.
filter
(
Map
.
Entry
::
getValue
)
.
map
(
Map
.
Entry
::
getKey
)
.
map
(
FlagsValue:
:
formatFlag
)
.
sorted
()
.
collect
(
Collectors
.
joining
(
", "
));
}
}
private
static
boolean
filterFlags
(
Map
<
String
,
Boolean
>
map
)
{
if
(
map
.
get
(
Flags
.
FLAG_USE_NEW_AIRPLANE_MODE
))
{
return
!
map
.
get
(
Flags
.
FLAG_AIRPLANE_RESSOURCES_IN_APP
);
}
return
true
;
}
/** Generate the Map of flag for this test Suite */
@Parameters
(
name
=
"{0}"
)
public
static
Iterable
<?
extends
Object
>
generateParameterizedFlagsValue
()
{
final
String
[]
flags
=
{
Flags
.
FLAG_AIRPLANE_RESSOURCES_IN_APP
,
Flags
.
FLAG_USE_NEW_AIRPLANE_MODE
,
Flags
.
FLAG_USE_NEW_SATELLITE_MODE
,
};
final
Boolean
[]
values
=
{
true
,
false
};
List
<
List
<
Map
.
Entry
<
String
,
Boolean
>>>
flagValues
=
Arrays
.
stream
(
flags
)
.
map
(
flag
->
Arrays
.
stream
(
values
).
map
(
val
->
Map
.
entry
(
flag
,
val
)))
.
map
(
Stream:
:
toList
)
.
toList
();
return
Lists
.
cartesianProduct
(
flagValues
).
stream
()
.
map
(
list
->
list
.
toArray
(
new
Map
.
Entry
[
0
]))
.
map
(
Map:
:
ofEntries
)
.
filter
(
BluetoothManagerServiceTest:
:
filterFlags
)
.
map
(
FlagsValue:
:
new
)
.
map
(
List:
:
of
)
.
map
(
List:
:
toArray
)
.
toList
();
}
TestLooper
mLooper
;
boolean
mHasException
=
false
;
...
...
@@ -148,9 +214,7 @@ public class BluetoothManagerServiceTest {
mLooper
=
new
TestLooper
();
mFakeFlagsImpl
=
new
FakeFeatureFlagsImpl
();
mFakeFlagsImpl
.
setFlag
(
Flags
.
FLAG_AIRPLANE_RESSOURCES_IN_APP
,
false
);
mFakeFlagsImpl
.
setFlag
(
Flags
.
FLAG_USE_NEW_AIRPLANE_MODE
,
false
);
mFakeFlagsImpl
.
setFlag
(
Flags
.
FLAG_USE_NEW_SATELLITE_MODE
,
false
);
mFlagsValue
.
mFlagsValue
.
forEach
(
mFakeFlagsImpl:
:
setFlag
);
mManagerService
=
new
BluetoothManagerService
(
mContext
,
mLooper
.
getLooper
(),
mFakeFlagsImpl
);
...
...
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