Fix LauncherProvider newScreenId issue

Remove maxScreenId from LauncherProvider and whenever we need
a new screenId, query the database to calculate a new screenId.
Also converted and refactored AddWorkspaceItemsTaskTest
and added some extra test cases.

Test: manual & AddWorkspaceItemsTaskTest.kt
Bug: 199160559
Change-Id: I185f6823fed171d778af0130497f5ffaf89c0a70
This commit is contained in:
Andras Kloczl
2021-10-15 21:16:48 +01:00
committed by Alex Chau
parent f75725830a
commit 953eb8041e
5 changed files with 13 additions and 62 deletions

View File

@@ -86,8 +86,6 @@ public class AddWorkspaceItemsTaskTest {
@Test
public void testFindSpaceForItem_prefers_second() throws Exception {
mIdp.isSplitDisplay = false;
// First screen has only one hole of size 1
int nextId = setupWorkspaceWithHoles(1, 1, new Rect(2, 2, 3, 3));
@@ -108,24 +106,6 @@ public class AddWorkspaceItemsTaskTest {
.isRegionVacant(spaceFound[1], spaceFound[2], 2, 3));
}
@Test
public void testFindSpaceForItem_prefers_third_on_split_display() throws Exception {
mIdp.isSplitDisplay = true;
// First screen has only one hole of size 1
int nextId = setupWorkspaceWithHoles(1, 1, new Rect(2, 2, 3, 3));
// Second screen has 2 holes of sizes 3x2 and 2x3
setupWorkspaceWithHoles(nextId, 2, new Rect(2, 0, 5, 2), new Rect(0, 2, 2, 5));
int[] spaceFound = newTask().findSpaceForItem(
mAppState, mModelHelper.getBgDataModel(), mExistingScreens, mNewScreens, 1, 1);
// For split display, it picks the next screen, even if there is enough space
// on previous screen
assertEquals(2, spaceFound[0]);
assertTrue(mScreenOccupancy.get(spaceFound[0])
.isRegionVacant(spaceFound[1], spaceFound[2], 1, 1));
}
@Test
public void testFindSpaceForItem_adds_new_screen() throws Exception {
// First screen has 2 holes of sizes 3x2 and 2x3