aconfig: Respect flag naming convention on test flags
Test: atest aconfig.test Bug: 311152507 Change-Id: I960867d32415007db5dacab57e97b813cbbee650
This commit is contained in:
committed by
Oriol Prieto Gascó
parent
7c607a0e32
commit
bbeda85949
@@ -193,6 +193,9 @@ mod tests {
|
||||
@com.android.aconfig.annotations.AssumeTrueForR8
|
||||
@UnsupportedAppUsage
|
||||
boolean enabledRo();
|
||||
@com.android.aconfig.annotations.AssumeTrueForR8
|
||||
@UnsupportedAppUsage
|
||||
boolean enabledRoExported();
|
||||
@UnsupportedAppUsage
|
||||
boolean enabledRw();
|
||||
}
|
||||
@@ -217,6 +220,8 @@ mod tests {
|
||||
/** @hide */
|
||||
public static final String FLAG_ENABLED_RO = "com.android.aconfig.test.enabled_ro";
|
||||
/** @hide */
|
||||
public static final String FLAG_ENABLED_RO_EXPORTED = "com.android.aconfig.test.enabled_ro_exported";
|
||||
/** @hide */
|
||||
public static final String FLAG_ENABLED_RW = "com.android.aconfig.test.enabled_rw";
|
||||
|
||||
@com.android.aconfig.annotations.AssumeFalseForR8
|
||||
@@ -246,6 +251,11 @@ mod tests {
|
||||
public static boolean enabledRo() {
|
||||
return FEATURE_FLAGS.enabledRo();
|
||||
}
|
||||
@com.android.aconfig.annotations.AssumeTrueForR8
|
||||
@UnsupportedAppUsage
|
||||
public static boolean enabledRoExported() {
|
||||
return FEATURE_FLAGS.enabledRoExported();
|
||||
}
|
||||
@UnsupportedAppUsage
|
||||
public static boolean enabledRw() {
|
||||
return FEATURE_FLAGS.enabledRw();
|
||||
@@ -295,6 +305,11 @@ mod tests {
|
||||
}
|
||||
@Override
|
||||
@UnsupportedAppUsage
|
||||
public boolean enabledRoExported() {
|
||||
return getValue(Flags.FLAG_ENABLED_RO_EXPORTED);
|
||||
}
|
||||
@Override
|
||||
@UnsupportedAppUsage
|
||||
public boolean enabledRw() {
|
||||
return getValue(Flags.FLAG_ENABLED_RW);
|
||||
}
|
||||
@@ -324,6 +339,7 @@ mod tests {
|
||||
Map.entry(Flags.FLAG_DISABLED_RW_IN_OTHER_NAMESPACE, false),
|
||||
Map.entry(Flags.FLAG_ENABLED_FIXED_RO, false),
|
||||
Map.entry(Flags.FLAG_ENABLED_RO, false),
|
||||
Map.entry(Flags.FLAG_ENABLED_RO_EXPORTED, false),
|
||||
Map.entry(Flags.FLAG_ENABLED_RW, false)
|
||||
)
|
||||
);
|
||||
@@ -442,6 +458,11 @@ mod tests {
|
||||
}
|
||||
@Override
|
||||
@UnsupportedAppUsage
|
||||
public boolean enabledRoExported() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
@UnsupportedAppUsage
|
||||
public boolean enabledRw() {
|
||||
if (!aconfig_test_is_cached) {
|
||||
load_overrides_aconfig_test();
|
||||
@@ -494,19 +515,19 @@ mod tests {
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
/** @hide */
|
||||
public final class Flags {
|
||||
/** @hide */
|
||||
public static final String FLAG_DISABLED_RW = "com.android.aconfig.test.disabled_rw";
|
||||
/** @hide */
|
||||
public static final String FLAG_DISABLED_RW_EXPORTED = "com.android.aconfig.test.disabled_rw_exported";
|
||||
/** @hide */
|
||||
public static final String FLAG_ENABLED_RO_EXPORTED = "com.android.aconfig.test.enabled_ro_exported";
|
||||
|
||||
@UnsupportedAppUsage
|
||||
public static boolean disabledRw() {
|
||||
return FEATURE_FLAGS.disabledRw();
|
||||
}
|
||||
@UnsupportedAppUsage
|
||||
public static boolean disabledRwExported() {
|
||||
return FEATURE_FLAGS.disabledRwExported();
|
||||
}
|
||||
@UnsupportedAppUsage
|
||||
public static boolean enabledRoExported() {
|
||||
return FEATURE_FLAGS.enabledRoExported();
|
||||
}
|
||||
private static FeatureFlags FEATURE_FLAGS = new FeatureFlagsImpl();
|
||||
}
|
||||
"#;
|
||||
@@ -517,10 +538,10 @@ mod tests {
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
/** @hide */
|
||||
public interface FeatureFlags {
|
||||
@UnsupportedAppUsage
|
||||
boolean disabledRw();
|
||||
@UnsupportedAppUsage
|
||||
boolean disabledRwExported();
|
||||
@UnsupportedAppUsage
|
||||
boolean enabledRoExported();
|
||||
}
|
||||
"#;
|
||||
|
||||
@@ -534,17 +555,17 @@ mod tests {
|
||||
public final class FeatureFlagsImpl implements FeatureFlags {
|
||||
private static boolean aconfig_test_is_cached = false;
|
||||
private static boolean other_namespace_is_cached = false;
|
||||
private static boolean disabledRw = false;
|
||||
private static boolean disabledRwExported = false;
|
||||
private static boolean enabledRoExported = false;
|
||||
|
||||
|
||||
private void load_overrides_aconfig_test() {
|
||||
try {
|
||||
Properties properties = DeviceConfig.getProperties("aconfig_test");
|
||||
disabledRw =
|
||||
properties.getBoolean("com.android.aconfig.test.disabled_rw", false);
|
||||
disabledRwExported =
|
||||
properties.getBoolean("com.android.aconfig.test.disabled_rw_exported", false);
|
||||
enabledRoExported =
|
||||
properties.getBoolean("com.android.aconfig.test.enabled_ro_exported", false);
|
||||
} catch (NullPointerException e) {
|
||||
throw new RuntimeException(
|
||||
"Cannot read value from namespace aconfig_test "
|
||||
@@ -574,15 +595,6 @@ mod tests {
|
||||
other_namespace_is_cached = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@UnsupportedAppUsage
|
||||
public boolean disabledRw() {
|
||||
if (!aconfig_test_is_cached) {
|
||||
load_overrides_aconfig_test();
|
||||
}
|
||||
return disabledRw;
|
||||
}
|
||||
|
||||
@Override
|
||||
@UnsupportedAppUsage
|
||||
public boolean disabledRwExported() {
|
||||
@@ -591,6 +603,15 @@ mod tests {
|
||||
}
|
||||
return disabledRwExported;
|
||||
}
|
||||
|
||||
@Override
|
||||
@UnsupportedAppUsage
|
||||
public boolean enabledRoExported() {
|
||||
if (!aconfig_test_is_cached) {
|
||||
load_overrides_aconfig_test();
|
||||
}
|
||||
return enabledRoExported;
|
||||
}
|
||||
}"#;
|
||||
|
||||
let expect_fake_feature_flags_impl_content = r#"
|
||||
@@ -606,13 +627,13 @@ mod tests {
|
||||
}
|
||||
@Override
|
||||
@UnsupportedAppUsage
|
||||
public boolean disabledRw() {
|
||||
return getValue(Flags.FLAG_DISABLED_RW);
|
||||
public boolean disabledRwExported() {
|
||||
return getValue(Flags.FLAG_DISABLED_RW_EXPORTED);
|
||||
}
|
||||
@Override
|
||||
@UnsupportedAppUsage
|
||||
public boolean disabledRwExported() {
|
||||
return getValue(Flags.FLAG_DISABLED_RW_EXPORTED);
|
||||
public boolean enabledRoExported() {
|
||||
return getValue(Flags.FLAG_ENABLED_RO_EXPORTED);
|
||||
}
|
||||
public void setFlag(String flagName, boolean value) {
|
||||
if (!this.mFlagMap.containsKey(flagName)) {
|
||||
@@ -640,6 +661,7 @@ mod tests {
|
||||
Map.entry(Flags.FLAG_DISABLED_RW_IN_OTHER_NAMESPACE, false),
|
||||
Map.entry(Flags.FLAG_ENABLED_FIXED_RO, false),
|
||||
Map.entry(Flags.FLAG_ENABLED_RO, false),
|
||||
Map.entry(Flags.FLAG_ENABLED_RO_EXPORTED, false),
|
||||
Map.entry(Flags.FLAG_ENABLED_RW, false)
|
||||
)
|
||||
);
|
||||
@@ -739,6 +761,12 @@ mod tests {
|
||||
}
|
||||
@Override
|
||||
@UnsupportedAppUsage
|
||||
public boolean enabledRoExported() {
|
||||
throw new UnsupportedOperationException(
|
||||
"Method is not implemented.");
|
||||
}
|
||||
@Override
|
||||
@UnsupportedAppUsage
|
||||
public boolean enabledRw() {
|
||||
throw new UnsupportedOperationException(
|
||||
"Method is not implemented.");
|
||||
|
Reference in New Issue
Block a user