Merge "Fix null DadProxy failure in R Tethering unit test" am: 220e7854bd am: 668adf955c am: 8b3c07d951 am: a6bb7e3340

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1485808

Change-Id: I351e5dc3afaf61e5cf82913872ec0bec1e99a094
This commit is contained in:
Mark Chien
2020-11-09 06:53:04 +00:00
committed by Automerger Merge Worker

View File

@@ -125,6 +125,7 @@ import android.net.wifi.WifiManager;
import android.net.wifi.p2p.WifiP2pGroup;
import android.net.wifi.p2p.WifiP2pInfo;
import android.net.wifi.p2p.WifiP2pManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@@ -844,6 +845,14 @@ public class TetheringTest {
mLooper.dispatchAll();
}
private void assertSetIfaceToDadProxy(final int numOfCalls, final String ifaceName) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R || "S".equals(Build.VERSION.CODENAME)
|| "T".equals(Build.VERSION.CODENAME)) {
verify(mDadProxy, times(numOfCalls)).setUpstreamIface(
argThat(ifaceParams -> ifaceName.equals(ifaceParams.name)));
}
}
@Test
public void workingMobileUsbTethering_IPv4() throws Exception {
UpstreamNetworkState upstreamState = buildMobileIPv4UpstreamState();
@@ -853,7 +862,7 @@ public class TetheringTest {
verify(mNetd, times(1)).ipfwdAddInterfaceForward(TEST_USB_IFNAME, TEST_MOBILE_IFNAME);
sendIPv6TetherUpdates(upstreamState);
verify(mDadProxy, never()).setUpstreamIface(notNull());
assertSetIfaceToDadProxy(0 /* numOfCalls */, "" /* ifaceName */);
verify(mRouterAdvertisementDaemon, never()).buildNewRa(any(), notNull());
verify(mDhcpServer, timeout(DHCPSERVER_START_TIMEOUT_MS).times(1)).startWithCallbacks(
any(), any());
@@ -881,7 +890,7 @@ public class TetheringTest {
sendIPv6TetherUpdates(upstreamState);
// TODO: add interfaceParams to compare in verify.
verify(mDadProxy, times(1)).setUpstreamIface(notNull());
assertSetIfaceToDadProxy(1 /* numOfCalls */, TEST_MOBILE_IFNAME /* ifaceName */);
verify(mRouterAdvertisementDaemon, times(1)).buildNewRa(any(), notNull());
verify(mNetd, times(1)).tetherApplyDnsInterfaces();
}
@@ -898,7 +907,7 @@ public class TetheringTest {
any(), any());
sendIPv6TetherUpdates(upstreamState);
verify(mDadProxy, times(1)).setUpstreamIface(notNull());
assertSetIfaceToDadProxy(1 /* numOfCalls */, TEST_MOBILE_IFNAME /* ifaceName */);
verify(mRouterAdvertisementDaemon, times(1)).buildNewRa(any(), notNull());
verify(mNetd, times(1)).tetherApplyDnsInterfaces();
}
@@ -916,7 +925,7 @@ public class TetheringTest {
verify(mNetd, times(1)).ipfwdAddInterfaceForward(TEST_USB_IFNAME, TEST_MOBILE_IFNAME);
sendIPv6TetherUpdates(upstreamState);
verify(mDadProxy, times(1)).setUpstreamIface(notNull());
assertSetIfaceToDadProxy(1 /* numOfCalls */, TEST_MOBILE_IFNAME /* ifaceName */);
verify(mRouterAdvertisementDaemon, times(1)).buildNewRa(any(), notNull());
verify(mNetd, times(1)).tetherApplyDnsInterfaces();
}