Loading libs/WindowManager/Shell/src/com/android/wm/shell/common/MultiDisplayDragMoveIndicatorController.kt +5 −9 Original line number Original line Diff line number Diff line Loading @@ -59,13 +59,10 @@ class MultiDisplayDragMoveIndicatorController( desktopExecutor.execute { desktopExecutor.execute { val startDisplayDpi = val startDisplayDpi = displayController.getDisplayLayout(startDisplayId)?.densityDpi() ?: return@execute displayController.getDisplayLayout(startDisplayId)?.densityDpi() ?: return@execute val transaction = transactionSupplier() for (displayId in displayIds) { for (displayId in displayIds) { if ( if (!desktopState.isDesktopModeSupportedOnDisplay(displayId)) { displayId == startDisplayId || // No need to render indicators on displays that do not support desktop mode. !desktopState.isDesktopModeSupportedOnDisplay(displayId) ) { // No need to render indicators on the original display where the drag started, // or on displays that do not support desktop mode. continue continue } } val displayLayout = displayController.getDisplayLayout(displayId) ?: continue val displayLayout = displayController.getDisplayLayout(displayId) ?: continue Loading Loading @@ -100,14 +97,12 @@ class MultiDisplayDragMoveIndicatorController( val dragIndicatorsForTask = val dragIndicatorsForTask = dragIndicators.getOrPut(taskInfo.taskId) { mutableMapOf() } dragIndicators.getOrPut(taskInfo.taskId) { mutableMapOf() } dragIndicatorsForTask[displayId]?.also { existingIndicator -> dragIndicatorsForTask[displayId]?.also { existingIndicator -> val transaction = transactionSupplier() existingIndicator.relayout(boundsPx, transaction, visibility) existingIndicator.relayout(boundsPx, transaction, visibility) transaction.apply() } } ?: run { ?: run { val newIndicator = indicatorSurfaceFactory.create(displayContext, taskLeash) val newIndicator = indicatorSurfaceFactory.create(displayContext, taskLeash) newIndicator.show( newIndicator.show( transactionSupplier(), transaction, taskInfo, taskInfo, rootTaskDisplayAreaOrganizer, rootTaskDisplayAreaOrganizer, displayId, displayId, Loading @@ -118,6 +113,7 @@ class MultiDisplayDragMoveIndicatorController( dragIndicatorsForTask[displayId] = newIndicator dragIndicatorsForTask[displayId] = newIndicator } } } } transaction.apply() } } } } Loading libs/WindowManager/Shell/src/com/android/wm/shell/common/MultiDisplayDragMoveIndicatorSurface.kt +0 −1 Original line number Original line Diff line number Diff line Loading @@ -94,7 +94,6 @@ class MultiDisplayDragMoveIndicatorSurface(context: Context, taskSurface: Surfac rootTaskDisplayAreaOrganizer.reparentToDisplayArea(displayId, sc, transaction) rootTaskDisplayAreaOrganizer.reparentToDisplayArea(displayId, sc, transaction) relayout(bounds, transaction, visibility) relayout(bounds, transaction, visibility) transaction.show(sc).setLayer(sc, MOVE_INDICATOR_LAYER).setScale(sc, scale, scale) transaction.show(sc).setLayer(sc, MOVE_INDICATOR_LAYER).setScale(sc, scale, scale) transaction.apply() } } /** /** Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/MultiDisplayVeiledResizeTaskPositioner.kt +6 −10 Original line number Original line Diff line number Diff line Loading @@ -211,19 +211,15 @@ class MultiDisplayVeiledResizeTaskPositioner( transactionSupplier, transactionSupplier, ) ) // Put the task window outside of the display to make it invisible from user. // This is needed because mirroring surfaces cannot have a bigger alpha value than // the original surface. // Only DragMoveIndicator is visible for users while multi-display aware drag move. t.setPosition( t.setPosition( desktopWindowDecoration.leash, desktopWindowDecoration.leash, repositionTaskBounds.left.toFloat(), startDisplayLayout.width().toFloat(), repositionTaskBounds.top.toFloat(), startDisplayLayout.height().toFloat(), ) ) // Make the window translucent in the case when the cursor moves to another display. val alpha = if (startDisplayId == displayId) { ALPHA_FOR_WINDOW_ON_DISPLAY_WITH_CURSOR } else { ALPHA_FOR_WINDOW_ON_NON_CURSOR_DISPLAY } t.setAlpha(desktopWindowDecoration.leash, alpha) } } t.setFrameTimeline(Choreographer.getInstance().vsyncId) t.setFrameTimeline(Choreographer.getInstance().vsyncId) t.apply() t.apply() Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/MultiDisplayDragMoveIndicatorSurfaceTest.kt +0 −1 Original line number Original line Diff line number Diff line Loading @@ -128,7 +128,6 @@ class MultiDisplayDragMoveIndicatorSurfaceTest : ShellTestCase() { .setPosition(eq(mockSurface), eq(BOUNDS.left.toFloat()), eq(BOUNDS.top.toFloat())) .setPosition(eq(mockSurface), eq(BOUNDS.left.toFloat()), eq(BOUNDS.top.toFloat())) verify(mockTransaction).show(eq(mockSurface)) verify(mockTransaction).show(eq(mockSurface)) verify(mockTransaction).setScale(eq(mockSurface), eq(SCALE), eq(SCALE)) verify(mockTransaction).setScale(eq(mockSurface), eq(SCALE), eq(SCALE)) verify(mockTransaction).apply() } } @Test @Test Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/MultiDisplayVeiledResizeTaskPositionerTest.kt +44 −21 Original line number Original line Diff line number Diff line Loading @@ -69,6 +69,7 @@ import org.mockito.Mockito.`when` as whenever import org.mockito.Mockito.`when` import org.mockito.Mockito.`when` import org.mockito.MockitoAnnotations import org.mockito.MockitoAnnotations import org.mockito.kotlin.any import org.mockito.kotlin.any import org.mockito.kotlin.argumentCaptor /** /** * Tests for [MultiDisplayVeiledResizeTaskPositioner]. * Tests for [MultiDisplayVeiledResizeTaskPositioner]. Loading Loading @@ -212,6 +213,9 @@ class MultiDisplayVeiledResizeTaskPositionerTest : ShellTestCase() { @Test @Test fun testDragResize_movesTask_doesNotShowResizeVeil() = runOnUiThread { fun testDragResize_movesTask_doesNotShowResizeVeil() = runOnUiThread { whenever(spyDisplayLayout0.width()).thenReturn(DISPLAY_BOUNDS.width()) whenever(spyDisplayLayout0.height()).thenReturn(DISPLAY_BOUNDS.height()) taskPositioner.onDragPositioningStart( taskPositioner.onDragPositioningStart( CTRL_TYPE_UNDEFINED, CTRL_TYPE_UNDEFINED, DISPLAY_ID_0, DISPLAY_ID_0, Loading @@ -224,10 +228,16 @@ class MultiDisplayVeiledResizeTaskPositionerTest : ShellTestCase() { STARTING_BOUNDS.left.toFloat() + 60, STARTING_BOUNDS.left.toFloat() + 60, STARTING_BOUNDS.top.toFloat() + 100, STARTING_BOUNDS.top.toFloat() + 100, ) ) val rectAfterMove = Rect(STARTING_BOUNDS) val leftAfterMoveCaptor = argumentCaptor<Float>() rectAfterMove.offset(60, 100) val topAfterMoveCaptor = argumentCaptor<Float>() verify(mockTransaction) verify(mockTransaction) .setPosition(any(), eq(rectAfterMove.left.toFloat()), eq(rectAfterMove.top.toFloat())) .setPosition(any(), leftAfterMoveCaptor.capture(), topAfterMoveCaptor.capture()) val rectAfterMove = Rect(STARTING_BOUNDS) rectAfterMove.offsetTo( leftAfterMoveCaptor.firstValue.toInt(), topAfterMoveCaptor.firstValue.toInt(), ) Assert.assertFalse(DISPLAY_BOUNDS.intersect(rectAfterMove)) val endBounds = val endBounds = taskPositioner.onDragPositioningEnd( taskPositioner.onDragPositioningEnd( Loading Loading @@ -266,6 +276,9 @@ class MultiDisplayVeiledResizeTaskPositionerTest : ShellTestCase() { @Test @Test fun testDragResize_movesTaskToNewDisplay() = runOnUiThread { fun testDragResize_movesTaskToNewDisplay() = runOnUiThread { whenever(spyDisplayLayout0.width()).thenReturn(DISPLAY_BOUNDS.width()) whenever(spyDisplayLayout0.height()).thenReturn(DISPLAY_BOUNDS.height()) taskPositioner.onDragPositioningStart( taskPositioner.onDragPositioningStart( CTRL_TYPE_UNDEFINED, CTRL_TYPE_UNDEFINED, DISPLAY_ID_0, DISPLAY_ID_0, Loading @@ -275,11 +288,16 @@ class MultiDisplayVeiledResizeTaskPositionerTest : ShellTestCase() { taskPositioner.onDragPositioningMove(DISPLAY_ID_1, 200f, 1900f) taskPositioner.onDragPositioningMove(DISPLAY_ID_1, 200f, 1900f) val rectAfterMove = Rect(200, -50, 300, 50) val leftAfterMoveCaptor = argumentCaptor<Float>() verify(mockTransaction) val topAfterMoveCaptor = argumentCaptor<Float>() .setPosition(any(), eq(rectAfterMove.left.toFloat()), eq(rectAfterMove.top.toFloat())) verify(mockTransaction) verify(mockTransaction) .setAlpha(eq(mockDesktopWindowDecoration.leash), eq(ALPHA_FOR_TRANSLUCENT_WINDOW)) .setPosition(any(), leftAfterMoveCaptor.capture(), topAfterMoveCaptor.capture()) val boundsAfterMove = Rect(STARTING_BOUNDS) boundsAfterMove.offsetTo( leftAfterMoveCaptor.firstValue.toInt(), topAfterMoveCaptor.firstValue.toInt(), ) Assert.assertFalse(DISPLAY_BOUNDS.intersect(boundsAfterMove)) val endBounds = taskPositioner.onDragPositioningEnd(DISPLAY_ID_1, 300f, 450f) val endBounds = taskPositioner.onDragPositioningEnd(DISPLAY_ID_1, 300f, 450f) val rectAfterEnd = Rect(300, 450, 500, 650) val rectAfterEnd = Rect(300, 450, 500, 650) Loading @@ -292,6 +310,9 @@ class MultiDisplayVeiledResizeTaskPositionerTest : ShellTestCase() { @Test @Test fun testDragResize_movesTaskToNewDisplayThenBackToOriginalDisplay() = runOnUiThread { fun testDragResize_movesTaskToNewDisplayThenBackToOriginalDisplay() = runOnUiThread { whenever(spyDisplayLayout0.width()).thenReturn(DISPLAY_BOUNDS.width()) whenever(spyDisplayLayout0.height()).thenReturn(DISPLAY_BOUNDS.height()) taskPositioner.onDragPositioningStart( taskPositioner.onDragPositioningStart( CTRL_TYPE_UNDEFINED, CTRL_TYPE_UNDEFINED, DISPLAY_ID_0, DISPLAY_ID_0, Loading @@ -303,32 +324,36 @@ class MultiDisplayVeiledResizeTaskPositionerTest : ShellTestCase() { // Move to the display 1 // Move to the display 1 taskPositioner.onDragPositioningMove(DISPLAY_ID_1, 200f, 800f) taskPositioner.onDragPositioningMove(DISPLAY_ID_1, 200f, 800f) val rectAfterMove = Rect(200, -600, 300, -400) val leftAfterMoveCaptor = argumentCaptor<Float>() inOrder val topAfterMoveCaptor = argumentCaptor<Float>() .verify(mockTransaction) .setPosition(any(), eq(rectAfterMove.left.toFloat()), eq(rectAfterMove.top.toFloat())) inOrder inOrder .verify(mockTransaction) .verify(mockTransaction) .setAlpha(eq(mockDesktopWindowDecoration.leash), eq(ALPHA_FOR_TRANSLUCENT_WINDOW)) .setPosition(any(), leftAfterMoveCaptor.capture(), topAfterMoveCaptor.capture()) val boundsAfterMove = Rect(STARTING_BOUNDS) boundsAfterMove.offsetTo( leftAfterMoveCaptor.firstValue.toInt(), topAfterMoveCaptor.firstValue.toInt(), ) Assert.assertFalse(DISPLAY_BOUNDS.intersect(boundsAfterMove)) // Moving back to the original display // Moving back to the original display taskPositioner.onDragPositioningMove(DISPLAY_ID_0, 100f, 1500f) taskPositioner.onDragPositioningMove(DISPLAY_ID_0, 100f, 1500f) rectAfterMove.set(100, 1500, 200, 1700) inOrder inOrder .verify(mockTransaction) .verify(mockTransaction) .setPosition(any(), eq(rectAfterMove.left.toFloat()), eq(rectAfterMove.top.toFloat())) .setPosition( inOrder any(), .verify(mockTransaction) eq(boundsAfterMove.left.toFloat()), .setAlpha(eq(mockDesktopWindowDecoration.leash), eq(ALPHA_FOR_VISIBLE_WINDOW)) eq(boundsAfterMove.top.toFloat()), ) // Finish the drag move on the original display // Finish the drag move on the original display val endBounds = taskPositioner.onDragPositioningEnd(DISPLAY_ID_0, 50f, 50f) val endBounds = taskPositioner.onDragPositioningEnd(DISPLAY_ID_0, 50f, 50f) rectAfterMove.set(50, 50, 150, 150) val rectAfterFinishingMove = Rect(50, 50, 150, 150) verify(mockDesktopWindowDecoration, never()).showResizeVeil(any()) verify(mockDesktopWindowDecoration, never()).showResizeVeil(any()) verify(mockDesktopWindowDecoration, never()).hideResizeVeil() verify(mockDesktopWindowDecoration, never()).hideResizeVeil() verify(mockMultiDisplayDragMoveIndicatorController).onDragEnd(eq(TASK_ID), any()) verify(mockMultiDisplayDragMoveIndicatorController).onDragEnd(eq(TASK_ID), any()) Assert.assertEquals(rectAfterMove, endBounds) Assert.assertEquals(rectAfterFinishingMove, endBounds) } } @Test @Test Loading Loading @@ -719,8 +744,6 @@ class MultiDisplayVeiledResizeTaskPositionerTest : ShellTestCase() { private const val NAVBAR_HEIGHT = 50 private const val NAVBAR_HEIGHT = 50 private const val CAPTION_HEIGHT = 50 private const val CAPTION_HEIGHT = 50 private const val DISALLOWED_AREA_FOR_END_BOUNDS_HEIGHT = 10 private const val DISALLOWED_AREA_FOR_END_BOUNDS_HEIGHT = 10 private const val ALPHA_FOR_TRANSLUCENT_WINDOW = 0.7f private const val ALPHA_FOR_VISIBLE_WINDOW = 1.0f private val DISPLAY_BOUNDS = Rect(0, 0, 2400, 1600) private val DISPLAY_BOUNDS = Rect(0, 0, 2400, 1600) private val STARTING_BOUNDS = Rect(100, 100, 200, 200) private val STARTING_BOUNDS = Rect(100, 100, 200, 200) private val STABLE_BOUNDS_LANDSCAPE = private val STABLE_BOUNDS_LANDSCAPE = Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/common/MultiDisplayDragMoveIndicatorController.kt +5 −9 Original line number Original line Diff line number Diff line Loading @@ -59,13 +59,10 @@ class MultiDisplayDragMoveIndicatorController( desktopExecutor.execute { desktopExecutor.execute { val startDisplayDpi = val startDisplayDpi = displayController.getDisplayLayout(startDisplayId)?.densityDpi() ?: return@execute displayController.getDisplayLayout(startDisplayId)?.densityDpi() ?: return@execute val transaction = transactionSupplier() for (displayId in displayIds) { for (displayId in displayIds) { if ( if (!desktopState.isDesktopModeSupportedOnDisplay(displayId)) { displayId == startDisplayId || // No need to render indicators on displays that do not support desktop mode. !desktopState.isDesktopModeSupportedOnDisplay(displayId) ) { // No need to render indicators on the original display where the drag started, // or on displays that do not support desktop mode. continue continue } } val displayLayout = displayController.getDisplayLayout(displayId) ?: continue val displayLayout = displayController.getDisplayLayout(displayId) ?: continue Loading Loading @@ -100,14 +97,12 @@ class MultiDisplayDragMoveIndicatorController( val dragIndicatorsForTask = val dragIndicatorsForTask = dragIndicators.getOrPut(taskInfo.taskId) { mutableMapOf() } dragIndicators.getOrPut(taskInfo.taskId) { mutableMapOf() } dragIndicatorsForTask[displayId]?.also { existingIndicator -> dragIndicatorsForTask[displayId]?.also { existingIndicator -> val transaction = transactionSupplier() existingIndicator.relayout(boundsPx, transaction, visibility) existingIndicator.relayout(boundsPx, transaction, visibility) transaction.apply() } } ?: run { ?: run { val newIndicator = indicatorSurfaceFactory.create(displayContext, taskLeash) val newIndicator = indicatorSurfaceFactory.create(displayContext, taskLeash) newIndicator.show( newIndicator.show( transactionSupplier(), transaction, taskInfo, taskInfo, rootTaskDisplayAreaOrganizer, rootTaskDisplayAreaOrganizer, displayId, displayId, Loading @@ -118,6 +113,7 @@ class MultiDisplayDragMoveIndicatorController( dragIndicatorsForTask[displayId] = newIndicator dragIndicatorsForTask[displayId] = newIndicator } } } } transaction.apply() } } } } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/common/MultiDisplayDragMoveIndicatorSurface.kt +0 −1 Original line number Original line Diff line number Diff line Loading @@ -94,7 +94,6 @@ class MultiDisplayDragMoveIndicatorSurface(context: Context, taskSurface: Surfac rootTaskDisplayAreaOrganizer.reparentToDisplayArea(displayId, sc, transaction) rootTaskDisplayAreaOrganizer.reparentToDisplayArea(displayId, sc, transaction) relayout(bounds, transaction, visibility) relayout(bounds, transaction, visibility) transaction.show(sc).setLayer(sc, MOVE_INDICATOR_LAYER).setScale(sc, scale, scale) transaction.show(sc).setLayer(sc, MOVE_INDICATOR_LAYER).setScale(sc, scale, scale) transaction.apply() } } /** /** Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/MultiDisplayVeiledResizeTaskPositioner.kt +6 −10 Original line number Original line Diff line number Diff line Loading @@ -211,19 +211,15 @@ class MultiDisplayVeiledResizeTaskPositioner( transactionSupplier, transactionSupplier, ) ) // Put the task window outside of the display to make it invisible from user. // This is needed because mirroring surfaces cannot have a bigger alpha value than // the original surface. // Only DragMoveIndicator is visible for users while multi-display aware drag move. t.setPosition( t.setPosition( desktopWindowDecoration.leash, desktopWindowDecoration.leash, repositionTaskBounds.left.toFloat(), startDisplayLayout.width().toFloat(), repositionTaskBounds.top.toFloat(), startDisplayLayout.height().toFloat(), ) ) // Make the window translucent in the case when the cursor moves to another display. val alpha = if (startDisplayId == displayId) { ALPHA_FOR_WINDOW_ON_DISPLAY_WITH_CURSOR } else { ALPHA_FOR_WINDOW_ON_NON_CURSOR_DISPLAY } t.setAlpha(desktopWindowDecoration.leash, alpha) } } t.setFrameTimeline(Choreographer.getInstance().vsyncId) t.setFrameTimeline(Choreographer.getInstance().vsyncId) t.apply() t.apply() Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/MultiDisplayDragMoveIndicatorSurfaceTest.kt +0 −1 Original line number Original line Diff line number Diff line Loading @@ -128,7 +128,6 @@ class MultiDisplayDragMoveIndicatorSurfaceTest : ShellTestCase() { .setPosition(eq(mockSurface), eq(BOUNDS.left.toFloat()), eq(BOUNDS.top.toFloat())) .setPosition(eq(mockSurface), eq(BOUNDS.left.toFloat()), eq(BOUNDS.top.toFloat())) verify(mockTransaction).show(eq(mockSurface)) verify(mockTransaction).show(eq(mockSurface)) verify(mockTransaction).setScale(eq(mockSurface), eq(SCALE), eq(SCALE)) verify(mockTransaction).setScale(eq(mockSurface), eq(SCALE), eq(SCALE)) verify(mockTransaction).apply() } } @Test @Test Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/MultiDisplayVeiledResizeTaskPositionerTest.kt +44 −21 Original line number Original line Diff line number Diff line Loading @@ -69,6 +69,7 @@ import org.mockito.Mockito.`when` as whenever import org.mockito.Mockito.`when` import org.mockito.Mockito.`when` import org.mockito.MockitoAnnotations import org.mockito.MockitoAnnotations import org.mockito.kotlin.any import org.mockito.kotlin.any import org.mockito.kotlin.argumentCaptor /** /** * Tests for [MultiDisplayVeiledResizeTaskPositioner]. * Tests for [MultiDisplayVeiledResizeTaskPositioner]. Loading Loading @@ -212,6 +213,9 @@ class MultiDisplayVeiledResizeTaskPositionerTest : ShellTestCase() { @Test @Test fun testDragResize_movesTask_doesNotShowResizeVeil() = runOnUiThread { fun testDragResize_movesTask_doesNotShowResizeVeil() = runOnUiThread { whenever(spyDisplayLayout0.width()).thenReturn(DISPLAY_BOUNDS.width()) whenever(spyDisplayLayout0.height()).thenReturn(DISPLAY_BOUNDS.height()) taskPositioner.onDragPositioningStart( taskPositioner.onDragPositioningStart( CTRL_TYPE_UNDEFINED, CTRL_TYPE_UNDEFINED, DISPLAY_ID_0, DISPLAY_ID_0, Loading @@ -224,10 +228,16 @@ class MultiDisplayVeiledResizeTaskPositionerTest : ShellTestCase() { STARTING_BOUNDS.left.toFloat() + 60, STARTING_BOUNDS.left.toFloat() + 60, STARTING_BOUNDS.top.toFloat() + 100, STARTING_BOUNDS.top.toFloat() + 100, ) ) val rectAfterMove = Rect(STARTING_BOUNDS) val leftAfterMoveCaptor = argumentCaptor<Float>() rectAfterMove.offset(60, 100) val topAfterMoveCaptor = argumentCaptor<Float>() verify(mockTransaction) verify(mockTransaction) .setPosition(any(), eq(rectAfterMove.left.toFloat()), eq(rectAfterMove.top.toFloat())) .setPosition(any(), leftAfterMoveCaptor.capture(), topAfterMoveCaptor.capture()) val rectAfterMove = Rect(STARTING_BOUNDS) rectAfterMove.offsetTo( leftAfterMoveCaptor.firstValue.toInt(), topAfterMoveCaptor.firstValue.toInt(), ) Assert.assertFalse(DISPLAY_BOUNDS.intersect(rectAfterMove)) val endBounds = val endBounds = taskPositioner.onDragPositioningEnd( taskPositioner.onDragPositioningEnd( Loading Loading @@ -266,6 +276,9 @@ class MultiDisplayVeiledResizeTaskPositionerTest : ShellTestCase() { @Test @Test fun testDragResize_movesTaskToNewDisplay() = runOnUiThread { fun testDragResize_movesTaskToNewDisplay() = runOnUiThread { whenever(spyDisplayLayout0.width()).thenReturn(DISPLAY_BOUNDS.width()) whenever(spyDisplayLayout0.height()).thenReturn(DISPLAY_BOUNDS.height()) taskPositioner.onDragPositioningStart( taskPositioner.onDragPositioningStart( CTRL_TYPE_UNDEFINED, CTRL_TYPE_UNDEFINED, DISPLAY_ID_0, DISPLAY_ID_0, Loading @@ -275,11 +288,16 @@ class MultiDisplayVeiledResizeTaskPositionerTest : ShellTestCase() { taskPositioner.onDragPositioningMove(DISPLAY_ID_1, 200f, 1900f) taskPositioner.onDragPositioningMove(DISPLAY_ID_1, 200f, 1900f) val rectAfterMove = Rect(200, -50, 300, 50) val leftAfterMoveCaptor = argumentCaptor<Float>() verify(mockTransaction) val topAfterMoveCaptor = argumentCaptor<Float>() .setPosition(any(), eq(rectAfterMove.left.toFloat()), eq(rectAfterMove.top.toFloat())) verify(mockTransaction) verify(mockTransaction) .setAlpha(eq(mockDesktopWindowDecoration.leash), eq(ALPHA_FOR_TRANSLUCENT_WINDOW)) .setPosition(any(), leftAfterMoveCaptor.capture(), topAfterMoveCaptor.capture()) val boundsAfterMove = Rect(STARTING_BOUNDS) boundsAfterMove.offsetTo( leftAfterMoveCaptor.firstValue.toInt(), topAfterMoveCaptor.firstValue.toInt(), ) Assert.assertFalse(DISPLAY_BOUNDS.intersect(boundsAfterMove)) val endBounds = taskPositioner.onDragPositioningEnd(DISPLAY_ID_1, 300f, 450f) val endBounds = taskPositioner.onDragPositioningEnd(DISPLAY_ID_1, 300f, 450f) val rectAfterEnd = Rect(300, 450, 500, 650) val rectAfterEnd = Rect(300, 450, 500, 650) Loading @@ -292,6 +310,9 @@ class MultiDisplayVeiledResizeTaskPositionerTest : ShellTestCase() { @Test @Test fun testDragResize_movesTaskToNewDisplayThenBackToOriginalDisplay() = runOnUiThread { fun testDragResize_movesTaskToNewDisplayThenBackToOriginalDisplay() = runOnUiThread { whenever(spyDisplayLayout0.width()).thenReturn(DISPLAY_BOUNDS.width()) whenever(spyDisplayLayout0.height()).thenReturn(DISPLAY_BOUNDS.height()) taskPositioner.onDragPositioningStart( taskPositioner.onDragPositioningStart( CTRL_TYPE_UNDEFINED, CTRL_TYPE_UNDEFINED, DISPLAY_ID_0, DISPLAY_ID_0, Loading @@ -303,32 +324,36 @@ class MultiDisplayVeiledResizeTaskPositionerTest : ShellTestCase() { // Move to the display 1 // Move to the display 1 taskPositioner.onDragPositioningMove(DISPLAY_ID_1, 200f, 800f) taskPositioner.onDragPositioningMove(DISPLAY_ID_1, 200f, 800f) val rectAfterMove = Rect(200, -600, 300, -400) val leftAfterMoveCaptor = argumentCaptor<Float>() inOrder val topAfterMoveCaptor = argumentCaptor<Float>() .verify(mockTransaction) .setPosition(any(), eq(rectAfterMove.left.toFloat()), eq(rectAfterMove.top.toFloat())) inOrder inOrder .verify(mockTransaction) .verify(mockTransaction) .setAlpha(eq(mockDesktopWindowDecoration.leash), eq(ALPHA_FOR_TRANSLUCENT_WINDOW)) .setPosition(any(), leftAfterMoveCaptor.capture(), topAfterMoveCaptor.capture()) val boundsAfterMove = Rect(STARTING_BOUNDS) boundsAfterMove.offsetTo( leftAfterMoveCaptor.firstValue.toInt(), topAfterMoveCaptor.firstValue.toInt(), ) Assert.assertFalse(DISPLAY_BOUNDS.intersect(boundsAfterMove)) // Moving back to the original display // Moving back to the original display taskPositioner.onDragPositioningMove(DISPLAY_ID_0, 100f, 1500f) taskPositioner.onDragPositioningMove(DISPLAY_ID_0, 100f, 1500f) rectAfterMove.set(100, 1500, 200, 1700) inOrder inOrder .verify(mockTransaction) .verify(mockTransaction) .setPosition(any(), eq(rectAfterMove.left.toFloat()), eq(rectAfterMove.top.toFloat())) .setPosition( inOrder any(), .verify(mockTransaction) eq(boundsAfterMove.left.toFloat()), .setAlpha(eq(mockDesktopWindowDecoration.leash), eq(ALPHA_FOR_VISIBLE_WINDOW)) eq(boundsAfterMove.top.toFloat()), ) // Finish the drag move on the original display // Finish the drag move on the original display val endBounds = taskPositioner.onDragPositioningEnd(DISPLAY_ID_0, 50f, 50f) val endBounds = taskPositioner.onDragPositioningEnd(DISPLAY_ID_0, 50f, 50f) rectAfterMove.set(50, 50, 150, 150) val rectAfterFinishingMove = Rect(50, 50, 150, 150) verify(mockDesktopWindowDecoration, never()).showResizeVeil(any()) verify(mockDesktopWindowDecoration, never()).showResizeVeil(any()) verify(mockDesktopWindowDecoration, never()).hideResizeVeil() verify(mockDesktopWindowDecoration, never()).hideResizeVeil() verify(mockMultiDisplayDragMoveIndicatorController).onDragEnd(eq(TASK_ID), any()) verify(mockMultiDisplayDragMoveIndicatorController).onDragEnd(eq(TASK_ID), any()) Assert.assertEquals(rectAfterMove, endBounds) Assert.assertEquals(rectAfterFinishingMove, endBounds) } } @Test @Test Loading Loading @@ -719,8 +744,6 @@ class MultiDisplayVeiledResizeTaskPositionerTest : ShellTestCase() { private const val NAVBAR_HEIGHT = 50 private const val NAVBAR_HEIGHT = 50 private const val CAPTION_HEIGHT = 50 private const val CAPTION_HEIGHT = 50 private const val DISALLOWED_AREA_FOR_END_BOUNDS_HEIGHT = 10 private const val DISALLOWED_AREA_FOR_END_BOUNDS_HEIGHT = 10 private const val ALPHA_FOR_TRANSLUCENT_WINDOW = 0.7f private const val ALPHA_FOR_VISIBLE_WINDOW = 1.0f private val DISPLAY_BOUNDS = Rect(0, 0, 2400, 1600) private val DISPLAY_BOUNDS = Rect(0, 0, 2400, 1600) private val STARTING_BOUNDS = Rect(100, 100, 200, 200) private val STARTING_BOUNDS = Rect(100, 100, 200, 200) private val STABLE_BOUNDS_LANDSCAPE = private val STABLE_BOUNDS_LANDSCAPE = Loading