mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-02 17:06:49 +00:00
Moving come tests to Roboelectric
> Fixing resource loading in robo tests Change-Id: Id5b8a0e4916a2a200da7a41b03f19846834beb1f
This commit is contained in:
@@ -1,73 +0,0 @@
|
||||
package com.android.launcher3.model;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.launcher3.ItemInfo;
|
||||
import com.android.launcher3.LauncherAppWidgetInfo;
|
||||
import com.android.launcher3.ShortcutInfo;
|
||||
import com.android.launcher3.compat.PackageInstallerCompat;
|
||||
import com.android.launcher3.compat.PackageInstallerCompat.PackageInstallInfo;
|
||||
|
||||
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}
|
||||
*/
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class PackageInstallStateChangedTaskTest extends BaseModelUpdateTaskTestCase {
|
||||
|
||||
@Before
|
||||
public void initData() throws Exception {
|
||||
initializeData("package_install_state_change_task_data");
|
||||
}
|
||||
|
||||
private PackageInstallStateChangedTask newTask(String pkg, int progress) {
|
||||
int state = PackageInstallerCompat.STATUS_INSTALLING;
|
||||
PackageInstallInfo installInfo = new PackageInstallInfo(pkg, state, progress);
|
||||
return new PackageInstallStateChangedTask(installInfo);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSessionUpdate_ignore_installed() throws Exception {
|
||||
executeTaskForTest(newTask("app1", 30));
|
||||
|
||||
// No shortcuts were updated
|
||||
verifyProgressUpdate(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSessionUpdate_shortcuts_updated() throws Exception {
|
||||
executeTaskForTest(newTask("app3", 30));
|
||||
|
||||
verifyProgressUpdate(30, 5, 6, 7);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSessionUpdate_widgets_updated() throws Exception {
|
||||
executeTaskForTest(newTask("app4", 30));
|
||||
|
||||
verifyProgressUpdate(30, 8, 9);
|
||||
}
|
||||
|
||||
private void verifyProgressUpdate(int progress, Integer... idsUpdated) {
|
||||
HashSet<Integer> updates = new HashSet<>(Arrays.asList(idsUpdated));
|
||||
for (ItemInfo info : bgDataModel.itemsIdMap) {
|
||||
if (info instanceof ShortcutInfo) {
|
||||
assertEquals(updates.contains(info.id) ? progress: 0,
|
||||
((ShortcutInfo) info).getInstallProgress());
|
||||
} else {
|
||||
assertEquals(updates.contains(info.id) ? progress: -1,
|
||||
((LauncherAppWidgetInfo) info).installProgress);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user