use of android.net.ConnectivityMetricsEvent in project android_frameworks_base by DirtyUnicorns.
the class MetricsLoggerServiceTest method logAndDumpConcurrently.
public void logAndDumpConcurrently() throws Exception {
final CountDownLatch latch = new CountDownLatch((int) N_EVENTS);
final FileDescriptor fd = new FileOutputStream("/dev/null").getFD();
for (ConnectivityMetricsEvent ev : EVENTS) {
new Thread() {
public void run() {
mService.mBinder.logEvent(ev);
latch.countDown();
}
}.start();
}
new Thread() {
public void run() {
while (latch.getCount() > 0) {
mService.mBinder.dump(fd, new String[] { "--all" });
}
}
}.start();
latch.await(100, TimeUnit.MILLISECONDS);
Reference r = new Reference(0);
ConnectivityMetricsEvent[] got = mService.mBinder.getEvents(r);
Arrays.sort(got, new EventComparator());
assertArrayEquals(EVENTS, got);
assertEquals(N_EVENTS, r.getValue());
}
use of android.net.ConnectivityMetricsEvent 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.ConnectivityMetricsEvent in project android_frameworks_base by crdroidandroid.
the class IpConnectivityEventBuilderTest method testValidationProbeEventSerialization.
@SmallTest
public void testValidationProbeEventSerialization() {
ConnectivityMetricsEvent ev = describeIpEvent(aType(ValidationProbeEvent.class), anInt(120), aLong(40730), anInt(ValidationProbeEvent.PROBE_HTTP), anInt(204));
String want = joinLines("dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " validation_probe_event <", " latency_ms: 40730", " network_id <", " network_id: 120", " >", " probe_result: 204", " probe_type: 1", " >", ">", "version: 2");
verifySerialization(want, ev);
}
use of android.net.ConnectivityMetricsEvent in project android_frameworks_base by crdroidandroid.
the class IpConnectivityEventBuilderTest method testIpManagerEventSerialization.
@SmallTest
public void testIpManagerEventSerialization() {
ConnectivityMetricsEvent ev = describeIpEvent(aType(IpManagerEvent.class), aString("wlan0"), anInt(IpManagerEvent.PROVISIONING_OK), aLong(5678));
String want = joinLines("dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " ip_provisioning_event <", " event_type: 1", " if_name: \"wlan0\"", " latency_ms: 5678", " >", ">", "version: 2");
verifySerialization(want, ev);
}
use of android.net.ConnectivityMetricsEvent in project android_frameworks_base by crdroidandroid.
the class IpConnectivityEventBuilderTest method testNetworkEventSerialization.
@SmallTest
public void testNetworkEventSerialization() {
ConnectivityMetricsEvent ev = describeIpEvent(aType(NetworkEvent.class), anInt(100), anInt(5), aLong(20410));
String want = joinLines("dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " network_event <", " event_type: 5", " latency_ms: 20410", " network_id <", " network_id: 100", " >", " >", ">", "version: 2");
verifySerialization(want, ev);
}
Aggregations