Skip to content

clean up usages of resetXyz for TestFlutterView#180840

Merged
auto-submit[bot] merged 2 commits into
flutter:masterfrom
navaronbracke:test_view_reset_cleanup
Jan 17, 2026
Merged

clean up usages of resetXyz for TestFlutterView#180840
auto-submit[bot] merged 2 commits into
flutter:masterfrom
navaronbracke:test_view_reset_cleanup

Conversation

@navaronbracke

Copy link
Copy Markdown
Contributor

While reviewing #180728 we noticed that usage of TestFlutterView.resetXyz() was quite liberal and some places benefit from using TestFlutterView.reset(), to avoid repetition.

This PR cleans that up.

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-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.

@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos labels Jan 12, 2026
tester.view.physicalSize = const Size(200, 160);
tester.view.devicePixelRatio = 1.0;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.reset);

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.

This sounds like a bug, since tester.view.devicePixelRatio was not reset?

// Regression test for https://github.com/flutter/flutter/issues/112163

tester.view.physicalSize = const Size(540, 340);
addTearDown(tester.view.resetPhysicalSize);

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 it upwards, so that it is easy to see that the teardown is there, instead of putting it at the bottom of the test.

@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 cleans up the usage of resetXyz methods for TestFlutterView in several tests, preferring TestFlutterView.reset() for conciseness and correctness. The changes are generally good, replacing multiple reset calls with a single one and fixing a bug where not all modified view properties were being reset. I've found one place where the cleanup could be improved by using addTearDown for more robust test cleanup, consistent with the changes in other files.

Comment thread packages/flutter/test/widgets/two_dimensional_viewport_test.dart Outdated

@huycozy huycozy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM with one nit! Thanks for cleaning this!

Can you also make this for

tester.view.physicalSize = Size(viewWidth * dpi, viewHeight * dpi);
as well?

@navaronbracke
navaronbracke requested a review from huycozy January 13, 2026 07:58
@github-actions github-actions Bot added the f: cupertino flutter/packages/flutter/cupertino repository label Jan 13, 2026
@navaronbracke

Copy link
Copy Markdown
Contributor Author

@Piinks Turns out that cleaning this up does reveal that usages of TestFlutterView's various test-only setters could probably use a custom lint rule for flutter/flutter. (there's a bunch of things, such as addTearDown being set up multiple times, the tear down being in an odd place in the test etc)

Who is in charge of figuring out which manual checks in dev/bots can be converted into lint rules? I'd like to reach out an propose a lint rule that makes this easier to clean up / catch in the future.

@huycozy huycozy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! Thank you!

@huycozy

huycozy commented Jan 13, 2026

Copy link
Copy Markdown
Member

Requesting @justinmc review: to trigger Google testing(looks like my approval triggered it somehow, I have no idea 🤷‍♂️)
, and also think this is good to be included and merged in test cleanup work to serve in decoupling project too.

@huycozy
huycozy requested a review from justinmc January 13, 2026 09:10
@navaronbracke

Copy link
Copy Markdown
Contributor Author

Requesting @justinmc review: to trigger Google testing, and also think this is good to be included and merged in test cleanup work to serve in decoupling project too.

I don't quite follow? TestFlutterView is unrelated to that project.

@huycozy

huycozy commented Jan 13, 2026

Copy link
Copy Markdown
Member

I don't quite follow? TestFlutterView is unrelated to that project.

It's just my thought. Sorry for not making it clearer. Because I personally think it's better to complete this work before two separate packages are out, rather than 3 PRs in the future (material, cupertino and flutter repo(s)). Does this make sense?

@navaronbracke

Copy link
Copy Markdown
Contributor Author

Right, all three do use TestFlutterView for some things in tests. My bad. Although the Material / Cupertino split on its own is going to take a while. I also think that if there is a flutter_lints specific lint rule for TestFlutterView, Cupertino and Material could adopt said rule independently.

@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.

Great catches on all of these, thanks for cleaning these up! LGTM 👍

@justinmc justinmc added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 16, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Jan 17, 2026
Merged via the queue into flutter:master with commit 74f162d Jan 17, 2026
71 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jan 17, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 17, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 17, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 18, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 18, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 19, 2026
calltekk pushed a commit to calltekk/flutter that referenced this pull request Jan 19, 2026
While reviewing flutter#180728 we
noticed that usage of `TestFlutterView.resetXyz()` was quite liberal and
some places benefit from using `TestFlutterView.reset()`, to avoid
repetition.

This PR cleans that up.

## 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].
- [ ] 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.
- [ ] 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
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 19, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 19, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 20, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 20, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 20, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 20, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 20, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 21, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 21, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 21, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 22, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 22, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 22, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 23, 2026
@navaronbracke
navaronbracke deleted the test_view_reset_cleanup branch January 30, 2026 07:26
flutter-zl pushed a commit to flutter-zl/flutter that referenced this pull request Feb 10, 2026
While reviewing flutter#180728 we
noticed that usage of `TestFlutterView.resetXyz()` was quite liberal and
some places benefit from using `TestFlutterView.reset()`, to avoid
repetition.

This PR cleans that up.

## 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].
- [ ] 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.
- [ ] 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants