Merge "[CM] Fix comments, add tests to TransportInfo API" am: 4060bc1480 am: e603fe8bc0
am: d548b6e050
Change-Id: I0a81b7b48bb02da202dd7feaa1440801b794ce67
diff --git a/core/java/android/net/NetworkCapabilities.java b/core/java/android/net/NetworkCapabilities.java
index 0c44a56..8a5f43d 100644
--- a/core/java/android/net/NetworkCapabilities.java
+++ b/core/java/android/net/NetworkCapabilities.java
@@ -931,7 +931,7 @@
* Returns a transport-specific information container. The application may cast this
* container to a concrete sub-class based on its knowledge of the network request. The
* application should be able to deal with a {@code null} return value or an invalid case,
- * e.g. use {@code instanceof} operation to verify expected type.
+ * e.g. use {@code instanceof} operator to verify expected type.
*
* @return A concrete implementation of the {@link TransportInfo} class or null if not
* available for the network.
diff --git a/tests/net/java/android/net/NetworkCapabilitiesTest.java b/tests/net/java/android/net/NetworkCapabilitiesTest.java
index 50aef1d..84f7359 100644
--- a/tests/net/java/android/net/NetworkCapabilitiesTest.java
+++ b/tests/net/java/android/net/NetworkCapabilitiesTest.java
@@ -474,7 +474,7 @@
new StringNetworkSpecifier("specs"));
try {
nc2.addTransportType(TRANSPORT_WIFI);
- fail("Cannot set NetworkSpecifier on a NetworkCapability with multiple transports!");
+ fail("Cannot set a second TransportType of a network which has a NetworkSpecifier!");
} catch (IllegalStateException expected) {
// empty
}
@@ -500,16 +500,23 @@
// empty
});
NetworkCapabilities nc2 = new NetworkCapabilities();
+ // new TransportInfo so that object is not #equals to nc1's TransportInfo (that's where
+ // combine fails)
nc2.setTransportInfo(new TransportInfo() {
// empty
});
try {
nc1.combineCapabilities(nc2);
- fail("Should not be able to combine NetworkCaabilities which contain TransportInfos");
+ fail("Should not be able to combine NetworkCabilities which contain TransportInfos");
} catch (IllegalStateException expected) {
// empty
}
+
+ // verify that can combine with identical TransportInfo objects
+ NetworkCapabilities nc3 = new NetworkCapabilities();
+ nc3.setTransportInfo(nc1.getTransportInfo());
+ nc1.combineCapabilities(nc3);
}
private void assertEqualsThroughMarshalling(NetworkCapabilities netCap) {