From 86b92aef1a92b0db7de9c630151405dd9ee21b36 Mon Sep 17 00:00:00 2001 From: ryanlwlin Date: Thu, 19 Aug 2021 18:44:42 +0800 Subject: [PATCH] Fix WindowMagnificationControllerTest failure on foldable targets In foldables, the bottom valure of system gestureinset is 0. We fix it with a test windowinset. Bug: 196931900 Test: atest WindowMagnificationControllerTest use forrest to run WindowMagnificationControllerTest Change-Id: Iaa58de87a89bf47edd9ac9beb52afa5b3cf006e7 --- .../WindowMagnificationControllerTest.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java index 76cc7a0eda133..77941366b4d3b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java @@ -188,6 +188,7 @@ public class WindowMagnificationControllerTest extends SysuiTestCase { public void deleteWindowMagnification_enableAtTheBottom_overlapFlagIsFalse() { final WindowManager wm = mContext.getSystemService(WindowManager.class); final Rect bounds = wm.getCurrentWindowMetrics().getBounds(); + setSystemGestureInsets(); mInstrumentation.runOnMainSync(() -> { mWindowMagnificationController.enableWindowMagnification(Float.NaN, Float.NaN, @@ -463,10 +464,7 @@ public class WindowMagnificationControllerTest extends SysuiTestCase { @Test public void moveWindowMagnificationToTheBottom_enabledWithGestureInset_overlapFlagIsTrue() { final Rect bounds = mWindowManager.getCurrentWindowMetrics().getBounds(); - final WindowInsets testInsets = new WindowInsets.Builder() - .setInsets(systemGestures(), Insets.of(0, 0, 0, 10)) - .build(); - mWindowManager.setWindowInsets(testInsets); + setSystemGestureInsets(); mInstrumentation.runOnMainSync(() -> { mWindowMagnificationController.enableWindowMagnification(Float.NaN, Float.NaN, Float.NaN); @@ -492,4 +490,11 @@ public class WindowMagnificationControllerTest extends SysuiTestCase { private boolean hasMagnificationOverlapFlag() { return (mSysUiState.getFlags() & SYSUI_STATE_MAGNIFICATION_OVERLAP) != 0; } + + private void setSystemGestureInsets() { + final WindowInsets testInsets = new WindowInsets.Builder() + .setInsets(systemGestures(), Insets.of(0, 0, 0, 10)) + .build(); + mWindowManager.setWindowInsets(testInsets); + } }