-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Reland Add test for dynamic_content_color.0.dart #158547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reland Add test for dynamic_content_color.0.dart #158547
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Because this example is somewhat complex, consider introducing several tests.
See my comment about factoring out the fake loader.
First test is the one you have (just removed the last step).
Second test would be the end of your test (switching brightness).
Third test would simulate selecting the second image and checking the color scheme has changed.
|
|
||
| testWidgets('The theme colors are created dynamically from the first image', (WidgetTester tester) async { | ||
| final List<(ImageProvider<Object>, Brightness)> loadColorSchemeCalls = <(ImageProvider<Object>, Brightness)>[]; | ||
| await tester.pumpWidget( | ||
| example.DynamicColorExample( | ||
| loadColorScheme: (ImageProvider<Object> provider, Brightness brightness) async { | ||
| loadColorSchemeCalls.add((provider, brightness)); | ||
| return const ColorScheme.light(); | ||
| }, | ||
| ), | ||
| ); | ||
| await tester.pump(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| testWidgets('The theme colors are created dynamically from the first image', (WidgetTester tester) async { | |
| final List<(ImageProvider<Object>, Brightness)> loadColorSchemeCalls = <(ImageProvider<Object>, Brightness)>[]; | |
| await tester.pumpWidget( | |
| example.DynamicColorExample( | |
| loadColorScheme: (ImageProvider<Object> provider, Brightness brightness) async { | |
| loadColorSchemeCalls.add((provider, brightness)); | |
| return const ColorScheme.light(); | |
| }, | |
| ), | |
| ); | |
| await tester.pump(); | |
| final List<(ImageProvider<Object>, Brightness)> loadColorSchemeCalls = <(ImageProvider<Object>, Brightness)>[]; | |
| Future<ColorScheme> fakeColorSchemeLoader(ImageProvider<Object> provider, Brightness brightness) async { | |
| loadColorSchemeCalls.add((provider, brightness)); | |
| return provider == example.DynamicColorExample.images[1] | |
| ? ColorScheme.fromSeed(seedColor: Colors.lightBlue) | |
| : const ColorScheme.light(); | |
| } | |
| setUp(() { | |
| loadColorSchemeCalls.clear(); | |
| }); | |
| testWidgets('The theme colors are created dynamically from the first image', (WidgetTester tester) async { | |
| await tester.pumpWidget( | |
| example.DynamicColorExample(loadColorScheme: fakeColorSchemeLoader), | |
| ); | |
| await tester.pump(); |
Proposed way to share the fake loader between several tests.
| Brightness.light, | ||
| ); | ||
|
|
||
| await tester.tap(find.byType(Switch)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Starting there, it could be more readable to start a new test, maybe named 'Brightness can be changed'
(the content should be updated because the list containing calls is cleared between tests).
|
Nice suggestions @bleroux ! I've done the changes in test: More detailed tests, hope it is good enough :) |
bleroux
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost ready, see my comments
| expect( | ||
| loadColorSchemeCalls.single.$1, | ||
| isA<NetworkImage>() | ||
| .having( | ||
| (NetworkImage provider) => provider.url, | ||
| 'url', | ||
| 'https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_1.png', | ||
| ), | ||
| ); | ||
| expect( | ||
| loadColorSchemeCalls.single.$2, | ||
| Brightness.light, | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe make the test shorter by removing those lines as it was already tested on the other test and it is not what this test focus on.
| loadColorSchemeCalls.last.$2, | ||
| Brightness.light, | ||
| ); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to check the app color scheme is the new one?
aac7e2c to
03b1bd1
Compare
bleroux
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Roll Flutter from ed553d1 to 0e2d55e (40 revisions) flutter/flutter@ed553d1...0e2d55e 2024-11-15 engine-flutter-autoroll@skia.org Roll Packages from b9ac917 to b164be3 (4 revisions) (flutter/flutter#158986) 2024-11-15 magder@google.com Label PRs with gradle and Android paths "platform-android" (flutter/flutter#158970) 2024-11-15 kustermann@google.com Fix code asset copying logic in native asset code (flutter/flutter#158984) 2024-11-15 kustermann@google.com Fix duplicate work in native assets release builds (flutter/flutter#158980) 2024-11-15 matanlurey@users.noreply.github.com Stop generate both `.kts` and non-`.kts` gradle files for a test project. (flutter/flutter#158965) 2024-11-15 matanlurey@users.noreply.github.com Further skip `native_assets_test`(s) that runs `flutter build apk`. (flutter/flutter#158966) 2024-11-15 49699333+dependabot[bot]@users.noreply.github.com Bump actions/checkout from 4.2.1 to 4.2.2 (flutter/flutter#157473) 2024-11-15 matanlurey@users.noreply.github.com Try running historically flaky tests first to make `flutter build apk` health tests time out more often? (flutter/flutter#158967) 2024-11-15 bkonyi@google.com [ tool ] Don't throw StateError when DDS fails to start (flutter/flutter#158744) 2024-11-14 katelovett@google.com Create merge_queue.md (flutter/flutter#158959) 2024-11-14 fluttergithubbot@gmail.com Marks Mac_x64 hot_mode_dev_cycle_macos_target__benchmark to be flaky (flutter/flutter#158569) 2024-11-14 fluttergithubbot@gmail.com Marks Mac_arm64 mac_desktop_impeller to be unflaky (flutter/flutter#158564) 2024-11-14 gengesa@gmail.com [gen_l10n] When localizing a message, prefer placeholder definitions defined by the current locale rather than the template locale (flutter/flutter#153459) 2024-11-14 august.oberhauser@swissinfo.ch feat: Include web 1.x.x in plugin template (flutter/flutter#156947) 2024-11-14 andrewrkolos@gmail.com hide members where possible (flutter/flutter#158492) 2024-11-14 andrewrkolos@gmail.com Move platform-specific log-reading implementation details from `ResidentRunner`/`FlutterDevice` to `DeviceLogReader` implementations (flutter/flutter#156181) 2024-11-14 98221114+Neutrino2711@users.noreply.github.com Updated document to clarify Clip Behaviour (flutter/flutter#157719) 2024-11-14 bkonyi@google.com Enable --verbose for android_plugin_skip_unsupported_test tests (flutter/flutter#158933) 2024-11-14 engine-flutter-autoroll@skia.org Roll Packages from 26e123a to b9ac917 (5 revisions) (flutter/flutter#158938) 2024-11-14 43054281+camsim99@users.noreply.github.com Add `dev_dependency` attribute to plugins in `.flutter-plugins-dependencies` (flutter/flutter#158009) 2024-11-14 matanlurey@users.noreply.github.com No longer pass `--verbose` to implicit `pub` calls when `flutter --verbose` is set. (flutter/flutter#158898) 2024-11-14 stuartmorgan@google.com Update triage flow chart for SVG packages (flutter/flutter#158670) 2024-11-14 bruno.leroux@gmail.com Add one MenuAnchor alignment test (flutter/flutter#158915) 2024-11-14 32538273+ValentinVignal@users.noreply.github.com Reland Add test for dynamic_content_color.0.dart (flutter/flutter#158547) 2024-11-14 engine-flutter-autoroll@skia.org Roll Flutter Engine from e97b148e796d to 619804c0fbb7 (1 revision) (flutter/flutter#158905) 2024-11-14 engine-flutter-autoroll@skia.org Roll Flutter Engine from 82940a9aa714 to e97b148e796d (1 revision) (flutter/flutter#158901) 2024-11-14 matanlurey@users.noreply.github.com Move explicit package dependencies to a feature flag (flutter/flutter#158016) 2024-11-14 matanlurey@users.noreply.github.com Try with `bringup: true` debugging why `flutter build apk` often times out. (flutter/flutter#158895) 2024-11-14 rexios@rexios.dev Add constraint options to `SearchAnchor` suggestions builder (flutter/flutter#148856) 2024-11-14 50643541+Mairramer@users.noreply.github.com Adjusts the Hindi TimeOfDayFormat to display in a LTR orientation in localizations. (flutter/flutter#157998) 2024-11-14 38378650+hgraceb@users.noreply.github.com Fix update order of SliverAppBar (flutter/flutter#158159) 2024-11-13 42980667+srivats22@users.noreply.github.com #154792 - CupertinoActionSheetAction cursor doesn't change to clickable on desktop (flutter/flutter#158470) 2024-11-13 58190796+MitchellGoodwin@users.noreply.github.com Adds a skip message for analyzer (flutter/flutter#158890) 2024-11-13 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Marks Mac_arm64_ios hot_mode_dev_cycle_ios__benchmark to be flaky (#158242)" (flutter/flutter#158891) 2024-11-13 737941+loic-sharma@users.noreply.github.com [SwiftPM] Move the logic for SwiftPM enablement to the platform project (flutter/flutter#158213) 2024-11-13 matanlurey@users.noreply.github.com Temporarily skip flutter build apk for native_assets tests. (flutter/flutter#158880) 2024-11-13 me@alestiago.com docs: include Human Interface haptic information in HapticFeedback (flutter/flutter#158587) 2024-11-13 engine-flutter-autoroll@skia.org Roll Flutter Engine from db3e5af2ca22 to 82940a9aa714 (2 revisions) (flutter/flutter#158799) 2024-11-13 matanlurey@users.noreply.github.com Stream the output of `flutter build` for debugging. (flutter/flutter#158757) 2024-11-13 nate.w5687@gmail.com "Fix failing checks" wiki page for new contributors (flutter/flutter#154629) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC dit@google.com,stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. ...

Fixes #130459
Follow up of the reverted #158309
It adds a test for
examples/api/lib/material/color_scheme/dynamic_content_color.0.dartPre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.