Skip to content

Remove semantics_tester import from material_button_test.dart - #184807

Merged
auto-submit[bot] merged 7 commits into
flutter:masterfrom
Sanaullah49:chore/182636-material-button-semantics
Jun 2, 2026
Merged

Remove semantics_tester import from material_button_test.dart#184807
auto-submit[bot] merged 7 commits into
flutter:masterfrom
Sanaullah49:chore/182636-material-button-semantics

Conversation

@Sanaullah49

Copy link
Copy Markdown
Contributor

Part of #182636

Summary

Remove the semantics_tester.dart cross-import from material_button_test.dart.

What changed

  • Replaced the deprecated SemanticsTester/TestSemantics assertions in the MaterialButton semantics test with tester.getSemantics(...) and matchesSemantics(...)
  • Kept the semantic size verification for the enabled and disabled button states
  • Removed the ../widgets/semantics_tester.dart import

Testing

  • ../../bin/flutter analyze test/material/material_button_test.dart
  • ../../bin/flutter test test/material/material_button_test.dart

@github-actionsgithub-actionsBot added framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages labels Apr 9, 2026

@gemini-code-assistgemini-code-assistBot 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 the semantics tests for MaterialButton to use the matchesSemantics matcher and tester.getSemantics API, replacing the deprecated SemanticsTester. A review comment identifies that the updated assertions for the disabled button state are less rigorous than the original implementation and suggests explicitly verifying that the button is disabled and lacks a tap action to maintain test coverage.

Comment threadpackages/flutter/test/material/material_button_test.dart
@Sanaullah49

Copy link
Copy Markdown
ContributorAuthor

The disabled MaterialButton semantics check on the PR branch now explicitly verifies that isEnabled is false and the tap action is absent. Verified the changed test locally with ./bin/flutter test packages/flutter/test/material/material_button_test.dart --plain-name "Disabled MaterialButton has same semantic size as enabled and exposes disabled semantics".

),
);

final SemanticsNode semantics = tester.getSemantics(find.byType(MaterialButton));

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 find it somewhat strange that the previous tester.getSemantics is done inline inside of expect but this one isn't. A very minor nit though :)

Comment threadpackages/flutter/test/material/material_button_test.dart
@justinmcjustinmc moved this from Todo to In Progress in Test cross-imports Review QueueApr 29, 2026
@chunhtai
chunhtai self-requested a review April 30, 2026 16:19

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

This conversion looks good, left some comments


const expectedButtonSize = Rect.fromLTRB(0.0, 0.0, 116.0, 48.0);
// Button is in center of screen
final expectedButtonTransform = Matrix4.identity()

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.

can we keep the check for transform?

I think we can directly compare SemanticsNode.transform

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Kept — expect(enabledSemantics.transform, expectedButtonTransform) and the same for disabledSemantics are now in the test (lines 678 and 708). The expectedButtonTransform constant is preserved.

TestSemantics.fullScreen.width / 2 - expectedButtonSize.width / 2,
TestSemantics.fullScreen.height / 2 - expectedButtonSize.height / 2,
);
final SemanticsHandle handle = tester.ensureSemantics();

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.

This is not needed

Comment threadpackages/flutter/test/material/material_button_test.dart
@Sanaullah49

Copy link
Copy Markdown
ContributorAuthor

Thanks @justinmc and @chunhtai! Addressed all the feedback:

  • Replaced SemanticsHandle handle + manual handle.dispose() with addTearDown(tester.ensureSemantics().dispose)
  • Restored the transform check via SemanticsNode.transform as requested by @chunhtai
  • Extracted the enabled-button semantics into a variable for consistency with the disabled-button section

…tent semantics variables
- Replace manual SemanticsHandle + dispose with addTearDown pattern
- Restore expectedButtonTransform check via SemanticsNode.transform as
requested by @chunhtai
- Extract enabled button semantics into a variable for consistency with
the disabled button section
@Sanaullah49
Sanaullah49force-pushed the chore/182636-material-button-semantics branch from 4aa5acd to 71eb0dfCompareMay 5, 2026 05:51
@@ -636,11 +635,11 @@ void main() {
testWidgets(
'Disabled MaterialButton has same semantic size as enabled and exposes disabled semantics',
(WidgetTester tester) async {
final semantics = SemanticsTester(tester);
addTearDown(tester.ensureSemantics().dispose);

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 don't think this is needed?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Done in c4bb886 — you're right, tester.getSemantics reads debugSemantics directly via SemanticsController.find (no enable needed), and filled_button_test.dart follows the same pattern. Removed the addTearDown line.

tester.getSemantics reads debugSemantics directly via
SemanticsController.find, so ensureSemantics is not required
for this test. Matches the pattern used in filled_button_test.dart.
@dkwingsmtdkwingsmt added the CICD Run CI/CD label May 13, 2026
TestSemantics.fullScreen is defined in semantics_tester.dart, which
this PR removes the import for. Replace the reference with the
literal 400.0/300.0 (half of the 800x600 test screen) so the test
compiles without the semantics_tester import.
@github-actionsgithub-actionsBot removed the CICD Run CI/CD label May 15, 2026
@dkwingsmtdkwingsmt added the CICD Run CI/CD label May 20, 2026
@github-actionsgithub-actionsBot removed the CICD Run CI/CD label May 21, 2026
@Sanaullah49

Copy link
Copy Markdown
ContributorAuthor

Pushed a small fix for the failing run: removed the obvious local type annotations flagged by analyze and adjusted the transform expectation to include the root semantics scale. Local checks pass: ./bin/dart analyze packages/flutter/test/material/material_button_test.dart and ./bin/flutter test packages/flutter/test/material/material_button_test.dart --plain-name "Disabled MaterialButton has same semantic size as enabled and exposes disabled semantics".

@dkwingsmtdkwingsmt added the CICD Run CI/CD label May 27, 2026
@flutter-dashboard

Copy link
Copy Markdown

This pull request is not mergeable in its current state, likely because of a merge conflict. Pre-submit CI jobs were not triggered. Pushing a new commit to this branch that resolves the issue will result in pre-submit jobs being scheduled.

@github-actionsgithub-actionsBot removed the CICD Run CI/CD label May 27, 2026

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

@justinmcjustinmc 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 👍 . Thank you!

@justinmcjustinmc added CICD Run CI/CD override code freeze Override an active code freeze. labels Jun 2, 2026
@chunhtaichunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 2, 2026
@auto-submitauto-submitBot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jun 2, 2026
@auto-submit

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/184807, because - The status or check suite Mac_x64 framework_tests_misc has failed. Please fix the issues identified (or deflake) before re-applying this label.

@chunhtaichunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 2, 2026
@auto-submit
auto-submitBot added this pull request to the merge queueJun 2, 2026
Merged via the queue into flutter:master with commit 1668e8aJun 2, 2026
103 of 105 checks passed
@flutter-dashboardflutter-dashboardBot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jun 2, 2026
auto-submitBot pushed a commit to flutter/packages that referenced this pull request Jun 3, 2026
…11832)
Manual roll requested by tarrinneal@google.com
flutter/flutter@701665b...2ba5420
2026-06-03 engine-flutter-autoroll@skia.org Roll Packages from 818b310 to b11504f (8 revisions) (flutter/flutter#187511)
2026-06-03 mdebbar@google.com Add new file patterns for team-web labeler (flutter/flutter#187397)
2026-06-03 engine-flutter-autoroll@skia.org Roll Skia from 279b17fe9fc1 to d625048c853a (12 revisions) (flutter/flutter#187483)
2026-06-03 chris@bracken.jp [SwiftPM] Fix prefer_initializing_formals lint (flutter/flutter#187502)
2026-06-03 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from q27k7_um1GvVrySZS... to ap7MhLX4TdpWRrLS_... (flutter/flutter#187478)
2026-06-03 bkonyi@google.com [SwiftPM] Fix concurrent directory/file/symlink creation crashes (flutter/flutter#186953)
2026-06-03 flar@google.com [Impeller] Fix positioning of text shadow masks (flutter/flutter#187460)
2026-06-02 burak.karahan@mail.ru Remove Material imports from painting tests (flutter/flutter#186937)
2026-06-02 awolff@google.com Add android_hardware_smoke_test integration tests (flutter/flutter#187130)
2026-06-02 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#187471)
2026-06-02 pq@users.noreply.github.com [flutter tool] propagate analytics env to sub-tools (flutter/flutter#186780)
2026-06-02 30870216+gaaclarke@users.noreply.github.com Adds macro for fragment shaders to support flutter <= 3.44 (flutter/flutter#187316)
2026-06-02 116356835+AbdeMohlbi@users.noreply.github.com Small clean-up in different java files under `engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/` (flutter/flutter#186631)
2026-06-02 1961493+harryterkelsen@users.noreply.github.com refactor(web): Unify ui.Path code for CanvasKit and Skwasm (flutter/flutter#187331)
2026-06-02 engine-flutter-autoroll@skia.org Roll Packages from f5d50ca to 818b310 (2 revisions) (flutter/flutter#187441)
2026-06-02 faheemabbas766@gmail.com Allow selecting multi-digit device options (flutter/flutter#186184)
2026-06-02 puneetkukreja98@gmail.com Improve error message for type mismatch in Navigator.pop and maybePop. (flutter/flutter#186571)
2026-06-02 sanaullah.383@hotmail.com Remove semantics_tester import from material_button_test.dart (flutter/flutter#184807)
2026-06-02 bkonyi@google.com [flutter_tools] Refactor hostPlatform to use Abi.current() (flutter/flutter#185369)
2026-06-02 mvincentong@gmail.com Clean up avoid_type_to_string suppressions (flutter/flutter#186869)
2026-06-02 202459002+Lukes-Lair@users.noreply.github.com Update Flutter documentation links in flutter_console.bat (flutter/flutter#187354)
2026-06-02 154381524+flutteractionsbot@users.noreply.github.com Revert "[Impeller] Allow attaching specific texture mip levels and slices" (flutter/flutter#187445)
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 stuartmorgan@google.com,tarrinneal@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
…lutter#11832)
Manual roll requested by tarrinneal@google.com
flutter/flutter@701665b...2ba5420
2026-06-03 engine-flutter-autoroll@skia.org Roll Packages from 818b310 to b11504f (8 revisions) (flutter/flutter#187511)
2026-06-03 mdebbar@google.com Add new file patterns for team-web labeler (flutter/flutter#187397)
2026-06-03 engine-flutter-autoroll@skia.org Roll Skia from 279b17fe9fc1 to d625048c853a (12 revisions) (flutter/flutter#187483)
2026-06-03 chris@bracken.jp [SwiftPM] Fix prefer_initializing_formals lint (flutter/flutter#187502)
2026-06-03 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from q27k7_um1GvVrySZS... to ap7MhLX4TdpWRrLS_... (flutter/flutter#187478)
2026-06-03 bkonyi@google.com [SwiftPM] Fix concurrent directory/file/symlink creation crashes (flutter/flutter#186953)
2026-06-03 flar@google.com [Impeller] Fix positioning of text shadow masks (flutter/flutter#187460)
2026-06-02 burak.karahan@mail.ru Remove Material imports from painting tests (flutter/flutter#186937)
2026-06-02 awolff@google.com Add android_hardware_smoke_test integration tests (flutter/flutter#187130)
2026-06-02 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#187471)
2026-06-02 pq@users.noreply.github.com [flutter tool] propagate analytics env to sub-tools (flutter/flutter#186780)
2026-06-02 30870216+gaaclarke@users.noreply.github.com Adds macro for fragment shaders to support flutter <= 3.44 (flutter/flutter#187316)
2026-06-02 116356835+AbdeMohlbi@users.noreply.github.com Small clean-up in different java files under `engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/` (flutter/flutter#186631)
2026-06-02 1961493+harryterkelsen@users.noreply.github.com refactor(web): Unify ui.Path code for CanvasKit and Skwasm (flutter/flutter#187331)
2026-06-02 engine-flutter-autoroll@skia.org Roll Packages from f5d50ca to 818b310 (2 revisions) (flutter/flutter#187441)
2026-06-02 faheemabbas766@gmail.com Allow selecting multi-digit device options (flutter/flutter#186184)
2026-06-02 puneetkukreja98@gmail.com Improve error message for type mismatch in Navigator.pop and maybePop. (flutter/flutter#186571)
2026-06-02 sanaullah.383@hotmail.com Remove semantics_tester import from material_button_test.dart (flutter/flutter#184807)
2026-06-02 bkonyi@google.com [flutter_tools] Refactor hostPlatform to use Abi.current() (flutter/flutter#185369)
2026-06-02 mvincentong@gmail.com Clean up avoid_type_to_string suppressions (flutter/flutter#186869)
2026-06-02 202459002+Lukes-Lair@users.noreply.github.com Update Flutter documentation links in flutter_console.bat (flutter/flutter#187354)
2026-06-02 154381524+flutteractionsbot@users.noreply.github.com Revert "[Impeller] Allow attaching specific texture mip levels and slices" (flutter/flutter#187445)
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 stuartmorgan@google.com,tarrinneal@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
via-guy pushed a commit to via-guy/flutter that referenced this pull request Jun 26, 2026
…r#184807)
Part of flutter#182636
## Summary
Remove the `semantics_tester.dart` cross-import from
`material_button_test.dart`.
## What changed
* Replaced the deprecated `SemanticsTester`/`TestSemantics` assertions
in the MaterialButton semantics test with `tester.getSemantics(...)` and
`matchesSemantics(...)`
* Kept the semantic size verification for the enabled and disabled
button states
* Removed the `../widgets/semantics_tester.dart` import
## Testing
* `../../bin/flutter analyze test/material/material_button_test.dart`
* `../../bin/flutter test test/material/material_button_test.dart`
---------
Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
auto-submitBot pushed a commit to flutter/packages that referenced this pull request Jun 29, 2026
…11972)
Most Material and Cupertino code was copied over from flutter/flutter in #11888, but a few PRs landed after that copy. This PR copies one of those PRs to this repo.
Ports over flutter/flutter#184807.
Work towards flutter/flutter#188441
## Pre-Review Checklist
**Test exemption: cherry-pick of PR from flutter/flutter**
**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.
[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
pullBot pushed a commit to safarmer/flutter that referenced this pull request Jun 30, 2026
…er#188792)
flutter/packages@656ccaa...274ed3e
2026-06-30 nateshmbhat1@gmail.com [video_player_android] Add video track
selection support (flutter/packages#11475)
2026-06-30 engine-flutter-autoroll@skia.org Manual roll Flutter from
b081f33 to 0c80830 (1 revision) (flutter/packages#12058)
2026-06-30 36861262+QuncCccccc@users.noreply.github.com [material_ui]
Remove `widgets` import from `material_test.dart`
(flutter/packages#12056)
2026-06-29 36861262+QuncCccccc@users.noreply.github.com [material_ui]
Remove `widgets` imports from `card_test.dart`,
`checkbox_list_tile_test.dart` (flutter/packages#12054)
2026-06-29 36861262+QuncCccccc@users.noreply.github.com [material_ui]
Remove `widgets/clipboard_utils.dart`,
`widgets/text_selection_toolbar_utils.dart` imports from
`adaptive_text_selection_toolbar_test.dart` (flutter/packages#12053)
2026-06-29 engine-flutter-autoroll@skia.org Manual roll Flutter from
11e339e to b081f33 (1 revision) (flutter/packages#12050)
2026-06-29 36861262+QuncCccccc@users.noreply.github.com [material_ui]
Remove `widgets/clipboard_utils.dart` imports from
`date_picker_test.dart`, `input_date_picker_form_field_test.dart`,
`search_test.dart`, `selectable_text_test.dart`,
`text_form_field_test.dart`, `text_selection_test.dart`
(flutter/packages#12030)
2026-06-29 engine-flutter-autoroll@skia.org Manual roll Flutter from
87224e0 to 11e339e (4 revisions) (flutter/packages#12041)
2026-06-29 21270878+elliette@users.noreply.github.com [material_ui]
Enable `text_field_test` (flutter/packages#12022)
2026-06-29 21270878+elliette@users.noreply.github.com [material_ui] Port
PR (flutter#184807) from flutter/flutter to material_ui
(flutter/packages#11972)
2026-06-29 rmolivares@renzo-olivares.dev [cupertino_ui] Migrate
`button_test.dart` to `SemanticsHandle` (flutter/packages#11992)
2026-06-29 rmolivares@renzo-olivares.dev [cupertino_ui] Migrate
`radio_test.dart` to `SemanticsHandle` (flutter/packages#11981)
2026-06-29 rmolivares@renzo-olivares.dev [cupertino_ui] Migrate
`picker_test.dart` to `SemanticsHandle` (flutter/packages#12008)
2026-06-29 36861262+QuncCccccc@users.noreply.github.com [cupertino_ui]
Create util files. Remove widgets import in
`adaptive_text_selection_toolbar_test.dart` and
`text_selection_test.dart` (flutter/packages#12023)
2026-06-29 21270878+elliette@users.noreply.github.com [material_ui]
Enable `floating_action_button_test` (flutter/packages#12014)
2026-06-29 21270878+elliette@users.noreply.github.com [material_ui]
Enable `dropdown_test` (flutter/packages#12011)
2026-06-29 21270878+elliette@users.noreply.github.com [material_ui]
Enable `chip_test` (flutter/packages#12009)
2026-06-29 36861262+QuncCccccc@users.noreply.github.com [material_ui]
Remove widgets import in `data_table_test.dart`, `switch_test.dart` and
`tooltip_theme_test.dart` (flutter/packages#12031)
2026-06-29 burak.karahan@mail.ru [material_ui] Port flutter/flutter
flutter#186670 "Use local semantics tester in Material selection tests"
(flutter/packages#11983)
2026-06-29 21270878+elliette@users.noreply.github.com [material_ui]
Enable `switch_list_tile_test` (flutter/packages#12020)
2026-06-29 21270878+elliette@users.noreply.github.com [material_ui]
Enable `popup_menu_test` (flutter/packages#12018)
2026-06-29 21270878+elliette@users.noreply.github.com [material_ui]
Enable `date_range_picker_test` (flutter/packages#12010)
2026-06-29 stuartmorgan@google.com [google_sign_in] Simplify Android
user ID extraction (flutter/packages#12025)
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-flutter-autoroll
Please CC flutter-ecosystem@google.com on the revert to ensure that a
human
is aware of the problem.
To file a bug in Flutter:
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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICDRun CI/CDframeworkflutter/packages/flutter repository. See also f: labels.override code freezeOverride an active code freeze.p: material_uimaterial_ui package in flutter/packages

Projects

Development

Successfully merging this pull request may close these issues.

5 participants

@Sanaullah49@justinmc@chunhtai@dkwingsmt@alpesh76