use of com.google.firebase.perf.v1.PerfMetric in project firebase-android-sdk by firebase.
the class TransportManagerTest method validNetworkMetric_knownApplicationProcessState_getLogged.
@Test
public void validNetworkMetric_knownApplicationProcessState_getLogged() {
NetworkRequestMetric validNetworkRequest = createValidNetworkRequestMetric();
testTransportManager.log(validNetworkRequest, ApplicationProcessState.FOREGROUND);
fakeExecutorService.runAll();
PerfMetric loggedPerfMetric = getLastLoggedEvent(times(1));
assertThat(loggedPerfMetric.getNetworkRequestMetric()).isEqualTo(validNetworkRequest);
validateApplicationInfo(loggedPerfMetric, ApplicationProcessState.FOREGROUND);
}
use of com.google.firebase.perf.v1.PerfMetric in project firebase-android-sdk by firebase.
the class TransportManagerTest method logTraceMetric_globalCustomAttributesAreAdded.
// endregion
// region Global Custom Attributes Behaviour
@Test
public void logTraceMetric_globalCustomAttributesAreAdded() {
FirebasePerformance.getInstance().putAttribute("test_key1", "test_value1");
FirebasePerformance.getInstance().putAttribute("test_key2", "test_value2");
TraceMetric validTrace = createValidTraceMetric();
testTransportManager.log(validTrace);
fakeExecutorService.runAll();
PerfMetric loggedPerfMetric = getLastLoggedEvent(times(1));
assertThat(loggedPerfMetric.getTraceMetric()).isEqualTo(validTrace);
validateApplicationInfo(loggedPerfMetric, ApplicationProcessState.APPLICATION_PROCESS_STATE_UNKNOWN);
Map<String, String> globalCustomAttributes = loggedPerfMetric.getApplicationInfo().getCustomAttributesMap();
assertThat(globalCustomAttributes).hasSize(2);
assertThat(globalCustomAttributes).containsEntry("test_key1", "test_value1");
assertThat(globalCustomAttributes).containsEntry("test_key2", "test_value2");
}
use of com.google.firebase.perf.v1.PerfMetric in project firebase-android-sdk by firebase.
the class TransportManagerTest method validNetworkMetric_nullInstallationsDuringInitButValidValueLater_getLogged.
@Test
public void validNetworkMetric_nullInstallationsDuringInitButValidValueLater_getLogged() {
// Null Installations during initialization
mockInstallationsGetId(null);
initializeTransport(true);
fakeExecutorService.runAll();
// Valid FID later
mockInstallationsGetId(FAKE_FIREBASE_INSTALLATIONS_ID);
NetworkRequestMetric validNetworkRequest = createValidNetworkRequestMetric();
testTransportManager.log(validNetworkRequest);
fakeExecutorService.runAll();
PerfMetric loggedPerfMetric = getLastLoggedEvent(times(1));
assertThat(loggedPerfMetric.getNetworkRequestMetric()).isEqualTo(validNetworkRequest);
validateApplicationInfo(loggedPerfMetric, ApplicationProcessState.APPLICATION_PROCESS_STATE_UNKNOWN);
}
use of com.google.firebase.perf.v1.PerfMetric in project firebase-android-sdk by firebase.
the class TransportManagerTest method validGaugeMetric_transportNotInitialized_getLoggedAfterInitialization.
@Test
public void validGaugeMetric_transportNotInitialized_getLoggedAfterInitialization() {
initializeTransport(false);
GaugeMetric validGauge = createValidGaugeMetric();
testTransportManager.log(validGauge, ApplicationProcessState.BACKGROUND);
fakeExecutorService.runAll();
assertThat(getLastLoggedEvent(never())).isNull();
assertThat(testTransportManager.getPendingEventsQueue().size()).isEqualTo(1);
initializeTransport(true);
fakeExecutorService.runAll();
PerfMetric loggedPerfMetric = getLastLoggedEvent(times(1));
assertThat(loggedPerfMetric.getGaugeMetric()).isEqualTo(validGauge);
validateApplicationInfo(loggedPerfMetric, ApplicationProcessState.BACKGROUND);
assertThat(testTransportManager.getPendingEventsQueue().isEmpty()).isTrue();
}
use of com.google.firebase.perf.v1.PerfMetric in project firebase-android-sdk by firebase.
the class TransportManagerTest method validTraceMetric_transportNotInitialized_getLoggedAfterInitialization.
// region Transport Initialization
@Test
public void validTraceMetric_transportNotInitialized_getLoggedAfterInitialization() {
initializeTransport(false);
TraceMetric validTrace = createValidTraceMetric();
testTransportManager.log(validTrace, ApplicationProcessState.BACKGROUND);
fakeExecutorService.runAll();
assertThat(getLastLoggedEvent(never())).isNull();
assertThat(testTransportManager.getPendingEventsQueue().size()).isEqualTo(1);
initializeTransport(true);
fakeExecutorService.runAll();
PerfMetric loggedPerfMetric = getLastLoggedEvent(times(1));
assertThat(loggedPerfMetric.getTraceMetric()).isEqualTo(validTrace);
validateApplicationInfo(loggedPerfMetric, ApplicationProcessState.BACKGROUND);
assertThat(testTransportManager.getPendingEventsQueue().isEmpty()).isTrue();
}
Aggregations