use of com.google.firebase.perf.v1.NetworkRequestMetric in project firebase-android-sdk by firebase.
the class FirebasePerfUrlConnectionTest method testOpenStreamHttpConnectionError.
@Test
public void testOpenStreamHttpConnectionError() throws IOException {
URLWrapper wrapper = mock(URLWrapper.class);
when(wrapper.toString()).thenReturn("www.google.com");
when(wrapper.openConnection()).thenThrow(IOException.class);
try {
FirebasePerfUrlConnection.openStream(wrapper, transportManager, timer);
fail("expected IOException");
} catch (IOException e) {
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 FirebasePerfUrlConnectionTest method testGetContentClasses.
@Test
public void testGetContentClasses() throws IOException {
@SuppressWarnings("rawtypes") Class[] classes = { TransportManager.class };
URLWrapper wrapper = mock(URLWrapper.class);
when(wrapper.toString()).thenReturn("www.google.com");
when(wrapper.openConnection()).thenThrow(IOException.class);
try {
FirebasePerfUrlConnection.getContent(wrapper, classes, transportManager, timer);
fail("expected IOException");
} catch (IOException e) {
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 HttpMetricTest method removeAttribute.
@Test
public void removeAttribute() {
HttpMetric metric = new HttpMetric("https://www.google.com/", HttpMethod.GET, transportManager, timer);
metric.start();
metric.putAttribute("attr1", "free");
Map<String, String> attributes = metric.getAttributes();
assertThat(attributes.size()).isEqualTo(1);
metric.removeAttribute("attr1");
attributes = metric.getAttributes();
assertThat(attributes.size()).isEqualTo(0);
metric.stop();
verify(transportManager).log(networkArgumentCaptor.capture(), ArgumentMatchers.nullable(ApplicationProcessState.class));
NetworkRequestMetric metricValue = networkArgumentCaptor.getValue();
assertThat(metricValue.getUrl()).isEqualTo("https://www.google.com/");
assertThat(metricValue.getHttpMethod()).isEqualTo(com.google.firebase.perf.v1.NetworkRequestMetric.HttpMethod.GET);
assertThat(metricValue.getClientStartTimeUs()).isEqualTo(1000);
assertThat(metricValue.getTimeToResponseCompletedUs()).isEqualTo(2000);
assertThat(metricValue.getCustomAttributesCount()).isEqualTo(0);
}
use of com.google.firebase.perf.v1.NetworkRequestMetric in project firebase-android-sdk by firebase.
the class HttpMetricTest method markResponseStart.
@Test
public void markResponseStart() {
HttpMetric metric = new HttpMetric("https://www.google.com/", HttpMethod.GET, transportManager, timer);
metric.start();
metric.markResponseStart();
metric.stop();
verify(transportManager).log(networkArgumentCaptor.capture(), ArgumentMatchers.nullable(ApplicationProcessState.class));
NetworkRequestMetric metricValue = networkArgumentCaptor.getValue();
assertThat(metricValue.getUrl()).isEqualTo("https://www.google.com/");
assertThat(metricValue.getHttpMethod()).isEqualTo(com.google.firebase.perf.v1.NetworkRequestMetric.HttpMethod.GET);
assertThat(metricValue.getClientStartTimeUs()).isEqualTo(1000);
assertThat(metricValue.getTimeToResponseInitiatedUs()).isEqualTo(2000);
assertThat(metricValue.getTimeToResponseCompletedUs()).isEqualTo(3000);
}
use of com.google.firebase.perf.v1.NetworkRequestMetric in project firebase-android-sdk by firebase.
the class HttpMetricTest method addAttributeWithSameName.
@Test
public void addAttributeWithSameName() {
HttpMetric metric = new HttpMetric("https://www.google.com/", HttpMethod.GET, transportManager, timer);
metric.start();
metric.putAttribute("attr1", "free");
metric.putAttribute("attr1", "paid");
metric.stop();
verify(transportManager).log(networkArgumentCaptor.capture(), ArgumentMatchers.nullable(ApplicationProcessState.class));
NetworkRequestMetric metricValue = networkArgumentCaptor.getValue();
assertThat(metricValue.getUrl()).isEqualTo("https://www.google.com/");
assertThat(metricValue.getHttpMethod()).isEqualTo(com.google.firebase.perf.v1.NetworkRequestMetric.HttpMethod.GET);
assertThat(metricValue.getClientStartTimeUs()).isEqualTo(1000);
assertThat(metricValue.getTimeToResponseCompletedUs()).isEqualTo(2000);
assertThat(metricValue.getCustomAttributesCount()).isEqualTo(1);
assertThat(metricValue.getCustomAttributesMap()).containsEntry("attr1", "paid");
}
Aggregations