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

Commit 34ab4d95 authored by Chavi Weingarten's avatar Chavi Weingarten Committed by Android (Google) Code Review
Browse files

Merge "Catch and log exceptions from setup or teardown of WindowTestBase" into pi-dev

parents 20ebb0a6 578b6fed
Loading
Loading
Loading
Loading
+70 −52
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import static android.view.View.VISIBLE;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.hardware.display.DisplayManagerGlobal;
import android.util.Log;
import android.view.Display;
import android.view.DisplayInfo;
import org.junit.Assert;
@@ -62,6 +63,7 @@ import java.util.LinkedList;
 * Common base class for window manager unit test classes.
 */
class WindowTestsBase {
    private static final String TAG = WindowTestsBase.class.getSimpleName();
    static WindowManagerService sWm = null;
    private static final IWindow sIWindow = new TestIWindow();
    private static Session sMockSession;
@@ -91,6 +93,9 @@ class WindowTestsBase {

    @Before
    public void setUp() throws Exception {
        // If @Before throws an exception, the error isn't logged. This will make sure any failures
        // in the set up are clear. This can be removed when b/37850063 is fixed.
        try {
            if (!sOneTimeSetupDone) {
                sOneTimeSetupDone = true;

@@ -118,19 +123,25 @@ class WindowTestsBase {
            mWallpaperWindow = createCommonWindow(null, TYPE_WALLPAPER, "wallpaperWindow");
            mImeWindow = createCommonWindow(null, TYPE_INPUT_METHOD, "mImeWindow");
            sWm.mInputMethodWindow = mImeWindow;
        mImeDialogWindow = createCommonWindow(null, TYPE_INPUT_METHOD_DIALOG, "mImeDialogWindow");
            mImeDialogWindow = createCommonWindow(null, TYPE_INPUT_METHOD_DIALOG,
                    "mImeDialogWindow");
            mStatusBarWindow = createCommonWindow(null, TYPE_STATUS_BAR, "mStatusBarWindow");
            mNavBarWindow = createCommonWindow(null, TYPE_NAVIGATION_BAR, "mNavBarWindow");
        mDockedDividerWindow = createCommonWindow(null, TYPE_DOCK_DIVIDER, "mDockedDividerWindow");
            mDockedDividerWindow = createCommonWindow(null, TYPE_DOCK_DIVIDER,
                    "mDockedDividerWindow");
            mAppWindow = createCommonWindow(null, TYPE_BASE_APPLICATION, "mAppWindow");
            mChildAppWindowAbove = createCommonWindow(mAppWindow, TYPE_APPLICATION_ATTACHED_DIALOG,
                    "mChildAppWindowAbove");
            mChildAppWindowBelow = createCommonWindow(mAppWindow, TYPE_APPLICATION_MEDIA_OVERLAY,
                    "mChildAppWindowBelow");

        // Adding a display will cause freezing the display. Make sure to wait until it's unfrozen
        // to not run into race conditions with the tests.
            // Adding a display will cause freezing the display. Make sure to wait until it's
            // unfrozen to not run into race conditions with the tests.
            waitUntilHandlersIdle();
        } catch (Exception e) {
            Log.e(TAG, "Failed to set up test", e);
            throw e;
        }
    }

    void beforeCreateDisplay() {
@@ -139,6 +150,9 @@ class WindowTestsBase {

    @After
    public void tearDown() throws Exception {
        // If @After throws an exception, the error isn't logged. This will make sure any failures
        // in the tear down are clear. This can be removed when b/37850063 is fixed.
        try {
            final LinkedList<WindowState> nonCommonWindows = new LinkedList();

            synchronized (sWm.mWindowMap) {
@@ -158,6 +172,10 @@ class WindowTestsBase {

            // Wait until everything is really cleaned up.
            waitUntilHandlersIdle();
        } catch (Exception e) {
            Log.e(TAG, "Failed to tear down test", e);
            throw e;
        }
    }

    /**