diff options
| author | 2018-10-24 21:39:17 +0800 | |
|---|---|---|
| committer | 2018-10-24 21:47:03 +0800 | |
| commit | e60d55b17487a53121a9c84f623bf43b485f51e6 (patch) | |
| tree | 9035910a28d8dcb183097ccf09db0ccd6740faf7 | |
| parent | 59894496614f0f382c4306b542236dcf6d6f3d33 (diff) | |
Add tests for VR preferred display id calculation
Making sure that the VR activities can land on default
display and other activities should land on VR 2D display.
Bug: 117614904
Test: atest LaunchParamsControllerTests
Change-Id: I726836b88851d2e68652f2838e4b66077cef27ed
| -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. */ |