mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 10:48:19 +00:00
Merge "Method to override feature flag" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
fb9c4d25c4
@@ -33,6 +33,7 @@ import com.android.launcher3.pm.UserCache
|
||||
import com.android.launcher3.provider.LauncherDbUtils
|
||||
import com.android.launcher3.util.LauncherModelHelper
|
||||
import com.android.launcher3.util.LauncherModelHelper.*
|
||||
import com.android.launcher3.util.TestUtil
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
@@ -750,20 +751,14 @@ class GridSizeMigrationUtilTest {
|
||||
}
|
||||
|
||||
private fun enableNewMigrationLogic(srcGridSize: String) {
|
||||
context
|
||||
.getSharedPreferences(FeatureFlags.FLAGS_PREF_NAME, Context.MODE_PRIVATE)
|
||||
.edit()
|
||||
.putBoolean(FeatureFlags.ENABLE_NEW_MIGRATION_LOGIC.key, true)
|
||||
.commit()
|
||||
LauncherPrefs.get(context).putSync(WORKSPACE_SIZE.to(srcGridSize))
|
||||
TestUtil.overrideBooleanFlagValue(context,
|
||||
FeatureFlags.ENABLE_NEW_MIGRATION_LOGIC, true);
|
||||
FeatureFlags.initialize(context)
|
||||
}
|
||||
|
||||
private fun disableNewMigrationLogic() {
|
||||
context
|
||||
.getSharedPreferences(FeatureFlags.FLAGS_PREF_NAME, Context.MODE_PRIVATE)
|
||||
.edit()
|
||||
.putBoolean(FeatureFlags.ENABLE_NEW_MIGRATION_LOGIC.key, false)
|
||||
.commit()
|
||||
TestUtil.overrideBooleanFlagValue(context,
|
||||
FeatureFlags.ENABLE_NEW_MIGRATION_LOGIC, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.tapl.LauncherInstrumentation;
|
||||
import com.android.launcher3.ui.AbstractLauncherUiTest;
|
||||
import com.android.launcher3.util.LauncherModelHelper;
|
||||
import com.android.launcher3.util.TestUtil;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Ignore;
|
||||
@@ -278,10 +279,8 @@ public final class SecondaryDisplayLauncherTest extends AbstractLauncherUiTest {
|
||||
|
||||
private void setDragNDropFlag(Boolean status) {
|
||||
Context context = new LauncherModelHelper().sandboxContext;
|
||||
context.getSharedPreferences(FeatureFlags.FLAGS_PREF_NAME, Context.MODE_PRIVATE).edit()
|
||||
.putBoolean(FeatureFlags.SECONDARY_DRAG_N_DROP_TO_PIN.key, status)
|
||||
.commit();
|
||||
FeatureFlags.initialize(context);
|
||||
TestUtil.overrideBooleanFlagValue(
|
||||
context, FeatureFlags.SECONDARY_DRAG_N_DROP_TO_PIN, status);
|
||||
startSecondaryDisplayActivity();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,14 +19,18 @@ import static androidx.test.InstrumentationRegistry.getContext;
|
||||
import static androidx.test.InstrumentationRegistry.getInstrumentation;
|
||||
import static androidx.test.InstrumentationRegistry.getTargetContext;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.LauncherApps;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.test.uiautomator.UiDevice;
|
||||
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
@@ -68,6 +72,18 @@ public class TestUtil {
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
// Override feature flag, mainly to be used ONLY in tests
|
||||
public static void overrideBooleanFlagValue(
|
||||
Context context, FeatureFlags.BooleanFlag flagToOverride,
|
||||
boolean bool) {
|
||||
context.getSharedPreferences(FeatureFlags.FLAGS_PREF_NAME, Context.MODE_PRIVATE)
|
||||
.edit()
|
||||
.putBoolean(flagToOverride.key, bool)
|
||||
.commit();
|
||||
FeatureFlags.initialize(context);
|
||||
}
|
||||
|
||||
public static void uninstallDummyApp() throws IOException {
|
||||
UiDevice.getInstance(getInstrumentation()).executeShellCommand(
|
||||
"pm uninstall " + DUMMY_PACKAGE);
|
||||
|
||||
Reference in New Issue
Block a user