Don't replace task in list if NEW_TASK + MULTIPLE_TASK is set
Bug: 183046894 Test: atest RecentTasksTest Change-Id: Ifbaac51efa90b7a51bd3d64a32dde293ef45d040
This commit is contained in:
@@ -1573,6 +1573,10 @@ class RecentTasks {
|
|||||||
} else if (document || trIsDocument) {
|
} else if (document || trIsDocument) {
|
||||||
// Only one of these is a document. Not the droid we're looking for.
|
// Only one of these is a document. Not the droid we're looking for.
|
||||||
continue;
|
continue;
|
||||||
|
} else if (multiTasksAllowed) {
|
||||||
|
// Neither is a document, but the new task supports multiple tasks so keep the
|
||||||
|
// existing task
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ public class RecentTasksTest extends WindowTestsBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddTasksNoMultiple_expectNoTrim() {
|
public void testAddDocumentTasksNoMultiple_expectNoTrim() {
|
||||||
// Add same non-multiple-task document tasks will remove the task (to re-add it) but not
|
// Add same non-multiple-task document tasks will remove the task (to re-add it) but not
|
||||||
// trim it
|
// trim it
|
||||||
Task documentTask1 = createDocumentTask(".DocumentTask1");
|
Task documentTask1 = createDocumentTask(".DocumentTask1");
|
||||||
@@ -262,7 +262,7 @@ public class RecentTasksTest extends WindowTestsBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddTasksMultipleDocumentTasks_expectNoTrim() {
|
public void testAddMultipleDocumentTasks_expectNoTrim() {
|
||||||
// Add same multiple-task document tasks does not trim the first tasks
|
// Add same multiple-task document tasks does not trim the first tasks
|
||||||
Task documentTask1 = createDocumentTask(".DocumentTask1",
|
Task documentTask1 = createDocumentTask(".DocumentTask1",
|
||||||
FLAG_ACTIVITY_MULTIPLE_TASK);
|
FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||||
@@ -278,9 +278,33 @@ public class RecentTasksTest extends WindowTestsBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddTasksMultipleTasks_expectRemovedNoTrim() {
|
public void testAddTasks_expectRemovedNoTrim() {
|
||||||
// Add multiple same-affinity non-document tasks, ensure that it removes the other task,
|
// Add multiple same-affinity non-document tasks, ensure that it removes, but does not trim
|
||||||
// but that it does not trim it
|
// the other task
|
||||||
|
Task task1 = createTaskBuilder(".Task1")
|
||||||
|
.setFlags(FLAG_ACTIVITY_NEW_TASK)
|
||||||
|
.build();
|
||||||
|
Task task2 = createTaskBuilder(".Task1")
|
||||||
|
.setFlags(FLAG_ACTIVITY_NEW_TASK)
|
||||||
|
.build();
|
||||||
|
mRecentTasks.add(task1);
|
||||||
|
assertThat(mCallbacksRecorder.mAdded).hasSize(1);
|
||||||
|
assertThat(mCallbacksRecorder.mAdded).contains(task1);
|
||||||
|
assertThat(mCallbacksRecorder.mTrimmed).isEmpty();
|
||||||
|
assertThat(mCallbacksRecorder.mRemoved).isEmpty();
|
||||||
|
mCallbacksRecorder.clear();
|
||||||
|
mRecentTasks.add(task2);
|
||||||
|
assertThat(mCallbacksRecorder.mAdded).hasSize(1);
|
||||||
|
assertThat(mCallbacksRecorder.mAdded).contains(task2);
|
||||||
|
assertThat(mCallbacksRecorder.mTrimmed).isEmpty();
|
||||||
|
assertThat(mCallbacksRecorder.mRemoved).hasSize(1);
|
||||||
|
assertThat(mCallbacksRecorder.mRemoved).contains(task1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddMultipleTasks_expectNotRemoved() {
|
||||||
|
// Add multiple same-affinity non-document tasks with MULTIPLE_TASK, ensure that it does not
|
||||||
|
// remove the other task
|
||||||
Task task1 = createTaskBuilder(".Task1")
|
Task task1 = createTaskBuilder(".Task1")
|
||||||
.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK)
|
.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK)
|
||||||
.build();
|
.build();
|
||||||
@@ -297,8 +321,7 @@ public class RecentTasksTest extends WindowTestsBase {
|
|||||||
assertThat(mCallbacksRecorder.mAdded).hasSize(1);
|
assertThat(mCallbacksRecorder.mAdded).hasSize(1);
|
||||||
assertThat(mCallbacksRecorder.mAdded).contains(task2);
|
assertThat(mCallbacksRecorder.mAdded).contains(task2);
|
||||||
assertThat(mCallbacksRecorder.mTrimmed).isEmpty();
|
assertThat(mCallbacksRecorder.mTrimmed).isEmpty();
|
||||||
assertThat(mCallbacksRecorder.mRemoved).hasSize(1);
|
assertThat(mCallbacksRecorder.mRemoved).isEmpty();
|
||||||
assertThat(mCallbacksRecorder.mRemoved).contains(task1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user