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
2025-03-25 23:58:18 -07:00
parent 66ac9dc459
commit cb84230913
46 changed files with 584 additions and 744 deletions

View File

@@ -69,11 +69,10 @@ import com.android.launcher3.search.StringMatcherUtility;
import com.android.launcher3.util.ActivityContextWrapper;
import com.android.launcher3.util.FlagOp;
import com.android.launcher3.util.IntArray;
import com.android.launcher3.util.LauncherModelHelper.SandboxModelContext;
import com.android.launcher3.util.SandboxApplication;
import com.android.launcher3.util.TestUtil;
import com.android.launcher3.views.BaseDragLayer;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -119,7 +118,7 @@ public class BubbleTextViewTest {
private static final float SPACE_MULTIPLIER = 1;
private static final float SPACE_EXTRA = 0;
private SandboxModelContext mModelContext;
@Rule public SandboxApplication mModelContext = new SandboxApplication();
private BubbleTextView mBubbleTextView;
private ItemInfoWithIcon mItemInfoWithIcon;
@@ -131,7 +130,6 @@ public class BubbleTextViewTest {
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
Utilities.enableRunningInTestHarnessForTests();
mModelContext = new SandboxModelContext();
LauncherPrefs.get(mModelContext).put(ENABLE_TWOLINE_ALLAPPS_TOGGLE, true);
mContext = new ActivityContextWrapper(mModelContext);
@@ -160,11 +158,6 @@ public class BubbleTextViewTest {
mGmailAppInfo = new AppInfo(componentName, "Gmail", WORK_HANDLE, new Intent());
}
@After
public void tearDown() {
mModelContext.onDestroy();
}
@Test
@EnableFlags(Flags.FLAG_ENABLE_TWOLINE_TOGGLE)
public void testEmptyString_flagOn() {