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

Commit bf6b680c authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Verify removal of task leash in TaskView

Ensure the instance is a copy and it will be released on removal.

Bug: 411280316
Flag: EXEMPT TEST_ONLY
Test: TaskViewTest#testOnTaskVanished
Change-Id: I2198445207809cfe134595d27229e604ba5b035b
parent a21b506c
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -118,6 +118,11 @@ public class TaskViewTaskController implements ShellTaskOrganizer.TaskListener {
        mHideTaskWithSurface = hideTaskWithSurface;
    }

    @VisibleForTesting
    SurfaceControl getTaskLeash() {
        return mTaskLeash;
    }

    SurfaceControl getSurfaceControl() {
        return mSurfaceControl;
    }
+12 −0
Original line number Diff line number Diff line
@@ -433,10 +433,13 @@ public class TaskViewTest extends ShellTestCase {
        mTaskViewTransitions.prepareOpenAnimation(mTaskViewTaskController, true /* newTask */,
                new SurfaceControl.Transaction(), new SurfaceControl.Transaction(), mTaskInfo,
                mLeash, wct);
        final SurfaceControl taskLeash = mTaskViewTaskController.getTaskLeash();
        mTaskView.surfaceCreated(mock(SurfaceHolder.class));
        mTaskViewTaskController.prepareCloseAnimation();

        verify(mViewListener).onTaskRemovalStarted(eq(mTaskInfo.taskId));
        assertThat(mTaskViewTaskController.getTaskLeash()).isNull();
        assertThat(taskLeash.isValid()).isFalse();
    }

    @Test
@@ -586,6 +589,15 @@ public class TaskViewTest extends ShellTestCase {
        }
    }

    @Test
    public void testPrepareOpenAnimation_copiesLeash() {
        mTaskViewTransitions.prepareOpenAnimation(mTaskViewTaskController, true /* newTask */,
                new SurfaceControl.Transaction(), new SurfaceControl.Transaction(), mTaskInfo,
                mLeash, new WindowContainerTransaction());

        assertThat(mTaskViewTaskController.getTaskLeash()).isNotEqualTo(mLeash);
    }

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