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
This commit is contained in:
Jean Chen
2023-07-13 14:45:54 +08:00
parent d68a00cc40
commit 2bb5f88c7d

View File

@@ -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