mirror of
https://github.com/flutter/flutter
synced 2024-08-24 18:36:03 +00:00
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].
This commit is contained in:
parent
310a7edbca
commit
10f1e63579
|
@ -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(),
|
||||
|
|
Loading…
Reference in a new issue