@@ -22,7 +22,6 @@ const String kReplacementLine = 'fontSize: (orientation == Orientation.portrait)
2222
2323TaskFunction createHotModeTest ({
2424 String ? deviceIdOverride,
25- Map <String , String >? environment,
2625 bool checkAppRunningOnLocalDevice = false ,
2726}) {
2827 // This file is modified during the test and needs to be restored at the end.
@@ -63,71 +62,83 @@ TaskFunction createHotModeTest({
6362
6463 try {
6564 await inDirectory <void >(_editedFlutterGalleryDir, () async {
66- smallReloadData = await captureReloadData (options, environment, benchmarkFile, (String line, Process process) {
67- if (! line.contains ('Reloaded ' )) {
68- return ;
69- }
70- if (hotReloadCount == 0 ) {
71- // Update a file for 2 library invalidation.
72- final File appDartSource = file (path.join (
73- _editedFlutterGalleryDir.path, 'lib/gallery/app.dart' ,
74- ));
75- appDartSource.writeAsStringSync (
76- appDartSource.readAsStringSync ().replaceFirst (
77- "'Flutter Gallery'" , "'Updated Flutter Gallery'" ,
65+ smallReloadData = await captureReloadData (
66+ options: options,
67+ benchmarkFile: benchmarkFile,
68+ onLine: (String line, Process process) {
69+ if (! line.contains ('Reloaded ' )) {
70+ return ;
71+ }
72+ if (hotReloadCount == 0 ) {
73+ // Update a file for 2 library invalidation.
74+ final File appDartSource = file (path.join (
75+ _editedFlutterGalleryDir.path,
76+ 'lib/gallery/app.dart' ,
77+ ));
78+ appDartSource.writeAsStringSync (appDartSource.readAsStringSync ().replaceFirst (
79+ "'Flutter Gallery'" ,
80+ "'Updated Flutter Gallery'" ,
7881 ));
79- process.stdin.writeln ('r' );
80- hotReloadCount += 1 ;
81- } else {
82- process.stdin.writeln ('q' );
83- }
84- });
82+ process.stdin.writeln ('r' );
83+ hotReloadCount += 1 ;
84+ } else {
85+ process.stdin.writeln ('q' );
86+ }
87+ },
88+ );
8589
86- mediumReloadData = await captureReloadData (options, environment, benchmarkFile, (String line, Process process) {
87- if (! line.contains ('Reloaded ' )) {
88- return ;
89- }
90- if (hotReloadCount == 1 ) {
91- // Update a file for ~50 library invalidation.
92- final File appDartSource = file (path.join (
93- _editedFlutterGalleryDir.path, 'lib/demo/calculator/home.dart' ,
94- ));
95- appDartSource.writeAsStringSync (
96- appDartSource.readAsStringSync ().replaceFirst (kSourceLine, kReplacementLine)
97- );
98- process.stdin.writeln ('r' );
99- hotReloadCount += 1 ;
100- } else {
101- process.stdin.writeln ('q' );
102- }
103- });
90+ mediumReloadData = await captureReloadData (
91+ options: options,
92+ benchmarkFile: benchmarkFile,
93+ onLine: (String line, Process process) {
94+ if (! line.contains ('Reloaded ' )) {
95+ return ;
96+ }
97+ if (hotReloadCount == 1 ) {
98+ // Update a file for ~50 library invalidation.
99+ final File appDartSource = file (path.join (
100+ _editedFlutterGalleryDir.path, 'lib/demo/calculator/home.dart' ,
101+ ));
102+ appDartSource.writeAsStringSync (
103+ appDartSource.readAsStringSync ().replaceFirst (kSourceLine, kReplacementLine)
104+ );
105+ process.stdin.writeln ('r' );
106+ hotReloadCount += 1 ;
107+ } else {
108+ process.stdin.writeln ('q' );
109+ }
110+ },
111+ );
104112
105- largeReloadData = await captureReloadData (options, environment, benchmarkFile, (String line, Process process) async {
106- if (! line.contains ('Reloaded ' )) {
107- return ;
108- }
109- if (hotReloadCount == 2 ) {
110- // Trigger a framework invalidation (370 libraries) without modifying the source
111- flutterFrameworkSource.writeAsStringSync (
112- '${flutterFrameworkSource .readAsStringSync ()}\n '
113- );
114- process.stdin.writeln ('r' );
115- hotReloadCount += 1 ;
116- } else {
117- if (checkAppRunningOnLocalDevice) {
118- await _checkAppRunning (true );
113+ largeReloadData = await captureReloadData (
114+ options: options,
115+ benchmarkFile: benchmarkFile,
116+ onLine: (String line, Process process) async {
117+ if (! line.contains ('Reloaded ' )) {
118+ return ;
119+ }
120+ if (hotReloadCount == 2 ) {
121+ // Trigger a framework invalidation (370 libraries) without modifying the source
122+ flutterFrameworkSource.writeAsStringSync (
123+ '${flutterFrameworkSource .readAsStringSync ()}\n '
124+ );
125+ process.stdin.writeln ('r' );
126+ hotReloadCount += 1 ;
127+ } else {
128+ if (checkAppRunningOnLocalDevice) {
129+ await _checkAppRunning (true );
130+ }
131+ process.stdin.writeln ('q' );
119132 }
120- process.stdin.writeln ('q' );
121- }
122- });
133+ },
134+ );
123135
124136 // Start `flutter run` again to make sure it loads from the previous
125137 // state. Frontend loads up from previously generated kernel files.
126138 {
127- final Process process = await startProcess (
128- path.join (flutterDirectory.path, 'bin' , 'flutter' ),
129- flutterCommandArgs ('run' , options),
130- environment: environment,
139+ final Process process = await startFlutter (
140+ 'run' ,
141+ options: options,
131142 );
132143 final Completer <void > stdoutDone = Completer <void >();
133144 final Completer <void > stderrDone = Completer <void >();
@@ -233,16 +244,14 @@ TaskFunction createHotModeTest({
233244 };
234245}
235246
236- Future <Map <String , dynamic >> captureReloadData (
237- List <String > options,
238- Map <String , String >? environment,
239- File benchmarkFile,
240- void Function (String , Process ) onLine,
241- ) async {
242- final Process process = await startProcess (
243- path.join (flutterDirectory.path, 'bin' , 'flutter' ),
244- flutterCommandArgs ('run' , options),
245- environment: environment,
247+ Future <Map <String , dynamic >> captureReloadData ({
248+ required List <String > options,
249+ required File benchmarkFile,
250+ required void Function (String , Process ) onLine,
251+ }) async {
252+ final Process process = await startFlutter (
253+ 'run' ,
254+ options: options,
246255 );
247256
248257 final Completer <void > stdoutDone = Completer <void >();
0 commit comments