Search in sources :

Example 61 with NetworkRequestMetric

use of com.google.firebase.perf.v1.NetworkRequestMetric in project firebase-android-sdk by firebase.

the class NetworkRequestMetricBuilderTest method testSetHttpResponseCode.

@Test
public void testSetHttpResponseCode() {
    int code = 200;
    NetworkRequestMetric metric = networkMetricBuilder.setHttpResponseCode(code).build();
    assertThat(metric.getHttpResponseCode()).isEqualTo(code);
}
Also used : NetworkRequestMetric(com.google.firebase.perf.v1.NetworkRequestMetric) Test(org.junit.Test)

Example 62 with NetworkRequestMetric

use of com.google.firebase.perf.v1.NetworkRequestMetric in project firebase-android-sdk by firebase.

the class NetworkRequestMetricBuilderTest method testAllNullFields.

@Test
public void testAllNullFields() {
    NetworkRequestMetric metric = networkMetricBuilder.build();
    assertThat(metric.hasUrl()).isFalse();
    assertThat(metric.hasHttpMethod()).isFalse();
    assertThat(metric.hasRequestPayloadBytes()).isFalse();
    assertThat(metric.hasResponsePayloadBytes()).isFalse();
    assertThat(metric.hasNetworkClientErrorReason()).isFalse();
    assertThat(metric.hasHttpResponseCode()).isFalse();
    assertThat(metric.hasResponseContentType()).isFalse();
    assertThat(metric.hasClientStartTimeUs()).isFalse();
    assertThat(metric.hasTimeToRequestCompletedUs()).isFalse();
    assertThat(metric.hasTimeToResponseInitiatedUs()).isFalse();
    assertThat(metric.hasTimeToResponseCompletedUs()).isFalse();
}
Also used : NetworkRequestMetric(com.google.firebase.perf.v1.NetworkRequestMetric) Test(org.junit.Test)

Example 63 with NetworkRequestMetric

use of com.google.firebase.perf.v1.NetworkRequestMetric in project firebase-android-sdk by firebase.

the class NetworkRequestMetricBuilderTest method testSetUrl.

@Test
public void testSetUrl() {
    String url = "www.google.com";
    NetworkRequestMetric metric = networkMetricBuilder.setUrl(url).build();
    assertThat(metric.getUrl()).isEqualTo(url);
}
Also used : NetworkRequestMetric(com.google.firebase.perf.v1.NetworkRequestMetric) Test(org.junit.Test)

Example 64 with NetworkRequestMetric

use of com.google.firebase.perf.v1.NetworkRequestMetric in project firebase-android-sdk by firebase.

the class NetworkRequestMetricBuilderTest method testSetHttpMethod.

@Test
public void testSetHttpMethod() {
    String type = "GET";
    NetworkRequestMetric metric = networkMetricBuilder.setHttpMethod(type).build();
    assertThat(metric.getHttpMethod()).isEqualTo(HttpMethod.GET);
    type = "PUT";
    NetworkRequestMetric metric1 = networkMetricBuilder.setHttpMethod(type).build();
    assertThat(metric1.getHttpMethod()).isEqualTo(HttpMethod.PUT);
    type = "POST";
    NetworkRequestMetric metric2 = networkMetricBuilder.setHttpMethod(type).build();
    assertThat(metric2.getHttpMethod()).isEqualTo(HttpMethod.POST);
    type = "DELETE";
    NetworkRequestMetric metric3 = networkMetricBuilder.setHttpMethod(type).build();
    assertThat(metric3.getHttpMethod()).isEqualTo(HttpMethod.DELETE);
    type = "POST";
    NetworkRequestMetric metric4 = networkMetricBuilder.setHttpMethod(type).build();
    assertThat(metric4.getHttpMethod()).isEqualTo(HttpMethod.POST);
    type = "HEAD";
    NetworkRequestMetric metric5 = networkMetricBuilder.setHttpMethod(type).build();
    assertThat(metric5.getHttpMethod()).isEqualTo(HttpMethod.HEAD);
    type = "PATCH";
    NetworkRequestMetric metric6 = networkMetricBuilder.setHttpMethod(type).build();
    assertThat(metric6.getHttpMethod()).isEqualTo(HttpMethod.PATCH);
    type = "OPTIONS";
    NetworkRequestMetric metric7 = networkMetricBuilder.setHttpMethod(type).build();
    assertThat(metric7.getHttpMethod()).isEqualTo(HttpMethod.OPTIONS);
    type = "TRACE";
    NetworkRequestMetric metric8 = networkMetricBuilder.setHttpMethod(type).build();
    assertThat(metric8.getHttpMethod()).isEqualTo(HttpMethod.TRACE);
    type = "CONNECT";
    NetworkRequestMetric metric9 = networkMetricBuilder.setHttpMethod(type).build();
    assertThat(metric9.getHttpMethod()).isEqualTo(HttpMethod.CONNECT);
    type = "UNKNOWN";
    NetworkRequestMetric metric10 = networkMetricBuilder.setHttpMethod(type).build();
    assertThat(metric10.getHttpMethod()).isEqualTo(HttpMethod.HTTP_METHOD_UNKNOWN);
}
Also used : NetworkRequestMetric(com.google.firebase.perf.v1.NetworkRequestMetric) Test(org.junit.Test)

Example 65 with NetworkRequestMetric

use of com.google.firebase.perf.v1.NetworkRequestMetric in project firebase-android-sdk by firebase.

the class NetworkRequestMetricBuilderTest method testSetRequestStartTimeMicros.

@Test
public void testSetRequestStartTimeMicros() {
    long time = 2000;
    NetworkRequestMetric metric = networkMetricBuilder.setRequestStartTimeMicros(time).build();
    assertThat(metric.getClientStartTimeUs()).isEqualTo(time);
}
Also used : NetworkRequestMetric(com.google.firebase.perf.v1.NetworkRequestMetric) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)81 NetworkRequestMetric (com.google.firebase.perf.v1.NetworkRequestMetric)80 ApplicationProcessState (com.google.firebase.perf.v1.ApplicationProcessState)45 NetworkRequestMetricBuilder (com.google.firebase.perf.metrics.NetworkRequestMetricBuilder)13 IOException (java.io.IOException)13 HttpResponse (org.apache.http.HttpResponse)13 HttpClient (org.apache.http.client.HttpClient)12 HttpURLConnection (java.net.HttpURLConnection)11 PerfMetric (com.google.firebase.perf.v1.PerfMetric)10 HttpHost (org.apache.http.HttpHost)6 HttpRequest (org.apache.http.HttpRequest)6 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)6 HttpContext (org.apache.http.protocol.HttpContext)6 HttpUrl (okhttp3.HttpUrl)4 Request (okhttp3.Request)4 RequestBody (okhttp3.RequestBody)4 TransportManager (com.google.firebase.perf.transport.TransportManager)3 URLWrapper (com.google.firebase.perf.util.URLWrapper)3 HttpsURLConnection (javax.net.ssl.HttpsURLConnection)3 Response (okhttp3.Response)3