Add setFlag and resetAll in FeatureFlags test mode
Add methods setFlag and resetAll in FeatureFlags in test mode. For the injection usecase, user will use the interface FeatureFlags in the code to control the flags. Add tests for test mode. Bug: 280833463 Test: Atest AconfigJavaHostTest --host Change-Id: Ib59ba35a9011a6400af42fc9c283d37193577997
This commit is contained in:
@@ -8,12 +8,16 @@ import static com.android.aconfig.test.Flags.enabledRo;
|
||||
import static com.android.aconfig.test.Flags.enabledRw;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
import com.android.aconfig.test.FakeFeatureFlagsImpl;
|
||||
import com.android.aconfig.test.FeatureFlags;
|
||||
|
||||
@RunWith(JUnit4.class)
|
||||
public final class AconfigTest {
|
||||
@Test
|
||||
@@ -43,4 +47,10 @@ public final class AconfigTest {
|
||||
// (currently all flags are assigned the default READ_ONLY + DISABLED)
|
||||
assertFalse(enabledRw());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFakeFeatureFlagsImplNotImpl() {
|
||||
FeatureFlags featureFlags = new FakeFeatureFlagsImpl();
|
||||
assertThrows(UnsupportedOperationException.class, () -> featureFlags.enabledRw());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user