waitForHighlightTargetToPaint method

Future<void> waitForHighlightTargetToPaint(
  1. TestStepExecutor executor,
  2. TestStep step
)

Implementation

Future<void> waitForHighlightTargetToPaint(
  TestStepExecutor executor,
  TestStep step,
) async {
  return await RunnerBenchmark.async(
      'screenshot', 'waitForHighlightTargetToPaint', () async {
    if (step.type != 'waitForText') return;
    final finder = _highlightFinder(executor, step);
    if (finder == null) return;
    final initial =
        executor.assertions.firstVisuallyActionableElement(finder);
    if (initial == null) return;
    if (_effectiveOpacity(initial) >= 0.85) {
      // The successful wait already advanced Flutter to the matched frame.
      // A further pump can move the UI past the state being recorded.
      return;
    }

    await EventDrivenSettler(
      tester: executor.tester,
      hasExternalWork: () => executor.context.apiOverlay.hasPendingLiveCalls,
      waitForExternalWork: executor.context.apiOverlay.waitForLiveCalls,
      onPump: () => drainFlutterExceptions(executor.tester),
    ).waitFor(
      condition: () {
        final element =
            executor.assertions.firstVisuallyActionableElement(finder);
        return element == null || _effectiveOpacity(element) >= 0.85;
      },
      timeout: const Duration(milliseconds: 400),
    );
  });
}