testing library

Helpers for testing code that renders with Flutter GPU: a GPU probe that lets tests skip, waiting for submitted work, pixel readback and tolerant image comparison.

Test-only. Nothing here imports flutter_test, so depending on this package does not pull test packages into an app.

Classes

GlbWriter
Writes small glTF files for tests, so fixtures are generated, not checked-in binaries.
ImageDiff
How two same-sized images differ.
RgbaPixels
RGBA8 pixels read back from an image.

Functions

colorClose(List<int> actual, List<int> expected, {int tolerance = 2}) → bool
Whether every channel of actual is within tolerance of expected.
compareImages(RgbaPixels a, RgbaPixels b, {int tolerance = 2}) → ImageDiff
Compares a and b pixel by pixel. A pixel differs when any channel is more than tolerance apart.
gpuUnavailableReason() → String?
Why Flutter GPU can't be used here, or null when it can.
jointChainGlb(int joints) → Uint8List
A thin bar skinned to a chain of joints joints, each 0.1 m above the last, with a wave animation turning every joint a little about +Z and back over 1 s — for timing many joints.
mannequinGlb({List<double> body = const [0.85, 0.6, 0.35, 1], List<double> clothes = const [0.25, 0.35, 0.6, 1]}) → Uint8List
A box mannequin about 1.8 m tall, standing on y = 0 and facing +Z (glTF axes), skinned to 16 joints with an idle and a walk clip. Made in code, so it is free to use anywhere (CC0).
readPixels(Image image) → Future<RgbaPixels>
Reads image back as RGBA8.
skinnedBarGlb({List<double> rgba = const [0.9, 0.2, 0.2, 1], double halfWidth = 0.1}) → Uint8List
A square bar 2 m tall standing on y = 0 (glTF axes), skinned to two joints: root at the origin and tip 1 m up (child of root). Below 0.5 m vertices follow root, above 1.5 m tip, between they blend.
submitAndWait(CommandBuffer commandBuffer, {Duration timeout = const Duration(seconds: 5)}) → Future<bool>
Submits commandBuffer and completes once the GPU has finished it.