From d67ab967851137398c48cbaef827a56bf88216f5 Mon Sep 17 00:00:00 2001 From: James Mattis Date: Tue, 8 Mar 2022 18:05:14 -0800 Subject: 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 --- .../server/ethernet/EthernetNetworkFactoryTest.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'tests') 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); -- cgit v1.2.3