Repository navigation
[material_ui] port drawer tests over from flutter/widgets - #12711
auto-submit[bot] merged 2 commits into
Conversation
| state.openDrawer(); | ||
|
|
||
| await tester.pump(); | ||
| expect(find.text('Archive'), findsOneWidget); |
There was a problem hiding this comment.
This is ported over from the original test: https://github.com/flutter/flutter/blob/master/packages/flutter/test/widgets/drawer_test.dart#L32
|
|
||
| expect(find.text('header'), findsOneWidget); | ||
|
|
||
| Navigator.pop(savedContext); |
There was a problem hiding this comment.
This is ported over from the original test https://github.com/flutter/flutter/blob/master/packages/flutter/test/widgets/drawer_test.dart#L35-L39
There was a problem hiding this comment.
Code Review
This pull request ports drawer tests from flutter/widgets into material_ui, updating existing tests to verify drawer dismissal animations and adding several new tests covering tap, hover, gesture cancellation, and semantics behaviors. The review feedback suggests replacing hardcoded strings in the semantics tests (such as 'Dismiss' and 'Navigation menu') with localized values from DefaultMaterialLocalizations to make the tests robust against localization changes.
| await tester.pump(const Duration(milliseconds: 100)); | ||
|
|
||
| expect(semantics, includesNodeWith(actions: <SemanticsAction>[SemanticsAction.tap])); | ||
| expect(semantics, includesNodeWith(label: 'Dismiss')); |
There was a problem hiding this comment.
Avoid using the hardcoded string 'Dismiss' for the semantics label. Instead, use const DefaultMaterialLocalizations().modalBarrierDismissLabel to ensure the test is robust against localization changes and matches the implementation's localized values.
| expect(semantics, includesNodeWith(label: 'Dismiss')); | |
| expect(semantics, includesNodeWith(label: const DefaultMaterialLocalizations().modalBarrierDismissLabel)); |
| includesNodeWith(actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.focus]), | ||
| ), | ||
| ); | ||
| expect(semantics, isNot(includesNodeWith(label: 'Dismiss'))); |
There was a problem hiding this comment.
Avoid using the hardcoded string 'Dismiss' for the semantics label. Instead, use const DefaultMaterialLocalizations().modalBarrierDismissLabel to ensure the test is robust against localization changes and matches the implementation's localized values.
| expect(semantics, isNot(includesNodeWith(label: 'Dismiss'))); | |
| expect(semantics, isNot(includesNodeWith(label: const DefaultMaterialLocalizations().modalBarrierDismissLabel))); |
| expect( | ||
| semantics, | ||
| includesNodeWith( | ||
| label: 'Navigation menu', | ||
| flags: <SemanticsFlag>[SemanticsFlag.scopesRoute, SemanticsFlag.namesRoute], | ||
| ), | ||
| ); |
There was a problem hiding this comment.
Avoid using the hardcoded string 'Navigation menu' for the semantics label. Instead, use const DefaultMaterialLocalizations().drawerLabel to ensure the test is robust against localization changes and matches the implementation's localized values.
| expect( | |
| semantics, | |
| includesNodeWith( | |
| label: 'Navigation menu', | |
| flags: <SemanticsFlag>[SemanticsFlag.scopesRoute, SemanticsFlag.namesRoute], | |
| ), | |
| ); | |
| expect( | |
| semantics, | |
| includesNodeWith( | |
| label: const DefaultMaterialLocalizations().drawerLabel, | |
| flags: <SemanticsFlag>[SemanticsFlag.scopesRoute, SemanticsFlag.namesRoute], | |
| ), | |
| ); |
| testWidgets('Material3 - Drawer control test', (WidgetTester tester) async { | ||
| const containerKey = Key('container'); | ||
|
|
||
| late BuildContext savedContext; |
There was a problem hiding this comment.
The same changes as the test above were applied here, since we have the M2/M3 split
| semantics.dispose(); | ||
| }, variant: TargetPlatformVariant.only(TargetPlatform.android)); | ||
|
|
||
| testWidgets('Drawer tap test', (WidgetTester tester) async { |
There was a problem hiding this comment.
Moved over verbatim
| expect(find.text('drawer'), findsNothing); | ||
| }); | ||
|
|
||
| testWidgets('Drawer hover test', (WidgetTester tester) async { |
There was a problem hiding this comment.
Moved over verbatim
| expect(finder, findsNothing); | ||
| }); | ||
|
|
||
| testWidgets('Close drawer with navigator pop', (WidgetTester tester) async { |
There was a problem hiding this comment.
Moved over verbatim, except for the test name: https://github.com/flutter/flutter/blob/master/packages/flutter/test/widgets/drawer_test.dart#L245
| expect(buttonPressed, equals(true)); | ||
| }); | ||
|
|
||
| testWidgets('Drawer closing can be canceled by gesture (LTR)', (WidgetTester tester) async { |
There was a problem hiding this comment.
Moved over verbatim, except for the test name: https://github.com/flutter/flutter/blob/master/packages/flutter/test/widgets/drawer_test.dart#L146
| await gesture.up(); | ||
| }); | ||
|
|
||
| testWidgets('Drawer closing can be canceled by gesture (RTL)', (WidgetTester tester) async { |
There was a problem hiding this comment.
Same for this test
| }); | ||
|
|
||
| testWidgets( | ||
| 'Dismissible Drawer includes button in semantic tree', |
There was a problem hiding this comment.
Moved over verbatim, except for the test name: https://github.com/flutter/flutter/blob/master/packages/flutter/test/widgets/drawer_test.dart#L293
| }), | ||
| ); | ||
|
|
||
| testWidgets('Dismissible Drawer is hidden on Android (back button is used to dismiss)', ( |
There was a problem hiding this comment.
Moved over verbatim, except for the test name: https://github.com/flutter/flutter/blob/master/packages/flutter/test/widgets/drawer_test.dart#L324
There was a problem hiding this comment.
The description sounds still a bit inaccurate because we are not really testing whether the drawer is hidden but the a11y label. How about
| testWidgets('Dismissible Drawer is hidden on Android (back button is used to dismiss)', ( | |
| testWidgets('Dismissible Drawer barrier is hidden from semantics on Android (back button is used to dismiss)', ( |
| await pumpDrawerWithTheme(TargetPlatform.iOS); | ||
| }, variant: TargetPlatformVariant.all()); | ||
|
|
||
| testWidgets('Drawer contains route semantics flags', (WidgetTester tester) async { |
There was a problem hiding this comment.
Moved over verbatim
elliette
left a comment
There was a problem hiding this comment.
I think the changelog entry should be removed, otherwise LGTM! Thanks for porting these tests over.
QuncCccccc
left a comment
There was a problem hiding this comment.
Overall looks good to me. Just left a few comments:)! Thanks a lot for your contribution!
| }), | ||
| ); | ||
|
|
||
| testWidgets('Dismissible Drawer is hidden on Android (back button is used to dismiss)', ( |
There was a problem hiding this comment.
The description sounds still a bit inaccurate because we are not really testing whether the drawer is hidden but the a11y label. How about
| testWidgets('Dismissible Drawer is hidden on Android (back button is used to dismiss)', ( | |
| testWidgets('Dismissible Drawer barrier is hidden from semantics on Android (back button is used to dismiss)', ( |
QuncCccccc
left a comment
There was a problem hiding this comment.
LGTM. Thank you for the contribution!
…er#192485) flutter/packages@9af9c60...36e088a 2026-09-09 daniel.leon@cloudsufi.com [quick_actions] Adopt code-excerpts for README (flutter/packages#12643) 2026-09-08 65155920+0xharkirat@users.noreply.github.com [camera_web] Fix TypeError when reading the torch capability (flutter/packages#12647) 2026-09-08 gibbonsj97@gmail.com [google_maps_flutter_web] Avoid replacing advanced marker content on move (flutter/packages#11952) 2026-09-08 mit@google.com [material_ui][cupertino_ui] Change issue tracker label in pubspec.yaml (flutter/packages#12792) 2026-09-08 saurabhmirajkar000@gmail.com [material_ui] Fix FilledButton Material 3 default style docs (flutter/packages#12620) 2026-09-08 21270878+elliette@users.noreply.github.com [infra] Use a modified no-response workflow in flutter/packages (flutter/packages#12745) 2026-09-08 21270878+elliette@users.noreply.github.com [material_ui] Migrate M3 Banner template to use new gen_defaults (flutter/packages#12734) 2026-09-08 engine-flutter-autoroll@skia.org Roll Flutter from 63170e9 to b444e78 (13 revisions) (flutter/packages#12791) 2026-09-08 fluttergithubbot@gmail.com Sync release-go_router-18.0.1 to main (flutter/packages#12725) 2026-09-08 fluttergithubbot@gmail.com Sync release-material_ui-1.1.1 to main (flutter/packages#12726) 2026-09-08 stuartmorgan@google.com [tool] Adopt `platform` 3.2.0 (flutter/packages#12789) 2026-09-07 50643541+Mairramer@users.noreply.github.com [material_ui] Fix SliverGeometry maxPaintExtent assertion in CarouselView.weighted (flutter/packages#12563) 2026-09-05 engine-flutter-autoroll@skia.org Roll Flutter from 5a6cfa7 to 63170e9 (15 revisions) (flutter/packages#12767) 2026-09-04 engine-flutter-autoroll@skia.org Manual roll Flutter from 70797e1 to 5a6cfa7 (52 revisions) (flutter/packages#12760) 2026-09-04 brackenavaron@gmail.com [material_ui] port drawer tests over from flutter/widgets (flutter/packages#12711) 2026-09-04 tarrinneal@gmail.com add cooldown (flutter/packages#12708) 2026-09-04 joeldumasbg@gmail.com [in_app_purchase] Support StoreKit 2 introductory offer eligibility JWS (flutter/packages#12584) 2026-09-04 21270878+elliette@users.noreply.github.com [material_ui] Migrate M3 Badge template to use new gen_defaults (flutter/packages#12733) 2026-09-04 stuartmorgan@google.com [google_maps_flutter] Convert heatmap controller to Swift (flutter/packages#12713) 2026-09-04 97480502+b-luk@users.noreply.github.com [material_ui] Remove unused `maintainState` constructor parameter in `scaffold_test.dart` (flutter/packages#12754) 2026-09-04 a1rwulf@users.noreply.github.com [video_player_avfoundation] Route video over AirPlay (flutter/packages#12490) 2026-09-04 jerome.dellamaria@proton.me [google_fonts] Add google_fonts_lite file to allow tree-shaking of the other huge files (flutter/packages#11433) 2026-09-04 engine-flutter-autoroll@skia.org Roll Flutter from 0cbd1a4 to 70797e1 (27 revisions) (flutter/packages#12727) 2026-09-04 stuartmorgan@google.com Update Chrome for stable tests (flutter/packages#12747) If this roll has caused a breakage, revert this CL and set the roller to dry run mode 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
) This PR moves tests from `packages/flutter` under `widgets/drawer_test.dart` into material_ui. Most tests were moved verbatim, except for a few tests that I renamed, because the test name was not very clear. The drawer control tests for Material 2/3 that already existed were updated to test some additional behavior. Part of flutter/flutter#177028 See flutter/flutter#192106 which removes the tests in flutter/flutter ## Pre-Review Checklist **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.
) This PR moves tests from `packages/flutter` under `widgets/drawer_test.dart` into material_ui. Most tests were moved verbatim, except for a few tests that I renamed, because the test name was not very clear. The drawer control tests for Material 2/3 that already existed were updated to test some additional behavior. Part of flutter/flutter#177028 See flutter/flutter#192106 which removes the tests in flutter/flutter ## Pre-Review Checklist **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.
This PR moves tests from
packages/flutterunderwidgets/drawer_test.dartinto material_ui.Most tests were moved verbatim, except for a few tests that I renamed, because the test name was not very clear.
The drawer control tests for Material 2/3 that already existed were updated to test some additional behavior.
Part of flutter/flutter#177028
See flutter/flutter#192106 which removes the tests in flutter/flutter
Pre-Review Checklist
[shared_preferences]///).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-assistbot 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.Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2