testing library
For a game's tests: run its world for a while, tap it, and name a point
in its view. HeadlessView draws it, view.png() saves a frame, and
view.expectFrame('test/frames/start.png') checks one against a saved
picture.
final world = World()..input.simulate.resize(320, 200);
final game = world.add(MyGame());
world.run(2);
world.tap(160, 100);
world.run(0.1);
Extensions
- HeadlessViewTesting on HeadlessView
- expectFrame on a HeadlessView.
- WorldTesting on World
- run, untilLoaded, tap and viewPoint on a World, for tests.
Functions
-
expectImage(
String path, Uint8List rgba, {required int width, required int height, bool? bless, String failures = 'build/fynkel_failures'}) → void -
Checks
rgba(RGBA8, rows top to bottom,width×height) against the PNG atpath, a picture saved before. Two pictures are the same when no channel differs by more than 2/255 (4/255 near black, where a GPU's dither moves it), but for at most 1 pixel in 1000: what passes from one Mac or GPU to another.
Exceptions / Errors
- ImageDiffers
- What expectImage throws: the picture isn't the one saved.