use of android.net.metrics.IpConnectivityLog in project android_frameworks_base by DirtyUnicorns.
the class IpConnectivityMetricsTest method testRateLimiting.
@SmallTest
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 android_frameworks_base by ResurrectionRemix.
the class IpConnectivityMetricsTest method testRateLimiting.
@SmallTest
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 android_frameworks_base by ResurrectionRemix.
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 testLoggingEvents.
@SmallTest
public void testLoggingEvents() throws Exception {
IpConnectivityLog logger = new IpConnectivityLog(mMockService);
assertTrue(logger.log(1, FAKE_EV));
assertTrue(logger.log(2, FAKE_EV));
assertTrue(logger.log(3, FAKE_EV));
List<ConnectivityMetricsEvent> got = verifyEvents(3);
assertEventsEqual(expectedEvent(1), got.get(0));
assertEventsEqual(expectedEvent(2), got.get(1));
assertEventsEqual(expectedEvent(3), got.get(2));
}
use of android.net.metrics.IpConnectivityLog in project android_frameworks_base by crdroidandroid.
the class IpConnectivityMetricsTest method testRateLimiting.
@SmallTest
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);
}
Aggregations