Skip to content

Conversation

@navaronbracke
Copy link
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
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
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.

Copy link
Contributor

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

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.

Copy link
Member

@huycozy huycozy left a comment

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

Copy link
Member

@huycozy huycozy left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you!

@huycozy
Copy link
Member

huycozy commented Jan 13, 2026

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
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
Copy link
Member

huycozy commented Jan 13, 2026

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

Copy link
Contributor

@justinmc justinmc left a comment

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