55import 'package:file/file.dart' ;
66import 'package:flutter_tools/src/tester/flutter_tester.dart' ;
77import 'package:flutter_tools/src/web/web_device.dart' show GoogleChromeDevice;
8+ import 'package:vm_service/vm_service.dart' ;
89
910import '../../src/common.dart' ;
1011import '../test_driver.dart' ;
@@ -34,7 +35,7 @@ void testAll({
3435 });
3536
3637 testWithoutContext (
37- 'hot reload displays a formatted error message when removing a field from a const class' ,
38+ 'hot reload displays a formatted error message when removing a field from a const class, and hot restart succeeds ' ,
3839 () async {
3940 await flutter.run (
4041 device:
@@ -53,16 +54,45 @@ void testAll({
5354 ),
5455 ),
5556 );
57+ await expectLater (flutter.hotRestart (), completes);
5658 },
5759 );
5860
59- testWithoutContext ('hot restart succeeds when removing a field from a const class' , () async {
60- await flutter.run (
61- device: chrome ? GoogleChromeDevice .kChromeDeviceId : FlutterTesterDevices .kTesterDeviceId,
62- additionalCommandArgs: additionalCommandArgs,
63- );
64- project.removeFieldFromConstClass ();
65- await expectLater (flutter.hotRestart (), completes);
66- });
61+ testWithoutContext (
62+ 'Expression evaluation succeeds after a hot reload rejection error' ,
63+ () async {
64+ await flutter.run (
65+ device:
66+ chrome ? GoogleChromeDevice .kChromeDeviceId : FlutterTesterDevices .kTesterDeviceId,
67+ withDebugger: true ,
68+ additionalCommandArgs: additionalCommandArgs,
69+ );
70+ project.removeFieldFromConstClass ();
71+ await expectLater (
72+ flutter.hotReload (),
73+ throwsA (
74+ isA <Exception >().having (
75+ (Exception e) => e.toString (),
76+ 'message' ,
77+ contains ('Try performing a hot restart instead.' ),
78+ ),
79+ ),
80+ );
81+ final LibraryRef library = (await flutter.getFlutterIsolate ()).libraries! .firstWhere (
82+ (LibraryRef l) => l.uri! .contains ('package:test/main.dart' ),
83+ );
84+ final ObjRef result = await flutter.evaluate (library.id! , '42.isEven' );
85+ expect (
86+ result,
87+ const TypeMatcher <InstanceRef >()
88+ .having ((InstanceRef instance) => instance.kind, 'kind' , InstanceKind .kBool)
89+ .having (
90+ (InstanceRef instance) => instance.valueAsString,
91+ 'valueAsString' ,
92+ true .toString (),
93+ ),
94+ );
95+ },
96+ );
6797 });
6898}
0 commit comments