Loading libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterbox/LetterboxUtils.kt +4 −2 Original line number Diff line number Diff line Loading @@ -93,7 +93,7 @@ object LetterboxUtils { // Utility methods about Transaction usage in Letterbox. object Transactions { // Sets position and crops in one method. // Sets position and crops in one method. The surface is hidden if the crop Rect is empty. fun Transaction.moveAndCrop( surface: SurfaceControl, rect: Rect Loading @@ -103,6 +103,8 @@ object LetterboxUtils { surface, rect.width(), rect.height() ) ).apply { setVisibility(surface, !rect.isEmpty) } } } libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/letterbox/LetterboxUtilsTest.kt +22 −1 Original line number Diff line number Diff line Loading @@ -115,11 +115,28 @@ class LetterboxUtilsTest : ShellTestCase() { } @Test fun `moveAndCrop invoked Move and then Crop`() { fun `moveAndCrop invoked Move and then Crop and Visible`() { runTestScenario { r -> r.invoke(Rect(1, 2, 51, 62)) r.verifySetPosition(expectedX = 1f, expectedY = 2f) r.verifySetWindowCrop(expectedWidth = 50, expectedHeight = 60) r.verifySetVisibility(expectedVisibility = true) } } @Test fun `moveAndCrop hide surface if rect has an empty dimension`() { runTestScenario { r -> r.invoke(Rect(100, 0, 100, 100)) r.verifySetVisibility(expectedVisibility = false) } } @Test fun `moveAndCrop hide surface if rect is empty`() { runTestScenario { r -> r.invoke(Rect(0, 0, 0, 0)) r.verifySetVisibility(expectedVisibility = false) } } Loading Loading @@ -219,6 +236,10 @@ class LetterboxUtilsTest : ShellTestCase() { verify(transaction).setWindowCrop(surface, expectedWidth, expectedHeight) } fun verifySetVisibility(expectedVisibility: Boolean) { verify(transaction).setVisibility(surface, expectedVisibility) } override fun buildController(): LetterboxController = firstLetterboxController.append(secondLetterboxController) .append(thirdLetterboxController) Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/compatui/letterbox/LetterboxUtils.kt +4 −2 Original line number Diff line number Diff line Loading @@ -93,7 +93,7 @@ object LetterboxUtils { // Utility methods about Transaction usage in Letterbox. object Transactions { // Sets position and crops in one method. // Sets position and crops in one method. The surface is hidden if the crop Rect is empty. fun Transaction.moveAndCrop( surface: SurfaceControl, rect: Rect Loading @@ -103,6 +103,8 @@ object LetterboxUtils { surface, rect.width(), rect.height() ) ).apply { setVisibility(surface, !rect.isEmpty) } } }
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/letterbox/LetterboxUtilsTest.kt +22 −1 Original line number Diff line number Diff line Loading @@ -115,11 +115,28 @@ class LetterboxUtilsTest : ShellTestCase() { } @Test fun `moveAndCrop invoked Move and then Crop`() { fun `moveAndCrop invoked Move and then Crop and Visible`() { runTestScenario { r -> r.invoke(Rect(1, 2, 51, 62)) r.verifySetPosition(expectedX = 1f, expectedY = 2f) r.verifySetWindowCrop(expectedWidth = 50, expectedHeight = 60) r.verifySetVisibility(expectedVisibility = true) } } @Test fun `moveAndCrop hide surface if rect has an empty dimension`() { runTestScenario { r -> r.invoke(Rect(100, 0, 100, 100)) r.verifySetVisibility(expectedVisibility = false) } } @Test fun `moveAndCrop hide surface if rect is empty`() { runTestScenario { r -> r.invoke(Rect(0, 0, 0, 0)) r.verifySetVisibility(expectedVisibility = false) } } Loading Loading @@ -219,6 +236,10 @@ class LetterboxUtilsTest : ShellTestCase() { verify(transaction).setWindowCrop(surface, expectedWidth, expectedHeight) } fun verifySetVisibility(expectedVisibility: Boolean) { verify(transaction).setVisibility(surface, expectedVisibility) } override fun buildController(): LetterboxController = firstLetterboxController.append(secondLetterboxController) .append(thirdLetterboxController) Loading