For fixed rotation test assert that PiP is within screen bounds
This is done by asserting on the center point of the PiP window, since
in the fixed rotation case the full PiP bounds can temporarily go
outside of screen bounds, as it is resizing from landscape fullscreen
to final PiP size.
The transition also involves rotating the display, which is why we have
to first assert against starting bounds in landscape, and then check
against the portrait bounds at the end of the transition. At that point
we are asserting full PiP bounds though, as it is expected to be fully
inside the display bounds.
Test: atest EnterPipToOtherOrientation
Bug: 275092905
Flag: none
Change-Id: I87f42c9c96e5a01c8aff44c6c44a06fb9d29c2de
diff --git a/libs/WindowManager/Shell/tests/flicker/pip/src/com/android/wm/shell/flicker/pip/EnterPipToOtherOrientation.kt b/libs/WindowManager/Shell/tests/flicker/pip/src/com/android/wm/shell/flicker/pip/EnterPipToOtherOrientation.kt
index ac7380f..9a1bd26 100644
--- a/libs/WindowManager/Shell/tests/flicker/pip/src/com/android/wm/shell/flicker/pip/EnterPipToOtherOrientation.kt
+++ b/libs/WindowManager/Shell/tests/flicker/pip/src/com/android/wm/shell/flicker/pip/EnterPipToOtherOrientation.kt
@@ -206,6 +206,18 @@
         }
     }
 
+    @Presubmit
+    @Test
+    fun pipLayerRemainInsideVisibleBounds() {
+        // during the transition we assert the center point is within the display bounds, since it
+        // might go outside of bounds as we resize from landscape fullscreen to destination bounds,
+        // and once the animation is over we assert that it's fully within the display bounds, at
+        // which point the device also performs orientation change from landscape to portrait
+        flicker.assertLayersVisibleRegion(pipApp.or(ComponentNameMatcher.PIP_CONTENT_OVERLAY)) {
+            regionsCenterPointInside(startingBounds).then().coversAtMost(endingBounds)
+        }
+    }
+
     /** {@inheritDoc} */
     @FlakyTest(bugId = 267424412)
     @Test