Skip to content

refactor: Remove material imports from Widget tests #185078

Merged
auto-submit[bot] merged 23 commits into
flutter:masterfrom
master-wayne7:refactor/cross-imports-v2
May 16, 2026
Merged

refactor: Remove material imports from Widget tests #185078
auto-submit[bot] merged 23 commits into
flutter:masterfrom
master-wayne7:refactor/cross-imports-v2

Conversation

@master-wayne7

@master-wayne7 master-wayne7 commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

This PR removes Material imports from:

  • default_text_editing_shortcuts_test.dart
  • framework_test.dart
  • scrollable_in_overlay_test.dart

Also moved TestRadio & TestSlider widgets to their respective separate files radio_tester.dart & slider_tester.dart

part of: #177415
dependent on #184798

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

rkishan516 and others added 2 commits April 11, 2026 04:31
…ditable_text_scribe_test, page_route_builder_test, radio_group_test, semantics_debugger_test, range_maintaining_scroll_physics_test, two_dimensional_scroll_view_test, routes_test, text_selection_test, selectable_region_test and text_golden_test
@github-actions github-actions Bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) f: scrolling Viewports, list views, slivers, etc. f: routes Navigator, Router, and related APIs. labels Apr 15, 2026

@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 widget tests to remove dependencies on the Material library, replacing Material widgets with custom test-specific implementations like TestCheckbox, TestRadio, and TestButton. It also updates the test infrastructure to use a custom TestWidgetsApp instead of MaterialApp. Feedback was provided regarding the use of instantaneous page changes in tests and a suggestion to improve the reusability of the newly introduced TestSlider widget.

Comment thread packages/flutter/test/widgets/framework_test.dart Outdated
Comment thread packages/flutter/test/widgets/semantics_debugger_test.dart Outdated

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

Just few small changes

Comment thread packages/flutter/test/widgets/default_text_editing_shortcuts_test.dart Outdated
Comment thread packages/flutter/test/widgets/framework_test.dart Outdated
@justinmc

Copy link
Copy Markdown
Contributor

Thanks for helping with the test decoupling effort! I'm going to focus on getting #184798 landed before I review this so that it's easier to see the specific changes done here. @master-wayne7 is the reason that you branched off of that PR because you needed TestCheckbox?

@master-wayne7

master-wayne7 commented Apr 16, 2026

Copy link
Copy Markdown
Contributor Author

@master-wayne7 is the reason that you branched off of that PR because you needed TestCheckbox?

Yeah in semantics_role_checks_test.dart I needed TechCheckbox.

rkishan516 and others added 7 commits April 24, 2026 12:06
…ditable_text_scribe_test, page_route_builder_test, radio_group_test, semantics_debugger_test, range_maintaining_scroll_physics_test, two_dimensional_scroll_view_test, routes_test, text_selection_test, selectable_region_test and text_golden_test
@github-actions github-actions Bot removed the f: routes Navigator, Router, and related APIs. label Apr 27, 2026
@master-wayne7

Copy link
Copy Markdown
Contributor Author

@rkishan516 @justinmc I have updated PR with master branch, now it will only show my changes. You guys can now review it.

/// A minimal implementation of [RadioGroupRegistry] for widget tests.
///
/// Useful when testing [RawRadio] in isolation, outside of a [RadioGroup].
class TestRegistry<T> extends RadioGroupRegistry<T> {

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.

Are we using TestRegistry somewhere? If not then shouldn't we remove it?

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.

Yes its used in radio_group_test.dart and radio_tester_test.dart

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.

Nit: I suggest renaming it to TestRadioGroupRegistry. Now that it is a public test util I think it helps to be more explicit about the name.


/// A stateful wrapper that hosts a [RadioGroup] with a mutable [groupValue],
/// making it easy to pump and interact with [TestRadio] buttons in tests.
class _TestRadioGroup<T> extends StatefulWidget {

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.

Could we have radio group tester like radio tester or maybe atleast we can move this to radio tester? Thoughts.

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'm happy either way. If we do make a radio_group_tester.dart we should also make a radio_group_tester_test.dart though.

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.

I am creating a separate radio_group_tester.dart which will have this code. But we already have a radio_group_test.dart file which is also using TestRadioGroup so no additional testing file is required for this.

Comment thread packages/flutter/test/widgets/restoration_scopes_moving_test.dart
Comment thread packages/flutter/test/widgets/semantics_debugger_test.dart Outdated

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

I think the only real blockers I see is that _TestSlider and the restoration_scopes_moving changes should be removed. Thanks!


/// A stateful wrapper that hosts a [RadioGroup] with a mutable [groupValue],
/// making it easy to pump and interact with [TestRadio] buttons in tests.
class _TestRadioGroup<T> extends StatefulWidget {

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'm happy either way. If we do make a radio_group_tester.dart we should also make a radio_group_tester_test.dart though.

Comment thread packages/flutter/test/widgets/restoration_scopes_moving_test.dart
Comment thread packages/flutter/test/widgets/semantics_debugger_test.dart Outdated

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

@justinmc justinmc added the CICD Run CI/CD label May 5, 2026
@justinmc justinmc requested a review from victorsanni May 5, 2026 22:27

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

@@ -0,0 +1,35 @@
// Copyright 2014 The Flutter Authors. All rights reserved.

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.

There is no associated test file for this class?

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.

Or do we not need a test here given widgets/radio_tester_test.dart already tests for mutable groupValue? And the widget has only a child property?

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.

There was already a radio_droup_test.dart file, I have updated that to use the TestRadioGroup.

@Piinks Piinks added the autosubmit Merge PR when tree becomes green via auto submit App label May 12, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 12, 2026
@auto-submit

auto-submit Bot commented May 12, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/185078, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR.

@github-actions github-actions Bot removed the CICD Run CI/CD label May 13, 2026
@master-wayne7

Copy link
Copy Markdown
Contributor Author

Hey @Piinks , I have updated the branch with the latest changes.

@Piinks Piinks added CICD Run CI/CD autosubmit Merge PR when tree becomes green via auto submit App labels May 13, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue May 14, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks May 15, 2026
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 15, 2026
@rkishan516 rkishan516 added the autosubmit Merge PR when tree becomes green via auto submit App label May 16, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue May 16, 2026
Merged via the queue into flutter:master with commit a8c3b09 May 16, 2026
176 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 16, 2026
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Test cross-imports Review Queue May 16, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request May 18, 2026
flutter/flutter@1ceffd1...3598686

2026-05-17 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from G9xv1qcMhvXOy-9pk... to 5Ki-dBY4SpWdQMF_3... (flutter/flutter#186636)
2026-05-17 bdero@google.com [Impeller] Canonicalize uniform block instance names for the GL backends (flutter/flutter#186394)
2026-05-16 srawlins@google.com [widgets] Use super parameters in missed spots (flutter/flutter#186198)
2026-05-16 120367427+master-wayne7@users.noreply.github.com refactor: Remove material imports from Widget tests  (flutter/flutter#185078)
2026-05-16 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#186602)
2026-05-16 chris@bracken.jp [gn] Fix typo in comment (flutter/flutter#186549)
2026-05-16 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from y6uQHA5xUN83IF395... to G9xv1qcMhvXOy-9pk... (flutter/flutter#186599)
2026-05-15 30870216+gaaclarke@users.noreply.github.com Removes bringup from passing macos/sdf tests (flutter/flutter#186527)
2026-05-15 mdebbar@google.com [web] Fix several WebParagraph bugs (flutter/flutter#186403)
2026-05-15 alex.medinsh@gmail.com Display the team ID and name when selecting a signing certificate (flutter/flutter#184665)
2026-05-15 chris@bracken.jp [iOS] Improve documentation on FlutterVSyncClient and FlutterDisplayLink (flutter/flutter#186456)
2026-05-15 jason-simmons@users.noreply.github.com Increase the run time of text field integration tests to 10 seconds (flutter/flutter#186475)
2026-05-15 155553833+MatejLNCD@users.noreply.github.com Fix web-server hot restart/reload not applying changes for entrypoints outside lib (flutter/flutter#183838)
2026-05-15 1063596+reidbaker@users.noreply.github.com Update dart_skills_lint dependency to e449787 and optimize skills validation test (flutter/flutter#186528)
2026-05-15 engine-flutter-autoroll@skia.org Roll Packages from 2ec2236 to 32c84d6 (3 revisions) (flutter/flutter#186583)
2026-05-15 53112208+BilalRehman08@users.noreply.github.com Dispose TextEditingController in IndexedStack example (flutter/flutter#186375)
2026-05-15 34465683+rkishan516@users.noreply.github.com refactor: update filename for sliver semantic widget (flutter/flutter#185917)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC bmparr@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
creatorpiyush pushed a commit to creatorpiyush/packages that referenced this pull request Jun 10, 2026
…r#11724)

flutter/flutter@1ceffd1...3598686

2026-05-17 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from G9xv1qcMhvXOy-9pk... to 5Ki-dBY4SpWdQMF_3... (flutter/flutter#186636)
2026-05-17 bdero@google.com [Impeller] Canonicalize uniform block instance names for the GL backends (flutter/flutter#186394)
2026-05-16 srawlins@google.com [widgets] Use super parameters in missed spots (flutter/flutter#186198)
2026-05-16 120367427+master-wayne7@users.noreply.github.com refactor: Remove material imports from Widget tests  (flutter/flutter#185078)
2026-05-16 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#186602)
2026-05-16 chris@bracken.jp [gn] Fix typo in comment (flutter/flutter#186549)
2026-05-16 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from y6uQHA5xUN83IF395... to G9xv1qcMhvXOy-9pk... (flutter/flutter#186599)
2026-05-15 30870216+gaaclarke@users.noreply.github.com Removes bringup from passing macos/sdf tests (flutter/flutter#186527)
2026-05-15 mdebbar@google.com [web] Fix several WebParagraph bugs (flutter/flutter#186403)
2026-05-15 alex.medinsh@gmail.com Display the team ID and name when selecting a signing certificate (flutter/flutter#184665)
2026-05-15 chris@bracken.jp [iOS] Improve documentation on FlutterVSyncClient and FlutterDisplayLink (flutter/flutter#186456)
2026-05-15 jason-simmons@users.noreply.github.com Increase the run time of text field integration tests to 10 seconds (flutter/flutter#186475)
2026-05-15 155553833+MatejLNCD@users.noreply.github.com Fix web-server hot restart/reload not applying changes for entrypoints outside lib (flutter/flutter#183838)
2026-05-15 1063596+reidbaker@users.noreply.github.com Update dart_skills_lint dependency to e449787 and optimize skills validation test (flutter/flutter#186528)
2026-05-15 engine-flutter-autoroll@skia.org Roll Packages from 2ec2236 to 32c84d6 (3 revisions) (flutter/flutter#186583)
2026-05-15 53112208+BilalRehman08@users.noreply.github.com Dispose TextEditingController in IndexedStack example (flutter/flutter#186375)
2026-05-15 34465683+rkishan516@users.noreply.github.com refactor: update filename for sliver semantic widget (flutter/flutter#185917)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC bmparr@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
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: text input Entering text in a text field or keyboard related problems CICD Run CI/CD framework flutter/packages/flutter repository. See also f: labels.

Projects

Development

Successfully merging this pull request may close these issues.

5 participants