Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksLimiter.kt +3 −0 Original line number Original line Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.view.SurfaceControl import android.view.WindowManager.TRANSIT_TO_BACK import android.view.WindowManager.TRANSIT_TO_BACK import android.window.TransitionInfo import android.window.TransitionInfo import android.window.WindowContainerTransaction import android.window.WindowContainerTransaction import android.window.flags.DesktopModeFlags import androidx.annotation.VisibleForTesting import androidx.annotation.VisibleForTesting import com.android.internal.jank.Cuj.CUJ_DESKTOP_MODE_MINIMIZE_WINDOW import com.android.internal.jank.Cuj.CUJ_DESKTOP_MODE_MINIMIZE_WINDOW import com.android.internal.jank.InteractionJankMonitor import com.android.internal.jank.InteractionJankMonitor Loading Loading @@ -161,6 +162,8 @@ class DesktopTasksLimiter ( @VisibleForTesting @VisibleForTesting inner class LeftoverMinimizedTasksRemover : DesktopModeTaskRepository.ActiveTasksListener { inner class LeftoverMinimizedTasksRemover : DesktopModeTaskRepository.ActiveTasksListener { override fun onActiveTasksChanged(displayId: Int) { override fun onActiveTasksChanged(displayId: Int) { // If back navigation is enabled, we shouldn't remove the leftover tasks if (DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION.isTrue()) return val wct = WindowContainerTransaction() val wct = WindowContainerTransaction() removeLeftoverMinimizedTasks(displayId, wct) removeLeftoverMinimizedTasks(displayId, wct) shellTaskOrganizer.applyTransaction(wct) shellTaskOrganizer.applyTransaction(wct) Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksTransitionObserver.kt +22 −1 Original line number Original line Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.window.flags.DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_WALLPAPER_ import com.android.internal.protolog.ProtoLog import com.android.internal.protolog.ProtoLog import com.android.wm.shell.ShellTaskOrganizer import com.android.wm.shell.ShellTaskOrganizer import com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE import com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE import com.android.wm.shell.shared.TransitionUtil import com.android.wm.shell.shared.desktopmode.DesktopModeStatus import com.android.wm.shell.shared.desktopmode.DesktopModeStatus import com.android.wm.shell.sysui.ShellInit import com.android.wm.shell.sysui.ShellInit import com.android.wm.shell.transition.Transitions import com.android.wm.shell.transition.Transitions Loading Loading @@ -67,9 +68,29 @@ class DesktopTasksTransitionObserver( ) { ) { // TODO: b/332682201 Update repository state // TODO: b/332682201 Update repository state updateWallpaperToken(info) updateWallpaperToken(info) if (DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION.isTrue()) { if (DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION.isTrue()) { handleBackNavigation(info) handleBackNavigation(info) removeTaskIfNeeded(info) } } private fun removeTaskIfNeeded(info: TransitionInfo) { // Since we are no longer removing all the tasks [onTaskVanished], we need to remove them by // checking the transitions. if (!TransitionUtil.isOpeningType(info.type)) return // Remove a task from the repository if the app is launched outside of desktop. for (change in info.changes) { val taskInfo = change.taskInfo if (taskInfo == null || taskInfo.taskId == -1) continue if (desktopModeTaskRepository.isActiveTask(taskInfo.taskId) && taskInfo.windowingMode != WINDOWING_MODE_FREEFORM ) { desktopModeTaskRepository.removeFreeformTask( taskInfo.displayId, taskInfo.taskId ) } } } } } Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksLimiterTest.kt +20 −0 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,8 @@ package com.android.wm.shell.desktopmode import android.app.ActivityManager.RunningTaskInfo import android.app.ActivityManager.RunningTaskInfo import android.os.Binder import android.os.Binder import android.os.Handler import android.os.Handler import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import android.platform.test.flag.junit.SetFlagsRule import android.platform.test.flag.junit.SetFlagsRule import android.testing.AndroidTestingRunner import android.testing.AndroidTestingRunner import android.view.Display.DEFAULT_DISPLAY import android.view.Display.DEFAULT_DISPLAY Loading @@ -33,6 +35,7 @@ import com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn import com.android.dx.mockito.inline.extended.StaticMockitoSession import com.android.dx.mockito.inline.extended.StaticMockitoSession import com.android.internal.jank.Cuj.CUJ_DESKTOP_MODE_MINIMIZE_WINDOW import com.android.internal.jank.Cuj.CUJ_DESKTOP_MODE_MINIMIZE_WINDOW import com.android.internal.jank.InteractionJankMonitor import com.android.internal.jank.InteractionJankMonitor import com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION import com.android.wm.shell.ShellTaskOrganizer import com.android.wm.shell.ShellTaskOrganizer import com.android.wm.shell.ShellTestCase import com.android.wm.shell.ShellTestCase import com.android.wm.shell.common.ShellExecutor import com.android.wm.shell.common.ShellExecutor Loading Loading @@ -243,6 +246,7 @@ class DesktopTasksLimiterTest : ShellTestCase() { } } @Test @Test @DisableFlags(FLAG_ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION) fun removeLeftoverMinimizedTasks_activeNonMinimizedTasksStillAround_doesNothing() { fun removeLeftoverMinimizedTasks_activeNonMinimizedTasksStillAround_doesNothing() { desktopTaskRepo.addActiveTask(displayId = DEFAULT_DISPLAY, taskId = 1) desktopTaskRepo.addActiveTask(displayId = DEFAULT_DISPLAY, taskId = 1) desktopTaskRepo.addActiveTask(displayId = DEFAULT_DISPLAY, taskId = 2) desktopTaskRepo.addActiveTask(displayId = DEFAULT_DISPLAY, taskId = 2) Loading @@ -256,6 +260,7 @@ class DesktopTasksLimiterTest : ShellTestCase() { } } @Test @Test @DisableFlags(FLAG_ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION) fun removeLeftoverMinimizedTasks_noMinimizedTasks_doesNothing() { fun removeLeftoverMinimizedTasks_noMinimizedTasks_doesNothing() { val wct = WindowContainerTransaction() val wct = WindowContainerTransaction() desktopTasksLimiter.leftoverMinimizedTasksRemover.removeLeftoverMinimizedTasks( desktopTasksLimiter.leftoverMinimizedTasksRemover.removeLeftoverMinimizedTasks( Loading @@ -265,6 +270,7 @@ class DesktopTasksLimiterTest : ShellTestCase() { } } @Test @Test @DisableFlags(FLAG_ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION) fun removeLeftoverMinimizedTasks_onlyMinimizedTasksLeft_removesAllMinimizedTasks() { fun removeLeftoverMinimizedTasks_onlyMinimizedTasksLeft_removesAllMinimizedTasks() { val task1 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) val task1 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) val task2 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) val task2 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) Loading @@ -282,6 +288,20 @@ class DesktopTasksLimiterTest : ShellTestCase() { assertThat(wct.hierarchyOps[1].container).isEqualTo(task2.token.asBinder()) assertThat(wct.hierarchyOps[1].container).isEqualTo(task2.token.asBinder()) } } @Test @EnableFlags(FLAG_ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION) fun removeLeftoverMinimizedTasks_onlyMinimizedTasksLeft_backNavEnabled_doesNothing() { val task1 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) val task2 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) desktopTaskRepo.minimizeTask(displayId = DEFAULT_DISPLAY, taskId = task1.taskId) desktopTaskRepo.minimizeTask(displayId = DEFAULT_DISPLAY, taskId = task2.taskId) val wct = WindowContainerTransaction() desktopTasksLimiter.leftoverMinimizedTasksRemover.onActiveTasksChanged(DEFAULT_DISPLAY) assertThat(wct.hierarchyOps).isEmpty() } @Test @Test fun addAndGetMinimizeTaskChangesIfNeeded_tasksWithinLimit_noTaskMinimized() { fun addAndGetMinimizeTaskChangesIfNeeded_tasksWithinLimit_noTaskMinimized() { (1..<MAX_TASK_LIMIT).forEach { _ -> setUpFreeformTask() } (1..<MAX_TASK_LIMIT).forEach { _ -> setUpFreeformTask() } Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksTransitionObserverTest.kt +37 −2 Original line number Original line Diff line number Diff line Loading @@ -18,11 +18,13 @@ package com.android.wm.shell.desktopmode import android.app.ActivityManager.RunningTaskInfo import android.app.ActivityManager.RunningTaskInfo import android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM import android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM import android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN import android.content.ComponentName import android.content.ComponentName import android.content.Context import android.content.Context import android.content.Intent import android.content.Intent import android.platform.test.annotations.EnableFlags import android.platform.test.annotations.EnableFlags import android.view.Display.DEFAULT_DISPLAY import android.view.Display.DEFAULT_DISPLAY import android.view.WindowManager.TRANSIT_OPEN import android.view.WindowManager.TRANSIT_TO_BACK import android.view.WindowManager.TRANSIT_TO_BACK import android.window.IWindowContainerToken import android.window.IWindowContainerToken import android.window.TransitionInfo import android.window.TransitionInfo Loading Loading @@ -110,6 +112,24 @@ class DesktopTasksTransitionObserverTest { verify(taskRepository, never()).minimizeTask(task.displayId, task.taskId) verify(taskRepository, never()).minimizeTask(task.displayId, task.taskId) } } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION) fun removeTasks_onTaskFullscreenLaunch_taskRemovedFromRepo() { val task = createTaskInfo(1, WINDOWING_MODE_FULLSCREEN) whenever(taskRepository.getVisibleTaskCount(any())).thenReturn(1) whenever(taskRepository.isActiveTask(task.taskId)).thenReturn(true) transitionObserver.onTransitionReady( transition = mock(), info = createOpenTransition(task), startTransaction = mock(), finishTransaction = mock(), ) verify(taskRepository, never()).minimizeTask(task.displayId, task.taskId) verify(taskRepository).removeFreeformTask(task.displayId, task.taskId) } private fun createBackNavigationTransition( private fun createBackNavigationTransition( task: RunningTaskInfo? task: RunningTaskInfo? ): TransitionInfo { ): TransitionInfo { Loading @@ -125,11 +145,26 @@ class DesktopTasksTransitionObserverTest { } } } } private fun createTaskInfo(id: Int) = private fun createOpenTransition( task: RunningTaskInfo? ): TransitionInfo { return TransitionInfo(TRANSIT_OPEN, 0 /* flags */).apply { addChange( Change(mock(), mock()).apply { mode = TRANSIT_OPEN parent = null taskInfo = task flags = flags } ) } } private fun createTaskInfo(id: Int, windowingMode: Int = WINDOWING_MODE_FREEFORM) = RunningTaskInfo().apply { RunningTaskInfo().apply { taskId = id taskId = id displayId = DEFAULT_DISPLAY displayId = DEFAULT_DISPLAY configuration.windowConfiguration.windowingMode = WINDOWING_MODE_FREEFORM configuration.windowConfiguration.windowingMode = windowingMode token = WindowContainerToken(Mockito.mock(IWindowContainerToken::class.java)) token = WindowContainerToken(Mockito.mock(IWindowContainerToken::class.java)) baseIntent = Intent().apply { baseIntent = Intent().apply { component = ComponentName("package", "component.name") component = ComponentName("package", "component.name") Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksLimiter.kt +3 −0 Original line number Original line Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.view.SurfaceControl import android.view.WindowManager.TRANSIT_TO_BACK import android.view.WindowManager.TRANSIT_TO_BACK import android.window.TransitionInfo import android.window.TransitionInfo import android.window.WindowContainerTransaction import android.window.WindowContainerTransaction import android.window.flags.DesktopModeFlags import androidx.annotation.VisibleForTesting import androidx.annotation.VisibleForTesting import com.android.internal.jank.Cuj.CUJ_DESKTOP_MODE_MINIMIZE_WINDOW import com.android.internal.jank.Cuj.CUJ_DESKTOP_MODE_MINIMIZE_WINDOW import com.android.internal.jank.InteractionJankMonitor import com.android.internal.jank.InteractionJankMonitor Loading Loading @@ -161,6 +162,8 @@ class DesktopTasksLimiter ( @VisibleForTesting @VisibleForTesting inner class LeftoverMinimizedTasksRemover : DesktopModeTaskRepository.ActiveTasksListener { inner class LeftoverMinimizedTasksRemover : DesktopModeTaskRepository.ActiveTasksListener { override fun onActiveTasksChanged(displayId: Int) { override fun onActiveTasksChanged(displayId: Int) { // If back navigation is enabled, we shouldn't remove the leftover tasks if (DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION.isTrue()) return val wct = WindowContainerTransaction() val wct = WindowContainerTransaction() removeLeftoverMinimizedTasks(displayId, wct) removeLeftoverMinimizedTasks(displayId, wct) shellTaskOrganizer.applyTransaction(wct) shellTaskOrganizer.applyTransaction(wct) Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksTransitionObserver.kt +22 −1 Original line number Original line Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.window.flags.DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_WALLPAPER_ import com.android.internal.protolog.ProtoLog import com.android.internal.protolog.ProtoLog import com.android.wm.shell.ShellTaskOrganizer import com.android.wm.shell.ShellTaskOrganizer import com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE import com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE import com.android.wm.shell.shared.TransitionUtil import com.android.wm.shell.shared.desktopmode.DesktopModeStatus import com.android.wm.shell.shared.desktopmode.DesktopModeStatus import com.android.wm.shell.sysui.ShellInit import com.android.wm.shell.sysui.ShellInit import com.android.wm.shell.transition.Transitions import com.android.wm.shell.transition.Transitions Loading Loading @@ -67,9 +68,29 @@ class DesktopTasksTransitionObserver( ) { ) { // TODO: b/332682201 Update repository state // TODO: b/332682201 Update repository state updateWallpaperToken(info) updateWallpaperToken(info) if (DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION.isTrue()) { if (DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION.isTrue()) { handleBackNavigation(info) handleBackNavigation(info) removeTaskIfNeeded(info) } } private fun removeTaskIfNeeded(info: TransitionInfo) { // Since we are no longer removing all the tasks [onTaskVanished], we need to remove them by // checking the transitions. if (!TransitionUtil.isOpeningType(info.type)) return // Remove a task from the repository if the app is launched outside of desktop. for (change in info.changes) { val taskInfo = change.taskInfo if (taskInfo == null || taskInfo.taskId == -1) continue if (desktopModeTaskRepository.isActiveTask(taskInfo.taskId) && taskInfo.windowingMode != WINDOWING_MODE_FREEFORM ) { desktopModeTaskRepository.removeFreeformTask( taskInfo.displayId, taskInfo.taskId ) } } } } } Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksLimiterTest.kt +20 −0 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,8 @@ package com.android.wm.shell.desktopmode import android.app.ActivityManager.RunningTaskInfo import android.app.ActivityManager.RunningTaskInfo import android.os.Binder import android.os.Binder import android.os.Handler import android.os.Handler import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import android.platform.test.flag.junit.SetFlagsRule import android.platform.test.flag.junit.SetFlagsRule import android.testing.AndroidTestingRunner import android.testing.AndroidTestingRunner import android.view.Display.DEFAULT_DISPLAY import android.view.Display.DEFAULT_DISPLAY Loading @@ -33,6 +35,7 @@ import com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn import com.android.dx.mockito.inline.extended.StaticMockitoSession import com.android.dx.mockito.inline.extended.StaticMockitoSession import com.android.internal.jank.Cuj.CUJ_DESKTOP_MODE_MINIMIZE_WINDOW import com.android.internal.jank.Cuj.CUJ_DESKTOP_MODE_MINIMIZE_WINDOW import com.android.internal.jank.InteractionJankMonitor import com.android.internal.jank.InteractionJankMonitor import com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION import com.android.wm.shell.ShellTaskOrganizer import com.android.wm.shell.ShellTaskOrganizer import com.android.wm.shell.ShellTestCase import com.android.wm.shell.ShellTestCase import com.android.wm.shell.common.ShellExecutor import com.android.wm.shell.common.ShellExecutor Loading Loading @@ -243,6 +246,7 @@ class DesktopTasksLimiterTest : ShellTestCase() { } } @Test @Test @DisableFlags(FLAG_ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION) fun removeLeftoverMinimizedTasks_activeNonMinimizedTasksStillAround_doesNothing() { fun removeLeftoverMinimizedTasks_activeNonMinimizedTasksStillAround_doesNothing() { desktopTaskRepo.addActiveTask(displayId = DEFAULT_DISPLAY, taskId = 1) desktopTaskRepo.addActiveTask(displayId = DEFAULT_DISPLAY, taskId = 1) desktopTaskRepo.addActiveTask(displayId = DEFAULT_DISPLAY, taskId = 2) desktopTaskRepo.addActiveTask(displayId = DEFAULT_DISPLAY, taskId = 2) Loading @@ -256,6 +260,7 @@ class DesktopTasksLimiterTest : ShellTestCase() { } } @Test @Test @DisableFlags(FLAG_ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION) fun removeLeftoverMinimizedTasks_noMinimizedTasks_doesNothing() { fun removeLeftoverMinimizedTasks_noMinimizedTasks_doesNothing() { val wct = WindowContainerTransaction() val wct = WindowContainerTransaction() desktopTasksLimiter.leftoverMinimizedTasksRemover.removeLeftoverMinimizedTasks( desktopTasksLimiter.leftoverMinimizedTasksRemover.removeLeftoverMinimizedTasks( Loading @@ -265,6 +270,7 @@ class DesktopTasksLimiterTest : ShellTestCase() { } } @Test @Test @DisableFlags(FLAG_ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION) fun removeLeftoverMinimizedTasks_onlyMinimizedTasksLeft_removesAllMinimizedTasks() { fun removeLeftoverMinimizedTasks_onlyMinimizedTasksLeft_removesAllMinimizedTasks() { val task1 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) val task1 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) val task2 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) val task2 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) Loading @@ -282,6 +288,20 @@ class DesktopTasksLimiterTest : ShellTestCase() { assertThat(wct.hierarchyOps[1].container).isEqualTo(task2.token.asBinder()) assertThat(wct.hierarchyOps[1].container).isEqualTo(task2.token.asBinder()) } } @Test @EnableFlags(FLAG_ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION) fun removeLeftoverMinimizedTasks_onlyMinimizedTasksLeft_backNavEnabled_doesNothing() { val task1 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) val task2 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) desktopTaskRepo.minimizeTask(displayId = DEFAULT_DISPLAY, taskId = task1.taskId) desktopTaskRepo.minimizeTask(displayId = DEFAULT_DISPLAY, taskId = task2.taskId) val wct = WindowContainerTransaction() desktopTasksLimiter.leftoverMinimizedTasksRemover.onActiveTasksChanged(DEFAULT_DISPLAY) assertThat(wct.hierarchyOps).isEmpty() } @Test @Test fun addAndGetMinimizeTaskChangesIfNeeded_tasksWithinLimit_noTaskMinimized() { fun addAndGetMinimizeTaskChangesIfNeeded_tasksWithinLimit_noTaskMinimized() { (1..<MAX_TASK_LIMIT).forEach { _ -> setUpFreeformTask() } (1..<MAX_TASK_LIMIT).forEach { _ -> setUpFreeformTask() } Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksTransitionObserverTest.kt +37 −2 Original line number Original line Diff line number Diff line Loading @@ -18,11 +18,13 @@ package com.android.wm.shell.desktopmode import android.app.ActivityManager.RunningTaskInfo import android.app.ActivityManager.RunningTaskInfo import android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM import android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM import android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN import android.content.ComponentName import android.content.ComponentName import android.content.Context import android.content.Context import android.content.Intent import android.content.Intent import android.platform.test.annotations.EnableFlags import android.platform.test.annotations.EnableFlags import android.view.Display.DEFAULT_DISPLAY import android.view.Display.DEFAULT_DISPLAY import android.view.WindowManager.TRANSIT_OPEN import android.view.WindowManager.TRANSIT_TO_BACK import android.view.WindowManager.TRANSIT_TO_BACK import android.window.IWindowContainerToken import android.window.IWindowContainerToken import android.window.TransitionInfo import android.window.TransitionInfo Loading Loading @@ -110,6 +112,24 @@ class DesktopTasksTransitionObserverTest { verify(taskRepository, never()).minimizeTask(task.displayId, task.taskId) verify(taskRepository, never()).minimizeTask(task.displayId, task.taskId) } } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION) fun removeTasks_onTaskFullscreenLaunch_taskRemovedFromRepo() { val task = createTaskInfo(1, WINDOWING_MODE_FULLSCREEN) whenever(taskRepository.getVisibleTaskCount(any())).thenReturn(1) whenever(taskRepository.isActiveTask(task.taskId)).thenReturn(true) transitionObserver.onTransitionReady( transition = mock(), info = createOpenTransition(task), startTransaction = mock(), finishTransaction = mock(), ) verify(taskRepository, never()).minimizeTask(task.displayId, task.taskId) verify(taskRepository).removeFreeformTask(task.displayId, task.taskId) } private fun createBackNavigationTransition( private fun createBackNavigationTransition( task: RunningTaskInfo? task: RunningTaskInfo? ): TransitionInfo { ): TransitionInfo { Loading @@ -125,11 +145,26 @@ class DesktopTasksTransitionObserverTest { } } } } private fun createTaskInfo(id: Int) = private fun createOpenTransition( task: RunningTaskInfo? ): TransitionInfo { return TransitionInfo(TRANSIT_OPEN, 0 /* flags */).apply { addChange( Change(mock(), mock()).apply { mode = TRANSIT_OPEN parent = null taskInfo = task flags = flags } ) } } private fun createTaskInfo(id: Int, windowingMode: Int = WINDOWING_MODE_FREEFORM) = RunningTaskInfo().apply { RunningTaskInfo().apply { taskId = id taskId = id displayId = DEFAULT_DISPLAY displayId = DEFAULT_DISPLAY configuration.windowConfiguration.windowingMode = WINDOWING_MODE_FREEFORM configuration.windowConfiguration.windowingMode = windowingMode token = WindowContainerToken(Mockito.mock(IWindowContainerToken::class.java)) token = WindowContainerToken(Mockito.mock(IWindowContainerToken::class.java)) baseIntent = Intent().apply { baseIntent = Intent().apply { component = ComponentName("package", "component.name") component = ComponentName("package", "component.name") Loading