Skip to content

Commit

Permalink
[go_router] Activate leak testing (flutter#7546)
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinVignal authored Nov 7, 2024
1 parent 0105013 commit 6d6cc9a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/go_router/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dev_dependencies:
flutter_test:
sdk: flutter
io: ^1.0.4
leak_tracker_flutter_testing: any
path: ^1.8.2

topics:
Expand Down
1 change: 1 addition & 0 deletions packages/go_router/test/extra_codec_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ void main() {
expect(find.text(initialString), findsOneWidget);

await tester.restartAndRestore();
addTearDown(tester.binding.restorationManager.dispose);

await tester.pumpAndSettle();
expect(find.text(initialString), findsOneWidget);
Expand Down
13 changes: 13 additions & 0 deletions packages/go_router/test/flutter_test_config.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';

import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';

Future<void> testExecutable(FutureOr<void> Function() testMain) async {
LeakTesting.enable();
LeakTracking.warnForUnsupportedPlatforms = false;
await testMain();
}
1 change: 1 addition & 0 deletions packages/go_router/test/go_router_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5458,6 +5458,7 @@ void main() {
),
],
);
addTearDown(router.dispose);
await tester.pumpWidget(
MaterialApp.router(
key: UniqueKey(),
Expand Down
6 changes: 6 additions & 0 deletions packages/go_router/test/information_provider_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ void main() {
late final GoRouteInformationProvider provider =
GoRouteInformationProvider(
initialLocation: initialRoute, initialExtra: null);
addTearDown(provider.dispose);
provider.addListener(expectAsync0(() {}));
provider.go(newRoute);
});
Expand All @@ -26,6 +27,7 @@ void main() {
late final GoRouteInformationProvider provider =
GoRouteInformationProvider(
initialLocation: initialRoute, initialExtra: null);
addTearDown(provider.dispose);
provider.addListener(expectAsync0(() {}));
provider
.didPushRouteInformation(RouteInformation(uri: Uri.parse(newRoute)));
Expand All @@ -41,6 +43,7 @@ void main() {
late final GoRouteInformationProvider provider =
GoRouteInformationProvider(
initialLocation: initialRoute, initialExtra: null);
addTearDown(provider.dispose);
provider.addListener(expectAsync0(() {}));
provider.didPushRouteInformation(
RouteInformation(uri: Uri.parse(expectedUriString)));
Expand All @@ -60,6 +63,7 @@ void main() {
late final GoRouteInformationProvider provider =
GoRouteInformationProvider(
initialLocation: initialRoute, initialExtra: null);
addTearDown(provider.dispose);
provider.addListener(expectAsync0(() {}));
provider.didPushRouteInformation(
RouteInformation(uri: Uri.parse(expectedUriString)));
Expand All @@ -78,6 +82,7 @@ void main() {
initialLocation: initialRoute,
initialExtra: null,
routerNeglect: true);
addTearDown(provider.dispose);
provider.addListener(expectAsync0(() {}));
provider.go(newRoute);
provider.routerReportsNewRouteInformation(
Expand All @@ -94,6 +99,7 @@ void main() {
late final GoRouteInformationProvider provider =
GoRouteInformationProvider(
initialLocation: initialRoute, initialExtra: null);
addTearDown(provider.dispose);
provider.addListener(expectAsync0(() {}));
provider.go(newRoute);
provider.routerReportsNewRouteInformation(
Expand Down
1 change: 1 addition & 0 deletions script/configs/allowed_unpinned_deps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
- io
- js
- json_serializable
- leak_tracker_flutter_testing
- lints
- logging
- markdown
Expand Down

0 comments on commit 6d6cc9a

Please sign in to comment.