Revert "Simplifying model testing rules"
Revert submission 32704934-model-test-cleanup Reason for revert: Droidmonitor created revert due to b/406588406. Will be verifying through ABTD before submission. Reverted changes: /q/submissionid:32704934-model-test-cleanup Change-Id: Ieeb7f5b5699afeae27f946f060147bb68afc36e5
This commit is contained in:
committed by
Android (Google) Code Review
parent
cb84230913
commit
35b6d322ab
+18
-25
@@ -20,7 +20,6 @@ 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.ModelTestExtensions.getBgDataModel;
|
||||
import static com.android.launcher3.util.TestUtil.runOnExecutorSync;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -28,21 +27,16 @@ import static org.junit.Assert.assertEquals;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.LauncherModel;
|
||||
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.ModelTestExtensions;
|
||||
import com.android.launcher3.util.SandboxApplication;
|
||||
import com.android.launcher3.util.rule.InstallerSessionRule;
|
||||
import com.android.launcher3.util.rule.LayoutProviderRule;
|
||||
import com.android.launcher3.util.LauncherModelHelper;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -56,16 +50,14 @@ public class PackageInstallStateChangedTaskTest {
|
||||
private static final String PENDING_APP_1 = TEST_PACKAGE + ".pending1";
|
||||
private static final String PENDING_APP_2 = TEST_PACKAGE + ".pending2";
|
||||
|
||||
@Rule public SandboxApplication mContext = new SandboxApplication();
|
||||
@Rule public LayoutProviderRule mLayoutProvider = new LayoutProviderRule(mContext);
|
||||
@Rule public InstallerSessionRule mInstallerSessionRule = new InstallerSessionRule();
|
||||
|
||||
private LauncherModelHelper mModelHelper;
|
||||
private IntSet mDownloadingApps;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
mInstallerSessionRule.createInstallerSession(PENDING_APP_1);
|
||||
mInstallerSessionRule.createInstallerSession(PENDING_APP_2);
|
||||
mModelHelper = new LauncherModelHelper();
|
||||
mModelHelper.createInstallerSession(PENDING_APP_1);
|
||||
mModelHelper.createInstallerSession(PENDING_APP_2);
|
||||
|
||||
LauncherLayoutBuilder builder = new LauncherLayoutBuilder()
|
||||
.atWorkspace(0, 0, 1).putApp(TEST_PACKAGE, TEST_ACTIVITY) // 1
|
||||
@@ -82,9 +74,14 @@ public class PackageInstallStateChangedTaskTest {
|
||||
.atWorkspace(0, 0, 10).putApp(PENDING_APP_2, TEST_ACTIVITY3); // 10
|
||||
|
||||
mDownloadingApps = IntSet.wrap(4, 5, 6, 7, 8, 9, 10);
|
||||
mLayoutProvider.setupDefaultLayoutProvider(builder);
|
||||
ModelTestExtensions.INSTANCE.loadModelSync(getModel());
|
||||
assertEquals(10, getBgDataModel(getModel()).itemsIdMap.size());
|
||||
mModelHelper.setupDefaultLayoutProvider(builder);
|
||||
mModelHelper.loadModelSync();
|
||||
assertEquals(10, mModelHelper.getBgDataModel().itemsIdMap.size());
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
mModelHelper.destroy();
|
||||
}
|
||||
|
||||
private PackageInstallStateChangedTask newTask(String pkg, int progress) {
|
||||
@@ -98,7 +95,7 @@ public class PackageInstallStateChangedTaskTest {
|
||||
public void testSessionUpdate_ignore_installed() {
|
||||
// Run on model executor so that no other task runs in the middle.
|
||||
runOnExecutorSync(MODEL_EXECUTOR, () -> {
|
||||
getModel().enqueueModelUpdateTask(newTask(TEST_PACKAGE, 30));
|
||||
mModelHelper.getModel().enqueueModelUpdateTask(newTask(TEST_PACKAGE, 30));
|
||||
|
||||
// No shortcuts were updated
|
||||
verifyProgressUpdate(0);
|
||||
@@ -109,7 +106,7 @@ public class PackageInstallStateChangedTaskTest {
|
||||
public void testSessionUpdate_shortcuts_updated() {
|
||||
// Run on model executor so that no other task runs in the middle.
|
||||
runOnExecutorSync(MODEL_EXECUTOR, () -> {
|
||||
getModel().enqueueModelUpdateTask(newTask(PENDING_APP_1, 30));
|
||||
mModelHelper.getModel().enqueueModelUpdateTask(newTask(PENDING_APP_1, 30));
|
||||
|
||||
verifyProgressUpdate(30, 4, 5, 6, 7);
|
||||
});
|
||||
@@ -119,7 +116,7 @@ public class PackageInstallStateChangedTaskTest {
|
||||
public void testSessionUpdate_widgets_updated() {
|
||||
// Run on model executor so that no other task runs in the middle.
|
||||
runOnExecutorSync(MODEL_EXECUTOR, () -> {
|
||||
getModel().enqueueModelUpdateTask(newTask(PENDING_APP_2, 30));
|
||||
mModelHelper.getModel().enqueueModelUpdateTask(newTask(PENDING_APP_2, 30));
|
||||
|
||||
verifyProgressUpdate(30, 8, 9, 10);
|
||||
});
|
||||
@@ -127,7 +124,7 @@ public class PackageInstallStateChangedTaskTest {
|
||||
|
||||
private void verifyProgressUpdate(int progress, int... idsUpdated) {
|
||||
IntSet updates = IntSet.wrap(idsUpdated);
|
||||
for (ItemInfo info : getBgDataModel(getModel()).itemsIdMap) {
|
||||
for (ItemInfo info : mModelHelper.getBgDataModel().itemsIdMap) {
|
||||
int expectedProgress = updates.contains(info.id) ? progress
|
||||
: (mDownloadingApps.contains(info.id) ? 0 : 100);
|
||||
if (info instanceof WorkspaceItemInfo wi) {
|
||||
@@ -137,8 +134,4 @@ public class PackageInstallStateChangedTaskTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private LauncherModel getModel() {
|
||||
return LauncherAppState.getInstance(mContext).getModel();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user