Unverified Commit 10f1e635 authored by Andrew Brampton's avatar Andrew Brampton Committed by GitHub

Update _goldens_io.dart to generate failure images during a size mism… (#142177)

Update the `matchesGoldenFile()` / `LocalComparisonOutput` code to generate failure images for golden tests that fail when the image sizes do not match. This can make it far quicker to identify what is wrong with the test image.

Fixes https://github.com/flutter/flutter/issues/141488

- [ x I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
parent 310a7edb
......@@ -210,9 +210,11 @@ Future<ComparisonResult> compareLists(List<int>? test, List<int>? master) async
error: 'Pixel test failed, image sizes do not match.\n'
'Master Image: ${masterImage.width} X ${masterImage.height}\n'
'Test Image: ${testImage.width} X ${testImage.height}',
diffs: <String, Image>{
'masterImage': masterImage,
'testImage': testImage,
},
);
masterImage.dispose();
testImage.dispose();
return result;
}
......
......@@ -244,6 +244,34 @@ void main() {
expect(masked.existsSync(), isTrue);
});
test('and generates correct output when images are not the same size', () async {
await fs.file(fix('/golden.png')).writeAsBytes(_kSizeFailurePngBytes);
await expectLater(
() => doComparison(),
throwsA(isFlutterError.having(
(FlutterError error) => error.message,
'message',
contains('image sizes do not match'),
)),
);
final io.File master = fs.file(
fix('/failures/golden_masterImage.png')
);
final io.File test = fs.file(
fix('/failures/golden_testImage.png')
);
final io.File isolated = fs.file(
fix('/failures/golden_isolatedDiff.png')
);
final io.File masked = fs.file(
fix('/failures/golden_maskedDiff.png')
);
expect(master.existsSync(), isTrue);
expect(test.existsSync(), isTrue);
expect(isolated.existsSync(), isFalse);
expect(masked.existsSync(), isFalse);
});
test('when golden file does not exist', () async {
await expectLater(
() => doComparison(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment