@@ -8,15 +8,11 @@ import 'dart:io' as io;
88
99import 'package:file/file.dart' ;
1010import 'package:flutter_plugin_tools/src/common/core.dart' ;
11- import 'package:flutter_plugin_tools/src/common/package_looping_command.dart' ;
1211import 'package:flutter_plugin_tools/src/common/process_runner.dart' ;
1312
1413import 'process_runner_apis.dart' ;
1514import 'tizen_sdk.dart' ;
1615
17- export 'package:flutter_plugin_tools/src/common/package_looping_command.dart'
18- show PackageResult, RunState;
19-
2016/// A reference to a Tizen device (either physical or emulator) that can run
2117/// Flutter applications.
2218///
@@ -114,36 +110,24 @@ class Device {
114110
115111 /// Runs integration test in [workingDir] .
116112 ///
117- /// [workingDir] must be a valid exisiting flutter directory where
118- /// `flutter pub get` has already been ran succesfully. For an app project,
113+ /// [workingDir] must be a valid existing Flutter project directory where
114+ /// `flutter pub get` has already been run succesfully. For an app project,
119115 /// [workingDir] is the app's source root. For a plugin project, [workingDir]
120116 /// is one of the example directories.
121117 ///
122- /// If test doesn't finish after [timeout] , it's considered a failure and the
123- /// function will return [PackageResult.fail] with time expired log.
124- ///
125- /// Returns [PackageResult.success] when every test passes succesfully,
126- /// otherwise returns [PackageResult.fail] . Never returns [PackageResult.skip]
127- /// nor [PackageResult.exclude] .
128- Future <PackageResult > runIntegrationTest (
118+ /// Returns null if all tests have passed successfully before [timeout] ,
119+ /// otherwise returns a string with the error details.
120+ Future <String ?> runIntegrationTest (
129121 Directory workingDir,
130- Duration timeout, {
131- bool debug = false ,
132- }) async {
122+ Duration timeout,
123+ ) async {
133124 if (! isConnected) {
134- return PackageResult .fail (
135- < String > ['Device $name ($profile ) is not connected.' ]);
125+ return 'Device $name ($profile ) is not connected.' ;
136126 }
137127
138128 final io.Process process = await _processRunner.start (
139129 'flutter-tizen' ,
140- < String > [
141- if (debug) '-v' ,
142- '-d' ,
143- serial! ,
144- 'test' ,
145- 'integration_test' ,
146- ],
130+ < String > ['-d' , serial! , 'test' , 'integration_test' ],
147131 workingDirectory: workingDir,
148132 );
149133
@@ -173,30 +157,27 @@ class Device {
173157 // guarantee that all buffered outputs of the process have returned.
174158 await completer.future;
175159
176- final List < String > errors = < String > [] ;
160+ String ? error ;
177161 if (timedOut) {
178- errors. add ( 'Timeout expired. The test may need more time to finish. '
162+ error = 'Timeout expired. The test may need more time to finish. '
179163 'If you expect the test to finish before timeout, check if the tests '
180164 'require device screen to be awake or if they require manually '
181- 'clicking the UI button for permissions.' ) ;
165+ 'clicking the UI button for permissions.' ;
182166 } else if (lastLine.startsWith ('No tests ran' )) {
183- errors. add (
184- 'Missing integration tests (use --exclude if this is intentional).' ) ;
167+ error =
168+ 'Missing integration tests (use --exclude if this is intentional).' ;
185169 } else if (lastLine.startsWith ('No devices found' )) {
186- errors. add ( 'Device was disconnected during test.' ) ;
170+ error = 'Device was disconnected during test.' ;
187171 } else {
188172 final RegExpMatch ? match = _logPattern.firstMatch (lastLine);
189173 if (match == null || match.group (2 ) == null ) {
190- throw Exception ( 'Log message is not parsed correctly.' ) ;
174+ error = 'Could not parse the log output.' ;
191175 } else if (! match.group (2 )! .startsWith ('All tests passed!' )) {
192- errors. add ( 'flutter-tizen test integration_test failed, see the output '
193- 'above for details.' ) ;
176+ error = 'flutter-tizen test integration_test failed, see the output '
177+ 'above for details.' ;
194178 }
195179 }
196-
197- return errors.isEmpty
198- ? PackageResult .success ()
199- : PackageResult .fail (errors);
180+ return error;
200181 }
201182}
202183
@@ -247,6 +228,7 @@ class EmulatorDevice extends Device {
247228 final io.ProcessResult result =
248229 _processRunner.runSync (_tizenSdk.emCli.path, < String > ['list-vm' ]);
249230 if (result.exitCode != 0 ) {
231+ print ('Error: Unable to list available emulators.' );
250232 throw ToolExit (result.exitCode);
251233 }
252234
@@ -319,11 +301,10 @@ class EmulatorDevice extends Device {
319301 }
320302
321303 /// Deletes this emulator.
322- Future <void > delete () async => await _processRunner.runAndStream (
323- _tizenSdk.emCli.path,
324- < String > ['delete' , '-n' , name],
325- exitOnError: true ,
326- );
304+ Future <void > delete () async {
305+ await _processRunner
306+ .runAndStream (_tizenSdk.emCli.path, < String > ['delete' , '-n' , name]);
307+ }
327308
328309 /// Launches this emualtor.
329310 Future <void > launch () async {
@@ -385,7 +366,7 @@ class EmulatorDevice extends Device {
385366 Future <void > _poll (
386367 FutureOr <bool > Function () function, {
387368 Duration interval = const Duration (seconds: 1 ),
388- Duration timeout = const Duration (minutes: 10 ),
369+ Duration timeout = const Duration (minutes: 5 ),
389370 }) async {
390371 final DateTime start = DateTime .now ();
391372 while (DateTime .now ().difference (start) <= timeout) {
@@ -398,11 +379,10 @@ class EmulatorDevice extends Device {
398379 }
399380
400381 @override
401- Future <PackageResult > runIntegrationTest (
382+ Future <String ? > runIntegrationTest (
402383 Directory workingDir,
403- Duration timeout, {
404- bool debug = false ,
405- }) async {
384+ Duration timeout,
385+ ) async {
406386 bool autoLaunched = false ;
407387 bool autoCreated = false ;
408388 try {
@@ -415,7 +395,7 @@ class EmulatorDevice extends Device {
415395 await launch ();
416396 }
417397 _disablePermissionPopups ();
418- return await super .runIntegrationTest (workingDir, timeout, debug : debug );
398+ return await super .runIntegrationTest (workingDir, timeout);
419399 } finally {
420400 if (autoLaunched) {
421401 await close ();
0 commit comments