Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request consolidates color-related tests into packages/flutter/test/material/colors_test.dart, incorporating test suites for HSVColor, HSLColor, ColorSwatch, and color space conversions including Display P3 to extended sRGB. The check_tests_cross_imports.dart configuration is updated to remove the reference to the painting colors test file. Feedback identifies a variable naming inconsistency in the HSVColor saturation sweep test where hslColor is used for an HSVColor instance.
|
An existing Git SHA, To re-trigger presubmits after closing or re-opeing a PR, or pushing a HEAD commit (i.e. with |
|
An existing Git SHA, To re-trigger presubmits after closing or re-opeing a PR, or pushing a HEAD commit (i.e. with |
bbf5410 to
237a1f0
Compare
victorsanni
left a comment
There was a problem hiding this comment.
Thanks for this PR. I don't think we want to move painting/colors_test.dart to material/. I looked through the file, only the test 'MaterialColor swatch comparison' is tied to material/, so only that test should move if anything.
In general we do not want to wholesale move tests from the framework into the design libraries unless necessary.
|
Converting to draft to remove this PR from our review queue. Feel free to reconvert after addressing comments when this is ready for review. |
There was a problem hiding this comment.
Code Review
This pull request consolidates and expands color-related tests in packages/flutter/test/material/colors_test.dart, adding comprehensive test suites for HSVColor, HSLColor, ColorSwatch, and color space conversions such as Display P3 to sRGB. It also updates the cross-import checker to reflect these structural changes. Feedback suggests improving the readability of the MaterialColor equality test by using more accurate variable names and adopting more idiomatic assertion syntax.
I am having trouble creating individual review comments. Click here to see my feedback.
packages/flutter/test/material/colors_test.dart (740-756)
The variable name differentMap is misleading because it contains the exact same content as sampleMap. In the context of this test, which verifies that MaterialColor equality correctly handles different map instances with identical content, a name like anotherMap or identicalMap would be more accurate and improve readability. Additionally, using expect(a, b) is more idiomatic in Flutter tests than expect(a == b, true) for testing equality operators.
test('MaterialColor swatch comparison', () {
final sampleMap = <int, MaterialColor>{
0: Colors.lightBlue,
1: Colors.deepOrange,
2: Colors.blueGrey,
};
final anotherMap = <int, MaterialColor>{
0: Colors.lightBlue,
1: Colors.deepOrange,
2: Colors.blueGrey,
};
final first = MaterialColor(0, sampleMap);
final second = MaterialColor(0, sampleMap);
final third = MaterialColor(0, anotherMap);
expect(first, second);
expect(first, third);
});
References
- Optimize for readability: Code is read more often than it is written. (link)
|
Maintainer label request: please add |
|
This is approved, and the only current status failure appears to be the global tree-status. Could you please add autosubmit when you get a chance? |
|
Given this a cross import change fixing painting importing material/cupertino (versus material/cupertino importing something bad), this is not a critical change for pre-release of material_ui/cupertino_ui. As such, I've marked this PR as not ready to port to flutter/packages yet. The changes not in the material or cupertino libraries will remain here, which means in the future this PR will need to be split up. |
|
This pull request contains changes to Material or Cupertino, which are currently frozen in this repository. Changes should be made in Please refer to #188444 for instructions. |
There was a problem hiding this comment.
Code Review
This pull request moves the MaterialColor swatch comparison test from painting/colors_test.dart to material/colors_test.dart, updates imports in painting/colors_test.dart to avoid importing material.dart, and adds two tests to the cross-import allowlist. Feedback suggests avoiding adding tests to the cross-import allowlist by refactoring their imports or moving them, and recommends updating the MaterialColor swatch comparison test to use standard Color values instead of nested MaterialColor instances.
| 'packages/flutter/test/painting/decoration_image_lerp_test.dart', | ||
| 'packages/flutter/test/painting/continuous_rectangle_border_test.dart', |
There was a problem hiding this comment.
Adding new tests to the knownPaintingCrossImports allowlist should be avoided if possible, as the goal is to reduce and eventually eliminate cross-imports from lower-level packages like painting to higher-level packages like material.\n\nPlease check if decoration_image_lerp_test.dart and continuous_rectangle_border_test.dart can be updated to import package:flutter/painting.dart instead of package:flutter/material.dart. If they actually require material-specific features for testing, they should be moved to the test/material/ directory instead of being added to this allowlist.
References
- Suggest simplification and refactoring: Assess whether the code can be made simpler or refactored to enhance readability and maintainability. (link)
| test('MaterialColor swatch comparison', () { | ||
| final sampleMap = <int, MaterialColor>{ | ||
| 0: Colors.lightBlue, | ||
| 1: Colors.deepOrange, | ||
| 2: Colors.blueGrey, | ||
| }; | ||
| final anotherMap = <int, MaterialColor>{ | ||
| 0: Colors.lightBlue, | ||
| 1: Colors.deepOrange, | ||
| 2: Colors.blueGrey, | ||
| }; | ||
| final first = MaterialColor(0, sampleMap); | ||
| final second = MaterialColor(0, sampleMap); | ||
| final third = MaterialColor(0, anotherMap); | ||
| expect(first, second); | ||
| expect(first, third); | ||
| }); |
There was a problem hiding this comment.
Using MaterialColor instances as values inside a MaterialColor's swatch map is unrealistic and can be confusing, as swatches typically map color strengths (e.g., 50, 100) to standard Color instances.\n\nWe can refactor this test to use standard Color values, which makes the test more idiomatic and realistic.
test('MaterialColor swatch comparison', () {\n final sampleMap = <int, Color>{\n 50: const Color(0xFFE1F5FE),\n 100: const Color(0xFFB3E5FC),\n };\n final anotherMap = <int, Color>{\n 50: const Color(0xFFE1F5FE),\n 100: const Color(0xFFB3E5FC),\n };\n final first = MaterialColor(0, sampleMap);\n final second = MaterialColor(0, sampleMap);\n final third = MaterialColor(0, anotherMap);\n expect(first, second);\n expect(first, third);\n });References
- Suggest simplification and refactoring: Assess whether the code can be made simpler or refactored to enhance readability and maintainability. (link)
This PR ports the Material-specific test from [flutter/flutter#186777](flutter/flutter#186777) to `material_ui`. The `MaterialColor swatch comparison` test verifies equality for separate swatch maps containing the same standard `Color` values. This is a test-only port, so no package version or changelog entry is needed. Part of [flutter/flutter#188444](flutter/flutter#188444). The PR that removes the test in the framework is flutter/flutter#192716
flutter/packages@1383427...93baed9 2026-10-22 [email protected] [material_ui] Port flutter/flutter flutter#186777 MaterialColor test (flutter/packages#12858) 2026-10-21 [email protected] [rfw] Migrate to material_ui (flutter/packages#12811) 2026-10-21 [email protected] [cupertino_ui] Fix the installing command of the cupertino_ui package (flutter/packages#13141) 2026-10-21 [email protected] [cupertino_ui] Unskip web tests that pass on CanvasKit and Skwasm: date_picker_test, spell_check_suggestions_toolbar_test (flutter/packages#13367) 2026-10-21 [email protected] [video_player] Convert player classes to Swift (flutter/packages#13197) 2026-10-21 [email protected] [camera_windows] Fall back to a physical stream for cameras that reject preferred-stream selectors (flutter/packages#12748) 2026-10-21 [email protected] [google_sign_in_ios, video_player] Specify types for pattern variable declarations (flutter/packages#13362) 2026-10-21 [email protected] [google_maps_flutter_web] Issue 64073 implement my location (flutter/packages#12186) 2026-10-21 [email protected] [material_ui] Unskip web tests that pass on CanvasKit and Skwasm: app_bar_theme_test, input_decorator_test, paginated_data_table_test, spell_check_suggestions_toolbar_test (flutter/packages#13352) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC [email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
flutter/packages@1383427...93baed9 2026-10-22 [email protected] [material_ui] Port flutter/flutter flutter#186777 MaterialColor test (flutter/packages#12858) 2026-10-21 [email protected] [rfw] Migrate to material_ui (flutter/packages#12811) 2026-10-21 [email protected] [cupertino_ui] Fix the installing command of the cupertino_ui package (flutter/packages#13141) 2026-10-21 [email protected] [cupertino_ui] Unskip web tests that pass on CanvasKit and Skwasm: date_picker_test, spell_check_suggestions_toolbar_test (flutter/packages#13367) 2026-10-21 [email protected] [video_player] Convert player classes to Swift (flutter/packages#13197) 2026-10-21 [email protected] [camera_windows] Fall back to a physical stream for cameras that reject preferred-stream selectors (flutter/packages#12748) 2026-10-21 [email protected] [google_sign_in_ios, video_player] Specify types for pattern variable declarations (flutter/packages#13362) 2026-10-21 [email protected] [google_maps_flutter_web] Issue 64073 implement my location (flutter/packages#12186) 2026-10-21 [email protected] [material_ui] Unskip web tests that pass on CanvasKit and Skwasm: app_bar_theme_test, input_decorator_test, paginated_data_table_test, spell_check_suggestions_toolbar_test (flutter/packages#13352) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC [email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Summary
Moves the Material color and palette tests from painting into the Material test directory:
packages/flutter/test/painting/colors_test.dart->packages/flutter/test/material/colors_test.dartRemoves the now-obsolete painting cross-import allowlist entry.
Part of #177414
Refs #177028
Tests
bin/cache/dart-sdk/bin/dart --enable-asserts dev/bots/check_tests_cross_imports.dartbin/cache/dart-sdk/bin/dart analyze packages/flutter/test/material/colors_test.dart dev/bots/check_tests_cross_imports.dartbin/cache/dart-sdk/bin/dart format --output=none --set-exit-if-changed packages/flutter/test/material/colors_test.dart dev/bots/check_tests_cross_imports.dartgit diff --check./bin/flutter analyze --no-pub packages/flutter/test/material/colors_test.dart dev/bots/check_tests_cross_imports.dart./bin/flutter test --no-pub packages/flutter/test/material/colors_test.dart