From b8c32a6e5dc6f500c493e7b279283e41bc99f298 Mon Sep 17 00:00:00 2001 From: Harry Terkelsen Date: Thu, 10 Jul 2025 16:34:19 -0700 Subject: [PATCH] Update test in rfw to not depend on toString() --- packages/rfw/test/argument_decoders_test.dart | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/rfw/test/argument_decoders_test.dart b/packages/rfw/test/argument_decoders_test.dart index 25f177f4aad..274418f1fcb 100644 --- a/packages/rfw/test/argument_decoders_test.dart +++ b/packages/rfw/test/argument_decoders_test.dart @@ -384,20 +384,21 @@ void main() { skip: !runGoldens || true, ); expect(find.byType(DecoratedBox), findsNWidgets(6)); - const String matrix = kIsWeb ? '1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1' - : '1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0'; - expect( - (tester.widgetList(find.byType(DecoratedBox)).toList()[1].decoration as BoxDecoration).image.toString(), - 'DecorationImage(AssetImage(bundle: null, name: "asset"), ' // this just seemed like the easiest way to check all this... - 'ColorFilter.matrix([$matrix]), ' - 'Alignment.center, centerSlice: Rect.fromLTRB(5.0, 8.0, 105.0, 78.0), scale 1.0, opacity 1.0, FilterQuality.none)', - ); + + final DecorationImage assetImage = (tester.widgetList(find.byType(DecoratedBox)).toList()[1].decoration as BoxDecoration).image!; + expect(assetImage.image, isA()); + expect((assetImage.image as AssetImage).assetName, 'asset'); expect( - (tester.widgetList(find.byType(DecoratedBox)).toList()[0].decoration as BoxDecoration).image.toString(), - 'DecorationImage(NetworkImage("x-invalid://", scale: 1.0), ' - 'ColorFilter.mode(${const Color(0xff8811ff)}, BlendMode.xor), Alignment.center, scale 1.0, ' - 'opacity 1.0, FilterQuality.high)', - ); + assetImage.colorFilter, + const ColorFilter.matrix([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])); + expect(assetImage.centerSlice, const Rect.fromLTRB(5.0, 8.0, 105.0, 78.0)); + expect(assetImage.filterQuality, FilterQuality.none); + + final DecorationImage networkImage = (tester.widgetList(find.byType(DecoratedBox)).toList()[0].decoration as BoxDecoration).image!; + expect(networkImage.image, isA()); + expect((networkImage.image as NetworkImage).url, 'x-invalid://'); + expect(networkImage.colorFilter, const ColorFilter.mode(Color(0xFF8811FF), BlendMode.xor)); + expect(networkImage.filterQuality, FilterQuality.high); ArgumentDecoders.colorFilterDecoders['custom'] = (DataSource source, List key) { return const ColorFilter.mode(Color(0x12345678), BlendMode.xor);