Merge "Fix rotation test faiulre on foldable devices" into sc-v2-dev am: 988a050fcb

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15674056

Change-Id: I407a96fffe6ea4427fae6cf81fcaba7fb4a891c6
This commit is contained in:
Ryan Lin
2021-08-31 01:36:28 +00:00
committed by Automerger Merge Worker

View File

@@ -252,7 +252,9 @@ public class WindowMagnificationControllerTest extends SysuiTestCase {
@Test @Test
public void onOrientationChanged_enabled_updateDisplayRotationAndCenterStayAtSamePosition() { public void onOrientationChanged_enabled_updateDisplayRotationAndCenterStayAtSamePosition() {
final Display display = Mockito.spy(mContext.getDisplay()); final Display display = Mockito.spy(mContext.getDisplay());
when(display.getRotation()).thenReturn(Surface.ROTATION_90); final int currentRotation = display.getRotation();
final int newRotation = (currentRotation + 1) % 4;
when(display.getRotation()).thenReturn(newRotation);
when(mContext.getDisplay()).thenReturn(display); when(mContext.getDisplay()).thenReturn(display);
mInstrumentation.runOnMainSync(() -> { mInstrumentation.runOnMainSync(() -> {
mWindowMagnificationController.enableWindowMagnification(Float.NaN, Float.NaN, mWindowMagnificationController.enableWindowMagnification(Float.NaN, Float.NaN,
@@ -261,7 +263,7 @@ public class WindowMagnificationControllerTest extends SysuiTestCase {
final PointF expectedCenter = new PointF(mWindowMagnificationController.getCenterY(), final PointF expectedCenter = new PointF(mWindowMagnificationController.getCenterY(),
mWindowMagnificationController.getCenterX()); mWindowMagnificationController.getCenterX());
final Rect windowBounds = new Rect(mWindowManager.getCurrentWindowMetrics().getBounds()); final Rect windowBounds = new Rect(mWindowManager.getCurrentWindowMetrics().getBounds());
// Rotate the window 90 degrees. // Rotate the window clockwise 90 degree.
windowBounds.set(windowBounds.top, windowBounds.left, windowBounds.bottom, windowBounds.set(windowBounds.top, windowBounds.left, windowBounds.bottom,
windowBounds.right); windowBounds.right);
mWindowManager.setWindowBounds(windowBounds); mWindowManager.setWindowBounds(windowBounds);
@@ -270,7 +272,7 @@ public class WindowMagnificationControllerTest extends SysuiTestCase {
mWindowMagnificationController.onConfigurationChanged(ActivityInfo.CONFIG_ORIENTATION); mWindowMagnificationController.onConfigurationChanged(ActivityInfo.CONFIG_ORIENTATION);
}); });
assertEquals(Surface.ROTATION_90, mWindowMagnificationController.mRotation); assertEquals(newRotation, mWindowMagnificationController.mRotation);
final PointF actualCenter = new PointF(mWindowMagnificationController.getCenterX(), final PointF actualCenter = new PointF(mWindowMagnificationController.getCenterX(),
mWindowMagnificationController.getCenterY()); mWindowMagnificationController.getCenterY());
assertEquals(expectedCenter, actualCenter); assertEquals(expectedCenter, actualCenter);