writeStepScreenshotArtifacts function

void writeStepScreenshotArtifacts({
  1. required WidgetTester tester,
  2. required EnsembleTestContext context,
  3. required TestStep step,
  4. required int stepIndex,
  5. required Image image,
  6. TestStep? labelStep,
  7. TestDeviceTarget? device,
  8. ScreenshotHighlight? highlight,
  9. DiagnosticUiSnapshot? observerSnapshot,
})

Publishes screenshot and Observer data as one same-turn report artifact.

Call immediately after rasterizing the frame and taking observerSnapshot. Keeping publication synchronous ensures Observer overlays are drawn against the image captured from the same UI state.

Implementation

void writeStepScreenshotArtifacts({
  required WidgetTester tester,
  required EnsembleTestContext context,
  required TestStep step,
  required int stepIndex,
  required ui.Image image,
  TestStep? labelStep,
  TestDeviceTarget? device,
  ScreenshotHighlight? highlight,
  DiagnosticUiSnapshot? observerSnapshot,
}) {
  final labelSource = labelStep ?? step;
  context.runtime.addScreenshotSheetFrame(
    ScreenshotSheetFrame(
      stepIndex: stepIndex,
      label: '${stepIndex + 1}. ${formatStepBrief(labelSource)}',
      image: image,
      deviceId: device?.id,
      deviceLabel: device?.displayLabel,
      platform: device?.platform,
      model: device?.model,
      highlight: highlight,
    ),
  );
  if (observerSnapshot != null) {
    upsertStepObserverFromSnapshot(
      ctx: context,
      tester: tester,
      stepIndex: stepIndex,
      snap: observerSnapshot,
    );
  }
}