Search in sources :

Example 16 with DnsEvent

use of android.net.metrics.DnsEvent in project android_frameworks_base by DirtyUnicorns.

the class NetdEventListenerServiceTest method testSeveralDmsBatches.

@SmallTest
public void testSeveralDmsBatches() throws Exception {
    log(105, LATENCIES);
    log(106, LATENCIES);
    log(105, LATENCIES);
    log(107, LATENCIES);
    verifyLoggedDnsEvents(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));
}
Also used : DnsEvent(android.net.metrics.DnsEvent) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 17 with DnsEvent

use of android.net.metrics.DnsEvent in project android_frameworks_base by ResurrectionRemix.

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));
}
Also used : FileOutputStream(java.io.FileOutputStream) PrintWriter(java.io.PrintWriter) DnsEvent(android.net.metrics.DnsEvent) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 18 with DnsEvent

use of android.net.metrics.DnsEvent in project android_frameworks_base by ResurrectionRemix.

the class NetdEventListenerServiceTest method testSeveralDmsBatches.

@SmallTest
public void testSeveralDmsBatches() throws Exception {
    log(105, LATENCIES);
    log(106, LATENCIES);
    log(105, LATENCIES);
    log(107, LATENCIES);
    verifyLoggedDnsEvents(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));
}
Also used : DnsEvent(android.net.metrics.DnsEvent) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 19 with DnsEvent

use of android.net.metrics.DnsEvent in project android_frameworks_base by ResurrectionRemix.

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));
}
Also used : Network(android.net.Network) DnsEvent(android.net.metrics.DnsEvent) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 20 with DnsEvent

use of android.net.metrics.DnsEvent in project android_frameworks_base by crdroidandroid.

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));
}
Also used : DnsEvent(android.net.metrics.DnsEvent) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

DnsEvent (android.net.metrics.DnsEvent)20 SmallTest (android.test.suitebuilder.annotation.SmallTest)20 Network (android.net.Network)8 FileOutputStream (java.io.FileOutputStream)8 PrintWriter (java.io.PrintWriter)8 ConnectivityManager (android.net.ConnectivityManager)4 NetworkCallback (android.net.ConnectivityManager.NetworkCallback)4 INetdEventListener (android.net.metrics.INetdEventListener)4 IpConnectivityLog (android.net.metrics.IpConnectivityLog)4 RemoteException (android.os.RemoteException)4 Arrays (java.util.Arrays)4 List (java.util.List)4 OptionalInt (java.util.OptionalInt)4 IntStream (java.util.stream.IntStream)4 TestCase (junit.framework.TestCase)4 Assert.assertArrayEquals (org.junit.Assert.assertArrayEquals)4 Assert.assertTrue (org.junit.Assert.assertTrue)4 Before (org.junit.Before)4 Test (org.junit.Test)4 ArgumentCaptor (org.mockito.ArgumentCaptor)4