@@ -268,7 +268,11 @@ void main() {
268
268
269
269
const String testRouteName = 'testRouteName' ;
270
270
final ByteData message = const JSONMethodCodec ().encodeMethodCall (const MethodCall ('pushRoute' , testRouteName));
271
- await tester.binding.defaultBinaryMessenger.handlePlatformMessage ('flutter/navigation' , message, (_) {});
271
+ final ByteData result = (await tester.binding.defaultBinaryMessenger
272
+ .handlePlatformMessage ('flutter/navigation' , message, (_) {}))! ;
273
+ final bool decodedResult = const JSONMethodCodec ().decodeEnvelope (result) as bool ;
274
+
275
+ expect (decodedResult, true );
272
276
expect (observer.pushedRoute, testRouteName);
273
277
274
278
WidgetsBinding .instance.removeObserver (observer);
@@ -286,8 +290,11 @@ void main() {
286
290
final ByteData message = const JSONMethodCodec ().encodeMethodCall (
287
291
const MethodCall ('pushRouteInformation' , testRouteInformation),
288
292
);
289
- await tester.binding.defaultBinaryMessenger
290
- .handlePlatformMessage ('flutter/navigation' , message, (_) {});
293
+ final ByteData result = (await tester.binding.defaultBinaryMessenger
294
+ .handlePlatformMessage ('flutter/navigation' , message, (_) {}))! ;
295
+ final bool decodedResult = const JSONMethodCodec ().decodeEnvelope (result) as bool ;
296
+
297
+ expect (decodedResult, true );
291
298
expect (observer.pushedRoute, 'testRouteName' );
292
299
WidgetsBinding .instance.removeObserver (observer);
293
300
});
@@ -377,6 +384,49 @@ void main() {
377
384
WidgetsBinding .instance.removeObserver (observer);
378
385
});
379
386
387
+ testWidgets ('pushRouteInformation not handled by observer returns false' , (WidgetTester tester) async {
388
+
389
+ const Map <String , dynamic > testRouteInformation = < String , dynamic > {
390
+ 'location' : 'testRouteName' ,
391
+ 'state' : null ,
392
+ };
393
+ final ByteData message = const JSONMethodCodec ().encodeMethodCall (
394
+ const MethodCall ('pushRouteInformation' , testRouteInformation),
395
+ );
396
+
397
+ final ByteData result = (await tester.binding.defaultBinaryMessenger
398
+ .handlePlatformMessage ('flutter/navigation' , message, (_) {}))! ;
399
+ final bool decodedResult = const JSONMethodCodec ().decodeEnvelope (result) as bool ;
400
+
401
+ expect (decodedResult, false );
402
+ });
403
+
404
+ testWidgets ('pushRoute not handled by observer returns false' , (WidgetTester tester) async {
405
+
406
+ const String testRoute = 'testRouteName' ;
407
+ final ByteData message = const JSONMethodCodec ().encodeMethodCall (
408
+ const MethodCall ('pushRoute' , testRoute),
409
+ );
410
+
411
+ final ByteData result = (await tester.binding.defaultBinaryMessenger
412
+ .handlePlatformMessage ('flutter/navigation' , message, (_) {}))! ;
413
+ final bool decodedResult = const JSONMethodCodec ().decodeEnvelope (result) as bool ;
414
+
415
+ expect (decodedResult, false );
416
+ });
417
+
418
+
419
+ testWidgets ('popRoute not handled by observer returns false' , (WidgetTester tester) async {
420
+ final ByteData message = const JSONMethodCodec ().encodeMethodCall (
421
+ const MethodCall ('popRoute' ),
422
+ );
423
+
424
+ final ByteData result = (await tester.binding.defaultBinaryMessenger
425
+ .handlePlatformMessage ('flutter/navigation' , message, (_) {}))! ;
426
+ final bool decodedResult = const JSONMethodCodec ().decodeEnvelope (result) as bool ;
427
+
428
+ expect (decodedResult, false );
429
+ });
380
430
testWidgets ('Application lifecycle affects frame scheduling' , (WidgetTester tester) async {
381
431
expect (tester.binding.hasScheduledFrame, isFalse);
382
432
0 commit comments