Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_frameworks_base-old
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Farzin Kazemzadeh
platform_frameworks_base-old
Commits
d8385e06
Commit
d8385e06
authored
4 years ago
by
TreeHugger Robot
Committed by
Android (Google) Code Review
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Add DisplayManager tests to presubmit." into sc-dev
parents
de2e5132
47f6fa73
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
services/tests/servicestests/src/com/android/server/display/DisplayManagerServiceTest.java
+50
-22
50 additions, 22 deletions
...com/android/server/display/DisplayManagerServiceTest.java
with
50 additions
and
22 deletions
services/tests/servicestests/src/com/android/server/display/DisplayManagerServiceTest.java
+
50
−
22
View file @
d8385e06
...
...
@@ -45,7 +45,9 @@ import android.hardware.display.VirtualDisplayConfig;
import
android.hardware.input.InputManagerInternal
;
import
android.os.Handler
;
import
android.os.IBinder
;
import
android.os.MessageQueue
;
import
android.os.Process
;
import
android.platform.test.annotations.Presubmit
;
import
android.view.Display
;
import
android.view.DisplayCutout
;
import
android.view.DisplayEventReceiver
;
...
...
@@ -76,10 +78,15 @@ import org.mockito.ArgumentCaptor;
import
org.mockito.Mock
;
import
org.mockito.MockitoAnnotations
;
import
java.time.Duration
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.LongStream
;
@SmallTest
@Presubmit
@RunWith
(
AndroidJUnit4
.
class
)
public
class
DisplayManagerServiceTest
{
private
static
final
int
MSG_REGISTER_DEFAULT_DISPLAY_ADAPTERS
=
1
;
...
...
@@ -193,8 +200,8 @@ public class DisplayManagerServiceTest {
verify
(
mMockInputManagerInternal
).
setDisplayViewports
(
viewportCaptor
.
capture
());
List
<
DisplayViewport
>
viewports
=
viewportCaptor
.
getValue
();
// Expect to receive 2 viewports: internal, and virtual
assert
Equals
(
2
,
viewports
.
size
());
// Expect to receive
at least
2 viewports:
at least 1
internal, and
1
virtual
assert
True
(
viewports
.
size
()
>=
2
);
DisplayViewport
virtualViewport
=
null
;
DisplayViewport
internalViewport
=
null
;
...
...
@@ -202,7 +209,10 @@ public class DisplayManagerServiceTest {
DisplayViewport
v
=
viewports
.
get
(
i
);
switch
(
v
.
type
)
{
case
DisplayViewport
.
VIEWPORT_INTERNAL
:
{
// If more than one internal viewport, this will get overwritten several times,
// which for the purposes of this test is fine.
internalViewport
=
v
;
assertTrue
(
internalViewport
.
valid
);
break
;
}
case
DisplayViewport
.
VIEWPORT_EXTERNAL
:
{
...
...
@@ -219,9 +229,6 @@ public class DisplayManagerServiceTest {
assertNotNull
(
internalViewport
);
assertNotNull
(
virtualViewport
);
// INTERNAL
assertTrue
(
internalViewport
.
valid
);
// VIRTUAL
assertEquals
(
height
,
virtualViewport
.
deviceHeight
);
assertEquals
(
width
,
virtualViewport
.
deviceWidth
);
...
...
@@ -243,10 +250,12 @@ public class DisplayManagerServiceTest {
when
(
mMockAppToken
.
asBinder
()).
thenReturn
(
mMockAppToken
);
final
int
displayIds
[]
=
bs
.
getDisplayIds
();
assertEquals
(
1
,
displayIds
.
length
);
final
int
displayId
=
displayIds
[
0
];
DisplayInfo
info
=
bs
.
getDisplayInfo
(
displayId
);
assertEquals
(
info
.
type
,
Display
.
TYPE_INTERNAL
);
final
int
size
=
displayIds
.
length
;
assertTrue
(
size
>
0
);
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
DisplayInfo
info
=
bs
.
getDisplayInfo
(
displayIds
[
i
]);
assertEquals
(
info
.
type
,
Display
.
TYPE_INTERNAL
);
}
displayManager
.
performTraversalInternal
(
mock
(
SurfaceControl
.
Transaction
.
class
));
...
...
@@ -257,16 +266,22 @@ public class DisplayManagerServiceTest {
verify
(
mMockInputManagerInternal
).
setDisplayViewports
(
viewportCaptor
.
capture
());
List
<
DisplayViewport
>
viewports
=
viewportCaptor
.
getValue
();
// Expect to receive actual viewports: 1 internal
assertEquals
(
1
,
viewports
.
size
());
DisplayViewport
internalViewport
=
viewports
.
get
(
0
);
// INTERNAL is the only one actual display.
assertNotNull
(
internalViewport
);
assertEquals
(
DisplayViewport
.
VIEWPORT_INTERNAL
,
internalViewport
.
type
);
assertTrue
(
internalViewport
.
valid
);
assertEquals
(
displayId
,
internalViewport
.
displayId
);
// Due to the nature of foldables, we may have a different number of viewports than
// displays, just verify there's at least one.
final
int
viewportSize
=
viewports
.
size
();
assertTrue
(
viewportSize
>
0
);
// Now verify that each viewport's displayId is valid.
Arrays
.
sort
(
displayIds
);
for
(
int
i
=
0
;
i
<
viewportSize
;
i
++)
{
DisplayViewport
internalViewport
=
viewports
.
get
(
i
);
// INTERNAL is the only one actual display.
assertNotNull
(
internalViewport
);
assertEquals
(
DisplayViewport
.
VIEWPORT_INTERNAL
,
internalViewport
.
type
);
assertTrue
(
internalViewport
.
valid
);
assertTrue
(
Arrays
.
binarySearch
(
displayIds
,
internalViewport
.
displayId
)
>=
0
);
}
}
@Test
...
...
@@ -486,7 +501,6 @@ public class DisplayManagerServiceTest {
* Tests that collection of display color sampling results are sensible.
*/
@Test
@FlakyTest
(
bugId
=
172555744
)
public
void
testDisplayedContentSampling
()
{
DisplayManagerService
displayManager
=
new
DisplayManagerService
(
mContext
,
mShortMockedInjector
);
...
...
@@ -937,8 +951,22 @@ public class DisplayManagerServiceTest {
// Would prefer to call displayManager.onStart() directly here but it performs binderService
// registration which triggers security exceptions when running from a test.
handler
.
sendEmptyMessage
(
MSG_REGISTER_DEFAULT_DISPLAY_ADAPTERS
);
// flush the handler
handler
.
runWithScissors
(()
->
{},
0
/* now */
);
waitForIdleHandler
(
handler
,
Duration
.
ofSeconds
(
1
));
}
private
void
waitForIdleHandler
(
Handler
handler
,
Duration
timeout
)
{
final
MessageQueue
queue
=
handler
.
getLooper
().
getQueue
();
final
CountDownLatch
latch
=
new
CountDownLatch
(
1
);
queue
.
addIdleHandler
(()
->
{
latch
.
countDown
();
// Remove idle handler
return
false
;
});
try
{
latch
.
await
(
timeout
.
toMillis
(),
TimeUnit
.
MILLISECONDS
);
}
catch
(
InterruptedException
e
)
{
fail
(
"Interrupted unexpectedly: "
+
e
);
}
}
private
class
FakeDisplayManagerCallback
extends
IDisplayManagerCallback
.
Stub
{
...
...
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