Remove divider from widgets tests#180999
Conversation
There was a problem hiding this comment.
Code Review
This pull request effectively removes usages of Divider from several widget tests to reduce dependencies on the material package. The changes correctly replace Divider with SizedBox or custom widget implementations as appropriate. A new file, widget_test_utils.dart, is introduced to provide basic widgets for tests, which is a good step towards better test modularity. The changes are well-executed and align with the PR's goal. I have one suggestion for the new test utility file to improve clarity and maintainability.
| /// Get a random color for use in a widget test. | ||
| /// | ||
| /// The returned color will be fully opaque, | ||
| /// but the [Color.r], [Color.g], and [Color.b] channels | ||
| /// will each be randomized between `00` and `FF`. | ||
| Color getRandomTestColor(int index) { |
There was a problem hiding this comment.
The function name getRandomTestColor and its documentation are misleading. The function returns a deterministic color from a predefined list based on the index, not a random color. The documentation also incorrectly states that RGB channels are randomized.
To improve clarity and accuracy, I suggest renaming the function to getTestColor and updating the documentation to reflect its actual behavior. This aligns with the style guide's emphasis on readability and useful documentation.
/// Get a deterministic color for use in a widget test.
///
/// The returned color will be fully opaque and is selected from a predefined
/// list of colors based on the given [index].
Color getTestColor(int index) {b8ee04d to
7ab2ade
Compare
|
|
||
| // Regression test for https://github.com/flutter/flutter/issues/100451 | ||
| testWidgets('ListView.separator respects findChildIndexCallback', (WidgetTester tester) async { | ||
| testWidgets('ListView.separated respects findChildIndexCallback', (WidgetTester tester) async { |
|
Since this has 2 approvals now, can this get an autosubmit as well? |
This PR removes `Divider` usages from `test/widgets/scroll_view_test.dart` and `test/widgets/list_view_test.dart`. Usages of `Divider()` still exist under `examples/api` and in code samples under `lib/widgets`, though. Part of flutter#177415 Part of flutter#180501 *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].* ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This PR removes `Divider` usages from `test/widgets/scroll_view_test.dart` and `test/widgets/list_view_test.dart`. Usages of `Divider()` still exist under `examples/api` and in code samples under `lib/widgets`, though. Part of flutter#177415 Part of flutter#180501 *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].* ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This PR removes
Dividerusages fromtest/widgets/scroll_view_test.dartandtest/widgets/list_view_test.dart.Usages of
Divider()still exist underexamples/apiand in code samples underlib/widgets, though.Part of #177415
Part of #180501
If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.