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

Commit 704e829f authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Apply task-limit policy in #moveToDisplay" into main

parents 4121f58b 9c4db782
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -1262,8 +1262,7 @@ class DesktopTasksController(
            wct.reparent(task.token, displayAreaInfo.token, /* onTop= */ true)
        }

        // TODO: b/391485148 - pass in the moving-to-desk |task| here to apply task-limit policy.
        val activationRunnable = addDeskActivationChanges(destinationDeskId, wct)
        val activationRunnable = addDeskActivationChanges(destinationDeskId, wct, task)

        if (Flags.enableDisplayFocusInShellTransitions()) {
            // Bring the destination display to top with includingParents=true, so that the
+32 −1
Original line number Diff line number Diff line
@@ -3125,6 +3125,36 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        verify(desksOrganizer).reorderTaskToFront(wct, targetDeskId, task2)
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND)
    fun moveToNextDisplay_toDesktopInOtherDisplay_appliesTaskLimit() {
        val transition = Binder()
        val sourceDeskId = 0
        val targetDeskId = 2
        taskRepository.addDesk(displayId = SECOND_DISPLAY, deskId = targetDeskId)
        taskRepository.setDeskInactive(deskId = targetDeskId)
        val targetDeskTasks =
            (1..MAX_TASK_LIMIT + 1).map { _ ->
                setUpFreeformTask(displayId = SECOND_DISPLAY, deskId = targetDeskId)
            }
        // Set up two display ids
        whenever(rootTaskDisplayAreaOrganizer.displayIds)
            .thenReturn(intArrayOf(DEFAULT_DISPLAY, SECOND_DISPLAY))
        // Create a mock for the target display area: second display
        val secondDisplayArea = DisplayAreaInfo(MockToken().token(), SECOND_DISPLAY, 0)
        whenever(rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(SECOND_DISPLAY))
            .thenReturn(secondDisplayArea)
        whenever(transitions.startTransition(eq(TRANSIT_CHANGE), any(), anyOrNull()))
            .thenReturn(transition)
        val task = setUpFreeformTask(displayId = DEFAULT_DISPLAY, deskId = sourceDeskId)

        controller.moveToNextDisplay(task.taskId)

        val wct = getLatestTransition()
        assertNotNull(wct)
        verify(desksOrganizer).minimizeTask(wct, targetDeskId, targetDeskTasks[0])
    }

    @Test
    @EnableFlags(
        Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY,
@@ -3194,10 +3224,11 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        verify(desksOrganizer).activateDesk(any(), eq(targetDeskId))
        verify(desksTransitionsObserver)
            .addPendingTransition(
                DeskTransition.ActivateDesk(
                DeskTransition.ActiveDeskWithTask(
                    token = transition,
                    displayId = SECOND_DISPLAY,
                    deskId = targetDeskId,
                    enterTaskId = task.taskId,
                )
            )
    }