Skip to content

Commit 1faa4e2

Browse files
authored
Restore fireperf smoke tests as #2158 is fixed. (#2282)
* Restore fireperf smoke tests as #2158 is fixed. #2158
1 parent b659461 commit 1faa4e2

File tree

2 files changed

+62
-2
lines changed

2 files changed

+62
-2
lines changed

smoke-tests/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ dependencies {
7373
// TODO(yifany): Restore after messaging in github is up to date
7474
// implementation "com.google.firebase:firebase-messaging"
7575
implementation "com.google.firebase:firebase-ml-vision"
76-
// TODO(b/174858514): Restore after M85 release is live
77-
// implementation "com.google.firebase:firebase-perf"
76+
implementation "com.google.firebase:firebase-perf"
7877
implementation "com.google.firebase:firebase-storage"
7978

8079
// Common utilities (application side)
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright 2020 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.google.firebase.testing;
16+
17+
import static com.google.common.truth.Truth.assertThat;
18+
19+
import androidx.test.runner.AndroidJUnit4;
20+
import com.google.firebase.perf.FirebasePerformance;
21+
import com.google.firebase.perf.metrics.HttpMetric;
22+
import com.google.firebase.perf.metrics.Trace;
23+
import org.junit.Test;
24+
import org.junit.runner.RunWith;
25+
26+
@RunWith(AndroidJUnit4.class)
27+
public final class PerformanceMonitoringTest {
28+
29+
@Test
30+
public void trace() {
31+
Trace trace = FirebasePerformance.getInstance().newTrace("test_trace");
32+
trace.start();
33+
34+
trace.putMetric("counter", 1);
35+
trace.incrementMetric("counter", 2);
36+
trace.putAttribute("is_test", "true");
37+
38+
trace.stop();
39+
40+
assertThat(trace.getLongMetric("counter")).isEqualTo(3);
41+
assertThat(trace.getAttribute("is_test")).isEqualTo("true");
42+
}
43+
44+
@Test
45+
public void networkRequest() {
46+
HttpMetric networkRequest =
47+
FirebasePerformance.getInstance()
48+
.newHttpMetric("https://www.google.com", FirebasePerformance.HttpMethod.GET);
49+
networkRequest.start();
50+
51+
networkRequest.setRequestPayloadSize(128);
52+
networkRequest.setResponsePayloadSize(1024);
53+
networkRequest.setHttpResponseCode(200);
54+
networkRequest.setResponseContentType("text/html");
55+
networkRequest.putAttribute("is_test", "true");
56+
57+
networkRequest.stop();
58+
59+
assertThat(networkRequest.getAttribute("is_test")).isEqualTo("true");
60+
}
61+
}

0 commit comments

Comments
 (0)