use of android.net.metrics.DnsEvent in project platform_frameworks_base by android.
the class NetdEventListenerServiceTest method testConcurrentBatchesAndDumps.
@SmallTest
public void testConcurrentBatchesAndDumps() 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();
logAsync(105, LATENCIES);
logAsync(106, LATENCIES);
logAsync(107, LATENCIES);
verifyLoggedEvents(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 platform_frameworks_base by android.
the class NetdEventListenerServiceTest method testSeveralBatches.
@SmallTest
public void testSeveralBatches() throws Exception {
log(105, LATENCIES);
log(106, LATENCIES);
log(105, LATENCIES);
log(107, LATENCIES);
verifyLoggedEvents(new DnsEvent(105, EVENT_TYPES, RETURN_CODES, LATENCIES), new DnsEvent(106, EVENT_TYPES, RETURN_CODES, LATENCIES), new DnsEvent(105, EVENT_TYPES, RETURN_CODES, LATENCIES), new DnsEvent(107, EVENT_TYPES, RETURN_CODES, LATENCIES));
}
use of android.net.metrics.DnsEvent in project platform_frameworks_base by android.
the class NetdEventListenerServiceTest method verifyLoggedEvents.
void verifyLoggedEvents(int wait, DnsEvent... expectedEvents) {
verify(mLog, timeout(wait).times(expectedEvents.length)).log(mEvCaptor.capture());
for (DnsEvent got : mEvCaptor.getAllValues()) {
OptionalInt index = IntStream.range(0, expectedEvents.length).filter(i -> eventsEqual(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 platform_frameworks_base by android.
the class NetdEventListenerServiceTest method testBatchAndNetworkLost.
@SmallTest
public void testBatchAndNetworkLost() 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);
verifyLoggedEvents(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 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));
}
Aggregations