diff options
| author | 2018-10-25 07:08:28 +0000 | |
|---|---|---|
| committer | 2018-10-25 07:08:28 +0000 | |
| commit | 1332beacbef762ac6d2cf6c2739f7eae593f6599 (patch) | |
| tree | 2442b15528246ae4c19f3e61dd75642f194ab53d | |
| parent | 86d0d9d8e5da33c0db9dc7a6d8c104427e85939e (diff) | |
| parent | e60d55b17487a53121a9c84f623bf43b485f51e6 (diff) | |
Merge "Add tests for VR preferred display id calculation"
| -rw-r--r-- | services/tests/servicestests/src/com/android/server/am/LaunchParamsControllerTests.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/services/tests/servicestests/src/com/android/server/am/LaunchParamsControllerTests.java b/services/tests/servicestests/src/com/android/server/am/LaunchParamsControllerTests.java index d4bab2ef2a43..2fb10e13ab0b 100644 --- a/services/tests/servicestests/src/com/android/server/am/LaunchParamsControllerTests.java +++ b/services/tests/servicestests/src/com/android/server/am/LaunchParamsControllerTests.java @@ -17,6 +17,8 @@ package com.android.server.am; import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; +import static android.view.Display.DEFAULT_DISPLAY; +import static android.view.Display.INVALID_DISPLAY; import static com.android.server.am.LaunchParamsController.LaunchParamsModifier.RESULT_CONTINUE; import static com.android.server.am.LaunchParamsController.LaunchParamsModifier.RESULT_DONE; @@ -189,6 +191,35 @@ public class LaunchParamsControllerTests extends ActivityTestsBase { } /** + * Tests preferred display id calculation for VR. + */ + @Test + public void testVrPreferredDisplay() { + final int vr2dDisplayId = 1; + mService.mVr2dDisplayId = vr2dDisplayId; + + final LaunchParams result = new LaunchParams(); + final ActivityRecord vrActivity = new ActivityBuilder(mService).build(); + vrActivity.requestedVrComponent = vrActivity.realActivity; + + // VR activities should always land on default display. + mController.calculate(null /*task*/, null /*layout*/, vrActivity /*activity*/, + null /*source*/, null /*options*/, result); + assertEquals(DEFAULT_DISPLAY, result.mPreferredDisplayId); + + // Otherwise, always lands on VR 2D display. + final ActivityRecord vr2dActivity = new ActivityBuilder(mService).build(); + mController.calculate(null /*task*/, null /*layout*/, vr2dActivity /*activity*/, + null /*source*/, null /*options*/, result); + assertEquals(vr2dDisplayId, result.mPreferredDisplayId); + mController.calculate(null /*task*/, null /*layout*/, null /*activity*/, null /*source*/, + null /*options*/, result); + assertEquals(vr2dDisplayId, result.mPreferredDisplayId); + + mService.mVr2dDisplayId = INVALID_DISPLAY; + } + + /** * Ensures that {@link LaunchParamsModifier} requests specifying display id during * layout are honored. */ |