use of android.net.metrics.DnsEvent in project android_frameworks_base by ResurrectionRemix.
the class NetdEventListenerServiceTest method verifyLoggedDnsEvents.
void verifyLoggedDnsEvents(int wait, DnsEvent... expectedEvents) {
verify(mLog, timeout(wait).times(expectedEvents.length)).log(mDnsEvCaptor.capture());
for (DnsEvent got : mDnsEvCaptor.getAllValues()) {
OptionalInt index = IntStream.range(0, expectedEvents.length).filter(i -> dnsEventsEqual(expectedEvents[i], got)).findFirst();
// Don't match same expected event more than once.
index.ifPresent(i -> expectedEvents[i] = null);
assertTrue(index.isPresent());
}
}
use of android.net.metrics.DnsEvent in project android_frameworks_base by DirtyUnicorns.
the class NetdEventListenerServiceTest method testConcurrentDnsBatchesAndDumps.
@SmallTest
public void testConcurrentDnsBatchesAndDumps() throws Exception {
final long stop = System.currentTimeMillis() + 100;
final PrintWriter pw = new PrintWriter(new FileOutputStream("/dev/null"));
new Thread() {
public void run() {
while (System.currentTimeMillis() < stop) {
mNetdEventListenerService.dump(pw);
}
}
}.start();
logDnsAsync(105, LATENCIES);
logDnsAsync(106, LATENCIES);
logDnsAsync(107, LATENCIES);
verifyLoggedDnsEvents(500, new DnsEvent(105, EVENT_TYPES, RETURN_CODES, LATENCIES), new DnsEvent(106, EVENT_TYPES, RETURN_CODES, LATENCIES), new DnsEvent(107, EVENT_TYPES, RETURN_CODES, LATENCIES));
}
use of android.net.metrics.DnsEvent in project android_frameworks_base by DirtyUnicorns.
the class NetdEventListenerServiceTest method testDnsBatchAndNetworkLost.
@SmallTest
public void testDnsBatchAndNetworkLost() throws Exception {
byte[] eventTypes = Arrays.copyOf(EVENT_TYPES, 20);
byte[] returnCodes = Arrays.copyOf(RETURN_CODES, 20);
int[] latencies = Arrays.copyOf(LATENCIES, 20);
log(105, LATENCIES);
log(105, latencies);
mCallbackCaptor.getValue().onLost(new Network(105));
log(105, LATENCIES);
verifyLoggedDnsEvents(new DnsEvent(105, eventTypes, returnCodes, latencies), new DnsEvent(105, EVENT_TYPES, RETURN_CODES, LATENCIES), new DnsEvent(105, EVENT_TYPES, RETURN_CODES, LATENCIES));
}
use of android.net.metrics.DnsEvent in project android_frameworks_base by DirtyUnicorns.
the class NetdEventListenerServiceTest method testOneDnsBatch.
@SmallTest
public void testOneDnsBatch() throws Exception {
log(105, LATENCIES);
// one lookup short of a batch event
log(106, Arrays.copyOf(LATENCIES, BATCH_SIZE - 1));
verifyLoggedDnsEvents(new DnsEvent(105, EVENT_TYPES, RETURN_CODES, LATENCIES));
log(106, Arrays.copyOfRange(LATENCIES, BATCH_SIZE - 1, BATCH_SIZE));
// reset argument captor
mDnsEvCaptor = ArgumentCaptor.forClass(DnsEvent.class);
verifyLoggedDnsEvents(new DnsEvent(105, EVENT_TYPES, RETURN_CODES, LATENCIES), new DnsEvent(106, EVENT_TYPES, RETURN_CODES, LATENCIES));
}
use of android.net.metrics.DnsEvent in project android_frameworks_base by DirtyUnicorns.
the class NetdEventListenerServiceTest method verifyLoggedDnsEvents.
void verifyLoggedDnsEvents(int wait, DnsEvent... expectedEvents) {
verify(mLog, timeout(wait).times(expectedEvents.length)).log(mDnsEvCaptor.capture());
for (DnsEvent got : mDnsEvCaptor.getAllValues()) {
OptionalInt index = IntStream.range(0, expectedEvents.length).filter(i -> dnsEventsEqual(expectedEvents[i], got)).findFirst();
// Don't match same expected event more than once.
index.ifPresent(i -> expectedEvents[i] = null);
assertTrue(index.isPresent());
}
}
Aggregations