@@ -18,12 +18,11 @@ const List<String> kSentinelStr = <String>[
1818 '==== sentinel #3 ====' ,
1919];
2020
21- // Regression test for https://github.com/flutter/flutter/issues/98973
22- // This test ensures that Choreographer#doFrame finishes during application startup .
23- // This test fails if the application hangs during this period.
24- // https://ui.perfetto.dev/#!/?s=da6628c3a92456ae8fa3f345d0186e781da77e90fc8a64d073e9fee11d1e65
21+ /// Tests that Choreographer#doFrame finishes during application startup.
22+ /// This test fails if the application hangs during this period .
23+ /// https://ui.perfetto.dev/#!/?s=da6628c3a92456ae8fa3f345d0186e781da77e90fc8a64d073e9fee11d1e65
24+ /// Regression test for https://github.com/flutter/flutter/issues/98973
2525TaskFunction androidChoreographerDoFrameTest ({
26- String ? deviceIdOverride,
2726 Map <String , String >? environment,
2827}) {
2928 final Directory tempDir = Directory .systemTemp
@@ -87,18 +86,19 @@ Future<void> main() async {
8786 }
8887
8988 section ('Flutter run (mode: $mode )' );
89+ late Process run;
9090 await inDirectory (path.join (tempDir.path, 'app' ), () async {
91- final Process run = await startProcess (
91+ run = await startProcess (
9292 path.join (flutterDirectory.path, 'bin' , 'flutter' ),
9393 flutterCommandArgs ('run' , < String > ['--$mode ' , '--verbose' ]),
9494 );
95+ });
9596
96- int currSentinelIdx = 0 ;
97- final StreamSubscription <void > stdout = run.stdout
98- .transform <String >(utf8.decoder)
99- .transform <String >(const LineSplitter ())
100- .listen ((String line) {
101-
97+ int currSentinelIdx = 0 ;
98+ final StreamSubscription <void > stdout = run.stdout
99+ .transform <String >(utf8.decoder)
100+ .transform <String >(const LineSplitter ())
101+ .listen ((String line) {
102102 if (currSentinelIdx < sentinelCompleters.keys.length &&
103103 line.contains (sentinelCompleters.keys.elementAt (currSentinelIdx))) {
104104 sentinelCompleters.values.elementAt (currSentinelIdx).complete ();
@@ -107,61 +107,59 @@ Future<void> main() async {
107107 } else {
108108 print ('stdout: $line ' );
109109 }
110-
111110 });
112111
113- final StreamSubscription <void > stderr = run.stderr
114- .transform <String >(utf8.decoder)
115- .transform <String >(const LineSplitter ())
116- .listen ((String line) {
117- print ('stderr: $line ' );
118- });
119-
120- final Completer <void > exitCompleter = Completer <void >();
121-
122- unawaited (run.exitCode.then ((int exitCode) {
123- exitCompleter.complete ();
124- }));
112+ final StreamSubscription <void > stderr = run.stderr
113+ .transform <String >(utf8.decoder)
114+ .transform <String >(const LineSplitter ())
115+ .listen ((String line) {
116+ print ('stderr: $line ' );
117+ });
125118
126- section ('Wait for sentinels (mode: $mode )' );
127- for (final Completer <void > completer in sentinelCompleters.values) {
128- if (nextCompleterIdx == 0 ) {
129- // Don't time out because we don't know how long it would take to get the first log.
119+ final Completer <void > exitCompleter = Completer <void >();
120+
121+ unawaited (run.exitCode.then ((int exitCode) {
122+ exitCompleter.complete ();
123+ }));
124+
125+ section ('Wait for sentinels (mode: $mode )' );
126+ for (final Completer <void > completer in sentinelCompleters.values) {
127+ if (nextCompleterIdx == 0 ) {
128+ // Don't time out because we don't know how long it would take to get the first log.
129+ await Future .any <dynamic >(
130+ < Future <dynamic >> [
131+ completer.future,
132+ exitCompleter.future,
133+ ],
134+ );
135+ } else {
136+ try {
137+ // Time out since this should not take 1s after the first log was received.
130138 await Future .any <dynamic >(
131139 < Future <dynamic >> [
132- completer.future,
140+ completer.future. timeout ( const Duration (seconds : 1 )) ,
133141 exitCompleter.future,
134142 ],
135143 );
136- } else {
137- try {
138- // Time out since this should not take 1s after the first log was received.
139- await Future .any <dynamic >(
140- < Future <dynamic >> [
141- completer.future.timeout (const Duration (seconds: 1 )),
142- exitCompleter.future,
143- ],
144- );
145- } on TimeoutException {
146- break ;
147- }
148- }
149- if (exitCompleter.isCompleted) {
150- // The process exited.
144+ } on TimeoutException {
151145 break ;
152146 }
153- nextCompleterIdx++ ;
154147 }
148+ if (exitCompleter.isCompleted) {
149+ // The process exited.
150+ break ;
151+ }
152+ nextCompleterIdx++ ;
153+ }
155154
156- section ('Quit app (mode: $mode )' );
157- run.stdin.write ('q' );
158- await exitCompleter.future;
155+ section ('Quit app (mode: $mode )' );
156+ run.stdin.write ('q' );
157+ await exitCompleter.future;
159158
160- section ('Stop listening to stdout and stderr (mode: $mode )' );
161- await stdout.cancel ();
162- await stderr.cancel ();
163- run.kill ();
164- });
159+ section ('Stop listening to stdout and stderr (mode: $mode )' );
160+ await stdout.cancel ();
161+ await stderr.cancel ();
162+ run.kill ();
165163
166164 if (nextCompleterIdx == sentinelCompleters.values.length) {
167165 return TaskResult .success (null );
0 commit comments