use of com.google.firebase.perf.v1.NetworkRequestMetric 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.v1.NetworkRequestMetric in project firebase-android-sdk by firebase.
the class FirebasePerfHttpClientTest method testExecuteHostRequestContextError.
// go/assertthrows-statements-lsc
@SuppressWarnings("AssertThrowsMultipleStatements")
@Test
public void testExecuteHostRequestContextError() throws IOException, URISyntaxException {
HttpClient client = mock(HttpClient.class);
HttpResponse response = mockHttpResponse();
HttpRequest request = mockHttpRequest();
HttpContext c = mock(HttpContext.class);
HttpHost host = mockHttpHost();
when(client.execute(host, request, c)).thenThrow(new IOException());
assertThrows(IOException.class, () -> {
HttpResponse httpResponse = FirebasePerfHttpClient.execute(client, host, request, c, timer, transportManager);
assertSame(httpResponse, response);
});
verify(transportManager).log(networkArgumentCaptor.capture(), ArgumentMatchers.any(ApplicationProcessState.class));
verify(timer).reset();
NetworkRequestMetric metric = networkArgumentCaptor.getValue();
verifyNetworkRequestMetricWithError(metric);
}
use of com.google.firebase.perf.v1.NetworkRequestMetric in project firebase-android-sdk by firebase.
the class FirebasePerfHttpClientTest method testExecuteRequest.
@Test
public void testExecuteRequest() throws IOException, URISyntaxException {
HttpClient client = mock(HttpClient.class);
HttpResponse response = mockHttpResponse();
HttpUriRequest request = mockHttpUriRequest();
when(client.execute(request)).thenReturn(response);
HttpResponse httpResponse = FirebasePerfHttpClient.execute(client, request, timer, transportManager);
assertSame(httpResponse, response);
verify(timer).reset();
verify(transportManager).log(networkArgumentCaptor.capture(), ArgumentMatchers.any(ApplicationProcessState.class));
NetworkRequestMetric metric = networkArgumentCaptor.getValue();
verifyNetworkRequestMetric(metric);
}
use of com.google.firebase.perf.v1.NetworkRequestMetric in project firebase-android-sdk by firebase.
the class FirebasePerfHttpClientTest method testRequestHandlerContextError.
@Test
public void testRequestHandlerContextError() throws IOException, URISyntaxException {
HttpClient client = mock(HttpClient.class);
HttpUriRequest request = mockHttpUriRequest();
HttpContext context = mock(HttpContext.class);
ResponseHandler<HttpResponse> handler = mock(ResponseHandlerInterface.class);
when(client.execute(eq(request), ArgumentMatchers.<InstrumentApacheHttpResponseHandler<HttpResponse>>any(), eq(context))).thenThrow(new IOException());
assertThrows(IOException.class, () -> {
FirebasePerfHttpClient.execute(client, request, handler, context, timer, transportManager);
});
verify(transportManager).log(networkArgumentCaptor.capture(), ArgumentMatchers.any(ApplicationProcessState.class));
verify(timer).reset();
NetworkRequestMetric metric = networkArgumentCaptor.getValue();
verifyNetworkRequestMetricWithError(metric);
}
use of com.google.firebase.perf.v1.NetworkRequestMetric in project firebase-android-sdk by firebase.
the class FirebasePerfHttpClientTest method testExecuteRequestContextError.
// go/assertthrows-statements-lsc
@SuppressWarnings("AssertThrowsMultipleStatements")
@Test
public void testExecuteRequestContextError() throws IOException, URISyntaxException {
HttpClient client = mock(HttpClient.class);
HttpResponse response = mockHttpResponse();
HttpUriRequest request = mockHttpUriRequest();
HttpContext context = mock(HttpContext.class);
when(client.execute(request, context)).thenThrow(new IOException());
assertThrows(IOException.class, () -> {
HttpResponse httpResponse = FirebasePerfHttpClient.execute(client, request, context, timer, transportManager);
assertSame(httpResponse, response);
});
verify(transportManager).log(networkArgumentCaptor.capture(), ArgumentMatchers.any(ApplicationProcessState.class));
verify(timer).reset();
NetworkRequestMetric metric = networkArgumentCaptor.getValue();
verifyNetworkRequestMetricWithError(metric);
}
Aggregations