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

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

Merge "Merge onCreateCallbacks when an unassigned create request is found." into main

parents d720ebf6 ec488fe9
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -110,7 +110,14 @@ class RootTaskDesksOrganizer(
        val unassignedRequest = createDeskRootRequests.firstOrNull { it.userId == null }
        if (unassignedRequest != null) {
            createDeskRootRequests.remove(unassignedRequest)
            createDeskRootRequests += unassignedRequest.copy(userId = userId)
            createDeskRootRequests +=
                unassignedRequest.copy(
                    userId = userId,
                    onCreateCallback = { deskId ->
                        unassignedRequest.onCreateCallback.onCreated(deskId)
                        callback.onCreated(deskId)
                    },
                )
            return
        }
        // Must request a new root.
+14 −0
Original line number Diff line number Diff line
@@ -245,6 +245,20 @@ class RootTaskDesksOrganizerTest : ShellTestCase() {
            )
    }

    @Test
    fun testCreateDesk_warmUpInProgress_appliesCallback() = runTest {
        val freeformRoot = createFreeformTask().apply { parentTaskId = -1 }
        var callbackApplied = false

        organizer.warmUpDefaultDesk(userId = PRIMARY_USER_ID, displayId = DEFAULT_DISPLAY)
        organizer.createDesk(userId = PRIMARY_USER_ID, displayId = DEFAULT_DISPLAY) { _ ->
            callbackApplied = true
        }
        organizer.onTaskAppeared(freeformRoot, SurfaceControl())

        assertThat(callbackApplied).isTrue()
    }

    @Test
    fun testCreateDesk_twice_warmUpInProgress_usesWarmedUpDeskAndCreatesOne() = runTest {
        val displayId = DEFAULT_DISPLAY