Add CTS test for Network.fromNetworkHandle()
Bug: 77210159 Bug: 64148938 Test: make CtsNetTestCases Change-Id: I38d34cb4af681f1b1030d7f8d0404af210e43912
This commit is contained in:
@@ -152,4 +152,27 @@ public class MultinetworkApiTest extends AndroidTestCase {
|
||||
// to query on the default network.
|
||||
// assertEquals(-OsConstants.ENONET, runGetaddrinfoCheck(eNoNetHandle));
|
||||
}
|
||||
|
||||
public void testNetworkHandle() {
|
||||
// Test Network -> NetworkHandle -> Network results in the same Network.
|
||||
for (Network network : getTestableNetworks()) {
|
||||
long networkHandle = network.getNetworkHandle();
|
||||
Network newNetwork = Network.fromNetworkHandle(networkHandle);
|
||||
assertEquals(newNetwork, network);
|
||||
}
|
||||
|
||||
// Test that only obfuscated handles are allowed.
|
||||
try {
|
||||
Network.fromNetworkHandle(100);
|
||||
fail();
|
||||
} catch (IllegalArgumentException e) {}
|
||||
try {
|
||||
Network.fromNetworkHandle(-1);
|
||||
fail();
|
||||
} catch (IllegalArgumentException e) {}
|
||||
try {
|
||||
Network.fromNetworkHandle(0);
|
||||
fail();
|
||||
} catch (IllegalArgumentException e) {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user