Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTaskPosition.kt +4 −4 Original line number Diff line number Diff line Loading @@ -116,10 +116,10 @@ fun canChangeTaskPosition(taskInfo: TaskInfo): Boolean { @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) fun Rect.getDesktopTaskPosition(bounds: Rect): DesktopTaskPosition { return when { top == bounds.top && left == bounds.left -> TopLeft top == bounds.top && right == bounds.right -> TopRight bottom == bounds.bottom && left == bounds.left -> BottomLeft bottom == bounds.bottom && right == bounds.right -> BottomRight top == bounds.top && left == bounds.left && bottom != bounds.bottom -> TopLeft top == bounds.top && right == bounds.right && bottom != bounds.bottom -> TopRight bottom == bounds.bottom && left == bounds.left && top != bounds.top -> BottomLeft bottom == bounds.bottom && right == bounds.right && top != bounds.top -> BottomRight else -> Center } } Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +58 −0 Original line number Diff line number Diff line Loading @@ -729,6 +729,64 @@ class DesktopTasksControllerTest : ShellTestCase() { .isEqualTo(DesktopTaskPosition.Center) } @Test @EnableFlags(Flags.FLAG_ENABLE_CASCADING_WINDOWS) fun addMoveToDesktopChanges_lastWindowSnapLeft_positionResetsToCenter() { setUpLandscapeDisplay() val stableBounds = Rect() displayLayout.getStableBoundsForDesktopMode(stableBounds) // Add freeform task with half display size snap bounds at left side. setUpFreeformTask(bounds = Rect(stableBounds.left, stableBounds.top, 500, stableBounds.bottom)) val task = setUpFullscreenTask() val wct = WindowContainerTransaction() controller.addMoveToDesktopChanges(wct, task) val finalBounds = findBoundsChange(wct, task) assertThat(stableBounds.getDesktopTaskPosition(finalBounds!!)) .isEqualTo(DesktopTaskPosition.Center) } @Test @EnableFlags(Flags.FLAG_ENABLE_CASCADING_WINDOWS) fun addMoveToDesktopChanges_lastWindowSnapRight_positionResetsToCenter() { setUpLandscapeDisplay() val stableBounds = Rect() displayLayout.getStableBoundsForDesktopMode(stableBounds) // Add freeform task with half display size snap bounds at right side. setUpFreeformTask(bounds = Rect( stableBounds.right - 500, stableBounds.top, stableBounds.right, stableBounds.bottom)) val task = setUpFullscreenTask() val wct = WindowContainerTransaction() controller.addMoveToDesktopChanges(wct, task) val finalBounds = findBoundsChange(wct, task) assertThat(stableBounds.getDesktopTaskPosition(finalBounds!!)) .isEqualTo(DesktopTaskPosition.Center) } @Test @EnableFlags(Flags.FLAG_ENABLE_CASCADING_WINDOWS) fun addMoveToDesktopChanges_lastWindowMaximised_positionResetsToCenter() { setUpLandscapeDisplay() val stableBounds = Rect() displayLayout.getStableBoundsForDesktopMode(stableBounds) // Add maximised freeform task. setUpFreeformTask(bounds = Rect(stableBounds)) val task = setUpFullscreenTask() val wct = WindowContainerTransaction() controller.addMoveToDesktopChanges(wct, task) val finalBounds = findBoundsChange(wct, task) assertThat(stableBounds.getDesktopTaskPosition(finalBounds!!)) .isEqualTo(DesktopTaskPosition.Center) } @Test @EnableFlags(Flags.FLAG_ENABLE_CASCADING_WINDOWS) fun addMoveToDesktopChanges_defaultToCenterIfFree() { Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTaskPosition.kt +4 −4 Original line number Diff line number Diff line Loading @@ -116,10 +116,10 @@ fun canChangeTaskPosition(taskInfo: TaskInfo): Boolean { @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) fun Rect.getDesktopTaskPosition(bounds: Rect): DesktopTaskPosition { return when { top == bounds.top && left == bounds.left -> TopLeft top == bounds.top && right == bounds.right -> TopRight bottom == bounds.bottom && left == bounds.left -> BottomLeft bottom == bounds.bottom && right == bounds.right -> BottomRight top == bounds.top && left == bounds.left && bottom != bounds.bottom -> TopLeft top == bounds.top && right == bounds.right && bottom != bounds.bottom -> TopRight bottom == bounds.bottom && left == bounds.left && top != bounds.top -> BottomLeft bottom == bounds.bottom && right == bounds.right && top != bounds.top -> BottomRight else -> Center } } Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +58 −0 Original line number Diff line number Diff line Loading @@ -729,6 +729,64 @@ class DesktopTasksControllerTest : ShellTestCase() { .isEqualTo(DesktopTaskPosition.Center) } @Test @EnableFlags(Flags.FLAG_ENABLE_CASCADING_WINDOWS) fun addMoveToDesktopChanges_lastWindowSnapLeft_positionResetsToCenter() { setUpLandscapeDisplay() val stableBounds = Rect() displayLayout.getStableBoundsForDesktopMode(stableBounds) // Add freeform task with half display size snap bounds at left side. setUpFreeformTask(bounds = Rect(stableBounds.left, stableBounds.top, 500, stableBounds.bottom)) val task = setUpFullscreenTask() val wct = WindowContainerTransaction() controller.addMoveToDesktopChanges(wct, task) val finalBounds = findBoundsChange(wct, task) assertThat(stableBounds.getDesktopTaskPosition(finalBounds!!)) .isEqualTo(DesktopTaskPosition.Center) } @Test @EnableFlags(Flags.FLAG_ENABLE_CASCADING_WINDOWS) fun addMoveToDesktopChanges_lastWindowSnapRight_positionResetsToCenter() { setUpLandscapeDisplay() val stableBounds = Rect() displayLayout.getStableBoundsForDesktopMode(stableBounds) // Add freeform task with half display size snap bounds at right side. setUpFreeformTask(bounds = Rect( stableBounds.right - 500, stableBounds.top, stableBounds.right, stableBounds.bottom)) val task = setUpFullscreenTask() val wct = WindowContainerTransaction() controller.addMoveToDesktopChanges(wct, task) val finalBounds = findBoundsChange(wct, task) assertThat(stableBounds.getDesktopTaskPosition(finalBounds!!)) .isEqualTo(DesktopTaskPosition.Center) } @Test @EnableFlags(Flags.FLAG_ENABLE_CASCADING_WINDOWS) fun addMoveToDesktopChanges_lastWindowMaximised_positionResetsToCenter() { setUpLandscapeDisplay() val stableBounds = Rect() displayLayout.getStableBoundsForDesktopMode(stableBounds) // Add maximised freeform task. setUpFreeformTask(bounds = Rect(stableBounds)) val task = setUpFullscreenTask() val wct = WindowContainerTransaction() controller.addMoveToDesktopChanges(wct, task) val finalBounds = findBoundsChange(wct, task) assertThat(stableBounds.getDesktopTaskPosition(finalBounds!!)) .isEqualTo(DesktopTaskPosition.Center) } @Test @EnableFlags(Flags.FLAG_ENABLE_CASCADING_WINDOWS) fun addMoveToDesktopChanges_defaultToCenterIfFree() { Loading