use of com.google.firebase.perf.v1.NetworkRequestMetric in project firebase-android-sdk by firebase.
the class HttpMetricTest method setResponseSize.
@Test
public void setResponseSize() {
HttpMetric metric = new HttpMetric("https://www.google.com/", HttpMethod.GET, transportManager, timer);
metric.start();
metric.setResponsePayloadSize(256);
metric.stop();
verify(transportManager).log(networkArgumentCaptor.capture(), ArgumentMatchers.nullable(ApplicationProcessState.class));
NetworkRequestMetric metricValue = networkArgumentCaptor.getValue();
verifyMetric(metricValue);
assertThat(metricValue.getResponsePayloadBytes()).isEqualTo(256);
}
use of com.google.firebase.perf.v1.NetworkRequestMetric in project firebase-android-sdk by firebase.
the class HttpMetricTest method putAttribute.
@Test
public void putAttribute() {
HttpMetric metric = new HttpMetric("https://www.google.com/", HttpMethod.GET, transportManager, timer);
metric.start();
metric.putAttribute("attr1", "free");
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", "free");
}
use of com.google.firebase.perf.v1.NetworkRequestMetric in project firebase-android-sdk by firebase.
the class HttpMetricTest method markRequestComplete.
@Test
public void markRequestComplete() {
HttpMetric metric = new HttpMetric("https://www.google.com/", HttpMethod.GET, transportManager, timer);
metric.start();
metric.markRequestComplete();
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.getTimeToRequestCompletedUs()).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 removeAttributeAfterStopped.
@Test
public void removeAttributeAfterStopped() {
HttpMetric metric = new HttpMetric("https://www.google.com/", HttpMethod.GET, transportManager, timer);
metric.start();
metric.putAttribute("attr1", "free");
metric.stop();
metric.removeAttribute("attr1");
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", "free");
}
use of com.google.firebase.perf.v1.NetworkRequestMetric in project firebase-android-sdk by firebase.
the class HttpMetricTest method setHttpResponseCode.
@Test
public void setHttpResponseCode() {
HttpMetric metric = new HttpMetric("https://www.google.com/", HttpMethod.GET, transportManager, timer);
metric.start();
metric.setHttpResponseCode(200);
metric.stop();
verify(transportManager).log(networkArgumentCaptor.capture(), ArgumentMatchers.nullable(ApplicationProcessState.class));
NetworkRequestMetric metricValue = networkArgumentCaptor.getValue();
verifyMetric(metricValue);
assertThat(metricValue.getHttpResponseCode()).isEqualTo(200);
}
Aggregations