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

Commit 3ae93956 authored by Ken Chen's avatar Ken Chen Committed by Automerger Merge Worker
Browse files

Merge "Add testVpnTypesEqual to verify consistency" am: 785dc487

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1705385

Change-Id: I18b5716252efc4f7c33ec8263c09df1f9396d1fe
parents d0ab30ad 785dc487
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -58,7 +58,6 @@ import java.util.List;
 * @see Ikev2VpnProfile
 */
public class VpnManager {
    // TODO: add a unit test to ensure that TYPE_VPN_xxx matches android.net.NativeVpnType.
    /** Type representing a lack of VPN @hide */
    @SystemApi(client = MODULE_LIBRARIES)
    public static final int TYPE_VPN_NONE = -1;
+16 −0
Original line number Diff line number Diff line
@@ -28,11 +28,13 @@ import static org.mockito.Mockito.when;
import android.content.ComponentName;
import android.content.Intent;
import android.test.mock.MockContext;
import android.util.SparseArray;

import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;

import com.android.internal.net.VpnProfile;
import com.android.internal.util.MessageUtils;

import org.junit.Before;
import org.junit.Test;
@@ -119,4 +121,18 @@ public class VpnManagerTest {
                .setAuthPsk(PSK_BYTES)
                .build();
    }

    @Test
    public void testVpnTypesEqual() throws Exception {
        SparseArray<String> vmVpnTypes = MessageUtils.findMessageNames(
                new Class[] { VpnManager.class }, new String[]{ "TYPE_VPN_" });
        SparseArray<String> nativeVpnType = MessageUtils.findMessageNames(
                new Class[] { NativeVpnType.class }, new String[]{ "" });

        // TYPE_VPN_NONE = -1 is only defined in VpnManager.
        assertEquals(vmVpnTypes.size() - 1, nativeVpnType.size());
        for (int i = VpnManager.TYPE_VPN_SERVICE; i < vmVpnTypes.size(); i++) {
            assertEquals(vmVpnTypes.get(i), "TYPE_VPN_" + nativeVpnType.get(i));
        }
    }
}