no-op: Add test to verify legacyTether does not use explicit request
Add a test that verifies that legacyTether will not use the explicit pending TetheringRequest set by startTethering. Bug: 216524590 Test: atest TetheringTest Change-Id: I3e0638a3c60cdf3b73b1accc136ed7098e7b48f6
This commit is contained in:
parent
40baa445a2
commit
c22dc00557
1 changed files with 39 additions and 0 deletions
|
|
@ -89,6 +89,7 @@ import static com.android.testutils.TestPermissionUtil.runAsShell;
|
|||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
|
@ -2878,6 +2879,44 @@ public class TetheringTest {
|
|||
assertEquals(clientAddrParceled, params.singleClientAddr);
|
||||
}
|
||||
|
||||
@Test
|
||||
@IgnoreAfter(Build.VERSION_CODES.VANILLA_ICE_CREAM)
|
||||
public void testRequestStaticIpLegacyTetherFailure() throws Exception {
|
||||
initTetheringOnTestThread();
|
||||
|
||||
// Call startTethering with static ip
|
||||
final LinkAddress serverLinkAddr = new LinkAddress("192.168.0.123/24");
|
||||
final LinkAddress clientLinkAddr = new LinkAddress("192.168.0.42/24");
|
||||
final String serverAddr = "192.168.0.123";
|
||||
final int clientAddrParceled = 0xc0a8002a;
|
||||
final ArgumentCaptor<DhcpServingParamsParcel> dhcpParamsCaptor =
|
||||
ArgumentCaptor.forClass(DhcpServingParamsParcel.class);
|
||||
when(mWifiManager.startTetheredHotspot(any())).thenReturn(true);
|
||||
mTethering.startTethering(createTetheringRequest(TETHERING_WIFI,
|
||||
serverLinkAddr, clientLinkAddr, false, CONNECTIVITY_SCOPE_GLOBAL, null),
|
||||
TEST_CALLER_PKG, null);
|
||||
mLooper.dispatchAll();
|
||||
verify(mWifiManager, times(1)).startTetheredHotspot(any());
|
||||
mTethering.interfaceStatusChanged(TEST_WLAN_IFNAME, true);
|
||||
|
||||
// Call legacyTether on the interface before the link layer event comes back.
|
||||
// This happens, for example, in pre-T bluetooth tethering: Settings calls startTethering,
|
||||
// and then the bluetooth code calls the tether() API.
|
||||
final ResultListener tetherResult = new ResultListener(TETHER_ERROR_NO_ERROR);
|
||||
mTethering.legacyTether(TEST_WLAN_IFNAME, tetherResult);
|
||||
mLooper.dispatchAll();
|
||||
tetherResult.assertHasResult();
|
||||
|
||||
// Verify that the static ip set in startTethering is not used
|
||||
verify(mNetd).interfaceSetCfg(argThat(cfg -> !serverAddr.equals(cfg.ipv4Addr)));
|
||||
verify(mIpServerDependencies, times(1)).makeDhcpServer(any(), dhcpParamsCaptor.capture(),
|
||||
any());
|
||||
final DhcpServingParamsParcel params = dhcpParamsCaptor.getValue();
|
||||
assertNotEquals(serverAddr, intToInet4AddressHTH(params.serverAddr).getHostAddress());
|
||||
assertEquals(24, params.serverAddrPrefixLength);
|
||||
assertNotEquals(clientAddrParceled, params.singleClientAddr);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpstreamNetworkChanged() throws Exception {
|
||||
initTetheringOnTestThread();
|
||||
|
|
|
|||
Loading…
Reference in a new issue