mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-02 17:06:49 +00:00
Removing support for lagacy shortcuts
> Addition/removal of shortcus is already removed. This just cleans up the unused code path Bug: 275875209 Test: Updated tests Flag: N/A Change-Id: I8ab7f57b693f996920e50e8beecafcffab5167e9
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
package com.android.launcher3.model;
|
||||
|
||||
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
|
||||
import static com.android.launcher3.util.LauncherModelHelper.TEST_ACTIVITY;
|
||||
import static com.android.launcher3.util.LauncherModelHelper.TEST_ACTIVITY2;
|
||||
import static com.android.launcher3.util.LauncherModelHelper.TEST_ACTIVITY3;
|
||||
import static com.android.launcher3.util.LauncherModelHelper.TEST_PACKAGE;
|
||||
import static com.android.launcher3.util.TestUtil.runOnExecutorSync;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
@@ -9,6 +16,8 @@ import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.pm.PackageInstallInfo;
|
||||
import com.android.launcher3.util.IntSet;
|
||||
import com.android.launcher3.util.LauncherLayoutBuilder;
|
||||
import com.android.launcher3.util.LauncherModelHelper;
|
||||
|
||||
import org.junit.After;
|
||||
@@ -16,9 +25,6 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Tests for {@link PackageInstallStateChangedTask}
|
||||
*/
|
||||
@@ -26,12 +32,36 @@ import java.util.HashSet;
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class PackageInstallStateChangedTaskTest {
|
||||
|
||||
private static final String PENDING_APP_1 = TEST_PACKAGE + ".pending1";
|
||||
private static final String PENDING_APP_2 = TEST_PACKAGE + ".pending2";
|
||||
|
||||
private LauncherModelHelper mModelHelper;
|
||||
private IntSet mDownloadingApps;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
mModelHelper = new LauncherModelHelper();
|
||||
mModelHelper.initializeData("package_install_state_change_task_data");
|
||||
mModelHelper.createInstallerSession(PENDING_APP_1);
|
||||
mModelHelper.createInstallerSession(PENDING_APP_2);
|
||||
|
||||
LauncherLayoutBuilder builder = new LauncherLayoutBuilder()
|
||||
.atWorkspace(0, 0, 1).putApp(TEST_PACKAGE, TEST_ACTIVITY) // 1
|
||||
.atWorkspace(0, 0, 2).putApp(TEST_PACKAGE, TEST_ACTIVITY2) // 2
|
||||
.atWorkspace(0, 0, 3).putApp(TEST_PACKAGE, TEST_ACTIVITY3) // 3
|
||||
|
||||
.atWorkspace(0, 0, 4).putApp(PENDING_APP_1, TEST_ACTIVITY) // 4
|
||||
.atWorkspace(0, 0, 5).putApp(PENDING_APP_1, TEST_ACTIVITY2) // 5
|
||||
.atWorkspace(0, 0, 6).putApp(PENDING_APP_1, TEST_ACTIVITY3) // 6
|
||||
.atWorkspace(0, 0, 7).putWidget(PENDING_APP_1, "pending.widget", 1, 1) // 7
|
||||
|
||||
.atWorkspace(0, 0, 8).putApp(PENDING_APP_2, TEST_ACTIVITY) // 8
|
||||
.atWorkspace(0, 0, 9).putApp(PENDING_APP_2, TEST_ACTIVITY2) // 9
|
||||
.atWorkspace(0, 0, 10).putApp(PENDING_APP_2, TEST_ACTIVITY3); // 10
|
||||
|
||||
mDownloadingApps = IntSet.wrap(4, 5, 6, 7, 8, 9, 10);
|
||||
mModelHelper.setupDefaultLayoutProvider(builder);
|
||||
mModelHelper.loadModelSync();
|
||||
assertEquals(10, mModelHelper.getBgDataModel().itemsIdMap.size());
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -47,36 +77,45 @@ public class PackageInstallStateChangedTaskTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSessionUpdate_ignore_installed() throws Exception {
|
||||
mModelHelper.executeTaskForTest(newTask("app1", 30));
|
||||
public void testSessionUpdate_ignore_installed() {
|
||||
// Run on model executor so that no other task runs in the middle.
|
||||
runOnExecutorSync(MODEL_EXECUTOR, () -> {
|
||||
mModelHelper.getModel().enqueueModelUpdateTask(newTask(TEST_PACKAGE, 30));
|
||||
|
||||
// No shortcuts were updated
|
||||
verifyProgressUpdate(0);
|
||||
// No shortcuts were updated
|
||||
verifyProgressUpdate(0);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSessionUpdate_shortcuts_updated() throws Exception {
|
||||
mModelHelper.executeTaskForTest(newTask("app3", 30));
|
||||
public void testSessionUpdate_shortcuts_updated() {
|
||||
// Run on model executor so that no other task runs in the middle.
|
||||
runOnExecutorSync(MODEL_EXECUTOR, () -> {
|
||||
mModelHelper.getModel().enqueueModelUpdateTask(newTask(PENDING_APP_1, 30));
|
||||
|
||||
verifyProgressUpdate(30, 5, 6, 7);
|
||||
verifyProgressUpdate(30, 4, 5, 6, 7);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSessionUpdate_widgets_updated() throws Exception {
|
||||
mModelHelper.executeTaskForTest(newTask("app4", 30));
|
||||
public void testSessionUpdate_widgets_updated() {
|
||||
// Run on model executor so that no other task runs in the middle.
|
||||
runOnExecutorSync(MODEL_EXECUTOR, () -> {
|
||||
mModelHelper.getModel().enqueueModelUpdateTask(newTask(PENDING_APP_2, 30));
|
||||
|
||||
verifyProgressUpdate(30, 8, 9);
|
||||
verifyProgressUpdate(30, 8, 9, 10);
|
||||
});
|
||||
}
|
||||
|
||||
private void verifyProgressUpdate(int progress, Integer... idsUpdated) {
|
||||
HashSet<Integer> updates = new HashSet<>(Arrays.asList(idsUpdated));
|
||||
private void verifyProgressUpdate(int progress, int... idsUpdated) {
|
||||
IntSet updates = IntSet.wrap(idsUpdated);
|
||||
for (ItemInfo info : mModelHelper.getBgDataModel().itemsIdMap) {
|
||||
if (info instanceof WorkspaceItemInfo) {
|
||||
assertEquals(updates.contains(info.id) ? progress: 100,
|
||||
((WorkspaceItemInfo) info).getProgressLevel());
|
||||
int expectedProgress = updates.contains(info.id) ? progress
|
||||
: (mDownloadingApps.contains(info.id) ? 0 : 100);
|
||||
if (info instanceof WorkspaceItemInfo wi) {
|
||||
assertEquals(expectedProgress, wi.getProgressLevel());
|
||||
} else {
|
||||
assertEquals(updates.contains(info.id) ? progress: -1,
|
||||
((LauncherAppWidgetInfo) info).installProgress);
|
||||
assertEquals(expectedProgress, ((LauncherAppWidgetInfo) info).installProgress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user