aconfig: Add resetAll method to test mode FeatureFlagsImpl

Add resetAll method to test mode FeatureFlagsImpl. This method
is used to reset all the flags values to null. It provides convenient
way to the test tools to reset the flags values.

Bug: 280833463
Test: atest aconfig.test
Change-Id: I4bf1d3ba69ee106ef8d0c1cc62c00bbeca1b72aa
This commit is contained in:
Zhi Dou
2023-06-29 15:15:32 +00:00
parent a41cc5ecf9
commit 8d27cc39b1
2 changed files with 13 additions and 0 deletions

View File

@@ -234,6 +234,7 @@ mod tests {
package com.android.aconfig.test;
import static java.util.stream.Collectors.toMap;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Stream;
public final class FeatureFlagsImpl implements FeatureFlags {
@Override
@@ -258,6 +259,11 @@ mod tests {
}
this.mFlagMap.put(flagName, value);
}
public void resetAll() {
for (Map.Entry entry : mFlagMap.entrySet()) {
entry.setValue(null);
}
}
private boolean getFlag(String flagName) {
Boolean value = this.mFlagMap.get(flagName);
if (value == null) {

View File

@@ -3,6 +3,7 @@ package {package_name};
import static java.util.stream.Collectors.toMap;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Stream;
{{ else}}
{{ if is_read_write- }}
@@ -36,6 +37,12 @@ public final class FeatureFlagsImpl implements FeatureFlags \{
this.mFlagMap.put(flagName, value);
}
public void resetAll() \{
for (Map.Entry entry : mFlagMap.entrySet()) \{
entry.setValue(null);
}
}
private boolean getFlag(String flagName) \{
Boolean value = this.mFlagMap.get(flagName);
if (value == null) \{