fix(world): ensured when the Flutter driver is closed it cannot throw an unhandled exception causing the test run the stop

This commit is contained in:
Jon Samwell 2020-01-07 11:52:05 +11:00
parent c98936c679
commit 109ef7a962
4 changed files with 27 additions and 8 deletions

View File

@ -1,3 +1,7 @@
## [1.1.7+1] - 07/01/2019
* Ensured when the Flutter driver is closed it cannot throw an unhandled exception causing the test run the stop
* Updated Gherkin library version
## [1.1.7] - 06/01/2019
* `WhenFillFieldStep` Ensure widget is scrolled into view before setting it's value
* Fixed lint warnings

View File

@ -18,10 +18,10 @@ class FlutterWorld extends World {
_flutterRunProcessHandler = flutterRunProcessHandler;
}
Future<bool> restartApp(
{Duration timeout = const Duration(seconds: 60)}) async {
await _driver.waitUntilNoTransientCallbacks();
await _driver.close();
Future<bool> restartApp({
Duration timeout = const Duration(seconds: 60),
}) async {
await _closeDriver(timeout: timeout);
final result = await _flutterRunProcessHandler?.restart(
timeout: timeout,
);
@ -37,6 +37,21 @@ class FlutterWorld extends World {
void dispose() async {
super.dispose();
_flutterRunProcessHandler = null;
await _driver?.close();
await _closeDriver(timeout: const Duration(seconds: 5));
}
Future<void> _closeDriver({
Duration timeout = const Duration(seconds: 60),
}) async {
try {
if (_driver != null) {
await _driver.waitUntilNoTransientCallbacks(timeout: timeout);
await _driver.close();
}
} catch (e, st) {
print('Error closing Flutter driver:\n\n`${e}`\n\n${st}');
} finally {
_driver = null;
}
}
}

View File

@ -118,7 +118,7 @@ packages:
name: gherkin
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.5+1"
version: "1.1.5+2"
glob:
dependency: "direct main"
description:
@ -139,7 +139,7 @@ packages:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.0+3"
version: "0.12.0+4"
http_multi_server:
dependency: transitive
description:

View File

@ -16,7 +16,7 @@ dependencies:
sdk: flutter
glob: ^1.1.7
meta: ">=1.1.6 <2.0.0"
gherkin: ^1.1.5+1
gherkin: ^1.1.5+2
dev_dependencies:
test: