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
actualis withintoleranceofexpected. -
compareImages(
RgbaPixels a, RgbaPixels b, {int tolerance = 2}) → ImageDiff -
Compares
aandbpixel by pixel. A pixel differs when any channel is more thantoleranceapart. - 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
jointsjoints, each 0.1 m above the last, with awaveanimation 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
idleand awalkclip. Made in code, so it is free to use anywhere (CC0). -
readPixels(
Image image) → Future< RgbaPixels> -
Reads
imageback 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:
rootat the origin andtip1 m up (child ofroot). Below 0.5 m vertices followroot, above 1.5 mtip, between they blend. -
submitAndWait(
CommandBuffer commandBuffer, {Duration timeout = const Duration(seconds: 5)}) → Future< bool> -
Submits
commandBufferand completes once the GPU has finished it.