5
5
import 'package:flutter/material.dart' ;
6
6
import 'package:flutter/rendering.dart' ;
7
7
import 'package:flutter_test/flutter_test.dart' ;
8
+ import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart' ;
8
9
9
10
void main () {
10
11
@@ -20,9 +21,11 @@ void main() {
20
21
);
21
22
}
22
23
23
- testWidgets ('updates its registrar and delegate based on the number of selectables' , (WidgetTester tester) async {
24
+ testWidgetsWithLeakTracking ('updates its registrar and delegate based on the number of selectables' , (WidgetTester tester) async {
24
25
final TestSelectionRegistrar registrar = TestSelectionRegistrar ();
25
26
final TestContainerDelegate delegate = TestContainerDelegate ();
27
+ addTearDown (delegate.dispose);
28
+
26
29
await pumpContainer (
27
30
tester,
28
31
SelectionContainer (
@@ -42,9 +45,11 @@ void main() {
42
45
expect (delegate.selectables.length, 3 );
43
46
});
44
47
45
- testWidgets ('disabled container' , (WidgetTester tester) async {
48
+ testWidgetsWithLeakTracking ('disabled container' , (WidgetTester tester) async {
46
49
final TestSelectionRegistrar registrar = TestSelectionRegistrar ();
47
50
final TestContainerDelegate delegate = TestContainerDelegate ();
51
+ addTearDown (delegate.dispose);
52
+
48
53
await pumpContainer (
49
54
tester,
50
55
SelectionContainer (
@@ -65,10 +70,13 @@ void main() {
65
70
expect (delegate.selectables.length, 0 );
66
71
});
67
72
68
- testWidgets ('Swapping out container delegate does not crash' , (WidgetTester tester) async {
73
+ testWidgetsWithLeakTracking ('Swapping out container delegate does not crash' , (WidgetTester tester) async {
69
74
final TestSelectionRegistrar registrar = TestSelectionRegistrar ();
70
75
final TestContainerDelegate delegate = TestContainerDelegate ();
76
+ addTearDown (delegate.dispose);
71
77
final TestContainerDelegate childDelegate = TestContainerDelegate ();
78
+ addTearDown (childDelegate.dispose);
79
+
72
80
await pumpContainer (
73
81
tester,
74
82
SelectionContainer (
@@ -90,6 +98,8 @@ void main() {
90
98
expect (delegate.value.hasContent, isTrue);
91
99
92
100
final TestContainerDelegate newDelegate = TestContainerDelegate ();
101
+ addTearDown (newDelegate.dispose);
102
+
93
103
await pumpContainer (
94
104
tester,
95
105
SelectionContainer (
@@ -112,10 +122,13 @@ void main() {
112
122
expect (tester.takeException (), isNull);
113
123
});
114
124
115
- testWidgets ('Can update within one frame' , (WidgetTester tester) async {
125
+ testWidgetsWithLeakTracking ('Can update within one frame' , (WidgetTester tester) async {
116
126
final TestSelectionRegistrar registrar = TestSelectionRegistrar ();
117
127
final TestContainerDelegate delegate = TestContainerDelegate ();
128
+ addTearDown (delegate.dispose);
118
129
final TestContainerDelegate childDelegate = TestContainerDelegate ();
130
+ addTearDown (childDelegate.dispose);
131
+
119
132
await pumpContainer (
120
133
tester,
121
134
SelectionContainer (
@@ -139,9 +152,11 @@ void main() {
139
152
expect (delegate.value.hasContent, isTrue);
140
153
});
141
154
142
- testWidgets ('selection container registers itself if there is a selectable child' , (WidgetTester tester) async {
155
+ testWidgetsWithLeakTracking ('selection container registers itself if there is a selectable child' , (WidgetTester tester) async {
143
156
final TestSelectionRegistrar registrar = TestSelectionRegistrar ();
144
157
final TestContainerDelegate delegate = TestContainerDelegate ();
158
+ addTearDown (delegate.dispose);
159
+
145
160
await pumpContainer (
146
161
tester,
147
162
SelectionContainer (
@@ -181,9 +196,10 @@ void main() {
181
196
expect (registrar.selectables.length, 0 );
182
197
});
183
198
184
- testWidgets ('selection container gets registrar from context if not provided' , (WidgetTester tester) async {
199
+ testWidgetsWithLeakTracking ('selection container gets registrar from context if not provided' , (WidgetTester tester) async {
185
200
final TestSelectionRegistrar registrar = TestSelectionRegistrar ();
186
201
final TestContainerDelegate delegate = TestContainerDelegate ();
202
+ addTearDown (delegate.dispose);
187
203
188
204
await pumpContainer (
189
205
tester,
0 commit comments