@@ -29,9 +29,22 @@ Future<void> main() async {
29
29
expect (cleanedLeaks.total, 1 );
30
30
});
31
31
32
- group ('Leak tracking works for non-web' , () {
32
+ test ('$LeakCleaner catches extra leaks' , () {
33
+ Leaks leaks = _leaksOfAllTypes ();
34
+ final LeakReport leak = leaks.notDisposed.first;
35
+ leaks.notDisposed.add (leak);
36
+
37
+ final LeakTrackingTestConfig config = LeakTrackingTestConfig (
38
+ notDisposedAllowList: < String , int ? > {leak.type: 1 },
39
+ );
40
+ leaks = LeakCleaner (config).clean (leaks);
41
+
42
+ expect (leaks.notDisposed, hasLength (2 ));
43
+ });
44
+
45
+ group ('Leak tracking works for non-web, and' , () {
33
46
testWidgetsWithLeakTracking (
34
- 'Leak tracker respects all allow lists' ,
47
+ 'respects all allow lists' ,
35
48
(WidgetTester tester) async {
36
49
await tester.pumpWidget (_StatelessLeakingWidget ());
37
50
},
@@ -41,7 +54,41 @@ Future<void> main() async {
41
54
),
42
55
);
43
56
44
- group ('Leak tracker respects notGCed allow lists' , () {
57
+ testWidgetsWithLeakTracking (
58
+ 'respects count in allow lists' ,
59
+ (WidgetTester tester) async {
60
+ await tester.pumpWidget (_StatelessLeakingWidget ());
61
+ },
62
+ leakTrackingConfig: LeakTrackingTestConfig (
63
+ notDisposedAllowList: < String , int ? > {_leakTrackedClassName: 1 },
64
+ notGCedAllowList: < String , int ? > {_leakTrackedClassName: 1 },
65
+ ),
66
+ );
67
+
68
+ group ('fails if number or leaks is more than allowed' , () {
69
+ // This test cannot run inside other tests because test nesting is forbidden.
70
+ // So, `expect` happens outside the tests, in `tearDown`.
71
+ late Leaks leaks;
72
+
73
+ testWidgetsWithLeakTracking (
74
+ 'for $_StatelessLeakingWidget ' ,
75
+ (WidgetTester tester) async {
76
+ await tester.pumpWidget (_StatelessLeakingWidget ());
77
+ await tester.pumpWidget (_StatelessLeakingWidget ());
78
+ },
79
+ leakTrackingConfig: LeakTrackingTestConfig (
80
+ onLeaks: (Leaks theLeaks) {
81
+ leaks = theLeaks;
82
+ },
83
+ failTestOnLeaks: false ,
84
+ notDisposedAllowList: < String , int ? > {_leakTrackedClassName: 1 },
85
+ ),
86
+ );
87
+
88
+ tearDown (() => _verifyLeaks (leaks, expectedNotDisposed: 2 ));
89
+ });
90
+
91
+ group ('respects notGCed allow lists' , () {
45
92
// These tests cannot run inside other tests because test nesting is forbidden.
46
93
// So, `expect` happens outside the tests, in `tearDown`.
47
94
late Leaks leaks;
@@ -63,8 +110,8 @@ Future<void> main() async {
63
110
tearDown (() => _verifyLeaks (leaks, expectedNotDisposed: 1 ));
64
111
});
65
112
66
- group ('Leak tracker catches that' , () {
67
- // These tests cannot run inside other tests because test nesting is forbidden.
113
+ group ('catches that' , () {
114
+ // These test cannot run inside other tests because test nesting is forbidden.
68
115
// So, `expect` happens outside the tests, in `tearDown`.
69
116
late Leaks leaks;
70
117
0 commit comments