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

Commit 69488549 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add clear_overrides unit test" into main

parents 20fedf9d 2b139134
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -534,9 +534,8 @@ public class SettingsToPropertiesMapper {
     * @param packageName the package of the flag
     * @param flagName the name of the flag
     * @param immediate if true, clear immediately; otherwise, clear on next reboot
     *
     * @hide
     */
    @VisibleForTesting
    public static void writeFlagOverrideRemovalRequest(
        ProtoOutputStream proto, String packageName, String flagName, boolean immediate) {
      long msgsToken = proto.start(StorageRequestMessages.MSGS);
@@ -592,7 +591,8 @@ public class SettingsToPropertiesMapper {
     * apply flag local override in aconfig new storage
     * @param props
     */
    static void setLocalOverridesInNewStorage(DeviceConfig.Properties props) {
    @VisibleForTesting
    public static void setLocalOverridesInNewStorage(DeviceConfig.Properties props) {
        int num_requests = 0;
        ProtoOutputStream requests = new ProtoOutputStream();
        for (String flagName : props.getKeyset()) {
+19 −0
Original line number Diff line number Diff line
@@ -21,10 +21,14 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.anyString;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doAnswer;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;

import static org.mockito.Mockito.verify;

import android.content.ContentResolver;
import android.os.SystemProperties;
import android.provider.DeviceConfig;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.proto.ProtoOutputStream;

import com.android.dx.mockito.inline.extended.ExtendedMockito;

@@ -34,6 +38,7 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoSession;
import org.mockito.quality.Strictness;
import org.mockito.stubbing.Answer;
@@ -110,6 +115,20 @@ public class SettingsToPropertiesMapperTest {
        mSession.finishMocking();
    }

    @Test
    public void testClearAconfigStorageOverride() {
        SettingsToPropertiesMapper spyMapper = Mockito.spy(new SettingsToPropertiesMapper(
                mMockContentResolver, TEST_MAPPING, new String[] {}, new String[] {}));
        HashMap flags = new HashMap();
        flags.put("test_package.test_flag", null);
        DeviceConfig.Properties props = new DeviceConfig.Properties("test_namespace", flags);

        spyMapper.setLocalOverridesInNewStorage(props);

        verify(spyMapper).writeFlagOverrideRemovalRequest(new ProtoOutputStream(),
                "test_package", "test_flag", true);
    }

    @Test
    public void validateRegisteredGlobalSettings() {
        HashSet<String> hashSet = new HashSet<>();