Skip to content

Commit 3caa48b

Browse files
authored
[go_router] Migrates test for leak testing (#10276)
migrating test for flutter/flutter#176519 ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent db53dae commit 3caa48b

File tree

1 file changed

+32
-24
lines changed

1 file changed

+32
-24
lines changed

packages/go_router/test/extra_codec_test.dart

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'dart:convert';
77
import 'package:flutter/material.dart';
88
import 'package:flutter_test/flutter_test.dart';
99
import 'package:go_router/go_router.dart';
10+
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
1011

1112
import 'test_helpers.dart';
1213

@@ -52,33 +53,40 @@ void main() {
5253
expect(find.text(initialString), findsOneWidget);
5354
});
5455

55-
testWidgets('Restores state correctly', (WidgetTester tester) async {
56-
const String initialString = 'some string';
57-
const String empty = 'empty';
58-
final List<RouteBase> routes = <RouteBase>[
59-
GoRoute(
60-
path: '/',
61-
builder: (_, GoRouterState state) {
62-
return Text((state.extra as ComplexData?)?.data ?? empty);
63-
},
64-
),
65-
];
56+
testWidgets(
57+
'Restores state correctly',
58+
(WidgetTester tester) async {
59+
const String initialString = 'some string';
60+
const String empty = 'empty';
61+
final List<RouteBase> routes = <RouteBase>[
62+
GoRoute(
63+
path: '/',
64+
builder: (_, GoRouterState state) {
65+
return Text((state.extra as ComplexData?)?.data ?? empty);
66+
},
67+
),
68+
];
6669

67-
await createRouter(
68-
routes,
69-
tester,
70-
initialExtra: ComplexData(initialString),
71-
restorationScopeId: 'test',
72-
extraCodec: ComplexDataCodec(),
73-
);
74-
expect(find.text(initialString), findsOneWidget);
70+
await createRouter(
71+
routes,
72+
tester,
73+
initialExtra: ComplexData(initialString),
74+
restorationScopeId: 'test',
75+
extraCodec: ComplexDataCodec(),
76+
);
77+
expect(find.text(initialString), findsOneWidget);
7578

76-
await tester.restartAndRestore();
77-
addTearDown(tester.binding.restorationManager.dispose);
79+
await tester.restartAndRestore();
7880

79-
await tester.pumpAndSettle();
80-
expect(find.text(initialString), findsOneWidget);
81-
});
81+
await tester.pumpAndSettle();
82+
expect(find.text(initialString), findsOneWidget);
83+
},
84+
// TODO(hgraceb): Remove when minimum flutter version includes
85+
// https://github.com/flutter/flutter/pull/176519
86+
experimentalLeakTesting: LeakTesting.settings.withIgnored(
87+
classes: const <String>['TestRestorationManager', 'RestorationBucket'],
88+
),
89+
);
8290
}
8391

8492
class ComplexData {

0 commit comments

Comments
 (0)