@@ -268,7 +268,11 @@ void main() {
268268
269269 const String testRouteName = 'testRouteName' ;
270270 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 );
272276 expect (observer.pushedRoute, testRouteName);
273277
274278 WidgetsBinding .instance.removeObserver (observer);
@@ -286,8 +290,11 @@ void main() {
286290 final ByteData message = const JSONMethodCodec ().encodeMethodCall (
287291 const MethodCall ('pushRouteInformation' , testRouteInformation),
288292 );
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 );
291298 expect (observer.pushedRoute, 'testRouteName' );
292299 WidgetsBinding .instance.removeObserver (observer);
293300 });
@@ -377,6 +384,49 @@ void main() {
377384 WidgetsBinding .instance.removeObserver (observer);
378385 });
379386
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+ });
380430 testWidgets ('Application lifecycle affects frame scheduling' , (WidgetTester tester) async {
381431 expect (tester.binding.hasScheduledFrame, isFalse);
382432
0 commit comments