Skip to content

[test cross imports] flutter_test cross import fixes#189265

Open
navaronbracke wants to merge 12 commits into
flutter:masterfrom
navaronbracke:cross_import_fixes
Open

[test cross imports] flutter_test cross import fixes#189265
navaronbracke wants to merge 12 commits into
flutter:masterfrom
navaronbracke:cross_import_fixes

Conversation

@navaronbracke

Copy link
Copy Markdown
Contributor

This PR fixes some more tests in flutter_test in relation to importing Material

The finders_test was 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-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.

@navaronbracke
navaronbracke requested review from Piinks and justinmc July 10, 2026 14:28
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jul 10, 2026
@github-actions github-actions Bot added a: tests "flutter test", flutter_test, or one of our tests framework flutter/packages/flutter repository. See also f: labels. a: animation Animation APIs a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) f: routes Navigator, Router, and related APIs. c: tech-debt Technical debt, code quality, testing, etc. labels Jul 10, 2026
Comment thread packages/flutter/test_fixes/dart_ui/dart_ui.dart

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/flutter_test/test/navigator_test.dart
Comment thread packages/flutter_test/test/navigator_test.dart
return tree;
}

PageRoute<T> defaultPageRouteBuilder<T>(RouteSettings settings, WidgetBuilder builder) {

@navaronbracke navaronbracke Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@navaronbracke navaronbracke Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread packages/flutter_test/test/navigator_test.dart
Comment thread packages/flutter_test/test/live_widget_controller_test.dart Outdated
justinmc
justinmc previously approved these changes Jul 10, 2026

@justinmc justinmc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but I do wonder if we want to move TestApp etc. here now as in my comment.

Comment thread packages/flutter_test/test/finders_test.dart Outdated
return tree;
}

PageRoute<T> defaultPageRouteBuilder<T>(RouteSettings settings, WidgetBuilder builder) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@navaronbracke

Copy link
Copy Markdown
Contributor Author

Going to mark this as a draft. I think I should tackle the test widgets app thing first.

AbdeMohlbi pushed a commit to AbdeMohlbi/flutter that referenced this pull request Jul 21, 2026
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
@github-actions github-actions Bot added the a: text input Entering text in a text field or keyboard related problems label Jul 23, 2026
@navaronbracke
navaronbracke marked this pull request as ready for review July 23, 2026 11:44
@navaronbracke
navaronbracke requested a review from justinmc July 23, 2026 11:44

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/flutter_test/test/navigator_test.dart
Comment thread packages/flutter_test/test/navigator_test.dart
@navaronbracke

Copy link
Copy Markdown
Contributor Author

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) a: animation Animation APIs a: tests "flutter test", flutter_test, or one of our tests a: text input Entering text in a text field or keyboard related problems c: tech-debt Technical debt, code quality, testing, etc. CICD Run CI/CD f: routes Navigator, Router, and related APIs. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants