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

Commit abbab5b2 authored by Jagrut Desai's avatar Jagrut Desai Committed by Android (Google) Code Review
Browse files

Merge "Notifying tasks visibility change when removing desk" into main

parents 5aedb9f4 42a6207b
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -733,7 +733,8 @@ class DesktopRepository(
        desktopData.getActiveDesk(displayId)?.topTransparentFullscreenTaskId = null
    }

    private fun notifyVisibleTaskListeners(displayId: Int, visibleTasksCount: Int) {
    @VisibleForTesting
    public fun notifyVisibleTaskListeners(displayId: Int, visibleTasksCount: Int) {
        visibleTasksListeners.forEach { (listener, executor) ->
            executor.execute { listener.onTasksVisibilityChanged(displayId, visibleTasksCount) }
        }
@@ -915,6 +916,7 @@ class DesktopRepository(
        val wasActive = desktopData.getActiveDesk(desk.displayId)?.deskId == desk.deskId
        val activeTasks = ArraySet(desk.activeTasks)
        desktopData.remove(desk.deskId)
        notifyVisibleTaskListeners(desk.displayId, getVisibleTaskCount(displayId = desk.displayId))
        deskChangeListeners.forEach { (listener, executor) ->
            executor.execute {
                if (wasActive) {
+7 −1
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ class DesktopRepositoryTest(flags: FlagsParameterization) : ShellTestCase() {
        datastoreScope = CoroutineScope(Dispatchers.Unconfined + SupervisorJob())
        shellInit = spy(ShellInit(testExecutor))

        repo = DesktopRepository(persistentRepository, datastoreScope, DEFAULT_USER_ID)
        repo = spy(DesktopRepository(persistentRepository, datastoreScope, DEFAULT_USER_ID))
        whenever(runBlocking { persistentRepository.readDesktop(any(), any()) })
            .thenReturn(Desktop.getDefaultInstance())
        shellInit.init()
@@ -1171,6 +1171,7 @@ class DesktopRepositoryTest(flags: FlagsParameterization) : ShellTestCase() {

        val tasksBeforeRemoval = repo.removeDesk(deskId = DEFAULT_DISPLAY)

        verify(repo, times(1)).notifyVisibleTaskListeners(DEFAULT_DISPLAY, visibleTasksCount = 0)
        assertThat(tasksBeforeRemoval).containsExactly(1, 2, 3).inOrder()
        assertThat(repo.getActiveTasks(displayId = DEFAULT_DISPLAY)).isEmpty()
    }
@@ -1184,6 +1185,7 @@ class DesktopRepositoryTest(flags: FlagsParameterization) : ShellTestCase() {

        repo.removeDesk(deskId = 3)

        verify(repo, times(1)).notifyVisibleTaskListeners(DEFAULT_DISPLAY, visibleTasksCount = 0)
        assertThat(repo.getDeskIds(displayId = DEFAULT_DISPLAY)).doesNotContain(3)
    }

@@ -1196,6 +1198,7 @@ class DesktopRepositoryTest(flags: FlagsParameterization) : ShellTestCase() {

        repo.removeDesk(deskId = 2)

        verify(repo, times(1)).notifyVisibleTaskListeners(DEFAULT_DISPLAY, visibleTasksCount = 0)
        assertThat(repo.getDeskIds(displayId = DEFAULT_DISPLAY)).doesNotContain(2)
    }

@@ -1424,6 +1427,7 @@ class DesktopRepositoryTest(flags: FlagsParameterization) : ShellTestCase() {
        repo.removeDesk(deskId = 1)
        executor.flushAll()

        verify(repo, times(1)).notifyVisibleTaskListeners(DEFAULT_DISPLAY, visibleTasksCount = 0)
        val lastRemoval = assertNotNull(listener.lastRemoval)
        assertThat(lastRemoval.displayId).isEqualTo(0)
        assertThat(lastRemoval.deskId).isEqualTo(1)
@@ -1440,6 +1444,7 @@ class DesktopRepositoryTest(flags: FlagsParameterization) : ShellTestCase() {
        repo.removeDesk(deskId = 2)
        executor.flushAll()

        verify(repo, times(0)).notifyVisibleTaskListeners(DEFAULT_DISPLAY, visibleTasksCount = 0)
        assertThat(listener.lastRemoval).isNull()
    }

@@ -1455,6 +1460,7 @@ class DesktopRepositoryTest(flags: FlagsParameterization) : ShellTestCase() {
        repo.removeDesk(deskId = 1)
        executor.flushAll()

        verify(repo, times(1)).notifyVisibleTaskListeners(DEFAULT_DISPLAY, visibleTasksCount = 0)
        val lastActivationChange = assertNotNull(listener.lastActivationChange)
        assertThat(lastActivationChange.displayId).isEqualTo(0)
        assertThat(lastActivationChange.oldActive).isEqualTo(1)