Add a new field in the declaration to indicate whether the permission can be overridden. When the field “is_fixed_read_only” is set to true, the flag permission will be set as fixed “READ_ONLY”, and the permission should not be changed by Gantry. Bug: 292521627 Test: atest aconfig.test Change-Id: Ic9bcd7823bccb8b947cf05568c7ced3763490a23
67 lines
2.6 KiB
Java
67 lines
2.6 KiB
Java
import static com.android.aconfig.test.Flags.FLAG_DISABLED_RO;
|
|
import static com.android.aconfig.test.Flags.FLAG_DISABLED_RW;
|
|
import static com.android.aconfig.test.Flags.FLAG_ENABLED_FIXED_RO;
|
|
import static com.android.aconfig.test.Flags.FLAG_ENABLED_RO;
|
|
import static com.android.aconfig.test.Flags.FLAG_ENABLED_RW;
|
|
import static com.android.aconfig.test.Flags.disabledRo;
|
|
import static com.android.aconfig.test.Flags.disabledRw;
|
|
import static com.android.aconfig.test.Flags.enabledFixedRo;
|
|
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
|
|
public void testDisabledReadOnlyFlag() {
|
|
assertEquals("com.android.aconfig.test.disabled_ro", FLAG_DISABLED_RO);
|
|
assertFalse(disabledRo());
|
|
}
|
|
|
|
@Test
|
|
public void testEnabledReadOnlyFlag() {
|
|
assertEquals("com.android.aconfig.test.disabled_rw", FLAG_DISABLED_RW);
|
|
// TODO: change to assertTrue(enabledRo()) when the build supports reading tests/*.values
|
|
// (currently all flags are assigned the default READ_ONLY + DISABLED)
|
|
assertFalse(enabledRo());
|
|
}
|
|
|
|
@Test
|
|
public void testEnabledFixedReadOnlyFlag() {
|
|
assertEquals("com.android.aconfig.test.enabled_fixed_ro", FLAG_ENABLED_FIXED_RO);
|
|
// TODO: change to assertTrue(enabledFixedRo()) when the build supports reading tests/*.values
|
|
// (currently all flags are assigned the default READ_ONLY + DISABLED)
|
|
assertFalse(enabledFixedRo());
|
|
}
|
|
|
|
@Test
|
|
public void testDisabledReadWriteFlag() {
|
|
assertEquals("com.android.aconfig.test.enabled_ro", FLAG_ENABLED_RO);
|
|
assertFalse(disabledRw());
|
|
}
|
|
|
|
@Test
|
|
public void testEnabledReadWriteFlag() {
|
|
assertEquals("com.android.aconfig.test.enabled_rw", FLAG_ENABLED_RW);
|
|
// TODO: change to assertTrue(enabledRw()) when the build supports reading tests/*.values
|
|
// (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());
|
|
}
|
|
}
|