Package io.klib.swtbot.support
Class Screenshots
java.lang.Object
io.klib.swtbot.support.Screenshots
Captures screenshots using an explicitly supplied, existing application Display.
Does not create a Display or change workbench state. Shell suppliers run on that
Display's UI thread. Scope instances to a test/session: diagnosed throwables are
retained for duplicate suppression. Keep shells visible until capture completes.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceTest action that may throw any original test failure. -
Constructor Summary
ConstructorsConstructorDescriptionScreenshots(CaptureOptions options, String testId, Supplier<org.eclipse.swt.widgets.Display> displaySupplier) Creates isolated artifact directories without obtaining or creating a Display. -
Method Summary
Modifier and TypeMethodDescriptioncapture(String checkpoint, CaptureMode mode, Supplier<org.eclipse.swt.widgets.Shell> shellSupplier) Captures one PNG, returning skipped/failed outcomes when evidence is unavailable.checkpoint(String checkpoint, Supplier<org.eclipse.swt.widgets.Shell> shell) Captures each configured mode sequentially, with a separate timeout per mode.Returns the directory containing this instance's artifacts.voidDiagnoses an original failure at most once by identity within this instance.voidguard(String checkpoint, Supplier<org.eclipse.swt.widgets.Shell> shell, Screenshots.Action action) Runs an action on the calling thread; diagnoses failures before caller teardown and rethrows the same original throwable, never a replacement diagnostic error.voidrequireCheckpoint(String checkpoint, Supplier<org.eclipse.swt.widgets.Shell> shell) Captures all configured modes and requires every outcome to be captured.
-
Constructor Details
-
Screenshots
public Screenshots(CaptureOptions options, String testId, Supplier<org.eclipse.swt.widgets.Display> displaySupplier) throws IOException Creates isolated artifact directories without obtaining or creating a Display.- Parameters:
options- non-null capture settingstestId- non-null test identity used for a sanitized directory namedisplaySupplier- non-null supplier of the existing application Display; may return null- Throws:
IOException- if artifact directories cannot be createdNullPointerException- if an argument is null
-
-
Method Details
-
directory
Returns the directory containing this instance's artifacts.- Returns:
- the absolute artifact directory for this instance
-
checkpoint
public List<CaptureResult> checkpoint(String checkpoint, Supplier<org.eclipse.swt.widgets.Shell> shell) Captures each configured mode sequentially, with a separate timeout per mode.- Parameters:
checkpoint- artifact label, sanitized and bounded during allocationshell- supplier evaluated on the application UI thread- Returns:
- immutable outcomes in configured mode order
-
requireCheckpoint
Captures all configured modes and requires every outcome to be captured.- Parameters:
checkpoint- artifact labelshell- supplier evaluated on the application UI thread- Throws:
IllegalStateException- if any capture was skipped or failed
-
guard
public void guard(String checkpoint, Supplier<org.eclipse.swt.widgets.Shell> shell, Screenshots.Action action) throws Throwable Runs an action on the calling thread; diagnoses failures before caller teardown and rethrows the same original throwable, never a replacement diagnostic error.- Parameters:
checkpoint- failure artifact labelshell- supplier evaluated on the application UI thread during captureaction- test action- Throws:
Throwable- the original action failure
-
failure
public void failure(String checkpoint, Supplier<org.eclipse.swt.widgets.Shell> shell, Throwable original) Diagnoses an original failure at most once by identity within this instance. Logs outcomes and attaches capture problems as suppressed exceptions instead of throwing them. Invoke while application UI still exists.- Parameters:
checkpoint- failure artifact labelshell- supplier evaluated on the application UI threadoriginal- non-null original failure to preserve
-
capture
public CaptureResult capture(String checkpoint, CaptureMode mode, Supplier<org.eclipse.swt.widgets.Shell> shellSupplier) Captures one PNG, returning skipped/failed outcomes when evidence is unavailable. Runs immediately on the UI thread or queues bounded work otherwise. Timeout or interruption cancels queued work without interrupting executing native work; interruption status is restored. Screen modes can include occlusion/private pixels. Native images and graphics contexts are disposed after capture.- Parameters:
checkpoint- artifact label, sanitized and bounded during allocationmode- non-null region to captureshellSupplier- supplier of a visible live shell on the application Display- Returns:
- capture outcome, including PNG path/dimensions on success
- Throws:
NullPointerException- if mode is null
-