Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +10 −10 Original line number Diff line number Diff line Loading @@ -5713,14 +5713,13 @@ class DesktopTasksController( validDragArea, ) if ( destinationBounds == dragStartBounds && destinationBounds != currentDragBounds ) { if (destinationBounds == dragStartBounds) { // There's no actual difference between the start and end bounds, so while a // WCT change isn't needed, the dragged surface still needs to be snapped back // to its original location. This is as long as it moved some in the first // place, if it didn't and |currentDragBounds| is already at destination then // there's no need to animate. if (currentDragBounds != dragStartBounds) { releaseVisualIndicator() returnToDragStartAnimator.start( taskInfo.taskId, Loading @@ -5728,6 +5727,7 @@ class DesktopTasksController( startBounds = currentDragBounds, endBounds = dragStartBounds, ) } return true } Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +41 −1 Original line number Diff line number Diff line Loading @@ -9312,7 +9312,45 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() } @Test fun onDesktopDragEnd_noIndicator_noBoundsMovement_noReturnToStartAnimation() { fun onDesktopDragEnd_noIndicator_noBoundsMovement_outOfValidArea_startsReturnToStartAnimation_noWct() { val task = setUpFreeformTask(bounds = STABLE_BOUNDS) val spyController = spy(controller) val mockSurface = mock(SurfaceControl::class.java) whenever(spyController.getVisualIndicator()).thenReturn(desktopModeVisualIndicator) whenever(desktopModeVisualIndicator.updateIndicatorType(any(), anyOrNull())) .thenReturn(DesktopModeVisualIndicator.IndicatorType.NO_INDICATOR) whenever(motionEvent.displayId).thenReturn(DEFAULT_DISPLAY) val startBounds = Rect(0, 50, 500, 550) // Drag slightly outside of valid drag area val currentDragBounds = Rect(-10, 50, 490, 550) spyController.onDragPositioningEnd( taskInfo = task, taskSurface = mockSurface, displayId = DEFAULT_DISPLAY, inputCoordinate = PointF(250f, 300f), currentDragBounds = currentDragBounds, validDragArea = Rect(0, 50, 2000, 2000), dragStartBounds = startBounds, motionEvent = motionEvent, ) // Verify animation to return to start is triggered. verify(mReturnToDragStartAnimator) .start( eq(task.taskId), eq(mockSurface), eq(currentDragBounds), eq(startBounds), anyOrNull(), ) // Verify no WCT is started. verify(transitions, never()).startTransition(any(), any(), any()) } @Test fun onDesktopDragEnd_noIndicator_noBoundsMovement_noReturnToStartAnimation_noWct() { val task = setUpFreeformTask(bounds = STABLE_BOUNDS) val spyController = spy(controller) val mockSurface = mock(SurfaceControl::class.java) Loading Loading @@ -9353,6 +9391,8 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() // return because the current bounds are also the same as start/end. verify(mReturnToDragStartAnimator, never()) .start(eq(task.taskId), eq(mockSurface), any(), any(), anyOrNull()) // Verify no WCT is started. verify(transitions, never()).startTransition(any(), any(), any()) } @Test Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +10 −10 Original line number Diff line number Diff line Loading @@ -5713,14 +5713,13 @@ class DesktopTasksController( validDragArea, ) if ( destinationBounds == dragStartBounds && destinationBounds != currentDragBounds ) { if (destinationBounds == dragStartBounds) { // There's no actual difference between the start and end bounds, so while a // WCT change isn't needed, the dragged surface still needs to be snapped back // to its original location. This is as long as it moved some in the first // place, if it didn't and |currentDragBounds| is already at destination then // there's no need to animate. if (currentDragBounds != dragStartBounds) { releaseVisualIndicator() returnToDragStartAnimator.start( taskInfo.taskId, Loading @@ -5728,6 +5727,7 @@ class DesktopTasksController( startBounds = currentDragBounds, endBounds = dragStartBounds, ) } return true } Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +41 −1 Original line number Diff line number Diff line Loading @@ -9312,7 +9312,45 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() } @Test fun onDesktopDragEnd_noIndicator_noBoundsMovement_noReturnToStartAnimation() { fun onDesktopDragEnd_noIndicator_noBoundsMovement_outOfValidArea_startsReturnToStartAnimation_noWct() { val task = setUpFreeformTask(bounds = STABLE_BOUNDS) val spyController = spy(controller) val mockSurface = mock(SurfaceControl::class.java) whenever(spyController.getVisualIndicator()).thenReturn(desktopModeVisualIndicator) whenever(desktopModeVisualIndicator.updateIndicatorType(any(), anyOrNull())) .thenReturn(DesktopModeVisualIndicator.IndicatorType.NO_INDICATOR) whenever(motionEvent.displayId).thenReturn(DEFAULT_DISPLAY) val startBounds = Rect(0, 50, 500, 550) // Drag slightly outside of valid drag area val currentDragBounds = Rect(-10, 50, 490, 550) spyController.onDragPositioningEnd( taskInfo = task, taskSurface = mockSurface, displayId = DEFAULT_DISPLAY, inputCoordinate = PointF(250f, 300f), currentDragBounds = currentDragBounds, validDragArea = Rect(0, 50, 2000, 2000), dragStartBounds = startBounds, motionEvent = motionEvent, ) // Verify animation to return to start is triggered. verify(mReturnToDragStartAnimator) .start( eq(task.taskId), eq(mockSurface), eq(currentDragBounds), eq(startBounds), anyOrNull(), ) // Verify no WCT is started. verify(transitions, never()).startTransition(any(), any(), any()) } @Test fun onDesktopDragEnd_noIndicator_noBoundsMovement_noReturnToStartAnimation_noWct() { val task = setUpFreeformTask(bounds = STABLE_BOUNDS) val spyController = spy(controller) val mockSurface = mock(SurfaceControl::class.java) Loading Loading @@ -9353,6 +9391,8 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() // return because the current bounds are also the same as start/end. verify(mReturnToDragStartAnimator, never()) .start(eq(task.taskId), eq(mockSurface), any(), any(), anyOrNull()) // Verify no WCT is started. verify(transitions, never()).startTransition(any(), any(), any()) } @Test Loading