summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Mattis <jmattis@google.com>2022-03-08 18:05:14 -0800
committerJames Mattis <jmattis@google.com>2022-03-15 13:29:16 -0700
commitd67ab967851137398c48cbaef827a56bf88216f5 (patch)
tree77ef582e9f3fcad3ad702c266182572e4c2e6e32
parent145b155f14a1379c9f290ad7b2f91d5daccb1cab (diff)
downloadethernet-d67ab967851137398c48cbaef827a56bf88216f5.tar.gz
Cleaning EthernetNetworkFactoryTest Unprovisioned
Clearing up the EthernetNetworkFactoryTest unprovisioned helped method a bit to accomplish the same thing with fewer lines of code and not rely on the ref count to stop an interface. Bug: 197548738 Test: atest EthernetServiceTests Change-Id: I0fb80b569b6f59ee82fbd528ffad044278ab80c8
-rw-r--r--tests/java/com/android/server/ethernet/EthernetNetworkFactoryTest.java16
1 files changed, 5 insertions, 11 deletions
diff --git a/tests/java/com/android/server/ethernet/EthernetNetworkFactoryTest.java b/tests/java/com/android/server/ethernet/EthernetNetworkFactoryTest.java
index 61425bf..28fcf3e 100644
--- a/tests/java/com/android/server/ethernet/EthernetNetworkFactoryTest.java
+++ b/tests/java/com/android/server/ethernet/EthernetNetworkFactoryTest.java
@@ -280,19 +280,13 @@ public class EthernetNetworkFactoryTest {
// creates an unprovisioned interface
private void createUnprovisionedInterface(String iface) throws Exception {
- // the only way to create an unprovisioned interface is by calling needNetworkFor
- // followed by releaseNetworkFor which will stop the NetworkAgent and IpClient. When
- // EthernetNetworkFactory#updateInterfaceLinkState(iface, true) is called, the interface
- // is automatically provisioned even if nobody has ever called needNetworkFor
+ // To create an unprovisioned interface, provision and then "stop" it, i.e. stop its
+ // NetworkAgent and IpClient. One way this can be done is by provisioning an interface and
+ // then calling onNetworkUnwanted.
createAndVerifyProvisionedInterface(iface);
- // Interface is already provisioned, so startProvisioning / register should not be called
- // again
- mNetFactory.needNetworkFor(createDefaultRequest());
- verify(mIpClient, never()).startProvisioning(any());
- verify(mNetworkAgent, never()).register();
-
- mNetFactory.releaseNetworkFor(createDefaultRequest());
+ mNetworkAgent.getCallbacks().onNetworkUnwanted();
+ mLooper.dispatchAll();
verifyStop();
clearInvocations(mIpClient);