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

Commit 6272c7f8 authored by Bryce Lee's avatar Bryce Lee
Browse files

Do not remove the default display during tests.

The default display is used by some tests that exercise features only
functional only on the default display (like policy rotation). This CL
makes this display not get removed with the created test displays and
ensures no collision in id space from a previous test run (done in the
test setup).

Change-Id: Ia14b9c023c779d263283fe8c7b512dca17ff312f
Fix: 36385757
Test: bit FrameworksServicesTests:com.android.server.wm.StackWindowControllerTests#testRemoveContainer_deferRemoval
parent 44277fbd
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -132,9 +132,10 @@ public class AppWindowTokenTests extends WindowTestsBase {
        sWm.mDisplayEnabled = true;

        // Create an app window with token on a display.
        final TaskStack stack = createTaskStackOnDisplay(sDisplayContent);
        final DisplayContent defaultDisplayContent = sWm.getDefaultDisplayContentLocked();
        final TaskStack stack = createTaskStackOnDisplay(defaultDisplayContent);
        final Task task = createTaskInStack(stack, 0 /* userId */);
        final TestAppWindowToken appWindowToken = new TestAppWindowToken(sDisplayContent);
        final TestAppWindowToken appWindowToken = new TestAppWindowToken(defaultDisplayContent);
        task.addChild(appWindowToken, 0);
        final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(
                TYPE_BASE_APPLICATION);
+12 −6
Original line number Diff line number Diff line
@@ -73,8 +73,8 @@ class WindowTestsBase {
    private final static Session sMockSession = mock(Session.class);
    // 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;
    // added display should be treated as default. This cannot be the default display
    private static int sNextDisplayId = Display.DEFAULT_DISPLAY + 1;
    static int sNextStackId = FIRST_DYNAMIC_STACK_ID;
    private static int sNextTaskId = 0;

@@ -105,17 +105,23 @@ class WindowTestsBase {
        sWm = TestWindowManagerPolicy.getWindowManagerService(context);
        sPolicy = (TestWindowManagerPolicy) sWm.mPolicy;
        sLayersController = new WindowLayersController(sWm);
        sDisplayContent = sWm.mRoot.getDisplayContent(context.getDisplay().getDisplayId());
        if (sDisplayContent != null) {
            sDisplayContent.removeImmediately();
        }

        // Make sure that display ids don't overlap, so there won't be several displays with same
        // ids among RootWindowContainer children.
        for (DisplayContent dc : sWm.mRoot.mChildren) {
            if (dc.getDisplayId() >= sNextDisplayId) {
                sNextDisplayId = dc.getDisplayId() + 1;
            }

            // The default display must be preserved as some tests require it to function
            // (such as policy rotation).
            if (dc.getDisplayId() != Display.DEFAULT_DISPLAY) {
                // It is safe to remove these displays as new displays will always be created with
                // new ids.
                dc.removeImmediately();
            }
        }

        context.getDisplay().getDisplayInfo(sDisplayInfo);
        sDisplayContent = createNewDisplay();
        sWm.mDisplayEnabled = true;