Backport some helpers in ConnectivityServiceTest.
These were added in aosp/1527378, which is impractical to backport. Bug: 172870110 Test: test-only change Change-Id: Id3d12b23034b284c8f7dffb5167244e1e43987e2 Merged-In: I827543751dbf5e626a24ec02cd6f50b423f5f761
This commit is contained in:
@@ -36,6 +36,7 @@ import static android.net.ConnectivityManager.TYPE_MOBILE;
|
|||||||
import static android.net.ConnectivityManager.TYPE_MOBILE_FOTA;
|
import static android.net.ConnectivityManager.TYPE_MOBILE_FOTA;
|
||||||
import static android.net.ConnectivityManager.TYPE_MOBILE_MMS;
|
import static android.net.ConnectivityManager.TYPE_MOBILE_MMS;
|
||||||
import static android.net.ConnectivityManager.TYPE_MOBILE_SUPL;
|
import static android.net.ConnectivityManager.TYPE_MOBILE_SUPL;
|
||||||
|
import static android.net.ConnectivityManager.TYPE_VPN;
|
||||||
import static android.net.ConnectivityManager.TYPE_WIFI;
|
import static android.net.ConnectivityManager.TYPE_WIFI;
|
||||||
import static android.net.INetworkMonitor.NETWORK_VALIDATION_PROBE_DNS;
|
import static android.net.INetworkMonitor.NETWORK_VALIDATION_PROBE_DNS;
|
||||||
import static android.net.INetworkMonitor.NETWORK_VALIDATION_PROBE_FALLBACK;
|
import static android.net.INetworkMonitor.NETWORK_VALIDATION_PROBE_FALLBACK;
|
||||||
@@ -6289,6 +6290,19 @@ public class ConnectivityServiceTest {
|
|||||||
mCm.unregisterNetworkCallback(defaultCallback);
|
mCm.unregisterNetworkCallback(defaultCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkNetworkInfo(NetworkInfo ni, int type, DetailedState state) {
|
||||||
|
assertNotNull(ni);
|
||||||
|
assertEquals(type, ni.getType());
|
||||||
|
assertEquals(ConnectivityManager.getNetworkTypeName(type), state, ni.getDetailedState());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertActiveNetworkInfo(int type, DetailedState state) {
|
||||||
|
checkNetworkInfo(mCm.getActiveNetworkInfo(), type, state);
|
||||||
|
}
|
||||||
|
private void assertNetworkInfo(int type, DetailedState state) {
|
||||||
|
checkNetworkInfo(mCm.getNetworkInfo(type), type, state);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public final void testLoseTrusted() throws Exception {
|
public final void testLoseTrusted() throws Exception {
|
||||||
final NetworkRequest trustedRequest = new NetworkRequest.Builder()
|
final NetworkRequest trustedRequest = new NetworkRequest.Builder()
|
||||||
|
|||||||
Reference in New Issue
Block a user