Merge changes I6fff65eb,Ie49d2319,Ief974217
* changes: Make all ConnectivityService#doTestXyz methods private. Expect creating the DNS event listener in setUp, not in tests. Rename testPreferenceForUserNetworkUpDownForGivenPreference.
This commit is contained in:
@@ -1854,6 +1854,7 @@ public class ConnectivityServiceTest {
|
||||
// getSystemService() correctly.
|
||||
mCm = new WrappedConnectivityManager(InstrumentationRegistry.getContext(), mService);
|
||||
mService.systemReadyInternal();
|
||||
verify(mMockDnsResolver).registerUnsolicitedEventListener(any());
|
||||
mVpnManagerService = makeVpnManagerService();
|
||||
mVpnManagerService.systemReady();
|
||||
mockVpn(Process.myUid());
|
||||
@@ -2604,7 +2605,7 @@ public class ConnectivityServiceTest {
|
||||
doTestValidatedCellularOutscoresUnvalidatedWiFi(false);
|
||||
}
|
||||
|
||||
public void doTestValidatedCellularOutscoresUnvalidatedWiFi(
|
||||
private void doTestValidatedCellularOutscoresUnvalidatedWiFi(
|
||||
final boolean cellRadioTimesharingCapable) throws Exception {
|
||||
mService.mCellularRadioTimesharingCapable = cellRadioTimesharingCapable;
|
||||
// Test bringing up unvalidated WiFi
|
||||
@@ -2652,7 +2653,7 @@ public class ConnectivityServiceTest {
|
||||
doTestUnvalidatedWifiOutscoresUnvalidatedCellular(false);
|
||||
}
|
||||
|
||||
public void doTestUnvalidatedWifiOutscoresUnvalidatedCellular(
|
||||
private void doTestUnvalidatedWifiOutscoresUnvalidatedCellular(
|
||||
final boolean cellRadioTimesharingCapable) throws Exception {
|
||||
mService.mCellularRadioTimesharingCapable = cellRadioTimesharingCapable;
|
||||
// Test bringing up unvalidated cellular.
|
||||
@@ -2691,7 +2692,7 @@ public class ConnectivityServiceTest {
|
||||
doTestUnlingeringDoesNotValidate(false);
|
||||
}
|
||||
|
||||
public void doTestUnlingeringDoesNotValidate(
|
||||
private void doTestUnlingeringDoesNotValidate(
|
||||
final boolean cellRadioTimesharingCapable) throws Exception {
|
||||
mService.mCellularRadioTimesharingCapable = cellRadioTimesharingCapable;
|
||||
// Test bringing up unvalidated WiFi.
|
||||
@@ -2740,7 +2741,7 @@ public class ConnectivityServiceTest {
|
||||
doTestRequestMigrationToSameTransport(TRANSPORT_ETHERNET, true);
|
||||
}
|
||||
|
||||
public void doTestRequestMigrationToSameTransport(final int transport,
|
||||
private void doTestRequestMigrationToSameTransport(final int transport,
|
||||
final boolean expectLingering) throws Exception {
|
||||
// To speed up tests the linger delay is very short by default in tests but this
|
||||
// test needs to make sure the delay is not incurred so a longer value is safer (it
|
||||
@@ -2845,7 +2846,7 @@ public class ConnectivityServiceTest {
|
||||
doTestCellularOutscoresWeakWifi(false);
|
||||
}
|
||||
|
||||
public void doTestCellularOutscoresWeakWifi(
|
||||
private void doTestCellularOutscoresWeakWifi(
|
||||
final boolean cellRadioTimesharingCapable) throws Exception {
|
||||
mService.mCellularRadioTimesharingCapable = cellRadioTimesharingCapable;
|
||||
// Test bringing up validated cellular.
|
||||
@@ -2884,7 +2885,7 @@ public class ConnectivityServiceTest {
|
||||
doTestReapingNetwork(false);
|
||||
}
|
||||
|
||||
public void doTestReapingNetwork(
|
||||
private void doTestReapingNetwork(
|
||||
final boolean cellRadioTimesharingCapable) throws Exception {
|
||||
mService.mCellularRadioTimesharingCapable = cellRadioTimesharingCapable;
|
||||
// Test bringing up WiFi without NET_CAPABILITY_INTERNET.
|
||||
@@ -2926,7 +2927,7 @@ public class ConnectivityServiceTest {
|
||||
doTestCellularFallback(false);
|
||||
}
|
||||
|
||||
public void doTestCellularFallback(
|
||||
private void doTestCellularFallback(
|
||||
final boolean cellRadioTimesharingCapable) throws Exception {
|
||||
mService.mCellularRadioTimesharingCapable = cellRadioTimesharingCapable;
|
||||
// Test bringing up validated cellular.
|
||||
@@ -2977,7 +2978,7 @@ public class ConnectivityServiceTest {
|
||||
doTestWiFiFallback(false);
|
||||
}
|
||||
|
||||
public void doTestWiFiFallback(
|
||||
private void doTestWiFiFallback(
|
||||
final boolean cellRadioTimesharingCapable) throws Exception {
|
||||
mService.mCellularRadioTimesharingCapable = cellRadioTimesharingCapable;
|
||||
// Test bringing up unvalidated WiFi.
|
||||
@@ -7256,9 +7257,6 @@ public class ConnectivityServiceTest {
|
||||
public void testBasicDnsConfigurationPushed() throws Exception {
|
||||
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);
|
||||
waitForIdle();
|
||||
verify(mMockDnsResolver, never()).setResolverConfiguration(any());
|
||||
@@ -7331,9 +7329,6 @@ public class ConnectivityServiceTest {
|
||||
|
||||
@Test
|
||||
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()
|
||||
.clearCapabilities().addCapability(NET_CAPABILITY_INTERNET)
|
||||
.build();
|
||||
@@ -7392,9 +7387,6 @@ public class ConnectivityServiceTest {
|
||||
|
||||
@Test
|
||||
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").
|
||||
setPrivateDnsSettings(PRIVATE_DNS_MODE_OPPORTUNISTIC, "ignored.example.com");
|
||||
|
||||
@@ -9842,8 +9834,6 @@ public class ConnectivityServiceTest {
|
||||
cellLp.addRoute(ipv6Default);
|
||||
cellLp.addRoute(ipv6Subnet);
|
||||
mCellNetworkAgent = new TestNetworkAgentWrapper(TRANSPORT_CELLULAR, cellLp);
|
||||
reset(mMockDnsResolver);
|
||||
reset(mMockNetd);
|
||||
reset(mClatCoordinator);
|
||||
|
||||
// Connect with ipv6 link properties. Expect prefix discovery to be started.
|
||||
@@ -14360,7 +14350,7 @@ public class ConnectivityServiceTest {
|
||||
* Make sure per profile network preferences behave as expected for a given
|
||||
* profile network preference.
|
||||
*/
|
||||
public void testPreferenceForUserNetworkUpDownForGivenPreference(
|
||||
private void doTestPreferenceForUserNetworkUpDownForGivenPreference(
|
||||
ProfileNetworkPreference profileNetworkPreference,
|
||||
boolean connectWorkProfileAgentAhead,
|
||||
UserHandle testHandle,
|
||||
@@ -14604,7 +14594,7 @@ public class ConnectivityServiceTest {
|
||||
new ProfileNetworkPreference.Builder();
|
||||
profileNetworkPreferenceBuilder.setPreference(PROFILE_NETWORK_PREFERENCE_ENTERPRISE);
|
||||
profileNetworkPreferenceBuilder.setPreferenceEnterpriseId(NET_ENTERPRISE_ID_1);
|
||||
testPreferenceForUserNetworkUpDownForGivenPreference(
|
||||
doTestPreferenceForUserNetworkUpDownForGivenPreference(
|
||||
profileNetworkPreferenceBuilder.build(), false,
|
||||
testHandle, mProfileDefaultNetworkCallback, null);
|
||||
}
|
||||
@@ -14623,7 +14613,7 @@ public class ConnectivityServiceTest {
|
||||
PROFILE_NETWORK_PREFERENCE_ENTERPRISE_NO_FALLBACK);
|
||||
profileNetworkPreferenceBuilder.setPreferenceEnterpriseId(NET_ENTERPRISE_ID_1);
|
||||
registerDefaultNetworkCallbacks();
|
||||
testPreferenceForUserNetworkUpDownForGivenPreference(
|
||||
doTestPreferenceForUserNetworkUpDownForGivenPreference(
|
||||
profileNetworkPreferenceBuilder.build(), false,
|
||||
testHandle, mProfileDefaultNetworkCallback, null);
|
||||
}
|
||||
@@ -14644,7 +14634,7 @@ public class ConnectivityServiceTest {
|
||||
PROFILE_NETWORK_PREFERENCE_ENTERPRISE_NO_FALLBACK);
|
||||
profileNetworkPreferenceBuilder.setPreferenceEnterpriseId(NET_ENTERPRISE_ID_1);
|
||||
registerDefaultNetworkCallbacks();
|
||||
testPreferenceForUserNetworkUpDownForGivenPreference(
|
||||
doTestPreferenceForUserNetworkUpDownForGivenPreference(
|
||||
profileNetworkPreferenceBuilder.build(), true, testHandle,
|
||||
mProfileDefaultNetworkCallback, null);
|
||||
}
|
||||
@@ -14663,7 +14653,7 @@ public class ConnectivityServiceTest {
|
||||
profileNetworkPreferenceBuilder.setIncludedUids(
|
||||
new int[]{testHandle.getUid(TEST_WORK_PROFILE_APP_UID)});
|
||||
registerDefaultNetworkCallbacks();
|
||||
testPreferenceForUserNetworkUpDownForGivenPreference(
|
||||
doTestPreferenceForUserNetworkUpDownForGivenPreference(
|
||||
profileNetworkPreferenceBuilder.build(), false, testHandle,
|
||||
mProfileDefaultNetworkCallback, null);
|
||||
}
|
||||
@@ -14682,7 +14672,7 @@ public class ConnectivityServiceTest {
|
||||
profileNetworkPreferenceBuilder.setIncludedUids(
|
||||
new int[]{testHandle.getUid(TEST_WORK_PROFILE_APP_UID_2)});
|
||||
registerDefaultNetworkCallbacks();
|
||||
testPreferenceForUserNetworkUpDownForGivenPreference(
|
||||
doTestPreferenceForUserNetworkUpDownForGivenPreference(
|
||||
profileNetworkPreferenceBuilder.build(), false,
|
||||
testHandle, mProfileDefaultNetworkCallbackAsAppUid2, null);
|
||||
}
|
||||
@@ -14701,7 +14691,7 @@ public class ConnectivityServiceTest {
|
||||
profileNetworkPreferenceBuilder.setExcludedUids(
|
||||
new int[]{testHandle.getUid(TEST_WORK_PROFILE_APP_UID_2)});
|
||||
registerDefaultNetworkCallbacks();
|
||||
testPreferenceForUserNetworkUpDownForGivenPreference(
|
||||
doTestPreferenceForUserNetworkUpDownForGivenPreference(
|
||||
profileNetworkPreferenceBuilder.build(), false,
|
||||
testHandle, mProfileDefaultNetworkCallback,
|
||||
mProfileDefaultNetworkCallbackAsAppUid2);
|
||||
@@ -14797,7 +14787,7 @@ public class ConnectivityServiceTest {
|
||||
profileNetworkPreferenceBuilder.setPreference(PROFILE_NETWORK_PREFERENCE_ENTERPRISE);
|
||||
profileNetworkPreferenceBuilder.setPreferenceEnterpriseId(NET_ENTERPRISE_ID_1);
|
||||
registerDefaultNetworkCallbacks();
|
||||
testPreferenceForUserNetworkUpDownForGivenPreference(
|
||||
doTestPreferenceForUserNetworkUpDownForGivenPreference(
|
||||
profileNetworkPreferenceBuilder.build(), true,
|
||||
testHandle, mProfileDefaultNetworkCallback,
|
||||
null);
|
||||
@@ -14817,7 +14807,7 @@ public class ConnectivityServiceTest {
|
||||
PROFILE_NETWORK_PREFERENCE_ENTERPRISE_NO_FALLBACK);
|
||||
profileNetworkPreferenceBuilder.setPreferenceEnterpriseId(NET_ENTERPRISE_ID_1);
|
||||
registerDefaultNetworkCallbacks();
|
||||
testPreferenceForUserNetworkUpDownForGivenPreference(
|
||||
doTestPreferenceForUserNetworkUpDownForGivenPreference(
|
||||
profileNetworkPreferenceBuilder.build(), true,
|
||||
testHandle, mProfileDefaultNetworkCallback,
|
||||
null);
|
||||
@@ -14838,7 +14828,7 @@ public class ConnectivityServiceTest {
|
||||
profileNetworkPreferenceBuilder.setPreferenceEnterpriseId(
|
||||
NET_ENTERPRISE_ID_2);
|
||||
registerDefaultNetworkCallbacks();
|
||||
testPreferenceForUserNetworkUpDownForGivenPreference(
|
||||
doTestPreferenceForUserNetworkUpDownForGivenPreference(
|
||||
profileNetworkPreferenceBuilder.build(), true,
|
||||
testHandle, mProfileDefaultNetworkCallback, null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user