From e60d55b17487a53121a9c84f623bf43b485f51e6 Mon Sep 17 00:00:00 2001 From: Louis Chang Date: Wed, 24 Oct 2018 21:39:17 +0800 Subject: [PATCH] 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 --- .../am/LaunchParamsControllerTests.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) 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 d4bab2ef2a43c..2fb10e13ab0ba 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; @@ -188,6 +190,35 @@ public class LaunchParamsControllerTests extends ActivityTestsBase { assertEquals(result, positioner2.getLaunchParams()); } + /** + * 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.