feat(utils): added waitUntil util and updated docs
This commit is contained in:
parent
eb24f3a056
commit
592ccd0b7c
|
@ -1,6 +1,8 @@
|
|||
## [1.1.4] - 26/09/2019
|
||||
* Added configuration parameter `flutterBuildTimeout` to allow setting the app build wait timeout. Slower machine may need longer to build and start a Flutter app under test.
|
||||
## [1.1.4] - 27/09/2019
|
||||
* Added configuration parameter `flutterBuildTimeout` to allow setting the app build wait timeout. Slower machines may need longer to build and start the Flutter app under test.
|
||||
* Now logging the flutter driver command used when the configuration setting `logFlutterProcessOutput` is true
|
||||
* Verbose logging for the underlying Flutter process can be enabled via the configuration setting `verboseFlutterProcessLogs`
|
||||
* Added `waitUntil` helper method to the `FlutterDriverUtils` class that waits until a certain provided condition is true
|
||||
|
||||
## [1.1.3] - 25/09/2019
|
||||
* Added Flutter driver reporter - the Flutter Driver logs all messages (even non-error ones) to stderr and will cause the process to be marked as failed by a CI server becuase of this. So this reporter redirects the messages to the appropiate output stream (stdout / stderr).
|
||||
|
|
|
@ -927,7 +927,7 @@ For convenience the library defines a number of pre-defined steps so you can get
|
|||
|
||||
#### Flutter Driver Utilities
|
||||
|
||||
For convenience the library provides a static `FlutterDriverUtils` class that abstracts away some common Flutter driver functionality like tapping a button, getting and entering text, checking if an element is present or absent. See [lib/src/flutter/utils/driver_utils.dart](lib/src/flutter/utils/driver_utils.dart).
|
||||
For convenience the library provides a static `FlutterDriverUtils` class that abstracts away some common Flutter driver functionality like tapping a button, getting and entering text, checking if an element is present or absent, waiting for a condition to become true. See [lib/src/flutter/utils/driver_utils.dart](lib/src/flutter/utils/driver_utils.dart).
|
||||
|
||||
### Debugging
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_driver/flutter_driver.dart';
|
||||
|
||||
class FlutterDriverUtils {
|
||||
|
@ -50,4 +52,31 @@ class FlutterDriverUtils {
|
|||
await driver.tap(finder, timeout: timeout);
|
||||
await FlutterDriverUtils.waitForFlutter(driver, timeout: timeout);
|
||||
}
|
||||
|
||||
/// Waits until the [condition] returns true
|
||||
/// Will raise a complete with a [TimeoutException] if the
|
||||
/// condition does not return true with the timeout period.
|
||||
static Future<void> waitUntil(
|
||||
FlutterDriver driver,
|
||||
Future<bool> condition(), {
|
||||
Duration timeout = const Duration(seconds: 10),
|
||||
Duration pollInterval = const Duration(milliseconds: 500),
|
||||
}) async {
|
||||
return Future.microtask(() async {
|
||||
final completer = Completer<void>();
|
||||
int maxAttempts =
|
||||
(timeout.inMilliseconds / pollInterval.inMilliseconds).round();
|
||||
int attempts = 0;
|
||||
|
||||
while (attempts < maxAttempts) {
|
||||
final result = await condition();
|
||||
if (result) {
|
||||
completer.complete();
|
||||
break;
|
||||
} else {
|
||||
await Future.delayed(pollInterval);
|
||||
}
|
||||
}
|
||||
}).timeout(timeout);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ packages:
|
|||
name: gherkin
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.2"
|
||||
version: "1.1.3"
|
||||
glob:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
|
@ -16,7 +16,7 @@ dependencies:
|
|||
sdk: flutter
|
||||
glob: ^1.1.7
|
||||
meta: ">=1.1.6 <2.0.0"
|
||||
gherkin: ^1.1.2
|
||||
gherkin: ^1.1.3
|
||||
|
||||
dev_dependencies:
|
||||
test: ">=1.6.1 <1.7.0"
|
||||
|
|
Loading…
Reference in New Issue