gleonAlchemistExpectation function
- GoldenTolerance? tolerance,
- List<
Rect> ? ignoreRegions, - double? textTolerance,
- bool shouldHintObscuredText = true,
An alchemist golden file expectation that compares with gleon's
matchesGoldenFile; assign it to alchemist's goldenFileExpectationFn
in test/flutter_test_config.dart (see the README's "Golden harnesses").
Call loadAppFonts() there first: alchemist loads the app's fonts again
before each golden test, and text keeps the faces loaded first, which
loadAppFonts aligns to lay text out alike on every OS.
Alchemist passes the root Finder of each golden test unless its text is
obscured, so gleon captures the raw pixels with the boxes of their text,
like its own matcher with a widget. With obscureText (alchemist's
default for CI goldens) it passes an image of blocked text instead, which
gleon cannot compare as text: a failure then says how to compare the real
text, unless shouldHintObscuredText is false.
The tolerance, ignoreRegions and textTolerance apply to every
alchemist golden, like the parameters of matchesGoldenFile; null leaves
them to the golden's .gleon/gleon.yaml rule. The ignoreRegions are in
pixels of the capture (alchemist renders at a device pixel ratio of 1).
The diffThreshold of alchemist does not apply (a failure says so): use
a tolerance instead.
Throws an ArgumentError for the values matchesGoldenFile refuses.
Implementation
// ignore: prefer-static-class, a factory of a closure, like matchesGoldenFile.
AlchemistGoldenExpectation gleonAlchemistExpectation({
GoldenTolerance? tolerance,
List<ui.Rect>? ignoreRegions,
double? textTolerance,
bool shouldHintObscuredText = true,
}) => AlchemistExpectation.create(
tolerance: tolerance,
ignoreRegions: ignoreRegions,
textTolerance: textTolerance,
shouldHintObscuredText: shouldHintObscuredText,
);