use of com.google.firebase.perf.metrics.NetworkRequestMetricBuilder in project firebase-android-sdk by firebase.
the class FirebasePerfNetworkValidatorTest method testNullResponseCode.
@Test
public void testNullResponseCode() {
NetworkRequestMetricBuilder metricBuilder = NetworkRequestMetricBuilder.builder(TransportManager.getInstance());
// Set all the required fields except response code
metricBuilder.setUrl("https://www.google.com");
metricBuilder.setHttpMethod("GET");
metricBuilder.setRequestStartTimeMicros(System.currentTimeMillis() * 1000L);
metricBuilder.setTimeToResponseCompletedMicros(400L);
NetworkRequestMetric metric = metricBuilder.build();
assertFalse(metric.hasHttpResponseCode());
FirebasePerfNetworkValidator validator = new FirebasePerfNetworkValidator(metric, ApplicationProvider.getApplicationContext());
assertFalse(validator.isValidPerfMetric());
}
use of com.google.firebase.perf.metrics.NetworkRequestMetricBuilder in project firebase-android-sdk by firebase.
the class FirebasePerfNetworkValidatorTest method testInvalidResponseCode.
@Test
public void testInvalidResponseCode() {
NetworkRequestMetricBuilder metricBuilder = createNetworkRequestMetricBuilderWithRequiredValuesPresent();
metricBuilder.setHttpResponseCode(-2);
FirebasePerfNetworkValidator validator = new FirebasePerfNetworkValidator(metricBuilder.build(), ApplicationProvider.getApplicationContext());
assertFalse(validator.isValidPerfMetric());
}
use of com.google.firebase.perf.metrics.NetworkRequestMetricBuilder in project firebase-android-sdk by firebase.
the class FirebasePerfNetworkValidatorTest method testNullTimeToRequestCompleted.
@Test
public void testNullTimeToRequestCompleted() {
NetworkRequestMetricBuilder metricBuilder = createNetworkRequestMetricBuilderWithRequiredValuesPresent();
NetworkRequestMetric metric = metricBuilder.build();
assertFalse(metric.hasTimeToRequestCompletedUs());
FirebasePerfNetworkValidator validator = new FirebasePerfNetworkValidator(metric, ApplicationProvider.getApplicationContext());
assertTrue(validator.isValidPerfMetric());
}
use of com.google.firebase.perf.metrics.NetworkRequestMetricBuilder in project firebase-android-sdk by firebase.
the class FirebasePerfNetworkValidatorTest method testNegativeTimeToRequestCompleted.
@Test
public void testNegativeTimeToRequestCompleted() {
NetworkRequestMetricBuilder metricBuilder = createNetworkRequestMetricBuilderWithRequiredValuesPresent();
metricBuilder.setTimeToRequestCompletedMicros(-1L);
FirebasePerfNetworkValidator validator = new FirebasePerfNetworkValidator(metricBuilder.build(), ApplicationProvider.getApplicationContext());
assertFalse(validator.isValidPerfMetric());
}
use of com.google.firebase.perf.metrics.NetworkRequestMetricBuilder in project firebase-android-sdk by firebase.
the class FirebasePerfNetworkValidatorTest method testAbsenceOfHttpMethodFailsValidation.
@Test
public void testAbsenceOfHttpMethodFailsValidation() {
NetworkRequestMetricBuilder metricBuilder = NetworkRequestMetricBuilder.builder(TransportManager.getInstance());
// Set all required fields except httpMethod
metricBuilder.setUrl("https://www.google.com");
metricBuilder.setHttpResponseCode(200);
metricBuilder.setRequestStartTimeMicros(System.currentTimeMillis() * 1000L);
metricBuilder.setTimeToResponseCompletedMicros(400L);
FirebasePerfNetworkValidator metricValidator = new FirebasePerfNetworkValidator(metricBuilder.build(), ApplicationProvider.getApplicationContext());
assertThat(metricValidator.isValidPerfMetric()).isFalse();
}
Aggregations