diff --git a/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringTest.java b/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringTest.java index 114cb7ca6e..37a4d90a72 100644 --- a/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringTest.java +++ b/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringTest.java @@ -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(); }