Search in sources :

Example 11 with IpConnectivityLog

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

the class IpConnectivityMetricsTest method testLoggingEventsWithMultipleCallers.

@SmallTest
public void testLoggingEventsWithMultipleCallers() throws Exception {
    IpConnectivityLog logger = new IpConnectivityLog(mMockService);
    final int nCallers = 10;
    final int nEvents = 10;
    for (int n = 0; n < nCallers; n++) {
        final int i = n;
        new Thread() {

            public void run() {
                for (int j = 0; j < nEvents; j++) {
                    assertTrue(logger.log(i * 100 + j, FAKE_EV));
                }
            }
        }.start();
    }
    List<ConnectivityMetricsEvent> got = verifyEvents(nCallers * nEvents, 100);
    Collections.sort(got, EVENT_COMPARATOR);
    Iterator<ConnectivityMetricsEvent> iter = got.iterator();
    for (int i = 0; i < nCallers; i++) {
        for (int j = 0; j < nEvents; j++) {
            int expectedTimestamp = i * 100 + j;
            assertEventsEqual(expectedEvent(expectedTimestamp), iter.next());
        }
    }
}
Also used : IpConnectivityLog(android.net.metrics.IpConnectivityLog) ConnectivityMetricsEvent(android.net.ConnectivityMetricsEvent) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 12 with IpConnectivityLog

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

the class IpConnectivityMetricsTest method testBufferFlushing.

@SmallTest
public void testBufferFlushing() {
    String output1 = getdump("flush");
    assertEquals("", output1);
    new IpConnectivityLog(mService.impl).log(1, FAKE_EV);
    String output2 = getdump("flush");
    assertFalse("".equals(output2));
    String output3 = getdump("flush");
    assertEquals("", output3);
}
Also used : IpConnectivityLog(android.net.metrics.IpConnectivityLog) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 13 with IpConnectivityLog

use of android.net.metrics.IpConnectivityLog in project platform_frameworks_base by android.

the class IpConnectivityMetricsTest method testLoggingEventsWithMultipleCallers.

public void testLoggingEventsWithMultipleCallers() throws Exception {
    IpConnectivityLog logger = new IpConnectivityLog(mMockService);
    final int nCallers = 10;
    final int nEvents = 10;
    for (int n = 0; n < nCallers; n++) {
        final int i = n;
        new Thread() {

            public void run() {
                for (int j = 0; j < nEvents; j++) {
                    assertTrue(logger.log(i * 100 + j, FAKE_EV));
                }
            }
        }.start();
    }
    List<ConnectivityMetricsEvent> got = verifyEvents(nCallers * nEvents, 100);
    Collections.sort(got, EVENT_COMPARATOR);
    Iterator<ConnectivityMetricsEvent> iter = got.iterator();
    for (int i = 0; i < nCallers; i++) {
        for (int j = 0; j < nEvents; j++) {
            int expectedTimestamp = i * 100 + j;
            assertEventsEqual(expectedEvent(expectedTimestamp), iter.next());
        }
    }
}
Also used : IpConnectivityLog(android.net.metrics.IpConnectivityLog) ConnectivityMetricsEvent(android.net.ConnectivityMetricsEvent)

Example 14 with IpConnectivityLog

use of android.net.metrics.IpConnectivityLog in project platform_frameworks_base by android.

the class IpConnectivityMetricsTest method testRateLimiting.

public void testRateLimiting() {
    final IpConnectivityLog logger = new IpConnectivityLog(mService.impl);
    final ApfProgramEvent ev = new ApfProgramEvent(0, 0, 0, 0, 0);
    final long fakeTimestamp = 1;
    // More than burst quota, but less than buffer size.
    int attempt = 100;
    for (int i = 0; i < attempt; i++) {
        logger.log(ev);
    }
    String output1 = getdump("flush");
    assertFalse("".equals(output1));
    for (int i = 0; i < attempt; i++) {
        assertFalse("expected event to be dropped", logger.log(fakeTimestamp, ev));
    }
    String output2 = getdump("flush");
    assertEquals("", output2);
}
Also used : IpConnectivityLog(android.net.metrics.IpConnectivityLog) ApfProgramEvent(android.net.metrics.ApfProgramEvent)

Example 15 with IpConnectivityLog

use of android.net.metrics.IpConnectivityLog in project platform_frameworks_base by android.

the class IpConnectivityMetricsTest method testBufferFlushing.

public void testBufferFlushing() {
    String output1 = getdump("flush");
    assertEquals("", output1);
    new IpConnectivityLog(mService.impl).log(1, FAKE_EV);
    String output2 = getdump("flush");
    assertFalse("".equals(output2));
    String output3 = getdump("flush");
    assertEquals("", output3);
}
Also used : IpConnectivityLog(android.net.metrics.IpConnectivityLog)

Aggregations

IpConnectivityLog (android.net.metrics.IpConnectivityLog)20 SmallTest (android.test.suitebuilder.annotation.SmallTest)15 ConnectivityMetricsEvent (android.net.ConnectivityMetricsEvent)8 ApfProgramEvent (android.net.metrics.ApfProgramEvent)4 ApfStats (android.net.metrics.ApfStats)4 DefaultNetworkEvent (android.net.metrics.DefaultNetworkEvent)4 DhcpClientEvent (android.net.metrics.DhcpClientEvent)4 IpManagerEvent (android.net.metrics.IpManagerEvent)4 IpReachabilityEvent (android.net.metrics.IpReachabilityEvent)4 RaEvent (android.net.metrics.RaEvent)4 ValidationProbeEvent (android.net.metrics.ValidationProbeEvent)4 Parcelable (android.os.Parcelable)4