@@ -169,57 +169,75 @@ public void screenTrace_shouldNotAllowNonPositiveTotalFrames() {
169
169
}
170
170
171
171
@ Test
172
- public void traceValidator_invalidCustomAttribute_marksPerfMetricInvalid () {
172
+ public void traceValidator_customAttributeWithUnderscorePrefix_marksPerfMetricInvalid () {
173
173
TraceMetric .Builder trace = createValidTraceMetric ().putCustomAttributes ("_test" , "value" );
174
174
assertThat (new FirebasePerfTraceValidator (trace .build ()).isValidPerfMetric ()).isFalse ();
175
+ }
175
176
176
- trace = createValidTraceMetric ();
177
- trace .clearCustomAttributes ().putCustomAttributes ("0_test" , "value" );
177
+ @ Test
178
+ public void traceValidator_customAttributeWithNumberPrefix_marksPerfMetricInvalid () {
179
+ TraceMetric .Builder trace = createValidTraceMetric ().putCustomAttributes ("0_test" , "value" );
178
180
assertThat (new FirebasePerfTraceValidator (trace .build ()).isValidPerfMetric ()).isFalse ();
181
+ }
182
+
183
+ @ Test
184
+ public void traceValidator_customAttributeWithGooglePrefix_marksPerfMetricInvalid () {
185
+ TraceMetric .Builder trace = createValidTraceMetric ().putCustomAttributes ("google_test" , "value" );
186
+ assertThat (new FirebasePerfTraceValidator (trace .build ()).isValidPerfMetric ()).isFalse ();
187
+ }
179
188
180
- trace = trace .clone ();
181
- trace .clearCustomAttributes ().putCustomAttributes ("google_test" , "value" );
189
+ @ Test
190
+ public void traceValidator_customAttributeWithFirebasePrefix_marksPerfMetricInvalid () {
191
+ TraceMetric .Builder trace = createValidTraceMetric ().putCustomAttributes ("firebase_test" , "value" );
182
192
assertThat (new FirebasePerfTraceValidator (trace .build ()).isValidPerfMetric ()).isFalse ();
193
+ }
183
194
184
- trace = trace .clone ();
185
- trace .clearCustomAttributes ().putCustomAttributes ("firebase_test" , "value" );
195
+ @ Test
196
+ public void traceValidator_customAttributeWithGAPrefix_marksPerfMetricInvalid () {
197
+ TraceMetric .Builder trace = createValidTraceMetric ().putCustomAttributes ("ga_test" , "value" );
186
198
assertThat (new FirebasePerfTraceValidator (trace .build ()).isValidPerfMetric ()).isFalse ();
199
+ }
187
200
188
- trace = trace .clone ();
189
- trace .clearCustomAttributes ().putCustomAttributes ("ga_test" , "value" );
201
+ @ Test
202
+ public void traceValidator_customAttributeEmptyValue_marksPerfMetricInvalid () {
203
+ TraceMetric .Builder trace = createValidTraceMetric ().putCustomAttributes ("key" , "" );
190
204
assertThat (new FirebasePerfTraceValidator (trace .build ()).isValidPerfMetric ()).isFalse ();
205
+ }
191
206
192
- trace = trace .clone ();
193
- trace .clearCustomAttributes ().putCustomAttributes ("key" , "" );
207
+ @ Test
208
+ public void traceValidator_customAttributeEmptyKey_marksPerfMetricInvalid () {
209
+ TraceMetric .Builder trace = createValidTraceMetric ().putCustomAttributes ("" , "value" );
194
210
assertThat (new FirebasePerfTraceValidator (trace .build ()).isValidPerfMetric ()).isFalse ();
211
+ }
195
212
196
- trace = trace .clone ();
197
- trace .clearCustomAttributes ().putCustomAttributes ("" , "value" );
213
+ @ Test
214
+ public void traceValidator_customAttributeEmptyKeyAndValue_marksPerfMetricInvalid () {
215
+ TraceMetric .Builder trace = createValidTraceMetric ().putCustomAttributes ("" , "" );
198
216
assertThat (new FirebasePerfTraceValidator (trace .build ()).isValidPerfMetric ()).isFalse ();
217
+ }
218
+
219
+ @ Test
220
+ public void traceValidator_customAttributeWithLongKey_marksPerfMetricInvalid () {
199
221
200
222
StringBuilder longString = new StringBuilder ();
201
223
for (int i = 0 ; i <= Constants .MAX_ATTRIBUTE_KEY_LENGTH ; i ++) {
202
224
longString .append ("a" );
203
225
}
204
-
205
- trace = trace .clone ();
206
- trace .clearCustomAttributes ().putCustomAttributes (longString .toString (), "value" );
226
+ TraceMetric .Builder trace = createValidTraceMetric ().putCustomAttributes (longString .toString (), "value" );
207
227
assertThat (new FirebasePerfTraceValidator (trace .build ()).isValidPerfMetric ()).isFalse ();
228
+ }
208
229
209
- longString = new StringBuilder ();
230
+ @ Test
231
+ public void traceValidator_customAttributeWithLongValue_marksPerfMetricInvalid () {
232
+
233
+ StringBuilder longString = new StringBuilder ();
210
234
for (int i = 0 ; i <= Constants .MAX_ATTRIBUTE_VALUE_LENGTH ; i ++) {
211
235
longString .append ("a" );
212
236
}
213
-
214
- trace = trace .clone ();
215
- trace .clearCustomAttributes ().putCustomAttributes ("key" , longString .toString ());
237
+ TraceMetric .Builder trace = createValidTraceMetric ().putCustomAttributes ("key" , longString .toString ());
216
238
assertThat (new FirebasePerfTraceValidator (trace .build ()).isValidPerfMetric ()).isFalse ();
217
-
218
- trace = trace .clone ();
219
- trace .clearCustomAttributes ().putCustomAttributes ("test" , "value" );
220
- assertThat (new FirebasePerfTraceValidator (trace .build ()).isValidPerfMetric ()).isTrue ();
221
239
}
222
-
240
+
223
241
@ Test
224
242
public void testIsValid () {
225
243
TraceMetric .Builder trace = createValidTraceMetric ().putCounters ("counter" , 2 );
0 commit comments