Search in sources :

Example 6 with ApplicationProcessState

use of com.google.firebase.perf.v1.ApplicationProcessState in project firebase-android-sdk by firebase.

the class TransportManagerTest method validTraceMetric_knownApplicationProcessState_getLogged.

// endregion
// region ApplicationProcessState Behaviour
@Test
public void validTraceMetric_knownApplicationProcessState_getLogged() {
    TraceMetric validTrace = createValidTraceMetric();
    testTransportManager.log(validTrace, ApplicationProcessState.BACKGROUND);
    fakeExecutorService.runAll();
    PerfMetric loggedPerfMetric = getLastLoggedEvent(times(1));
    assertThat(loggedPerfMetric.getTraceMetric()).isEqualTo(validTrace);
    validateApplicationInfo(loggedPerfMetric, ApplicationProcessState.BACKGROUND);
}
Also used : TraceMetric(com.google.firebase.perf.v1.TraceMetric) PerfMetric(com.google.firebase.perf.v1.PerfMetric) Test(org.junit.Test)

Example 7 with ApplicationProcessState

use of com.google.firebase.perf.v1.ApplicationProcessState in project firebase-android-sdk by firebase.

the class TransportManagerTest method validGaugeMetric_withMetadata_isLogged.

@Test
public void validGaugeMetric_withMetadata_isLogged() {
    ApplicationProcessState expectedAppState = ApplicationProcessState.FOREGROUND;
    GaugeMetadata gaugeMetadata = GaugeMetadata.newBuilder().setDeviceRamSizeKb(2000).setMaxAppJavaHeapMemoryKb(1000).setMaxEncouragedAppJavaHeapMemoryKb(800).build();
    GaugeMetric validGauge = GaugeMetric.newBuilder().setSessionId("sessionId").setGaugeMetadata(gaugeMetadata).build();
    testTransportManager.log(validGauge, expectedAppState);
    fakeExecutorService.runAll();
    PerfMetric loggedPerfMetric = getLastLoggedEvent(times(1));
    assertThat(loggedPerfMetric.getGaugeMetric().getSessionId()).isEqualTo("sessionId");
    assertThat(loggedPerfMetric.getGaugeMetric().getGaugeMetadata().getDeviceRamSizeKb()).isEqualTo(2000);
    assertThat(loggedPerfMetric.getGaugeMetric().getGaugeMetadata().getMaxAppJavaHeapMemoryKb()).isEqualTo(1000);
    assertThat(loggedPerfMetric.getGaugeMetric().getGaugeMetadata().getMaxEncouragedAppJavaHeapMemoryKb()).isEqualTo(800);
}
Also used : ApplicationProcessState(com.google.firebase.perf.v1.ApplicationProcessState) PerfMetric(com.google.firebase.perf.v1.PerfMetric) GaugeMetadata(com.google.firebase.perf.v1.GaugeMetadata) GaugeMetric(com.google.firebase.perf.v1.GaugeMetric) Test(org.junit.Test)

Example 8 with ApplicationProcessState

use of com.google.firebase.perf.v1.ApplicationProcessState in project firebase-android-sdk by firebase.

the class TransportManagerTest method validGaugeMetric_withMemoryReadings_isLogged.

@Test
public void validGaugeMetric_withMemoryReadings_isLogged() {
    ApplicationProcessState expectedAppState = ApplicationProcessState.FOREGROUND;
    // Construct a list of Memory metric readings
    List<AndroidMemoryReading> expectedMemoryMetricReadings = new ArrayList<>();
    expectedMemoryMetricReadings.add(createValidAndroidMetricReading(/* currentUsedAppJavaHeapMemoryKb= */
    1234));
    expectedMemoryMetricReadings.add(createValidAndroidMetricReading(/* currentUsedAppJavaHeapMemoryKb= */
    23456));
    GaugeMetric validGauge = GaugeMetric.newBuilder().setSessionId("sessionId").addAllAndroidMemoryReadings(expectedMemoryMetricReadings).build();
    testTransportManager.log(validGauge, expectedAppState);
    fakeExecutorService.runAll();
    PerfMetric loggedPerfMetric = getLastLoggedEvent(times(1));
    assertThat(loggedPerfMetric.getGaugeMetric().getAndroidMemoryReadingsList()).containsExactlyElementsIn(expectedMemoryMetricReadings);
    assertThat(loggedPerfMetric.getGaugeMetric().getSessionId()).isEqualTo("sessionId");
}
Also used : AndroidMemoryReading(com.google.firebase.perf.v1.AndroidMemoryReading) ApplicationProcessState(com.google.firebase.perf.v1.ApplicationProcessState) PerfMetric(com.google.firebase.perf.v1.PerfMetric) ArrayList(java.util.ArrayList) GaugeMetric(com.google.firebase.perf.v1.GaugeMetric) Test(org.junit.Test)

Aggregations

ApplicationProcessState (com.google.firebase.perf.v1.ApplicationProcessState)5 PerfMetric (com.google.firebase.perf.v1.PerfMetric)5 GaugeMetric (com.google.firebase.perf.v1.GaugeMetric)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)2 WorkerThread (androidx.annotation.WorkerThread)1 AndroidMemoryReading (com.google.firebase.perf.v1.AndroidMemoryReading)1 CpuMetricReading (com.google.firebase.perf.v1.CpuMetricReading)1 GaugeMetadata (com.google.firebase.perf.v1.GaugeMetadata)1 TraceMetric (com.google.firebase.perf.v1.TraceMetric)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 ScheduledFuture (java.util.concurrent.ScheduledFuture)1