Revert "Superficial improvements to ZOrderingTest."

This reverts commit 515a40a14980f0df908a0a08c3220854beee8c14.

Reason for revert: CL Earlier in chain causes 71736995

Change-Id: Id1fc0edcad15aa2d785a911a782a05bb6b5766a9
(cherry picked from commit e6282e8f82aa5f8048771f974b158329eb341e45)
diff --git a/services/tests/servicestests/src/com/android/server/wm/ZOrderingTests.java b/services/tests/servicestests/src/com/android/server/wm/ZOrderingTests.java
index bcc9a1c..34277c3 100644
--- a/services/tests/servicestests/src/com/android/server/wm/ZOrderingTests.java
+++ b/services/tests/servicestests/src/com/android/server/wm/ZOrderingTests.java
@@ -76,11 +76,11 @@
             return super.setRelativeLayer(sc, relativeTo, layer);
         }
 
-        private int getLayer(SurfaceControl sc) {
+        int getLayer(SurfaceControl sc) {
             return mLayersForControl.getOrDefault(sc, 0);
         }
 
-        private SurfaceControl getRelativeLayer(SurfaceControl sc) {
+        SurfaceControl getRelativeLayer(SurfaceControl sc) {
             return mRelativeLayersForControl.get(sc);
         }
     };
@@ -148,9 +148,8 @@
         return p;
     }
 
-
-    void assertZOrderGreaterThan(LayerRecordingTransaction t, SurfaceControl left,
-            SurfaceControl right) throws Exception {
+    void assertZOrderGreaterThan(LayerRecordingTransaction t,
+            SurfaceControl left, SurfaceControl right) throws Exception {
         final LinkedList<SurfaceControl> leftParentChain = getAncestors(t, left);
         final LinkedList<SurfaceControl> rightParentChain = getAncestors(t, right);
 
@@ -174,12 +173,9 @@
         }
     }
 
-    void assertWindowHigher(WindowState left, WindowState right) throws Exception {
-        assertZOrderGreaterThan(mTransaction, left.getSurfaceControl(), right.getSurfaceControl());
-    }
-
-    WindowState createWindow(String name) {
-        return createWindow(null, TYPE_BASE_APPLICATION, mDisplayContent, name);
+    void assertWindowLayerGreaterThan(LayerRecordingTransaction t,
+            WindowState left, WindowState right) throws Exception {
+        assertZOrderGreaterThan(t, left.getSurfaceControl(), right.getSurfaceControl());
     }
 
     @Test
@@ -190,37 +186,38 @@
         // The Ime has an higher base layer than app windows and lower base layer than system
         // windows, so it should be above app windows and below system windows if there isn't an IME
         // target.
-        assertWindowHigher(mImeWindow, mChildAppWindowAbove);
-        assertWindowHigher(mImeWindow, mAppWindow);
-        assertWindowHigher(mNavBarWindow, mImeWindow);
-        assertWindowHigher(mStatusBarWindow, mImeWindow);
+        assertWindowLayerGreaterThan(mTransaction, mImeWindow, mChildAppWindowAbove);
+        assertWindowLayerGreaterThan(mTransaction, mImeWindow, mAppWindow);
+        assertWindowLayerGreaterThan(mTransaction, mNavBarWindow, mImeWindow);
+        assertWindowLayerGreaterThan(mTransaction, mStatusBarWindow, mImeWindow);
 
         // And, IME dialogs should always have an higher layer than the IME.
-        assertWindowHigher(mImeDialogWindow, mImeWindow);
+        assertWindowLayerGreaterThan(mTransaction, mImeDialogWindow, mImeWindow);
     }
 
     @Test
     public void testAssignWindowLayers_ForImeWithAppTarget() throws Exception {
-        final WindowState imeAppTarget = createWindow("imeAppTarget");
+        final WindowState imeAppTarget =
+                createWindow(null, TYPE_BASE_APPLICATION, mDisplayContent, "imeAppTarget");
         sWm.mInputMethodTarget = imeAppTarget;
-
         mDisplayContent.assignChildLayers(mTransaction);
 
         // Ime should be above all app windows and below system windows if it is targeting an app
         // window.
-        assertWindowHigher(mImeWindow, imeAppTarget);
-        assertWindowHigher(mImeWindow, mChildAppWindowAbove);
-        assertWindowHigher(mImeWindow, mAppWindow);
-        assertWindowHigher(mNavBarWindow, mImeWindow);
-        assertWindowHigher(mStatusBarWindow, mImeWindow);
+        assertWindowLayerGreaterThan(mTransaction, mImeWindow, imeAppTarget);
+        assertWindowLayerGreaterThan(mTransaction, mImeWindow, mChildAppWindowAbove);
+        assertWindowLayerGreaterThan(mTransaction, mImeWindow, mAppWindow);
+        assertWindowLayerGreaterThan(mTransaction, mNavBarWindow, mImeWindow);
+        assertWindowLayerGreaterThan(mTransaction, mStatusBarWindow, mImeWindow);
 
         // And, IME dialogs should always have an higher layer than the IME.
-        assertWindowHigher(mImeDialogWindow, mImeWindow);
+        assertWindowLayerGreaterThan(mTransaction, mImeDialogWindow, mImeWindow);
     }
 
     @Test
     public void testAssignWindowLayers_ForImeWithAppTargetWithChildWindows() throws Exception {
-        final WindowState imeAppTarget = createWindow("imeAppTarget");
+        final WindowState imeAppTarget =
+                createWindow(null, TYPE_BASE_APPLICATION, mDisplayContent, "imeAppTarget");
         final WindowState imeAppTargetChildAboveWindow = createWindow(imeAppTarget,
                 TYPE_APPLICATION_ATTACHED_DIALOG, imeAppTarget.mToken,
                 "imeAppTargetChildAboveWindow");
@@ -233,38 +230,41 @@
 
         // Ime should be above all app windows except for child windows that are z-ordered above it
         // and below system windows if it is targeting an app window.
-        assertWindowHigher(mImeWindow, imeAppTarget);
-        assertWindowHigher(imeAppTargetChildAboveWindow, mImeWindow);
-        assertWindowHigher(mImeWindow, mChildAppWindowAbove);
-        assertWindowHigher(mImeWindow, mAppWindow);
-        assertWindowHigher(mNavBarWindow, mImeWindow);
-        assertWindowHigher(mStatusBarWindow, mImeWindow);
+        assertWindowLayerGreaterThan(mTransaction, mImeWindow, imeAppTarget);
+        assertWindowLayerGreaterThan(mTransaction, imeAppTargetChildAboveWindow, mImeWindow);
+        assertWindowLayerGreaterThan(mTransaction, mImeWindow, mChildAppWindowAbove);
+        assertWindowLayerGreaterThan(mTransaction, mImeWindow, mAppWindow);
+        assertWindowLayerGreaterThan(mTransaction, mNavBarWindow, mImeWindow);
+        assertWindowLayerGreaterThan(mTransaction, mStatusBarWindow, mImeWindow);
 
         // And, IME dialogs should always have an higher layer than the IME.
-        assertWindowHigher(mImeDialogWindow, mImeWindow);
+        assertWindowLayerGreaterThan(mTransaction, mImeDialogWindow, mImeWindow);
     }
 
     @Test
     public void testAssignWindowLayers_ForImeWithAppTargetAndAppAbove() throws Exception {
-        final WindowState appBelowImeTarget = createWindow("appBelowImeTarget");
-        final WindowState imeAppTarget = createWindow("imeAppTarget");
-        final WindowState appAboveImeTarget = createWindow("appAboveImeTarget");
+        final WindowState appBelowImeTarget =
+                createWindow(null, TYPE_BASE_APPLICATION, mDisplayContent, "appBelowImeTarget");
+        final WindowState imeAppTarget =
+                createWindow(null, TYPE_BASE_APPLICATION, mDisplayContent, "imeAppTarget");
+        final WindowState appAboveImeTarget =
+                createWindow(null, TYPE_BASE_APPLICATION, mDisplayContent, "appAboveImeTarget");
 
         sWm.mInputMethodTarget = imeAppTarget;
         mDisplayContent.assignChildLayers(mTransaction);
 
         // Ime should be above all app windows except for non-fullscreen app window above it and
         // below system windows if it is targeting an app window.
-        assertWindowHigher(mImeWindow, imeAppTarget);
-        assertWindowHigher(mImeWindow, appBelowImeTarget);
-        assertWindowHigher(appAboveImeTarget, mImeWindow);
-        assertWindowHigher(mImeWindow, mChildAppWindowAbove);
-        assertWindowHigher(mImeWindow, mAppWindow);
-        assertWindowHigher(mNavBarWindow, mImeWindow);
-        assertWindowHigher(mStatusBarWindow, mImeWindow);
+        assertWindowLayerGreaterThan(mTransaction, mImeWindow, imeAppTarget);
+        assertWindowLayerGreaterThan(mTransaction, mImeWindow, appBelowImeTarget);
+        assertWindowLayerGreaterThan(mTransaction, appAboveImeTarget, mImeWindow);
+        assertWindowLayerGreaterThan(mTransaction, mImeWindow, mChildAppWindowAbove);
+        assertWindowLayerGreaterThan(mTransaction, mImeWindow, mAppWindow);
+        assertWindowLayerGreaterThan(mTransaction, mNavBarWindow, mImeWindow);
+        assertWindowLayerGreaterThan(mTransaction, mStatusBarWindow, mImeWindow);
 
         // And, IME dialogs should always have an higher layer than the IME.
-        assertWindowHigher(mImeDialogWindow, mImeWindow);
+        assertWindowLayerGreaterThan(mTransaction, mImeDialogWindow, mImeWindow);
     }
 
     @Test
@@ -278,20 +278,20 @@
 
         // The IME target base layer is higher than all window except for the nav bar window, so the
         // IME should be above all windows except for the nav bar.
-        assertWindowHigher(mImeWindow, imeSystemOverlayTarget);
-        assertWindowHigher(mImeWindow, mChildAppWindowAbove);
-        assertWindowHigher(mImeWindow, mAppWindow);
-        assertWindowHigher(mImeWindow, mDockedDividerWindow);
+        assertWindowLayerGreaterThan(mTransaction, mImeWindow, imeSystemOverlayTarget);
+        assertWindowLayerGreaterThan(mTransaction, mImeWindow, mChildAppWindowAbove);
+        assertWindowLayerGreaterThan(mTransaction, mImeWindow, mAppWindow);
+        assertWindowLayerGreaterThan(mTransaction, mImeWindow, mDockedDividerWindow);
 
         // The IME has a higher base layer than the status bar so we may expect it to go
         // above the status bar once they are both in the Non-App layer, as past versions of this
         // test enforced. However this seems like the wrong behavior unless the status bar is the
         // IME target.
-        assertWindowHigher(mNavBarWindow, mImeWindow);
-        assertWindowHigher(mStatusBarWindow, mImeWindow);
+        assertWindowLayerGreaterThan(mTransaction, mNavBarWindow, mImeWindow);
+        assertWindowLayerGreaterThan(mTransaction, mStatusBarWindow, mImeWindow);
 
         // And, IME dialogs should always have an higher layer than the IME.
-        assertWindowHigher(mImeDialogWindow, mImeWindow);
+        assertWindowLayerGreaterThan(mTransaction, mImeDialogWindow, mImeWindow);
     }
 
     @Test
@@ -299,18 +299,19 @@
         sWm.mInputMethodTarget = mStatusBarWindow;
         mDisplayContent.assignChildLayers(mTransaction);
 
-        assertWindowHigher(mImeWindow, mChildAppWindowAbove);
-        assertWindowHigher(mImeWindow, mAppWindow);
-        assertWindowHigher(mImeWindow, mDockedDividerWindow);
-        assertWindowHigher(mImeWindow, mStatusBarWindow);
+        assertWindowLayerGreaterThan(mTransaction, mImeWindow, mChildAppWindowAbove);
+        assertWindowLayerGreaterThan(mTransaction, mImeWindow, mAppWindow);
+        assertWindowLayerGreaterThan(mTransaction, mImeWindow, mDockedDividerWindow);
+        assertWindowLayerGreaterThan(mTransaction, mImeWindow, mStatusBarWindow);
 
         // And, IME dialogs should always have an higher layer than the IME.
-        assertWindowHigher(mImeDialogWindow, mImeWindow);
+        assertWindowLayerGreaterThan(mTransaction, mImeDialogWindow, mImeWindow);
     }
 
     @Test
     public void testStackLayers() throws Exception {
-        final WindowState anyWindow1 = createWindow("anyWindow");
+        final WindowState anyWindow1 =
+                createWindow(null, TYPE_BASE_APPLICATION, mDisplayContent, "anyWindow");
         final WindowState pinnedStackWindow = createWindowOnStack(null, WINDOWING_MODE_PINNED,
                 ACTIVITY_TYPE_STANDARD, TYPE_BASE_APPLICATION, mDisplayContent,
                 "pinnedStackWindow");
@@ -320,17 +321,18 @@
         final WindowState assistantStackWindow = createWindowOnStack(null, WINDOWING_MODE_FULLSCREEN,
                 ACTIVITY_TYPE_ASSISTANT, TYPE_BASE_APPLICATION,
                 mDisplayContent, "assistantStackWindow");
-        final WindowState anyWindow2 = createWindow("anyWindow2");
+        final WindowState anyWindow2 =
+                createWindow(null, TYPE_BASE_APPLICATION, mDisplayContent, "anyWindow");
 
         mDisplayContent.assignChildLayers(mTransaction);
 
         // We compare the split-screen windowing mode to two different normal windowing
         // mode windows added before and after it to ensure the correct Z ordering irrespective
         // of ordering in the child list.
-        assertWindowHigher(dockedStackWindow, anyWindow1);
-        assertWindowHigher(dockedStackWindow, anyWindow2);
-        assertWindowHigher(assistantStackWindow, dockedStackWindow);
-        assertWindowHigher(pinnedStackWindow, assistantStackWindow);
+        assertWindowLayerGreaterThan(mTransaction, dockedStackWindow, anyWindow1);
+        assertWindowLayerGreaterThan(mTransaction, dockedStackWindow, anyWindow2);
+        assertWindowLayerGreaterThan(mTransaction, assistantStackWindow, dockedStackWindow);
+        assertWindowLayerGreaterThan(mTransaction, pinnedStackWindow, assistantStackWindow);
     }
 
     @Test
@@ -345,9 +347,9 @@
 
         // Ime should be above all app windows and below system windows if it is targeting an app
         // window.
-        assertWindowHigher(navBarPanel, mNavBarWindow);
-        assertWindowHigher(statusBarPanel, mStatusBarWindow);
-        assertWindowHigher(statusBarSubPanel, statusBarPanel);
+        assertWindowLayerGreaterThan(mTransaction, navBarPanel, mNavBarWindow);
+        assertWindowLayerGreaterThan(mTransaction, statusBarPanel, mStatusBarWindow);
+        assertWindowLayerGreaterThan(mTransaction, statusBarSubPanel, statusBarPanel);
     }
 
     @Test
@@ -355,7 +357,8 @@
         // TODO(b/70040778): We should aim to eliminate the last user of TYPE_APPLICATION_MEDIA
         // then we can drop all negative layering on the windowing side.
 
-        final WindowState anyWindow = createWindow("anyWindow");
+        final WindowState anyWindow =
+                createWindow(null, TYPE_BASE_APPLICATION, mDisplayContent, "anyWindow");
         final WindowState child = createWindow(anyWindow, TYPE_APPLICATION_MEDIA, mDisplayContent,
                 "TypeApplicationMediaChild");
         final WindowState mediaOverlayChild = createWindow(anyWindow, TYPE_APPLICATION_MEDIA_OVERLAY,
@@ -363,8 +366,8 @@
 
         mDisplayContent.assignChildLayers(mTransaction);
 
-        assertWindowHigher(anyWindow, mediaOverlayChild);
-        assertWindowHigher(mediaOverlayChild, child);
+        assertWindowLayerGreaterThan(mTransaction, anyWindow, mediaOverlayChild);
+        assertWindowLayerGreaterThan(mTransaction, mediaOverlayChild, child);
     }
 
     @Test
@@ -386,9 +389,9 @@
 
         mDisplayContent.assignChildLayers(mTransaction);
 
-        assertWindowHigher(dockedDividerWindow, splitScreenWindow);
-        assertWindowHigher(dockedDividerWindow, splitScreenSecondaryWindow);
-        assertWindowHigher(assistantStackWindow, dockedDividerWindow);
-        assertWindowHigher(pinnedStackWindow, dockedDividerWindow);
+        assertWindowLayerGreaterThan(mTransaction, dockedDividerWindow, splitScreenWindow);
+        assertWindowLayerGreaterThan(mTransaction, dockedDividerWindow, splitScreenSecondaryWindow);
+        assertWindowLayerGreaterThan(mTransaction, assistantStackWindow, dockedDividerWindow);
+        assertWindowLayerGreaterThan(mTransaction, pinnedStackWindow, dockedDividerWindow);
     }
 }