From 3f75d2fde77a587969b2a62579497ba6dfc88ca6 Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Thu, 21 Oct 2021 18:39:42 +0900 Subject: [PATCH] Fix rotation bounds calculation in WindowMagnificationControllerTest On display WxH, a point (x,y) after 90 degree rotation is (y, W-x) in a new coordinate. Bug: 203361026 Test: atest com.android.systemui.accessibility.WindowMagnificationControllerTest#onOrientationChanged_enabled_updateDisplayRotationAndCenterStayAtSamePosition Change-Id: I6fbe248873cd49a3ec52a56a060ade2620fe8710 --- .../accessibility/WindowMagnificationControllerTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 4098677cd7f58..14a60be364721 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java @@ -278,6 +278,7 @@ public class WindowMagnificationControllerTest extends SysuiTestCase { when(mContext.getDisplay()).thenReturn(display); final Rect windowBounds = new Rect(mWindowManager.getCurrentWindowMetrics().getBounds()); final float center = Math.min(windowBounds.exactCenterX(), windowBounds.exactCenterY()); + final float displayWidth = windowBounds.width(); final PointF magnifiedCenter = new PointF(center, center + 5f); mInstrumentation.runOnMainSync(() -> { mWindowMagnificationController.enableWindowMagnification(Float.NaN, magnifiedCenter.x, @@ -295,7 +296,8 @@ public class WindowMagnificationControllerTest extends SysuiTestCase { ActivityInfo.CONFIG_ORIENTATION)); assertEquals(newRotation, mWindowMagnificationController.mRotation); - final PointF expectedCenter = new PointF(magnifiedCenter.y, magnifiedCenter.x); + final PointF expectedCenter = new PointF(magnifiedCenter.y, + displayWidth - magnifiedCenter.x); final PointF actualCenter = new PointF(mWindowMagnificationController.getCenterX(), mWindowMagnificationController.getCenterY()); assertEquals(expectedCenter, actualCenter);