use of android.net.ConnectivityMetricsEvent in project android_frameworks_base by DirtyUnicorns.
the class IpConnectivityEventBuilderTest method testDnsEventSerialization.
@SmallTest
public void testDnsEventSerialization() {
ConnectivityMetricsEvent ev = describeIpEvent(aType(DnsEvent.class), anInt(101), aByteArray(b(1), b(1), b(2), b(1), b(1), b(1), b(2), b(2)), aByteArray(b(0), b(0), b(22), b(3), b(1), b(0), b(200), b(178)), anIntArray(3456, 267, 1230, 45, 2111, 450, 638, 1300));
String want = joinLines("dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " dns_lookup_batch <", " event_types: 1", " event_types: 1", " event_types: 2", " event_types: 1", " event_types: 1", " event_types: 1", " event_types: 2", " event_types: 2", " latencies_ms: 3456", " latencies_ms: 267", " latencies_ms: 1230", " latencies_ms: 45", " latencies_ms: 2111", " latencies_ms: 450", " latencies_ms: 638", " latencies_ms: 1300", " network_id <", " network_id: 101", " >", " return_codes: 0", " return_codes: 0", " return_codes: 22", " return_codes: 3", " return_codes: 1", " return_codes: 0", " return_codes: 200", " return_codes: 178", " >", ">", "version: 2");
verifySerialization(want, ev);
}
use of android.net.ConnectivityMetricsEvent in project android_frameworks_base by DirtyUnicorns.
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 DirtyUnicorns.
the class IpConnectivityEventBuilderTest method testDhcpClientEventSerialization.
@SmallTest
public void testDhcpClientEventSerialization() {
ConnectivityMetricsEvent ev = describeIpEvent(aType(DhcpClientEvent.class), aString("wlan0"), aString("SomeState"), anInt(192));
String want = joinLines("dropped_events: 0", "events <", " time_ms: 1", " transport: 0", " dhcp_event <", " duration_ms: 192", " if_name: \"wlan0\"", " state_transition: \"SomeState\"", " >", ">", "version: 2");
verifySerialization(want, ev);
}
use of android.net.ConnectivityMetricsEvent in project android_frameworks_base by DirtyUnicorns.
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.ConnectivityMetricsEvent in project android_frameworks_base by DirtyUnicorns.
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());
}
}
}
Aggregations