@@ -23,9 +23,8 @@ public void calculateFrameMetrics_sparseIntArrayIsNull_returnsFrameMetricsWithAl
23
23
24
24
@ Test
25
25
public void calculateFrameMetrics_validSparseIntArray_returnsCorrectFrameMetrics () {
26
- // For a given non-null SparseIntArray, the results stored are the number of samples at each
27
- // millisecond value (rounded).
28
- // Slow frames are duration greater than 16ms and frozen frames are duration greater than 700ms.
26
+ // Slow frames have duration greater than 16ms and frozen frames have duration greater than
27
+ // 700ms. The key value pair means (duration, num_of_samples).
29
28
SparseIntArray sparseIntArray = new SparseIntArray ();
30
29
sparseIntArray .append (5 , 3 );
31
30
sparseIntArray .append (20 , 2 );
@@ -34,6 +33,8 @@ public void calculateFrameMetrics_validSparseIntArray_returnsCorrectFrameMetrics
34
33
arr [FrameMetricsAggregator .TOTAL_INDEX ] = sparseIntArray ;
35
34
36
35
FrameMetricsCalculator .FrameMetrics metrics = FrameMetricsCalculator .calculateFrameMetrics (arr );
36
+
37
+ // we should expect 3+2+5=10 total frames, 2+5=7 slow frames, and 5 frozen frames.
37
38
assertThat (metrics .getTotalFrames ()).isEqualTo (10 );
38
39
assertThat (metrics .getSlowFrames ()).isEqualTo (7 );
39
40
assertThat (metrics .getFrozenFrames ()).isEqualTo (5 );
@@ -42,16 +43,17 @@ public void calculateFrameMetrics_validSparseIntArray_returnsCorrectFrameMetrics
42
43
@ Test
43
44
public void
44
45
calculateFrameMetrics_validSparseIntArrayWithoutFrozenFrames_returnsCorrectFrameMetrics () {
45
- // For a given non-null SparseIntArray, the results stored are the number of samples at each
46
- // millisecond value (rounded).
47
- // Slow frames are duration greater than 16ms and frozen frames are duration greater than 700ms.
46
+ // Slow frames have duration greater than 16ms and frozen frames have duration greater than
47
+ // 700ms. The key value pair means (duration, num_of_samples).
48
48
SparseIntArray sparseIntArray = new SparseIntArray ();
49
49
sparseIntArray .append (5 , 3 );
50
50
sparseIntArray .append (20 , 2 );
51
51
SparseIntArray [] arr = new SparseIntArray [1 ];
52
52
arr [FrameMetricsAggregator .TOTAL_INDEX ] = sparseIntArray ;
53
53
54
54
FrameMetricsCalculator .FrameMetrics metrics = FrameMetricsCalculator .calculateFrameMetrics (arr );
55
+
56
+ // we should expect 3+2=5 total frames, 2 slow frames, and 0 frozen frames.
55
57
assertThat (metrics .getTotalFrames ()).isEqualTo (5 );
56
58
assertThat (metrics .getSlowFrames ()).isEqualTo (2 );
57
59
assertThat (metrics .getFrozenFrames ()).isEqualTo (0 );
@@ -60,16 +62,17 @@ public void calculateFrameMetrics_validSparseIntArray_returnsCorrectFrameMetrics
60
62
@ Test
61
63
public void
62
64
calculateFrameMetrics_validSparseIntArrayWithoutSlowFrames_returnsCorrectFrameMetrics () {
63
- // For a given non-null SparseIntArray, the results stored are the number of samples at each
64
- // millisecond value (rounded).
65
- // Slow frames are duration greater than 16ms and frozen frames are duration greater than 700ms.
65
+ // Slow frames have duration greater than 16ms and frozen frames have duration greater than
66
+ // 700ms. The key value pair means (duration, num_of_samples).
66
67
SparseIntArray sparseIntArray = new SparseIntArray ();
67
68
sparseIntArray .append (5 , 3 );
68
69
sparseIntArray .append (701 , 2 );
69
70
SparseIntArray [] arr = new SparseIntArray [1 ];
70
71
arr [FrameMetricsAggregator .TOTAL_INDEX ] = sparseIntArray ;
71
72
72
73
FrameMetricsCalculator .FrameMetrics metrics = FrameMetricsCalculator .calculateFrameMetrics (arr );
74
+
75
+ // we should expect 3+2=5 total frames, 0+2=2 slow frames, and 2 frozen frames.
73
76
assertThat (metrics .getTotalFrames ()).isEqualTo (5 );
74
77
assertThat (metrics .getSlowFrames ()).isEqualTo (2 );
75
78
assertThat (metrics .getFrozenFrames ()).isEqualTo (2 );
0 commit comments