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

Commit 97b2efcc authored by Automerger Merge Worker's avatar Automerger Merge Worker Committed by Android (Google) Code Review
Browse files

Merge "Merge "Return early in removeTask if there is no task token" into...

Merge "Merge "Return early in removeTask if there is no task token" into udc-dev am: 0ea18527" into udc-dev-plus-aosp
parents f05f404b 3beeaac2
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.content.pm.ShortcutInfo;
import android.graphics.Rect;
import android.os.Binder;
import android.util.CloseGuard;
import android.util.Slog;
import android.view.SurfaceControl;
import android.window.WindowContainerToken;
import android.window.WindowContainerTransaction;
@@ -49,6 +50,8 @@ import java.util.concurrent.Executor;
 */
public class TaskViewTaskController implements ShellTaskOrganizer.TaskListener {

    private static final String TAG = TaskViewTaskController.class.getSimpleName();

    private final CloseGuard mGuard = new CloseGuard();

    private final ShellTaskOrganizer mTaskOrganizer;
@@ -405,6 +408,11 @@ public class TaskViewTaskController implements ShellTaskOrganizer.TaskListener {
     * Call to remove the task from window manager. This task will not appear in recents.
     */
    void removeTask() {
        if (mTaskToken == null) {
            // Call to remove task before we have one, do nothing
            Slog.w(TAG, "Trying to remove a task that was never added? (no taskToken)");
            return;
        }
        WindowContainerTransaction wct = new WindowContainerTransaction();
        wct.removeTask(mTaskToken);
        mTaskViewTransitions.closeTaskView(wct, this);
+24 −0
Original line number Diff line number Diff line
@@ -520,4 +520,28 @@ public class TaskViewTest extends ShellTestCase {
        verify(mTaskViewTransitions).updateVisibilityState(eq(mTaskViewTaskController), eq(false));
        verify(mTaskViewTransitions, never()).updateBoundsState(eq(mTaskViewTaskController), any());
    }

    @Test
    public void testRemoveTaskView_noTask() {
        assumeTrue(Transitions.ENABLE_SHELL_TRANSITIONS);

        mTaskView.removeTask();
        verify(mTaskViewTransitions, never()).closeTaskView(any(), any());
    }

    @Test
    public void testRemoveTaskView() {
        assumeTrue(Transitions.ENABLE_SHELL_TRANSITIONS);

        mTaskView.surfaceCreated(mock(SurfaceHolder.class));
        WindowContainerTransaction wct = new WindowContainerTransaction();
        mTaskViewTaskController.prepareOpenAnimation(true /* newTask */,
                new SurfaceControl.Transaction(), new SurfaceControl.Transaction(), mTaskInfo,
                mLeash, wct);

        verify(mViewListener).onTaskCreated(eq(mTaskInfo.taskId), any());

        mTaskView.removeTask();
        verify(mTaskViewTransitions).closeTaskView(any(), eq(mTaskViewTaskController));
    }
}