@@ -40,7 +40,7 @@ void main() {
40
40
expect (find.widgetWithText (Navigator , 'foo' ), findsOneWidget);
41
41
});
42
42
43
- testWidgets ('Has default cupertino localizations' , (WidgetTester tester) async {
43
+ testWidgetsWithLeakTracking ('Has default cupertino localizations' , (WidgetTester tester) async {
44
44
await tester.pumpWidget (
45
45
CupertinoApp (
46
46
home: Builder (
@@ -62,7 +62,7 @@ void main() {
62
62
expect (find.text ('Thu Oct 4 ' ), findsOneWidget);
63
63
});
64
64
65
- testWidgets ('Can use dynamic color' , (WidgetTester tester) async {
65
+ testWidgetsWithLeakTracking ('Can use dynamic color' , (WidgetTester tester) async {
66
66
const CupertinoDynamicColor dynamicColor = CupertinoDynamicColor .withBrightness (
67
67
color: Color (0xFF000000 ),
68
68
darkColor: Color (0xFF000001 ),
@@ -84,7 +84,7 @@ void main() {
84
84
expect (tester.widget <Title >(find.byType (Title )).color.value, 0xFF000001 );
85
85
});
86
86
87
- testWidgets ('Can customize initial routes' , (WidgetTester tester) async {
87
+ testWidgetsWithLeakTracking ('Can customize initial routes' , (WidgetTester tester) async {
88
88
final GlobalKey <NavigatorState > navigatorKey = GlobalKey <NavigatorState >();
89
89
await tester.pumpWidget (
90
90
CupertinoApp (
@@ -131,7 +131,7 @@ void main() {
131
131
expect (find.text ('regular page two' ), findsNothing);
132
132
});
133
133
134
- testWidgets ('CupertinoApp.navigatorKey can be updated' , (WidgetTester tester) async {
134
+ testWidgetsWithLeakTracking ('CupertinoApp.navigatorKey can be updated' , (WidgetTester tester) async {
135
135
final GlobalKey <NavigatorState > key1 = GlobalKey <NavigatorState >();
136
136
await tester.pumpWidget (CupertinoApp (
137
137
navigatorKey: key1,
@@ -147,12 +147,13 @@ void main() {
147
147
expect (key1.currentState, isNull);
148
148
});
149
149
150
- testWidgets ('CupertinoApp.router works' , (WidgetTester tester) async {
150
+ testWidgetsWithLeakTracking ('CupertinoApp.router works' , (WidgetTester tester) async {
151
151
final PlatformRouteInformationProvider provider = PlatformRouteInformationProvider (
152
152
initialRouteInformation: RouteInformation (
153
153
uri: Uri .parse ('initial' ),
154
154
),
155
155
);
156
+ addTearDown (provider.dispose);
156
157
final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate (
157
158
builder: (BuildContext context, RouteInformation information) {
158
159
return Text (information.uri.toString ());
@@ -164,6 +165,7 @@ void main() {
164
165
return route.didPop (result);
165
166
},
166
167
);
168
+ addTearDown (delegate.dispose);
167
169
await tester.pumpWidget (CupertinoApp .router (
168
170
routeInformationProvider: provider,
169
171
routeInformationParser: SimpleRouteInformationParser (),
@@ -176,9 +178,14 @@ void main() {
176
178
await tester.binding.defaultBinaryMessenger.handlePlatformMessage ('flutter/navigation' , message, (_) { });
177
179
await tester.pumpAndSettle ();
178
180
expect (find.text ('popped' ), findsOneWidget);
179
- });
180
-
181
- testWidgets ('CupertinoApp.router route information parser is optional' , (WidgetTester tester) async {
181
+ },
182
+ // TODO(polina-c): remove after fixing
183
+ // https://github.com/flutter/flutter/issues/134205
184
+ leakTrackingTestConfig: const LeakTrackingTestConfig (
185
+ allowAllNotDisposed: true ,
186
+ ));
187
+
188
+ testWidgetsWithLeakTracking ('CupertinoApp.router route information parser is optional' , (WidgetTester tester) async {
182
189
final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate (
183
190
builder: (BuildContext context, RouteInformation information) {
184
191
return Text (information.uri.toString ());
@@ -190,6 +197,7 @@ void main() {
190
197
return route.didPop (result);
191
198
},
192
199
);
200
+ addTearDown (delegate.dispose);
193
201
delegate.routeInformation = RouteInformation (uri: Uri .parse ('initial' ));
194
202
await tester.pumpWidget (CupertinoApp .router (
195
203
routerDelegate: delegate,
@@ -201,9 +209,14 @@ void main() {
201
209
await tester.binding.defaultBinaryMessenger.handlePlatformMessage ('flutter/navigation' , message, (_) { });
202
210
await tester.pumpAndSettle ();
203
211
expect (find.text ('popped' ), findsOneWidget);
204
- });
205
-
206
- testWidgets ('CupertinoApp.router throw if route information provider is provided but no route information parser' , (WidgetTester tester) async {
212
+ },
213
+ // TODO(polina-c): remove after fixing
214
+ // https://github.com/flutter/flutter/issues/134205
215
+ leakTrackingTestConfig: const LeakTrackingTestConfig (
216
+ allowAllNotDisposed: true ,
217
+ ));
218
+
219
+ testWidgetsWithLeakTracking ('CupertinoApp.router throw if route information provider is provided but no route information parser' , (WidgetTester tester) async {
207
220
final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate (
208
221
builder: (BuildContext context, RouteInformation information) {
209
222
return Text (information.uri.toString ());
@@ -215,20 +228,22 @@ void main() {
215
228
return route.didPop (result);
216
229
},
217
230
);
231
+ addTearDown (delegate.dispose);
218
232
delegate.routeInformation = RouteInformation (uri: Uri .parse ('initial' ));
219
233
final PlatformRouteInformationProvider provider = PlatformRouteInformationProvider (
220
234
initialRouteInformation: RouteInformation (
221
235
uri: Uri .parse ('initial' ),
222
236
),
223
237
);
238
+ addTearDown (provider.dispose);
224
239
await tester.pumpWidget (CupertinoApp .router (
225
240
routeInformationProvider: provider,
226
241
routerDelegate: delegate,
227
242
));
228
243
expect (tester.takeException (), isAssertionError);
229
244
});
230
245
231
- testWidgets ('CupertinoApp.router throw if route configuration is provided along with other delegate' , (WidgetTester tester) async {
246
+ testWidgetsWithLeakTracking ('CupertinoApp.router throw if route configuration is provided along with other delegate' , (WidgetTester tester) async {
232
247
final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate (
233
248
builder: (BuildContext context, RouteInformation information) {
234
249
return Text (information.uri.toString ());
@@ -240,6 +255,7 @@ void main() {
240
255
return route.didPop (result);
241
256
},
242
257
);
258
+ addTearDown (delegate.dispose);
243
259
delegate.routeInformation = RouteInformation (uri: Uri .parse ('initial' ));
244
260
final RouterConfig <RouteInformation > routerConfig = RouterConfig <RouteInformation >(routerDelegate: delegate);
245
261
await tester.pumpWidget (CupertinoApp .router (
@@ -249,15 +265,19 @@ void main() {
249
265
expect (tester.takeException (), isAssertionError);
250
266
});
251
267
252
- testWidgets ('CupertinoApp.router router config works' , (WidgetTester tester) async {
268
+ testWidgetsWithLeakTracking ('CupertinoApp.router router config works' , (WidgetTester tester) async {
269
+ late SimpleNavigatorRouterDelegate delegate;
270
+ addTearDown (() => delegate.dispose ());
271
+ final PlatformRouteInformationProvider provider = PlatformRouteInformationProvider (
272
+ initialRouteInformation: RouteInformation (
273
+ uri: Uri .parse ('initial' ),
274
+ ),
275
+ );
276
+ addTearDown (provider.dispose);
253
277
final RouterConfig <RouteInformation > routerConfig = RouterConfig <RouteInformation >(
254
- routeInformationProvider: PlatformRouteInformationProvider (
255
- initialRouteInformation: RouteInformation (
256
- uri: Uri .parse ('initial' ),
257
- ),
258
- ),
278
+ routeInformationProvider: provider,
259
279
routeInformationParser: SimpleRouteInformationParser (),
260
- routerDelegate: SimpleNavigatorRouterDelegate (
280
+ routerDelegate: delegate = SimpleNavigatorRouterDelegate (
261
281
builder: (BuildContext context, RouteInformation information) {
262
282
return Text (information.uri.toString ());
263
283
},
@@ -280,9 +300,14 @@ void main() {
280
300
await tester.binding.defaultBinaryMessenger.handlePlatformMessage ('flutter/navigation' , message, (_) { });
281
301
await tester.pumpAndSettle ();
282
302
expect (find.text ('popped' ), findsOneWidget);
283
- });
284
-
285
- testWidgets ('CupertinoApp has correct default ScrollBehavior' , (WidgetTester tester) async {
303
+ },
304
+ // TODO(polina-c): remove after fixing
305
+ // https://github.com/flutter/flutter/issues/134205
306
+ leakTrackingTestConfig: const LeakTrackingTestConfig (
307
+ allowAllNotDisposed: true ,
308
+ ));
309
+
310
+ testWidgetsWithLeakTracking ('CupertinoApp has correct default ScrollBehavior' , (WidgetTester tester) async {
286
311
late BuildContext capturedContext;
287
312
await tester.pumpWidget (
288
313
CupertinoApp (
@@ -297,7 +322,7 @@ void main() {
297
322
expect (ScrollConfiguration .of (capturedContext).runtimeType, CupertinoScrollBehavior );
298
323
});
299
324
300
- testWidgets ('A ScrollBehavior can be set for CupertinoApp' , (WidgetTester tester) async {
325
+ testWidgetsWithLeakTracking ('A ScrollBehavior can be set for CupertinoApp' , (WidgetTester tester) async {
301
326
late BuildContext capturedContext;
302
327
await tester.pumpWidget (
303
328
CupertinoApp (
@@ -315,7 +340,7 @@ void main() {
315
340
expect (scrollBehavior.getScrollPhysics (capturedContext).runtimeType, NeverScrollableScrollPhysics );
316
341
});
317
342
318
- testWidgets ('When `useInheritedMediaQuery` is true an existing MediaQuery is used if one is available' , (WidgetTester tester) async {
343
+ testWidgetsWithLeakTracking ('When `useInheritedMediaQuery` is true an existing MediaQuery is used if one is available' , (WidgetTester tester) async {
319
344
late BuildContext capturedContext;
320
345
final UniqueKey uniqueKey = UniqueKey ();
321
346
await tester.pumpWidget (
@@ -335,7 +360,7 @@ void main() {
335
360
expect (capturedContext.dependOnInheritedWidgetOfExactType <MediaQuery >()? .key, uniqueKey);
336
361
});
337
362
338
- testWidgets ('Text color is correctly resolved when CupertinoThemeData.brightness is null' , (WidgetTester tester) async {
363
+ testWidgetsWithLeakTracking ('Text color is correctly resolved when CupertinoThemeData.brightness is null' , (WidgetTester tester) async {
339
364
debugBrightnessOverride = Brightness .dark;
340
365
341
366
await tester.pumpWidget (
@@ -374,7 +399,7 @@ void main() {
374
399
debugBrightnessOverride = null ;
375
400
});
376
401
377
- testWidgets ('Cursor color is resolved when CupertinoThemeData.brightness is null' , (WidgetTester tester) async {
402
+ testWidgetsWithLeakTracking ('Cursor color is resolved when CupertinoThemeData.brightness is null' , (WidgetTester tester) async {
378
403
debugBrightnessOverride = Brightness .dark;
379
404
380
405
RenderEditable findRenderEditable (WidgetTester tester) {
@@ -431,7 +456,7 @@ void main() {
431
456
debugBrightnessOverride = null ;
432
457
});
433
458
434
- testWidgets ('Assert in buildScrollbar that controller != null when using it' , (WidgetTester tester) async {
459
+ testWidgetsWithLeakTracking ('Assert in buildScrollbar that controller != null when using it' , (WidgetTester tester) async {
435
460
const ScrollBehavior defaultBehavior = CupertinoScrollBehavior ();
436
461
late BuildContext capturedContext;
437
462
0 commit comments