Merge "Test Data Stall with unknown detection type." am: 43fbab7444

Change-Id: If62bf0f152893d904b79320354267db1ce3cc320
This commit is contained in:
Cody Kesting
2020-05-29 21:30:41 +00:00
committed by Automerger Merge Worker

View File

@@ -81,6 +81,8 @@ public class ConnectivityDiagnosticsManagerTest {
private static final int DNS_CONSECUTIVE_TIMEOUTS = 5; private static final int DNS_CONSECUTIVE_TIMEOUTS = 5;
private static final int COLLECTION_PERIOD_MILLIS = 5000; private static final int COLLECTION_PERIOD_MILLIS = 5000;
private static final int FAIL_RATE_PERCENTAGE = 100; private static final int FAIL_RATE_PERCENTAGE = 100;
private static final int UNKNOWN_DETECTION_METHOD = 4;
private static final int FILTERED_UNKNOWN_DETECTION_METHOD = 0;
private static final Executor INLINE_EXECUTOR = x -> x.run(); private static final Executor INLINE_EXECUTOR = x -> x.run();
@@ -193,9 +195,28 @@ public class ConnectivityDiagnosticsManagerTest {
verifyOnDataStallSuspected(DETECTION_METHOD_TCP_METRICS, TIMESTAMP, extras); verifyOnDataStallSuspected(DETECTION_METHOD_TCP_METRICS, TIMESTAMP, extras);
} }
@Test
public void testOnDataStallSuspected_UnknownDetectionMethod() throws Exception {
verifyOnDataStallSuspected(
UNKNOWN_DETECTION_METHOD,
FILTERED_UNKNOWN_DETECTION_METHOD,
TIMESTAMP,
PersistableBundle.EMPTY);
}
private void verifyOnDataStallSuspected( private void verifyOnDataStallSuspected(
int detectionMethod, long timestampMillis, @NonNull PersistableBundle extras) int detectionMethod, long timestampMillis, @NonNull PersistableBundle extras)
throws Exception { throws Exception {
// Input detection method is expected to match received detection method
verifyOnDataStallSuspected(detectionMethod, detectionMethod, timestampMillis, extras);
}
private void verifyOnDataStallSuspected(
int inputDetectionMethod,
int expectedDetectionMethod,
long timestampMillis,
@NonNull PersistableBundle extras)
throws Exception {
mTestNetwork = setUpTestNetwork(); mTestNetwork = setUpTestNetwork();
final TestConnectivityDiagnosticsCallback cb = new TestConnectivityDiagnosticsCallback(); final TestConnectivityDiagnosticsCallback cb = new TestConnectivityDiagnosticsCallback();
@@ -208,11 +229,11 @@ public class ConnectivityDiagnosticsManagerTest {
runWithShellPermissionIdentity( runWithShellPermissionIdentity(
() -> mConnectivityManager.simulateDataStall( () -> mConnectivityManager.simulateDataStall(
detectionMethod, timestampMillis, mTestNetwork, extras), inputDetectionMethod, timestampMillis, mTestNetwork, extras),
android.Manifest.permission.MANAGE_TEST_NETWORKS); android.Manifest.permission.MANAGE_TEST_NETWORKS);
cb.expectOnDataStallSuspected( cb.expectOnDataStallSuspected(
mTestNetwork, interfaceName, detectionMethod, timestampMillis, extras); mTestNetwork, interfaceName, expectedDetectionMethod, timestampMillis, extras);
cb.assertNoCallback(); cb.assertNoCallback();
} }