Simplifying model testing rules

> Using Sandbox application everywhere to avoid test leaks
> Removing LauncherModelHelper and moving some utility methods to rules and extensions

Bug: 406521480
Flag: EXEMPT test only
Test: Presubmit

Change-Id: I17bd5ec2bdb0fc0cbe02be9c8ee76595effe3f11
This commit is contained in:
Sunny Goyal committed 2025-03-26 11:34:15 -07:00
1 parent 66ac9dc459
commit cb84230913
46 files changed
+584 -744

No files matched your search

@@ -63,14 +63,14 @@ import com.android.launcher3.model.ModelDbController;
import com.android.launcher3.pm.UserCache;
import com.android.launcher3.util.AllModulesForTest;
import com.android.launcher3.util.IntArray;
import com.android.launcher3.util.LauncherModelHelper;
import com.android.launcher3.util.LauncherModelHelper.SandboxModelContext;
import com.android.launcher3.util.SandboxApplication;
import dagger.BindsInstance;
import dagger.Component;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
@@ -89,8 +89,9 @@ public class RestoreDbTaskTest {
private final UserHandle mWorkUser = UserHandle.getUserHandleForUid(PER_USER_RANGE);
private LauncherModelHelper mModelHelper;
private SandboxModelContext mContext;
@Rule
public final SandboxApplication mContext = new SandboxApplication();
private UserCache mUserCacheSpy;
private RestoreDbTask mTask;
@@ -105,8 +106,6 @@ public class RestoreDbTaskTest {
@Before
public void setup() {
mModelHelper = new LauncherModelHelper();
mContext = mModelHelper.sandboxContext;
mUserCacheSpy = spy(UserCache.getInstance(getInstrumentation().getTargetContext()));
mContext.initDaggerComponent(
@@ -135,7 +134,6 @@ public class RestoreDbTaskTest {
if (mWidgetHost != null) {
mWidgetHost.deleteHost();
}
mModelHelper.destroy();
LauncherPrefs.get(mContext).removeSync(RESTORE_DEVICE);
}