Merge "Add testVpnTypesEqual to verify consistency" am: edeab9051e am: f16388a8f5
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1705385 Change-Id: Id2e9d16c88088ef5d3ffe6f698af5ee8201c7716
This commit is contained in:
@@ -28,11 +28,13 @@ import static org.mockito.Mockito.when;
|
|||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.test.mock.MockContext;
|
import android.test.mock.MockContext;
|
||||||
|
import android.util.SparseArray;
|
||||||
|
|
||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
import androidx.test.runner.AndroidJUnit4;
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
import com.android.internal.net.VpnProfile;
|
import com.android.internal.net.VpnProfile;
|
||||||
|
import com.android.internal.util.MessageUtils;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -119,4 +121,18 @@ public class VpnManagerTest {
|
|||||||
.setAuthPsk(PSK_BYTES)
|
.setAuthPsk(PSK_BYTES)
|
||||||
.build();
|
.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));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user