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

Commit 80389676 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Fixing bug in GridSizeMigrationTask, where it was not accounting for

an extra space when there is no all-apps icon

Bug: 29569843
Change-Id: Ib768f0d069aed413bd8f4c2aa86ab1d3d657680e
parent 4efaed56
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -150,7 +150,7 @@ public class GridSizeMigrationTask {
    protected boolean migrateHotseat() throws Exception {
        ArrayList<DbEntry> items = loadHotseatEntries();

        int requiredCount = mDestHotseatSize - 1;
        int requiredCount = FeatureFlags.NO_ALL_APPS_ICON ? mDestHotseatSize : mDestHotseatSize - 1;

        while (items.size() > requiredCount) {
            // Pick the center item by default.
+15 −4
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ import android.test.suitebuilder.annotation.MediumTest;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.LauncherModel;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.util.TestLauncherProvider;

@@ -61,9 +62,14 @@ public class GridSizeMigrationTaskTest extends ProviderTestCase2<TestLauncherPro
        mIdp.numHotseatIcons = 3;
        new GridSizeMigrationTask(getMockContext(), mIdp, mValidPackages, 5, 3)
                .migrateHotseat();
        if (FeatureFlags.NO_ALL_APPS_ICON) {
            // First item is dropped as it has the least weight.
            verifyHotseat(hotseatItems[1], hotseatItems[3], hotseatItems[4]);
        } else {
            // First & last items are dropped as they have the least weight.
            verifyHotseat(hotseatItems[1], -1, hotseatItems[3]);
        }
    }

    public void testHotseatMigration_shortcuts_dropped() throws Exception {
        long[] hotseatItems = {
@@ -77,9 +83,14 @@ public class GridSizeMigrationTaskTest extends ProviderTestCase2<TestLauncherPro
        mIdp.numHotseatIcons = 3;
        new GridSizeMigrationTask(getMockContext(), mIdp, mValidPackages, 5, 3)
                .migrateHotseat();
        if (FeatureFlags.NO_ALL_APPS_ICON) {
            // First item is dropped as it has the least weight.
            verifyHotseat(hotseatItems[1], hotseatItems[3], hotseatItems[4]);
        } else {
            // First & third items are dropped as they have the least weight.
            verifyHotseat(hotseatItems[1], -1, hotseatItems[4]);
        }
    }

    private void verifyHotseat(long... sortedIds) {
        int screenId = 0;