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
This commit is contained in:
ryanlwlin
2021-08-19 18:44:42 +08:00
parent cc2f80f5a0
commit 86b92aef1a

View File

@@ -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);
}
}