From 356d209b9e5a76805c451e333423e6355ce0b670 Mon Sep 17 00:00:00 2001 From: Jim Graham Date: Thu, 5 May 2022 15:43:29 -0700 Subject: [PATCH] golden test for Engine PR #33131 --- testing/dart/canvas_test.dart | 52 +++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/testing/dart/canvas_test.dart b/testing/dart/canvas_test.dart index 72c0e124648e9..4f5241e89c5ad 100644 --- a/testing/dart/canvas_test.dart +++ b/testing/dart/canvas_test.dart @@ -357,4 +357,56 @@ void main() { await fuzzyGoldenImageCompare(image, 'dotted_path_effect_mixed_with_stroked_geometry.png'); expect(areEqual, true); }, skip: !Platform.isLinux); // https://github.com/flutter/flutter/issues/53784 + + test('Gradients with matrices in Paragraphs render correctly', () async { + final Image image = await toImage((Canvas canvas) { + final Paint p = Paint(); + final Float64List transform = Float64List.fromList([ + 86.80000129342079, + 0.0, + 0.0, + 0.0, + 0.0, + 94.5, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 60.0, + 224.310302734375, + 0.0, + 1.0 + ]); + p.shader = Gradient.radial( + const Offset(2.5, 0.33), + 0.8, + [ + const Color(0xffff0000), + const Color(0xff00ff00), + const Color(0xff0000ff), + const Color(0xffff00ff) + ], + [0.0, 0.3, 0.7, 0.9], + TileMode.mirror, + transform, + const Offset(2.55, 0.4)); + final ParagraphBuilder builder = ParagraphBuilder(ParagraphStyle()); + builder.pushStyle(TextStyle( + foreground: p, + fontSize: 200, + )); + builder.addText('Woodstock!'); + final Paragraph paragraph = builder.build(); + paragraph.layout(const ParagraphConstraints(width: 1000)); + canvas.drawParagraph(paragraph, const Offset(10, 150)); + }, 600, 400); + expect(image.width, equals(600)); + expect(image.height, equals(400)); + + final bool areEqual = + await fuzzyGoldenImageCompare(image, 'text_with_gradient_with_matrix.png'); + expect(areEqual, true); + }); //, skip: !Platform.isLinux); // https://github.com/flutter/flutter/issues/53784 }