Remove semantics_tester import from material_button_test.dart#184807
Conversation
There was a problem hiding this comment.
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.
|
The disabled MaterialButton semantics check on the PR branch now explicitly verifies that |
| ), | ||
| ); | ||
|
|
||
| final SemanticsNode semantics = tester.getSemantics(find.byType(MaterialButton)); |
There was a problem hiding this comment.
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 :)
chunhtai
left a comment
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
can we keep the check for transform?
I think we can directly compare SemanticsNode.transform
There was a problem hiding this comment.
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(); |
|
Thanks @justinmc and @chunhtai! Addressed all the feedback:
|
…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
4aa5acd to
71eb0df
Compare
| @@ -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); | |||
There was a problem hiding this comment.
I don't think this is needed?
There was a problem hiding this comment.
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.
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.
|
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: |
|
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. |
|
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. |
…11832) Manual roll requested by [email protected] flutter/flutter@701665b...2ba5420 2026-06-03 [email protected] Roll Packages from 818b310 to b11504f (8 revisions) (flutter/flutter#187511) 2026-06-03 [email protected] Add new file patterns for team-web labeler (flutter/flutter#187397) 2026-06-03 [email protected] Roll Skia from 279b17fe9fc1 to d625048c853a (12 revisions) (flutter/flutter#187483) 2026-06-03 [email protected] [SwiftPM] Fix prefer_initializing_formals lint (flutter/flutter#187502) 2026-06-03 [email protected] Roll Fuchsia Linux SDK from q27k7_um1GvVrySZS... to ap7MhLX4TdpWRrLS_... (flutter/flutter#187478) 2026-06-03 [email protected] [SwiftPM] Fix concurrent directory/file/symlink creation crashes (flutter/flutter#186953) 2026-06-03 [email protected] [Impeller] Fix positioning of text shadow masks (flutter/flutter#187460) 2026-06-02 [email protected] Remove Material imports from painting tests (flutter/flutter#186937) 2026-06-02 [email protected] Add android_hardware_smoke_test integration tests (flutter/flutter#187130) 2026-06-02 [email protected] Roll pub packages (flutter/flutter#187471) 2026-06-02 [email protected] [flutter tool] propagate analytics env to sub-tools (flutter/flutter#186780) 2026-06-02 [email protected] Adds macro for fragment shaders to support flutter <= 3.44 (flutter/flutter#187316) 2026-06-02 [email protected] Small clean-up in different java files under `engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/` (flutter/flutter#186631) 2026-06-02 [email protected] refactor(web): Unify ui.Path code for CanvasKit and Skwasm (flutter/flutter#187331) 2026-06-02 [email protected] Roll Packages from f5d50ca to 818b310 (2 revisions) (flutter/flutter#187441) 2026-06-02 [email protected] Allow selecting multi-digit device options (flutter/flutter#186184) 2026-06-02 [email protected] Improve error message for type mismatch in Navigator.pop and maybePop. (flutter/flutter#186571) 2026-06-02 [email protected] Remove semantics_tester import from material_button_test.dart (flutter/flutter#184807) 2026-06-02 [email protected] [flutter_tools] Refactor hostPlatform to use Abi.current() (flutter/flutter#185369) 2026-06-02 [email protected] Clean up avoid_type_to_string suppressions (flutter/flutter#186869) 2026-06-02 [email protected] Update Flutter documentation links in flutter_console.bat (flutter/flutter#187354) 2026-06-02 [email protected] 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 [email protected],[email protected] 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
…lutter#11832) Manual roll requested by [email protected] flutter/flutter@701665b...2ba5420 2026-06-03 [email protected] Roll Packages from 818b310 to b11504f (8 revisions) (flutter/flutter#187511) 2026-06-03 [email protected] Add new file patterns for team-web labeler (flutter/flutter#187397) 2026-06-03 [email protected] Roll Skia from 279b17fe9fc1 to d625048c853a (12 revisions) (flutter/flutter#187483) 2026-06-03 [email protected] [SwiftPM] Fix prefer_initializing_formals lint (flutter/flutter#187502) 2026-06-03 [email protected] Roll Fuchsia Linux SDK from q27k7_um1GvVrySZS... to ap7MhLX4TdpWRrLS_... (flutter/flutter#187478) 2026-06-03 [email protected] [SwiftPM] Fix concurrent directory/file/symlink creation crashes (flutter/flutter#186953) 2026-06-03 [email protected] [Impeller] Fix positioning of text shadow masks (flutter/flutter#187460) 2026-06-02 [email protected] Remove Material imports from painting tests (flutter/flutter#186937) 2026-06-02 [email protected] Add android_hardware_smoke_test integration tests (flutter/flutter#187130) 2026-06-02 [email protected] Roll pub packages (flutter/flutter#187471) 2026-06-02 [email protected] [flutter tool] propagate analytics env to sub-tools (flutter/flutter#186780) 2026-06-02 [email protected] Adds macro for fragment shaders to support flutter <= 3.44 (flutter/flutter#187316) 2026-06-02 [email protected] Small clean-up in different java files under `engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/` (flutter/flutter#186631) 2026-06-02 [email protected] refactor(web): Unify ui.Path code for CanvasKit and Skwasm (flutter/flutter#187331) 2026-06-02 [email protected] Roll Packages from f5d50ca to 818b310 (2 revisions) (flutter/flutter#187441) 2026-06-02 [email protected] Allow selecting multi-digit device options (flutter/flutter#186184) 2026-06-02 [email protected] Improve error message for type mismatch in Navigator.pop and maybePop. (flutter/flutter#186571) 2026-06-02 [email protected] Remove semantics_tester import from material_button_test.dart (flutter/flutter#184807) 2026-06-02 [email protected] [flutter_tools] Refactor hostPlatform to use Abi.current() (flutter/flutter#185369) 2026-06-02 [email protected] Clean up avoid_type_to_string suppressions (flutter/flutter#186869) 2026-06-02 [email protected] Update Flutter documentation links in flutter_console.bat (flutter/flutter#187354) 2026-06-02 [email protected] 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 [email protected],[email protected] 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
…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 <[email protected]>
…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.
…er#188792) flutter/packages@656ccaa...274ed3e 2026-06-30 [email protected] [video_player_android] Add video track selection support (flutter/packages#11475) 2026-06-30 [email protected] Manual roll Flutter from b081f33 to 0c80830 (1 revision) (flutter/packages#12058) 2026-06-30 [email protected] [material_ui] Remove `widgets` import from `material_test.dart` (flutter/packages#12056) 2026-06-29 [email protected] [material_ui] Remove `widgets` imports from `card_test.dart`, `checkbox_list_tile_test.dart` (flutter/packages#12054) 2026-06-29 [email protected] [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 [email protected] Manual roll Flutter from 11e339e to b081f33 (1 revision) (flutter/packages#12050) 2026-06-29 [email protected] [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 [email protected] Manual roll Flutter from 87224e0 to 11e339e (4 revisions) (flutter/packages#12041) 2026-06-29 [email protected] [material_ui] Enable `text_field_test` (flutter/packages#12022) 2026-06-29 [email protected] [material_ui] Port PR (flutter#184807) from flutter/flutter to material_ui (flutter/packages#11972) 2026-06-29 [email protected] [cupertino_ui] Migrate `button_test.dart` to `SemanticsHandle` (flutter/packages#11992) 2026-06-29 [email protected] [cupertino_ui] Migrate `radio_test.dart` to `SemanticsHandle` (flutter/packages#11981) 2026-06-29 [email protected] [cupertino_ui] Migrate `picker_test.dart` to `SemanticsHandle` (flutter/packages#12008) 2026-06-29 [email protected] [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 [email protected] [material_ui] Enable `floating_action_button_test` (flutter/packages#12014) 2026-06-29 [email protected] [material_ui] Enable `dropdown_test` (flutter/packages#12011) 2026-06-29 [email protected] [material_ui] Enable `chip_test` (flutter/packages#12009) 2026-06-29 [email protected] [material_ui] Remove widgets import in `data_table_test.dart`, `switch_test.dart` and `tooltip_theme_test.dart` (flutter/packages#12031) 2026-06-29 [email protected] [material_ui] Port flutter/flutter flutter#186670 "Use local semantics tester in Material selection tests" (flutter/packages#11983) 2026-06-29 [email protected] [material_ui] Enable `switch_list_tile_test` (flutter/packages#12020) 2026-06-29 [email protected] [material_ui] Enable `popup_menu_test` (flutter/packages#12018) 2026-06-29 [email protected] [material_ui] Enable `date_range_picker_test` (flutter/packages#12010) 2026-06-29 [email protected] [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 [email protected] 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
Part of #182636
Summary
Remove the
semantics_tester.dartcross-import frommaterial_button_test.dart.What changed
SemanticsTester/TestSemanticsassertions in the MaterialButton semantics test withtester.getSemantics(...)andmatchesSemantics(...)../widgets/semantics_tester.dartimportTesting
../../bin/flutter analyze test/material/material_button_test.dart../../bin/flutter test test/material/material_button_test.dart