Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8d27cc39 authored by Zhi Dou's avatar Zhi Dou
Browse files

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
parent a41cc5ec
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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) {
+7 −0
Original line number Diff line number Diff line
@@ -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) \{