Expect creating the DNS event listener in setUp, not in tests.

This simplifies the code a bit.

Also remove an unnecessary reset(mMockNetd) call.

Bug: 143158421
Test: test-only change
Change-Id: Ie49d23193ef8d9dcb3f724a7dff249755c67a971
This commit is contained in:
Lorenzo Colitti
2022-08-01 10:24:35 +09:00
parent b82e25c51b
commit 410d4e18b0

View File

@@ -1854,6 +1854,7 @@ public class ConnectivityServiceTest {
// getSystemService() correctly. // getSystemService() correctly.
mCm = new WrappedConnectivityManager(InstrumentationRegistry.getContext(), mService); mCm = new WrappedConnectivityManager(InstrumentationRegistry.getContext(), mService);
mService.systemReadyInternal(); mService.systemReadyInternal();
verify(mMockDnsResolver).registerUnsolicitedEventListener(any());
mVpnManagerService = makeVpnManagerService(); mVpnManagerService = makeVpnManagerService();
mVpnManagerService.systemReady(); mVpnManagerService.systemReady();
mockVpn(Process.myUid()); mockVpn(Process.myUid());
@@ -7256,9 +7257,6 @@ public class ConnectivityServiceTest {
public void testBasicDnsConfigurationPushed() throws Exception { public void testBasicDnsConfigurationPushed() throws Exception {
setPrivateDnsSettings(PRIVATE_DNS_MODE_OPPORTUNISTIC, "ignored.example.com"); setPrivateDnsSettings(PRIVATE_DNS_MODE_OPPORTUNISTIC, "ignored.example.com");
// Clear any interactions that occur as a result of CS starting up.
reset(mMockDnsResolver);
mCellNetworkAgent = new TestNetworkAgentWrapper(TRANSPORT_CELLULAR); mCellNetworkAgent = new TestNetworkAgentWrapper(TRANSPORT_CELLULAR);
waitForIdle(); waitForIdle();
verify(mMockDnsResolver, never()).setResolverConfiguration(any()); verify(mMockDnsResolver, never()).setResolverConfiguration(any());
@@ -7331,9 +7329,6 @@ public class ConnectivityServiceTest {
@Test @Test
public void testDnsConfigurationTransTypesPushed() throws Exception { public void testDnsConfigurationTransTypesPushed() throws Exception {
// Clear any interactions that occur as a result of CS starting up.
reset(mMockDnsResolver);
final NetworkRequest request = new NetworkRequest.Builder() final NetworkRequest request = new NetworkRequest.Builder()
.clearCapabilities().addCapability(NET_CAPABILITY_INTERNET) .clearCapabilities().addCapability(NET_CAPABILITY_INTERNET)
.build(); .build();
@@ -7392,9 +7387,6 @@ public class ConnectivityServiceTest {
@Test @Test
public void testPrivateDnsSettingsChange() throws Exception { public void testPrivateDnsSettingsChange() throws Exception {
// Clear any interactions that occur as a result of CS starting up.
reset(mMockDnsResolver);
// The default on Android is opportunistic mode ("Automatic"). // The default on Android is opportunistic mode ("Automatic").
setPrivateDnsSettings(PRIVATE_DNS_MODE_OPPORTUNISTIC, "ignored.example.com"); setPrivateDnsSettings(PRIVATE_DNS_MODE_OPPORTUNISTIC, "ignored.example.com");
@@ -9845,8 +9837,6 @@ public class ConnectivityServiceTest {
cellLp.addRoute(ipv6Default); cellLp.addRoute(ipv6Default);
cellLp.addRoute(ipv6Subnet); cellLp.addRoute(ipv6Subnet);
mCellNetworkAgent = new TestNetworkAgentWrapper(TRANSPORT_CELLULAR, cellLp); mCellNetworkAgent = new TestNetworkAgentWrapper(TRANSPORT_CELLULAR, cellLp);
reset(mMockDnsResolver);
reset(mMockNetd);
reset(mClatCoordinator); reset(mClatCoordinator);
// Connect with ipv6 link properties. Expect prefix discovery to be started. // Connect with ipv6 link properties. Expect prefix discovery to be started.