waitForScreenshotTarget method
Implementation
Future<void> waitForScreenshotTarget(
TestStepExecutor executor,
TestStep step,
) async {
return await RunnerBenchmark.async('screenshot', 'waitForScreenshotTarget',
() async {
if (!shouldHighlightStep(step)) return;
final finder = _highlightFinder(executor, step);
if (finder == null) return;
final waitsForHitTestable = isUserActionStep(step);
final timeoutMs = step.args['timeoutMs'] as int? ??
executor.config.defaultWaitTimeout.inMilliseconds;
var scrollRequested = false;
var scrollApplied = false;
await EventDrivenSettler(
tester: executor.tester,
hasExternalWork: () => executor.context.apiOverlay.hasPendingLiveCalls,
waitForExternalWork: executor.context.apiOverlay.waitForLiveCalls,
onPump: () async {
if (scrollRequested && !scrollApplied) {
scrollApplied = true;
await ensureHighlightTargetVisible(executor, step);
}
},
).waitFor(
condition: () {
final ready = _isScreenshotTargetReady(
executor,
finder,
waitsForHitTestable,
) &&
isHighlightTargetPainted(executor, finder, waitsForHitTestable);
if (!ready && waitsForHitTestable && !scrollRequested) {
scrollRequested = true;
}
return ready;
},
timeout: Duration(milliseconds: timeoutMs),
);
});
}