Skip to content

Commit 6d6cc9a

Browse files
[go_router] Activate leak testing (#7546)
1 parent 0105013 commit 6d6cc9a

File tree

6 files changed

+23
-0
lines changed

6 files changed

+23
-0
lines changed

packages/go_router/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ dev_dependencies:
2222
flutter_test:
2323
sdk: flutter
2424
io: ^1.0.4
25+
leak_tracker_flutter_testing: any
2526
path: ^1.8.2
2627

2728
topics:

packages/go_router/test/extra_codec_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ void main() {
7474
expect(find.text(initialString), findsOneWidget);
7575

7676
await tester.restartAndRestore();
77+
addTearDown(tester.binding.restorationManager.dispose);
7778

7879
await tester.pumpAndSettle();
7980
expect(find.text(initialString), findsOneWidget);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
8+
9+
Future<void> testExecutable(FutureOr<void> Function() testMain) async {
10+
LeakTesting.enable();
11+
LeakTracking.warnForUnsupportedPlatforms = false;
12+
await testMain();
13+
}

packages/go_router/test/go_router_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5458,6 +5458,7 @@ void main() {
54585458
),
54595459
],
54605460
);
5461+
addTearDown(router.dispose);
54615462
await tester.pumpWidget(
54625463
MaterialApp.router(
54635464
key: UniqueKey(),

packages/go_router/test/information_provider_test.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ void main() {
1717
late final GoRouteInformationProvider provider =
1818
GoRouteInformationProvider(
1919
initialLocation: initialRoute, initialExtra: null);
20+
addTearDown(provider.dispose);
2021
provider.addListener(expectAsync0(() {}));
2122
provider.go(newRoute);
2223
});
@@ -26,6 +27,7 @@ void main() {
2627
late final GoRouteInformationProvider provider =
2728
GoRouteInformationProvider(
2829
initialLocation: initialRoute, initialExtra: null);
30+
addTearDown(provider.dispose);
2931
provider.addListener(expectAsync0(() {}));
3032
provider
3133
.didPushRouteInformation(RouteInformation(uri: Uri.parse(newRoute)));
@@ -41,6 +43,7 @@ void main() {
4143
late final GoRouteInformationProvider provider =
4244
GoRouteInformationProvider(
4345
initialLocation: initialRoute, initialExtra: null);
46+
addTearDown(provider.dispose);
4447
provider.addListener(expectAsync0(() {}));
4548
provider.didPushRouteInformation(
4649
RouteInformation(uri: Uri.parse(expectedUriString)));
@@ -60,6 +63,7 @@ void main() {
6063
late final GoRouteInformationProvider provider =
6164
GoRouteInformationProvider(
6265
initialLocation: initialRoute, initialExtra: null);
66+
addTearDown(provider.dispose);
6367
provider.addListener(expectAsync0(() {}));
6468
provider.didPushRouteInformation(
6569
RouteInformation(uri: Uri.parse(expectedUriString)));
@@ -78,6 +82,7 @@ void main() {
7882
initialLocation: initialRoute,
7983
initialExtra: null,
8084
routerNeglect: true);
85+
addTearDown(provider.dispose);
8186
provider.addListener(expectAsync0(() {}));
8287
provider.go(newRoute);
8388
provider.routerReportsNewRouteInformation(
@@ -94,6 +99,7 @@ void main() {
9499
late final GoRouteInformationProvider provider =
95100
GoRouteInformationProvider(
96101
initialLocation: initialRoute, initialExtra: null);
102+
addTearDown(provider.dispose);
97103
provider.addListener(expectAsync0(() {}));
98104
provider.go(newRoute);
99105
provider.routerReportsNewRouteInformation(

script/configs/allowed_unpinned_deps.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
- io
4646
- js
4747
- json_serializable
48+
- leak_tracker_flutter_testing
4849
- lints
4950
- logging
5051
- markdown

0 commit comments

Comments
 (0)