mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[driver] fix a race in finder logic (#3444)
This commit is contained in:
parent
fffbf6e97b
commit
7fe7de3f12
@ -120,7 +120,14 @@ class FlutterDriverExtension {
|
||||
Future<Health> getHealth(GetHealth command) async => new Health(HealthStatus.ok);
|
||||
|
||||
/// Runs [locator] repeatedly until it finds an [Element] or times out.
|
||||
Future<Element> _waitForElement(String descriptionGetter(), Element locator()) {
|
||||
Future<Element> _waitForElement(String descriptionGetter(), Element locator()) async {
|
||||
// Short-circuit if the element is already on the UI
|
||||
Element element = locator();
|
||||
if (element != null) {
|
||||
return element;
|
||||
}
|
||||
|
||||
// No element yet, so we retry on frames rendered in the future.
|
||||
Completer<Element> completer = new Completer<Element>();
|
||||
StreamSubscription<Duration> subscription;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user