summaryrefslogtreecommitdiff
path: root/tests/common/java/android/net/NetworkCapabilitiesTest.java
diff options
context:
space:
mode:
authorRemi NGUYEN VAN <reminv@google.com>2021-11-11 10:00:14 +0900
committerRemi NGUYEN VAN <reminv@google.com>2021-11-11 12:30:07 +0900
commitdaa03defee545fdbcbdd48bcfb3f56597e120147 (patch)
tree1ec5478734e1d3716374cb93e7ea80f6613ee820 /tests/common/java/android/net/NetworkCapabilitiesTest.java
parent7269fb17fd9009190d52299c311dc67f6e6c2fcd (diff)
Fix NetworkCapabilitiesTest on S
Mark NetworkCapabilitiesTest as ConnectivityModuleTest so that it is only run in MTS with the Connectivity module installed, and fix parceling tests to use the right number of fields in that case. NetworkCapabilitiesTest is only useful to test the Connectivity module, and not other modules like NetworkStack, as it is a unit test of a class in the Connectivity module. Bug: 205901761 Test: atest NetworkCapabilitiesTest Change-Id: I10ba0f866bc7a39b2c90bdde12a79feefea2d5ee
Diffstat (limited to 'tests/common/java/android/net/NetworkCapabilitiesTest.java')
-rw-r--r--tests/common/java/android/net/NetworkCapabilitiesTest.java21
1 files changed, 14 insertions, 7 deletions
diff --git a/tests/common/java/android/net/NetworkCapabilitiesTest.java b/tests/common/java/android/net/NetworkCapabilitiesTest.java
index a619d6b2d2..27a3cc259b 100644
--- a/tests/common/java/android/net/NetworkCapabilitiesTest.java
+++ b/tests/common/java/android/net/NetworkCapabilitiesTest.java
@@ -92,6 +92,7 @@ import java.util.Set;
@RunWith(AndroidJUnit4.class)
@SmallTest
+@ConnectivityModuleTest
public class NetworkCapabilitiesTest {
private static final String TEST_SSID = "TEST_SSID";
private static final String DIFFERENT_TEST_SSID = "DIFFERENT_TEST_SSID";
@@ -345,10 +346,16 @@ public class NetworkCapabilitiesTest {
}
private void testParcelSane(NetworkCapabilities cap) {
- if (isAtLeastT()) {
+ // This test can be run as unit test against the latest system image, as CTS to verify
+ // an Android release that is as recent as the test, or as MTS to verify the
+ // Connectivity module. In the first two cases NetworkCapabilities will be as recent
+ // as the test. In the last case, starting from S NetworkCapabilities is updated as part
+ // of Connectivity, so it is also as recent as the test. For MTS on Q and R,
+ // NetworkCapabilities is not updatable, so it may have a different number of fields.
+ if (isAtLeastS()) {
+ // When this test is run on S+, NetworkCapabilities is as recent as the test,
+ // so this should be the most recent known number of fields.
assertParcelSane(cap, 17);
- } else if (isAtLeastS()) {
- assertParcelSane(cap, 16);
} else if (isAtLeastR()) {
assertParcelSane(cap, 15);
} else {
@@ -1226,12 +1233,12 @@ public class NetworkCapabilitiesTest {
assertEquals(0, nc.getCapabilities().length);
}
- @Test @IgnoreUpTo(Build.VERSION_CODES.R) @ConnectivityModuleTest
+ @Test @IgnoreUpTo(Build.VERSION_CODES.R)
public void testRestrictCapabilitiesForTestNetworkByNotOwnerWithNonRestrictedNc() {
testRestrictCapabilitiesForTestNetworkWithNonRestrictedNc(false /* isOwner */);
}
- @Test @IgnoreUpTo(Build.VERSION_CODES.R) @ConnectivityModuleTest
+ @Test @IgnoreUpTo(Build.VERSION_CODES.R)
public void testRestrictCapabilitiesForTestNetworkByOwnerWithNonRestrictedNc() {
testRestrictCapabilitiesForTestNetworkWithNonRestrictedNc(true /* isOwner */);
}
@@ -1276,12 +1283,12 @@ public class NetworkCapabilitiesTest {
assertEquals(expectedNcBuilder.build(), nonRestrictedNc);
}
- @Test @IgnoreUpTo(Build.VERSION_CODES.R) @ConnectivityModuleTest
+ @Test @IgnoreUpTo(Build.VERSION_CODES.R)
public void testRestrictCapabilitiesForTestNetworkByNotOwnerWithRestrictedNc() {
testRestrictCapabilitiesForTestNetworkWithRestrictedNc(false /* isOwner */);
}
- @Test @IgnoreUpTo(Build.VERSION_CODES.R) @ConnectivityModuleTest
+ @Test @IgnoreUpTo(Build.VERSION_CODES.R)
public void testRestrictCapabilitiesForTestNetworkByOwnerWithRestrictedNc() {
testRestrictCapabilitiesForTestNetworkWithRestrictedNc(true /* isOwner */);
}