[resolved conflict] Add test case to test normalize am: f444e9d182
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/16214695
Bug: 206073065
Change-Id: I2bbac80ae1b2f64166d6598f72e156b23c0f019e
Merged-In: I80c9f887cf8b4714716d657da92ed273a532ce27
Merged-In: I2f5790b9217357ddcf3f466cec1b2b1afbb47210
Test: Test: I solemnly swear I tested this conflict resolution.
diff --git a/tests/unit/java/android/net/NetworkTemplateTest.kt b/tests/unit/java/android/net/NetworkTemplateTest.kt
index 2db77f2..572c1ef 100644
--- a/tests/unit/java/android/net/NetworkTemplateTest.kt
+++ b/tests/unit/java/android/net/NetworkTemplateTest.kt
@@ -46,6 +46,7 @@
import android.net.NetworkTemplate.buildTemplateMobileWithRatType
import android.net.NetworkTemplate.buildTemplateWifi
import android.net.NetworkTemplate.buildTemplateWifiWildcard
+import android.net.NetworkTemplate.normalize
import android.os.Build
import android.telephony.TelephonyManager
import com.android.testutils.DevSdkIgnoreRule
@@ -63,6 +64,7 @@
private const val TEST_IMSI1 = "imsi1"
private const val TEST_IMSI2 = "imsi2"
+private const val TEST_IMSI3 = "imsi3"
private const val TEST_SSID1 = "ssid1"
private const val TEST_SSID2 = "ssid2"
@@ -493,4 +495,45 @@
identSsid = TEST_SSID1)
matchOemManagedIdent(TYPE_WIFI, MATCH_WIFI_WILDCARD, identSsid = TEST_SSID1)
}
+
+ @Test
+ fun testNormalize() {
+ var mergedImsiList = listOf(arrayOf(TEST_IMSI1, TEST_IMSI2))
+ val identMobileImsi1 = buildNetworkIdentity(mockContext,
+ buildMobileNetworkState(TEST_IMSI1), false /* defaultNetwork */,
+ TelephonyManager.NETWORK_TYPE_UMTS)
+ val identMobileImsi2 = buildNetworkIdentity(mockContext,
+ buildMobileNetworkState(TEST_IMSI2), false /* defaultNetwork */,
+ TelephonyManager.NETWORK_TYPE_UMTS)
+ val identMobileImsi3 = buildNetworkIdentity(mockContext,
+ buildMobileNetworkState(TEST_IMSI3), false /* defaultNetwork */,
+ TelephonyManager.NETWORK_TYPE_UMTS)
+ val identWifiImsi1Ssid1 = buildNetworkIdentity(
+ mockContext, buildWifiNetworkState(TEST_IMSI1, TEST_SSID1), true, 0)
+ val identWifiImsi2Ssid1 = buildNetworkIdentity(
+ mockContext, buildWifiNetworkState(TEST_IMSI2, TEST_SSID1), true, 0)
+ val identWifiImsi3Ssid1 = buildNetworkIdentity(
+ mockContext, buildWifiNetworkState(TEST_IMSI3, TEST_SSID1), true, 0)
+
+ normalize(buildTemplateMobileAll(TEST_IMSI1), mergedImsiList).also {
+ it.assertMatches(identMobileImsi1)
+ it.assertMatches(identMobileImsi2)
+ it.assertDoesNotMatch(identMobileImsi3)
+ }
+ normalize(buildTemplateCarrierMetered(TEST_IMSI1), mergedImsiList).also {
+ it.assertMatches(identMobileImsi1)
+ it.assertMatches(identMobileImsi2)
+ it.assertDoesNotMatch(identMobileImsi3)
+ }
+ normalize(buildTemplateWifi(TEST_SSID1, TEST_IMSI1), mergedImsiList).also {
+ it.assertMatches(identWifiImsi1Ssid1)
+ it.assertMatches(identWifiImsi2Ssid1)
+ it.assertDoesNotMatch(identWifiImsi3Ssid1)
+ }
+ normalize(buildTemplateMobileWildcard(), mergedImsiList).also {
+ it.assertMatches(identMobileImsi1)
+ it.assertMatches(identMobileImsi2)
+ it.assertMatches(identMobileImsi3)
+ }
+ }
}