Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f33d9f67 authored by Qijing Yao's avatar Qijing Yao Committed by Android (Google) Code Review
Browse files

Merge "Fix lingering mirrored surface after misinterpreted drag" into main

parents a27bf408 e7b43582
Loading
Loading
Loading
Loading
+10 −10
Original line number Original line Diff line number Diff line
@@ -5713,14 +5713,13 @@ class DesktopTasksController(
                    validDragArea,
                    validDragArea,
                )
                )


                if (
                if (destinationBounds == dragStartBounds) {
                    destinationBounds == dragStartBounds && destinationBounds != currentDragBounds
                ) {
                    // There's no actual difference between the start and end bounds, so while a
                    // 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
                    // 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
                    // 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
                    // place, if it didn't and |currentDragBounds| is already at destination then
                    // there's no need to animate.
                    // there's no need to animate.
                    if (currentDragBounds != dragStartBounds) {
                        releaseVisualIndicator()
                        releaseVisualIndicator()
                        returnToDragStartAnimator.start(
                        returnToDragStartAnimator.start(
                            taskInfo.taskId,
                            taskInfo.taskId,
@@ -5728,6 +5727,7 @@ class DesktopTasksController(
                            startBounds = currentDragBounds,
                            startBounds = currentDragBounds,
                            endBounds = dragStartBounds,
                            endBounds = dragStartBounds,
                        )
                        )
                    }
                    return true
                    return true
                }
                }


+41 −1
Original line number Original line Diff line number Diff line
@@ -9312,7 +9312,45 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
    }
    }
    @Test
    @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 task = setUpFreeformTask(bounds = STABLE_BOUNDS)
        val spyController = spy(controller)
        val spyController = spy(controller)
        val mockSurface = mock(SurfaceControl::class.java)
        val mockSurface = mock(SurfaceControl::class.java)
@@ -9353,6 +9391,8 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        // return because the current bounds are also the same as start/end.
        // return because the current bounds are also the same as start/end.
        verify(mReturnToDragStartAnimator, never())
        verify(mReturnToDragStartAnimator, never())
            .start(eq(task.taskId), eq(mockSurface), any(), any(), anyOrNull())
            .start(eq(task.taskId), eq(mockSurface), any(), any(), anyOrNull())
        // Verify no WCT is started.
        verify(transitions, never()).startTransition(any(), any(), any())
    }
    }
    @Test
    @Test