use of com.google.firebase.perf.util.Timer in project firebase-android-sdk by firebase.
the class InstrumentApacheHttpResponseHandlerTest method mockTimer.
private static Timer mockTimer() {
Timer timer = mock(Timer.class);
when(timer.getDurationMicros()).thenReturn((long) 2000);
return timer;
}
use of com.google.firebase.perf.util.Timer in project firebase-android-sdk by firebase.
the class CpuGaugeCollectorTest method testStartCollectingAddsCpuMetricReadingsToTheConcurrentLinkedQueue.
@Test
public void testStartCollectingAddsCpuMetricReadingsToTheConcurrentLinkedQueue() throws Exception {
testGaugeCollector.startCollecting(100, new Timer());
fakeScheduledExecutorService.simulateSleepExecutingAtMostOneTask();
assertThat(testGaugeCollector.cpuMetricReadings).hasSize(1);
}
use of com.google.firebase.perf.util.Timer in project firebase-android-sdk by firebase.
the class CpuGaugeCollectorTest method testCollectOnce_addOnlyOneCpuMetricReadingToQueue.
@Test
public void testCollectOnce_addOnlyOneCpuMetricReadingToQueue() {
assertThat(testGaugeCollector.cpuMetricReadings).isEmpty();
testGaugeCollector.collectOnce(new Timer());
fakeScheduledExecutorService.simulateSleepExecutingAtMostOneTask();
assertThat(testGaugeCollector.cpuMetricReadings).hasSize(1);
}
use of com.google.firebase.perf.util.Timer in project firebase-android-sdk by firebase.
the class CpuGaugeCollectorTest method testStartCollectingDoesntAddAnythingToQueueWhenReadingProcPidStatFileFails.
@Test
public void testStartCollectingDoesntAddAnythingToQueueWhenReadingProcPidStatFileFails() {
deleteFakeProcFile();
testGaugeCollector.startCollecting(500, new Timer());
fakeScheduledExecutorService.simulateSleepExecutingAtMostOneTask();
assertThat(testGaugeCollector.cpuMetricReadings).hasSize(0);
}
use of com.google.firebase.perf.util.Timer in project firebase-android-sdk by firebase.
the class CpuGaugeCollectorTest method testDoesntCollectAnyDataWhenCpuClockTicksPerSecondIsZero.
@Test
public void testDoesntCollectAnyDataWhenCpuClockTicksPerSecondIsZero() {
final long invalidClockTicksPerSecond = 0;
testGaugeCollector = new CpuGaugeCollector(fakeScheduledExecutorService, fakeProcFile, invalidClockTicksPerSecond);
testGaugeCollector.startCollecting(100, new Timer());
assertThat(fakeScheduledExecutorService.isEmpty()).isTrue();
}
Aggregations