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());
}
}
}
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);
}
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());
}
}
}
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);
}
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);
}
Aggregations