Skip to content

Commit cdc3fd9

Browse files
goderbauernploi
authored andcommitted
[go_router] Migrate tests away from old handlePlatformMessage (flutter#3599)
[go_router] Migrate tests away from old handlePlatformMessage
1 parent 6274556 commit cdc3fd9

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

packages/go_router/example/test/path_and_query_params_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ void main() {
1818
ByteData message = const JSONMethodCodec().encodeMethodCall(
1919
MethodCall('pushRouteInformation', testRouteInformation),
2020
);
21-
await ServicesBinding.instance.defaultBinaryMessenger
21+
await tester.binding.defaultBinaryMessenger
2222
.handlePlatformMessage('flutter/navigation', message, (_) {});
2323

2424
await tester.pumpAndSettle();
@@ -34,7 +34,7 @@ void main() {
3434
message = const JSONMethodCodec().encodeMethodCall(
3535
MethodCall('pushRouteInformation', testRouteInformation),
3636
);
37-
await ServicesBinding.instance.defaultBinaryMessenger
37+
await tester.binding.defaultBinaryMessenger
3838
.handlePlatformMessage('flutter/navigation', message, (_) {});
3939

4040
await tester.pumpAndSettle();

packages/go_router/example/test/redirection_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void main() {
1919
ByteData message = const JSONMethodCodec().encodeMethodCall(
2020
MethodCall('pushRouteInformation', testRouteInformation),
2121
);
22-
await ServicesBinding.instance.defaultBinaryMessenger
22+
await tester.binding.defaultBinaryMessenger
2323
.handlePlatformMessage('flutter/navigation', message, (_) {});
2424

2525
await tester.pumpAndSettle();
@@ -36,7 +36,7 @@ void main() {
3636
message = const JSONMethodCodec().encodeMethodCall(
3737
MethodCall('pushRouteInformation', testRouteInformation),
3838
);
39-
await ServicesBinding.instance.defaultBinaryMessenger
39+
await tester.binding.defaultBinaryMessenger
4040
.handlePlatformMessage('flutter/navigation', message, (_) {});
4141

4242
await tester.pumpAndSettle();

packages/go_router/test/go_router_test.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ import 'test_helpers.dart';
2121
const bool enableLogs = false;
2222
final Logger log = Logger('GoRouter tests');
2323

24-
Future<void> sendPlatformUrl(String url) async {
24+
Future<void> sendPlatformUrl(String url, WidgetTester tester) async {
2525
final Map<String, dynamic> testRouteInformation = <String, dynamic>{
2626
'location': url,
2727
};
2828
final ByteData message = const JSONMethodCodec().encodeMethodCall(
2929
MethodCall('pushRouteInformation', testRouteInformation),
3030
);
31-
await ServicesBinding.instance.defaultBinaryMessenger
31+
await tester.binding.defaultBinaryMessenger
3232
.handlePlatformMessage('flutter/navigation', message, (_) {});
3333
}
3434

@@ -1495,7 +1495,7 @@ void main() {
14951495

14961496
redirected = false;
14971497
// Directly set the url through platform message.
1498-
await sendPlatformUrl('/dummy');
1498+
await sendPlatformUrl('/dummy', tester);
14991499

15001500
await tester.pumpAndSettle();
15011501
expect(router.location, '/login');
@@ -1528,7 +1528,7 @@ void main() {
15281528

15291529
expect(router.location, '/');
15301530
// Directly set the url through platform message.
1531-
await sendPlatformUrl('/dummy');
1531+
await sendPlatformUrl('/dummy', tester);
15321532
await tester.pumpAndSettle();
15331533
expect(router.location, '/dummy');
15341534
});
@@ -1631,7 +1631,7 @@ void main() {
16311631
});
16321632
redirected = false;
16331633
// Directly set the url through platform message.
1634-
await sendPlatformUrl('/dummy');
1634+
await sendPlatformUrl('/dummy', tester);
16351635

16361636
await tester.pumpAndSettle();
16371637
expect(router.location, '/login');
@@ -2024,7 +2024,7 @@ void main() {
20242024
final GoRouter router = await createRouter(routes, tester);
20252025

20262026
// Directly set the url through platform message.
2027-
await sendPlatformUrl('/dummy/dummy2');
2027+
await sendPlatformUrl('/dummy/dummy2', tester);
20282028

20292029
await tester.pumpAndSettle();
20302030
expect(router.location, '/other');

0 commit comments

Comments
 (0)