Skip to content

Commit 7018bc8

Browse files
[rfw] Update test to not depend on toString() (flutter#9590)
This is needed to land flutter#171916, which updates `NetworkImage.toString()`. Checking against `toString()` is flaky anyways. ## Pre-Review Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] page, which explains my responsibilities. - [x] I read and followed the [relevant style guides] and ran [the auto-formatter]. - [x] I signed the [CLA]. - [x] The title of the PR starts with the name of the package surrounded by square brackets, e.g. `[shared_preferences]` - [x] I [linked to at least one issue that this PR fixes] in the description above. - [x] I updated `pubspec.yaml` with an appropriate new version according to the [pub versioning philosophy], or I have commented below to indicate which [version change exemption] this PR falls under[^1]. - [x] I updated `CHANGELOG.md` to add a description of the change, [following repository CHANGELOG style], or I have commented below to indicate which [CHANGELOG exemption] this PR falls under[^1]. - [x] I updated/added any relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or I have commented below to indicate which [test exemption] this PR falls under[^1]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. <!-- Links --> [Contributor Guide]: https://github.com/flutter/packages/blob/main/CONTRIBUTING.md [Tree Hygiene]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md [relevant style guides]: https://github.com/flutter/packages/blob/main/CONTRIBUTING.md#style [the auto-formatter]: https://github.com/flutter/packages/blob/main/script/tool/README.md#format-code [CLA]: https://cla.developers.google.com/ [Discord]: https://github.com/flutter/flutter/blob/master/docs/contributing/Chat.md [linked to at least one issue that this PR fixes]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#overview [pub versioning philosophy]: https://dart.dev/tools/pub/versioning [version change exemption]: https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#version [following repository CHANGELOG style]: https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changelog-style [CHANGELOG exemption]: https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changelog [test exemption]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#tests
1 parent b4b9b41 commit 7018bc8

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

packages/rfw/test/argument_decoders_test.dart

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -384,20 +384,21 @@ void main() {
384384
skip: !runGoldens || true,
385385
);
386386
expect(find.byType(DecoratedBox), findsNWidgets(6));
387-
const String matrix = kIsWeb ? '1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1'
388-
: '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';
389-
expect(
390-
(tester.widgetList<DecoratedBox>(find.byType(DecoratedBox)).toList()[1].decoration as BoxDecoration).image.toString(),
391-
'DecorationImage(AssetImage(bundle: null, name: "asset"), ' // this just seemed like the easiest way to check all this...
392-
'ColorFilter.matrix([$matrix]), '
393-
'Alignment.center, centerSlice: Rect.fromLTRB(5.0, 8.0, 105.0, 78.0), scale 1.0, opacity 1.0, FilterQuality.none)',
394-
);
387+
388+
final DecorationImage assetImage = (tester.widgetList<DecoratedBox>(find.byType(DecoratedBox)).toList()[1].decoration as BoxDecoration).image!;
389+
expect(assetImage.image, isA<AssetImage>());
390+
expect((assetImage.image as AssetImage).assetName, 'asset');
395391
expect(
396-
(tester.widgetList<DecoratedBox>(find.byType(DecoratedBox)).toList()[0].decoration as BoxDecoration).image.toString(),
397-
'DecorationImage(NetworkImage("x-invalid://", scale: 1.0), '
398-
'ColorFilter.mode(${const Color(0xff8811ff)}, BlendMode.xor), Alignment.center, scale 1.0, '
399-
'opacity 1.0, FilterQuality.high)',
400-
);
392+
assetImage.colorFilter,
393+
const ColorFilter.matrix(<double>[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]));
394+
expect(assetImage.centerSlice, const Rect.fromLTRB(5.0, 8.0, 105.0, 78.0));
395+
expect(assetImage.filterQuality, FilterQuality.none);
396+
397+
final DecorationImage networkImage = (tester.widgetList<DecoratedBox>(find.byType(DecoratedBox)).toList()[0].decoration as BoxDecoration).image!;
398+
expect(networkImage.image, isA<NetworkImage>());
399+
expect((networkImage.image as NetworkImage).url, 'x-invalid://');
400+
expect(networkImage.colorFilter, const ColorFilter.mode(Color(0xFF8811FF), BlendMode.xor));
401+
expect(networkImage.filterQuality, FilterQuality.high);
401402

402403
ArgumentDecoders.colorFilterDecoders['custom'] = (DataSource source, List<Object> key) {
403404
return const ColorFilter.mode(Color(0x12345678), BlendMode.xor);

0 commit comments

Comments
 (0)