Merge "Verifying equality of LinkProperties with callbacks"
This commit is contained in:
commit
b99524e467
1 changed files with 17 additions and 1 deletions
|
|
@ -559,6 +559,11 @@ public class ConnectivityManagerTest {
|
|||
// got from other APIs.
|
||||
final Network[] networks = mCm.getAllNetworks();
|
||||
assertGreaterOrEqual(networks.length, 1);
|
||||
final TestableNetworkCallback allNetworkLinkPropertiesListener =
|
||||
new TestableNetworkCallback();
|
||||
mCm.registerNetworkCallback(new NetworkRequest.Builder().clearCapabilities().build(),
|
||||
allNetworkLinkPropertiesListener);
|
||||
|
||||
final List<NetworkStateSnapshot> snapshots = runWithShellPermissionIdentity(
|
||||
() -> mCm.getAllNetworkStateSnapshots(), NETWORK_SETTINGS);
|
||||
assertEquals(networks.length, snapshots.size());
|
||||
|
|
@ -584,7 +589,18 @@ public class ConnectivityManagerTest {
|
|||
assertEquals("", caps.describeImmutableDifferences(
|
||||
snapshot.getNetworkCapabilities()
|
||||
.setNetworkSpecifier(redactedSnapshotCapSpecifier)));
|
||||
assertEquals(mCm.getLinkProperties(network), snapshot.getLinkProperties());
|
||||
|
||||
// Don't check that the mutable fields are the same with synchronous calls, as
|
||||
// the device may add or remove content of these fields in the middle of the test.
|
||||
// Instead, search the target LinkProperties from received LinkPropertiesChanged
|
||||
// callbacks. This is guaranteed to succeed because the callback is registered
|
||||
// before getAllNetworkStateSnapshots is called.
|
||||
final LinkProperties lpFromSnapshot = snapshot.getLinkProperties();
|
||||
allNetworkLinkPropertiesListener.eventuallyExpect(CallbackEntry.LINK_PROPERTIES_CHANGED,
|
||||
NETWORK_CALLBACK_TIMEOUT_MS, 0 /* mark */, entry ->
|
||||
entry.getNetwork().equals(network)
|
||||
&& entry.getLp().equals(lpFromSnapshot));
|
||||
|
||||
assertEquals(mCm.getNetworkInfo(network).getType(), snapshot.getLegacyType());
|
||||
|
||||
if (network.equals(cellNetwork)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue