Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 310de9e5 authored by Bryce Lee's avatar Bryce Lee
Browse files

Fix AppWindowTokenTests#testLandscapeSeascapeRotationByPolicy

Previously this test was marked as blocked by b/35034729. This bug
has been fixed, however the test still fails due to other issues
addressed here.

Addressed issues are as follows:
1. Updating rotation by display manager requires a display with the
default display id present. This display is removed during setup. The
first id to be used by a display after this point is the
default id + 1. We already have logic in place to avoid collisions so
it is safe and correct to start out at the default id.
2. Without allowing the animator to complete its steps after a
rotation, future rotations will be deferred. We must simulate the
steps taken by the and resulting from the animtor. These include
marking the orientation change as complete and performing a surface
placement afterwards.

Bug: 35034729
Test: bit FrameworksServicesTests:com.android.server.wm.AppWindowTokenTests
Change-Id: Ib01c047ac49982a4a3c1debaa3cee1b7b9b53632
parent 70c8e868
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -126,8 +126,6 @@ public class AppWindowTokenTests extends WindowTestsBase {
    }

    @Test
    @Ignore
    // TODO(b/35034729): Need to fix before re-enabling
    public void testLandscapeSeascapeRotationByPolicy() throws Exception {
        // Some plumbing to get the service ready for rotation updates.
        sWm.mDisplayReady = true;
@@ -145,15 +143,20 @@ public class AppWindowTokenTests extends WindowTestsBase {
        appWindowToken.addWindow(appWindow);

        // Set initial orientation and update.
        ((TestWindowManagerPolicy) sWm.mPolicy).rotationToReport = Surface.ROTATION_90;
        sWm.updateRotation(false, false);
        performRotation(Surface.ROTATION_90);
        appWindow.resizeReported = false;

        // Update the rotation to perform 180 degree rotation and check that resize was reported.
        ((TestWindowManagerPolicy) sWm.mPolicy).rotationToReport = Surface.ROTATION_270;
        sWm.updateRotation(false, false);
        sWm.mRoot.performSurfacePlacement(false /* recoveringMemory */);
        performRotation(Surface.ROTATION_270);
        assertTrue(appWindow.resizeReported);
        appWindow.removeImmediately();
    }

    private void performRotation(int rotationToReport) {
        ((TestWindowManagerPolicy) sWm.mPolicy).rotationToReport = rotationToReport;
        sWm.updateRotation(false, false);
        // Simulate animator finishing orientation change
        sWm.mRoot.mOrientationChangeComplete = true;
        sWm.mRoot.performSurfacePlacement(false /* recoveringMemory */);
    }
}
+4 −1
Original line number Diff line number Diff line
@@ -70,7 +70,10 @@ class WindowTestsBase {
    static WindowManagerService sWm = null;
    static TestWindowManagerPolicy sPolicy = null;
    private final static Session sMockSession = mock(Session.class);
    private static int sNextDisplayId = Display.DEFAULT_DISPLAY + 1;
    // The default display is removed in {@link #setUp} and then we iterate over all displays to
    // make sure we don't collide with any existing display. If we run into no other display, the
    // added display should be treated as default.
    private static int sNextDisplayId = Display.DEFAULT_DISPLAY;
    static int sNextStackId = FIRST_DYNAMIC_STACK_ID;
    private static int sNextTaskId = 0;