Merge "NetworkCapabilities: fix describeImmutableDifferences" into oc-dr1-dev
am: 1b3877a965 Change-Id: I50748aa0c9332787797f91265afccf82ceabf332
This commit is contained in:
@@ -21,10 +21,14 @@ import static android.net.NetworkCapabilities.NET_CAPABILITY_EIMS;
|
||||
import static android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET;
|
||||
import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_METERED;
|
||||
import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED;
|
||||
import static android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED;
|
||||
import static android.net.NetworkCapabilities.RESTRICTED_CAPABILITIES;
|
||||
import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR;
|
||||
import static android.net.NetworkCapabilities.TRANSPORT_WIFI;
|
||||
import static android.net.NetworkCapabilities.UNRESTRICTED_CAPABILITIES;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
||||
@@ -114,4 +118,45 @@ public class NetworkCapabilitiesTest {
|
||||
assertFalse(netCap.hasCapability(NET_CAPABILITY_NOT_RESTRICTED));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDescribeImmutableDifferences() {
|
||||
NetworkCapabilities nc1;
|
||||
NetworkCapabilities nc2;
|
||||
|
||||
// Transports changing
|
||||
nc1 = new NetworkCapabilities().addTransportType(TRANSPORT_CELLULAR);
|
||||
nc2 = new NetworkCapabilities().addTransportType(TRANSPORT_WIFI);
|
||||
assertNotEquals("", nc1.describeImmutableDifferences(nc2));
|
||||
assertEquals("", nc1.describeImmutableDifferences(nc1));
|
||||
|
||||
// Mutable capability changing
|
||||
nc1 = new NetworkCapabilities().addCapability(NET_CAPABILITY_VALIDATED);
|
||||
nc2 = new NetworkCapabilities();
|
||||
assertEquals("", nc1.describeImmutableDifferences(nc2));
|
||||
assertEquals("", nc1.describeImmutableDifferences(nc1));
|
||||
|
||||
// NOT_METERED changing (http://b/63326103)
|
||||
nc1 = new NetworkCapabilities()
|
||||
.addCapability(NET_CAPABILITY_NOT_METERED)
|
||||
.addCapability(NET_CAPABILITY_INTERNET);
|
||||
nc2 = new NetworkCapabilities().addCapability(NET_CAPABILITY_INTERNET);
|
||||
assertEquals("", nc1.describeImmutableDifferences(nc2));
|
||||
assertEquals("", nc1.describeImmutableDifferences(nc1));
|
||||
|
||||
// Immutable capability changing
|
||||
nc1 = new NetworkCapabilities()
|
||||
.addCapability(NET_CAPABILITY_INTERNET)
|
||||
.removeCapability(NET_CAPABILITY_NOT_RESTRICTED);
|
||||
nc2 = new NetworkCapabilities().addCapability(NET_CAPABILITY_INTERNET);
|
||||
assertNotEquals("", nc1.describeImmutableDifferences(nc2));
|
||||
assertEquals("", nc1.describeImmutableDifferences(nc1));
|
||||
|
||||
// Specifier changing
|
||||
nc1 = new NetworkCapabilities().addTransportType(TRANSPORT_WIFI);
|
||||
nc2 = new NetworkCapabilities()
|
||||
.addTransportType(TRANSPORT_WIFI)
|
||||
.setNetworkSpecifier(new StringNetworkSpecifier("specs"));
|
||||
assertNotEquals("", nc1.describeImmutableDifferences(nc2));
|
||||
assertEquals("", nc1.describeImmutableDifferences(nc1));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user