[test cross imports] flutter_test cross import fixes#189265
[test cross imports] flutter_test cross import fixes#189265navaronbracke wants to merge 12 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors several tests in packages/flutter_test to remove dependencies on package:flutter/material.dart and package:flutter/cupertino.dart, replacing them with package:flutter/widgets.dart and custom test helpers like buildTestApp and TestButton. Feedback highlights a syntax error in packages/flutter_test/test/navigator_test.dart where .zero is used instead of Offset.zero in the custom page transition builders.
| return tree; | ||
| } | ||
|
|
||
| PageRoute<T> defaultPageRouteBuilder<T>(RouteSettings settings, WidgetBuilder builder) { |
There was a problem hiding this comment.
Since we haven't yet taken a decision on keeping TestWidgetsApp and the like in flutter_test...
This is another argument for said proposal. (copying this over is meh)
There was a problem hiding this comment.
I wonder how @chunhtai @Renzo-Olivares feel about making TestWidgetsApp and TestButton public in flutter_test now that they've been proven for a bit in flutter's tests privately? Maybe we should do it now instead of copying this.
There was a problem hiding this comment.
Moved TestWidgetsApp in #189435
I'm not sure about what to do with TestButton etc, since we're better off with a RawButton widget in that case? TestTextField is something that could be moved, though, I figured, since it makes the EditableText easier to use in tests
b559140 to
f788857
Compare
justinmc
left a comment
There was a problem hiding this comment.
LGTM but I do wonder if we want to move TestApp etc. here now as in my comment.
| return tree; | ||
| } | ||
|
|
||
| PageRoute<T> defaultPageRouteBuilder<T>(RouteSettings settings, WidgetBuilder builder) { |
There was a problem hiding this comment.
I wonder how @chunhtai @Renzo-Olivares feel about making TestWidgetsApp and TestButton public in flutter_test now that they've been proven for a bit in flutter's tests privately? Maybe we should do it now instead of copying this.
|
Going to mark this as a draft. I think I should tackle the test widgets app thing first. |
flutter#189435) This PR moves the `TestWidgetsApp` class from `flutter/test/widgets_app_tester.dart` to `flutter_test`, under `test_widgets_app.dart`. Part of flutter#181283 This came up in flutter#189265 as both Flutter and flutter_test require it for their tests (as well as future downstream consumers that could benefit from it) *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 [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [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]. If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance. **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 [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [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
216dee6 to
a4d1de9
Compare
There was a problem hiding this comment.
Code Review
This pull request refactors various tests in the Flutter package to decouple them from the Material library, replacing MaterialApp and Material-specific widgets with TestWidgetsApp, TestButton, and TestRoute. Two critical compilation errors were identified in packages/flutter_test/test/navigator_test.dart where .zero is incorrectly used instead of Offset.zero.
|
@justinmc Updated the PR now that TestWidgetsApp is under flutter_test. As for TestButton, I left it as is. I think with the idea of eventually providing a raw button primitive in the framework itself, we could replace TestButton with that instead, across both flutter/test and flutter_test |
This PR fixes some more tests in flutter_test in relation to importing Material
The
finders_testwas cleaned up a lot, but the remainder in that file is related to Material Tooltip, which is still a point of discussion relating to its test Finders.Part of #177415
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.
If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.
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.