From 2bb5f88c7d48654b7c1c29fb3cc639d152f1b2eb Mon Sep 17 00:00:00 2001 From: Jean Chen Date: Thu, 13 Jul 2023 14:45:54 +0800 Subject: [PATCH] Fix WindowMagnificationAnimationControllerTest fail The root cause is that we are using different types (int and float) between the code base and the test case. If we convert a floating-point number to an integer, the decimal part of the float value is truncated. But, the round() method rounds upward if the value after the decimal is greater than or equal to 5. Bug: 290648269 Test: atest WindowMagnificationAnimationControllerTest (Pixel 7 & Pixel Fold) Change-Id: I0ae0f69e9078f998f5d6c08b2aefbe00e1628af9 --- .../WindowMagnificationAnimationControllerTest.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationAnimationControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationAnimationControllerTest.java index 92c5014dc5f15..09d0eebd510df 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationAnimationControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationAnimationControllerTest.java @@ -512,10 +512,11 @@ public class WindowMagnificationAnimationControllerTest extends SysuiTestCase { assertNotNull(mirrorView); mirrorView.getBoundsOnScreen(mirrorViewBound); - assertEquals(mirrorViewBound.exactCenterX() - windowBounds.exactCenterX(), - Math.round(offsetRatio * mirrorViewBound.width() / 2), 0.1f); - assertEquals(mirrorViewBound.exactCenterY() - windowBounds.exactCenterY(), - Math.round(offsetRatio * mirrorViewBound.height() / 2), 0.1f); + assertEquals((int) (offsetRatio * mirrorViewBound.width() / 2), + (int) (mirrorViewBound.exactCenterX() - windowBounds.exactCenterX())); + assertEquals((int) (offsetRatio * mirrorViewBound.height() / 2), + (int) (mirrorViewBound.exactCenterY() - windowBounds.exactCenterY())); + } @Test