Search in sources :

Example 6 with Timer

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;
}
Also used : Timer(com.google.firebase.perf.util.Timer)

Example 7 with 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);
}
Also used : Timer(com.google.firebase.perf.util.Timer) Test(org.junit.Test)

Example 8 with Timer

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);
}
Also used : Timer(com.google.firebase.perf.util.Timer) Test(org.junit.Test)

Example 9 with Timer

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);
}
Also used : Timer(com.google.firebase.perf.util.Timer) Test(org.junit.Test)

Example 10 with Timer

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();
}
Also used : Timer(com.google.firebase.perf.util.Timer) Test(org.junit.Test)

Aggregations

Timer (com.google.firebase.perf.util.Timer)38 Test (org.junit.Test)29 Before (org.junit.Before)7 TransportManager (com.google.firebase.perf.transport.TransportManager)4 TraceMetric (com.google.firebase.perf.v1.TraceMetric)4 Truth.assertThat (com.google.common.truth.Truth.assertThat)3 FirebasePerformanceTestBase (com.google.firebase.perf.FirebasePerformanceTestBase)3 ConfigResolver (com.google.firebase.perf.config.ConfigResolver)3 DeviceCacheManager (com.google.firebase.perf.config.DeviceCacheManager)3 Clock (com.google.firebase.perf.util.Clock)3 Constants (com.google.firebase.perf.util.Constants)3 ApplicationProcessState (com.google.firebase.perf.v1.ApplicationProcessState)3 CpuMetricReading (com.google.firebase.perf.v1.CpuMetricReading)3 RunWith (org.junit.runner.RunWith)3 ArgumentCaptor (org.mockito.ArgumentCaptor)3 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)3 ArgumentMatchers.nullable (org.mockito.ArgumentMatchers.nullable)3 Mock (org.mockito.Mock)3 Mockito.doAnswer (org.mockito.Mockito.doAnswer)3 Mockito.mock (org.mockito.Mockito.mock)3