use of android.net.ConnectivityMetricsEvent.Reference in project android_frameworks_base by DirtyUnicorns.
the class MetricsLoggerServiceTest method testInterleavedLogAndGet.
public void testInterleavedLogAndGet() throws Exception {
mService.mBinder.logEvents(Arrays.copyOfRange(EVENTS, 0, 3));
Reference r = new Reference(0);
assertArrayEquals(Arrays.copyOfRange(EVENTS, 0, 3), mService.mBinder.getEvents(r));
assertEquals(3, r.getValue());
mService.mBinder.logEvents(Arrays.copyOfRange(EVENTS, 3, 8));
mService.mBinder.logEvents(Arrays.copyOfRange(EVENTS, 8, 10));
assertArrayEquals(Arrays.copyOfRange(EVENTS, 3, 10), mService.mBinder.getEvents(r));
assertEquals(N_EVENTS, r.getValue());
assertArrayEquals(NO_EVENTS, mService.mBinder.getEvents(r));
assertEquals(N_EVENTS, r.getValue());
}
use of android.net.ConnectivityMetricsEvent.Reference in project android_frameworks_base by ResurrectionRemix.
the class MetricsLoggerServiceTest method testLogAndGetEvents.
public void testLogAndGetEvents() throws Exception {
mService.mBinder.logEvents(EVENTS);
Reference r = new Reference(0);
assertArrayEquals(EVENTS, mService.mBinder.getEvents(r));
assertEquals(N_EVENTS, r.getValue());
assertArrayEquals(NO_EVENTS, mService.mBinder.getEvents(r));
assertEquals(N_EVENTS, r.getValue());
}
use of android.net.ConnectivityMetricsEvent.Reference in project android_frameworks_base by ResurrectionRemix.
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.Reference in project android_frameworks_base by crdroidandroid.
the class MetricsLoggerServiceTest method testMultipleGetAll.
public void testMultipleGetAll() throws Exception {
mService.mBinder.logEvents(Arrays.copyOf(EVENTS, 3));
Reference r1 = new Reference(0);
assertArrayEquals(Arrays.copyOf(EVENTS, 3), mService.mBinder.getEvents(r1));
assertEquals(3, r1.getValue());
mService.mBinder.logEvents(Arrays.copyOfRange(EVENTS, 3, 10));
Reference r2 = new Reference(0);
assertArrayEquals(EVENTS, mService.mBinder.getEvents(r2));
assertEquals(N_EVENTS, r2.getValue());
}
use of android.net.ConnectivityMetricsEvent.Reference in project android_frameworks_base by crdroidandroid.
the class MetricsLoggerServiceTest method testInterleavedLogAndGet.
public void testInterleavedLogAndGet() throws Exception {
mService.mBinder.logEvents(Arrays.copyOfRange(EVENTS, 0, 3));
Reference r = new Reference(0);
assertArrayEquals(Arrays.copyOfRange(EVENTS, 0, 3), mService.mBinder.getEvents(r));
assertEquals(3, r.getValue());
mService.mBinder.logEvents(Arrays.copyOfRange(EVENTS, 3, 8));
mService.mBinder.logEvents(Arrays.copyOfRange(EVENTS, 8, 10));
assertArrayEquals(Arrays.copyOfRange(EVENTS, 3, 10), mService.mBinder.getEvents(r));
assertEquals(N_EVENTS, r.getValue());
assertArrayEquals(NO_EVENTS, mService.mBinder.getEvents(r));
assertEquals(N_EVENTS, r.getValue());
}
Aggregations