Ensure all golden filenames end in .png. (flutter/engine#40604)

Ensure all golden filenames end in .png.
This commit is contained in:
Jackson Gardner
2023-03-24 12:28:57 -07:00
committed by GitHub
parent c5156e2370
commit b6af3bcc91
3 changed files with 5 additions and 2 deletions

View File

@@ -56,7 +56,7 @@ void testMain() {
canvas.drawParagraph(paragraph, const ui.Offset(10, 10));
final CkPicture picture = recorder.endRecording();
await matchPictureGolden(
'font_variation.jpg',
'font_variation.png',
picture,
region: ui.Rect.fromLTRB(0, 0, testWidth, paragraph.height + 20),
);

View File

@@ -779,7 +779,7 @@ void _testForImageCodecs({required bool useBrowserImageDecoder}) {
}
CanvasKitRenderer.instance.rasterizer.draw(sb.build().layerTree);
await matchGoldenFile(
'canvaskit_picture_texture_toimage',
'canvaskit_picture_texture_toimage.png',
region: const ui.Rect.fromLTRB(0, 0, 128, 128),
);
mandrill.dispose();

View File

@@ -49,6 +49,9 @@ enum PixelComparison {
/// [pixelComparison] determines the algorithm used to compare pixels. Uses
/// fuzzy comparison by default.
Future<void> matchGoldenFile(String filename, {Rect? region}) async {
if (!filename.endsWith('.png')) {
throw ArgumentError('Filename must end in .png or SkiaGold will ignore it.');
}
final Map<String, dynamic> serverParams = <String, dynamic>{
'filename': filename,
'region': region == null