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

Commit 72540aef authored by Chavi Weingarten's avatar Chavi Weingarten
Browse files

Dump WindowInfo when tests fail

Use assertAndDumpWindowState to check the condition and dump the window
state when it fails.

Test: SurfaceControlViewHostTests
Test: TrustedOverlayTests
Bug: 314243641
Change-Id: Ia1a785c6ddaefc415ca89573ee5913dcb2632824
parent 9ce31aea
Loading
Loading
Loading
Loading
+7 −22
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

package com.android.server.wm;

import static android.server.wm.CtsWindowInfoUtils.dumpWindowsOnScreen;
import static android.server.wm.CtsWindowInfoUtils.assertAndDumpWindowState;
import static android.server.wm.CtsWindowInfoUtils.waitForWindowFocus;
import static android.server.wm.CtsWindowInfoUtils.waitForWindowVisible;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
@@ -129,37 +129,22 @@ public class SurfaceControlViewHostTests {
            mScvh2.setView(mView2, lp2);
        });

        boolean wasVisible = waitForWindowVisible(mView1);
        if (!wasVisible) {
            dumpWindowsOnScreen(TAG, "requestFocusWithMultipleWindows");
        }
        assertTrue("Failed to wait for view1", wasVisible);

        wasVisible = waitForWindowVisible(mView2);
        if (!wasVisible) {
            dumpWindowsOnScreen(TAG, "requestFocusWithMultipleWindows-not visible");
        }
        assertTrue("Failed to wait for view2", wasVisible);
        assertAndDumpWindowState(TAG, "Failed to wait for view1", waitForWindowVisible(mView1));
        assertAndDumpWindowState(TAG, "Failed to wait for view2", waitForWindowVisible(mView2));

        IWindow window = IWindow.Stub.asInterface(mSurfaceView.getWindowToken());

        WindowManagerGlobal.getWindowSession().grantEmbeddedWindowFocus(window,
                mScvh1.getInputTransferToken(), true);

        boolean gainedFocus = waitForWindowFocus(mView1, true);
        if (!gainedFocus) {
            dumpWindowsOnScreen(TAG, "requestFocusWithMultipleWindows-view1 not focus");
        }
        assertTrue("Failed to gain focus for view1", gainedFocus);
        assertAndDumpWindowState(TAG, "Failed to wait for view1 focus",
                waitForWindowFocus(mView1, true));

        WindowManagerGlobal.getWindowSession().grantEmbeddedWindowFocus(window,
                mScvh2.getInputTransferToken(), true);

        gainedFocus = waitForWindowFocus(mView2, true);
        if (!gainedFocus) {
            dumpWindowsOnScreen(TAG, "requestFocusWithMultipleWindows-view2 not focus");
        }
        assertTrue("Failed to gain focus for view2", gainedFocus);
        assertAndDumpWindowState(TAG, "Failed to wait for view2 focus",
                waitForWindowFocus(mView2, true));
    }

    private static class TestWindowlessWindowManager extends WindowlessWindowManager {
+3 −5
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.wm;

import static android.server.wm.CtsWindowInfoUtils.assertAndDumpWindowState;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;

@@ -138,11 +139,8 @@ public class TrustedOverlayTests {
                    return false;
                }, TIMEOUT_S, TimeUnit.SECONDS);

        if (!foundTrusted[0]) {
            CtsWindowInfoUtils.dumpWindowsOnScreen(TAG, mName.getMethodName());
        }

        assertTrue("Failed to find window or was not marked trusted", foundTrusted[0]);
        assertAndDumpWindowState(TAG, "Failed to find window or was not marked trusted",
                foundTrusted[0]);
    }

    private void testTrustedOverlayChildHelper(boolean expectedTrustedChild)