Skip to content

Adds guideline tests to flutter create samples - #195827

Merged
auto-submit[bot] merged 1 commit into
flutter:masterfrom
chunhtai:add-guideline
Nov 6, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:masterfrom
chunhtai:add-guideline

Conversation

@chunhtai

@chunhtai chunhtai commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

as title

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

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.

@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If both you and the PR author believe this PR qualifies for a test exemption, escalate to the tech lead for the changed area to review and apply the test-exempt label. All reviewers should feel empowered to ask for tests before escalating.

@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 introduces a new accessibility guidelines test to the widget test template. The review feedback highlights that the test will fail because semantics are not enabled by default, and that applying both Android and iOS tap target guidelines unconditionally will cause conflicts. The feedback suggests enabling semantics and conditionally checking platform-specific guidelines.

Comment on lines +32 to +50
testWidgets('Meets accessibility guidelines', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());

// Checks that tappable nodes have a minimum size of 48 by 48 pixels
// for Android.
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));

// Checks that tappable nodes have a minimum size of 44 by 44 pixels
// for iOS.
await expectLater(tester, meetsGuideline(iOSTapTargetGuideline));

// Checks that touch targets with a tap or long press action are labeled.
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));

// Checks that text meets the minimum contrast ratio: 4.5:1 for normal
// text and 3:1 for large text.
await expectLater(tester, meetsGuideline(textContrastGuideline));
});

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.

critical

There are two main issues with this new test:\n\n1. Semantics are not enabled: The meetsGuideline matcher requires the semantics tree to be active to evaluate accessibility guidelines. By default, widget tests do not enable semantics. Without calling tester.ensureSemantics(), this test will fail with a rejection indicating that semantics are not enabled.\n2. Conflicting/Redundant platform guidelines: Running both androidTapTargetGuideline (requires 48x48) and iOSTapTargetGuideline (requires 44x44) unconditionally on the same widget tree means the test will fail if any touch target is designed to iOS standards (e.g., 44x44) but falls short of Android's 48x48 requirement. We should conditionally apply these guidelines based on the target platform.

  testWidgets('Meets accessibility guidelines', (WidgetTester tester) async {\n    final SemanticsHandle handle = tester.ensureSemantics();\n    try {\n      // Build our app and trigger a frame.\n      await tester.pumpWidget(const MyApp());\n\n      // Checks that tappable nodes have a minimum size of 48 by 48 pixels\n      // for Android, or 44 by 44 pixels for iOS.\n      if (defaultTargetPlatform == TargetPlatform.android) {\n        await expectLater(tester, meetsGuideline(androidTapTargetGuideline));\n      } else if (defaultTargetPlatform == TargetPlatform.iOS) {\n        await expectLater(tester, meetsGuideline(iOSTapTargetGuideline));\n      }\n\n      // Checks that touch targets with a tap or long press action are labeled.\n      await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));\n\n      // Checks that text meets the minimum contrast ratio: 4.5:1 for normal\n      // text and 3:1 for large text.\n      await expectLater(tester, meetsGuideline(textContrastGuideline));\n    } finally {\n      handle.dispose();\n    }\n  });

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 not sure if this is true or not, but if it is then I guess the PR won't pass CI.

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.

This is inaccurate, we have had semantics turn on by default in test for a long long time. For some reason, AI keep thinking it is not on by default. I am going to look into where they got this idea.

I have tested the generated sample code and run the test locally to confirm it works

@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 as long as the tests pass. Thanks for putting up the PR.

Comment on lines +32 to +50
testWidgets('Meets accessibility guidelines', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());

// Checks that tappable nodes have a minimum size of 48 by 48 pixels
// for Android.
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));

// Checks that tappable nodes have a minimum size of 44 by 44 pixels
// for iOS.
await expectLater(tester, meetsGuideline(iOSTapTargetGuideline));

// Checks that touch targets with a tap or long press action are labeled.
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));

// Checks that text meets the minimum contrast ratio: 4.5:1 for normal
// text and 3:1 for large text.
await expectLater(tester, meetsGuideline(textContrastGuideline));
});

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 not sure if this is true or not, but if it is then I guess the PR won't pass CI.

@loic-sharma loic-sharma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@loic-sharma

loic-sharma commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

cc @paul-geoghegan as this was an action item from the Canonical summit's accessibility discussion. Once this lands, new Flutter apps will have a test that uses meetsGuideline to check for common accessibility mistakes.

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Nov 2, 2026
@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 2, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 2, 2026
@auto-submit

auto-submit Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/195827, because - This pull request has the missing-tests label and does not have the test-exempt label. Please add tests or obtain a test exemption from a tech lead before re-applying the autosubmit label.

@chunhtai
chunhtai requested a review from bkonyi November 2, 2026 23:10
@chunhtai

chunhtai commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Hi @bkonyi can i get a test exemption for this one?

Reason: The change is actually a test that will be run in flutter/packages/flutter_tools/test/commands.shard/permeable/create_test.dart

@paul-geoghegan

Copy link
Copy Markdown

Seems great to me. Glad to have this in every new app.

@bkonyi bkonyi added the test-exempt Exempt from tests. Overrides `missing-tests` label label Nov 3, 2026
@bkonyi

bkonyi commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Hi @bkonyi can i get a test exemption for this one?

Reason: The change is actually a test that will be run in flutter/packages/flutter_tools/test/commands.shard/permeable/create_test.dart

Approved!

@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 6, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Nov 6, 2026
Merged via the queue into flutter:master with commit 1d9f736 Nov 6, 2026
44 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 6, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Nov 7, 2026
flutter/flutter@09175cd...e36b370

2026-11-07 [email protected] Roll Fuchsia Linux SDK from KIc0XZbhLmvDpTluZ... to Sf2yvdTiFXAKkfLkD... (flutter/flutter#196160)
2026-11-07 [email protected] Roll pub packages (flutter/flutter#196155)
2026-11-07 [email protected] [iOS a11y] Use a real `UIScrollView` as a11y scrollable container (flutter/flutter#195731)
2026-11-07 [email protected] Add ParagraphStyle.hyphenCharacter to dart:ui (flutter/flutter#195345)
2026-11-07 [email protected] Roll pub packages (flutter/flutter#196143)
2026-11-06 [email protected] [Linux] Fix layer position when compositing without glBlitFramebuffer (flutter/flutter#196083)
2026-11-06 [email protected] Add support for riscv64 desktop linux engine (flutter/flutter#178712)
2026-11-06 [email protected] Add ResizeImagePolicy.cover (flutter/flutter#194665)
2026-11-06 [email protected] Roll Skia from f533d4034900 to b11315d0a096 (6 revisions) (flutter/flutter#196138)
2026-11-06 [email protected] iOS: Remove dead code/unused imports from FlutterPlatformViewsController (flutter/flutter#196084)
2026-11-06 [email protected] Replace pull_request_target workflows with pull_request + workflow_run (flutter/flutter#195536)
2026-11-06 [email protected] [master] Update Flutter DEPS to Dart 3b174b7217fe09b21da836ea623932b5f041b091 (flutter/flutter#196004)
2026-11-06 [email protected] Fix android_hardware_smoke_test retry mechanisms (flutter/flutter#195708)
2026-11-06 [email protected] Roll Skia from 452b9c1e5db6 to f533d4034900 (1 revision) (flutter/flutter#196129)
2026-11-06 [email protected] [flutter_tools] Use `ErrorHandlingFileSystem.deleteIfExists` for `IOSCoreDeviceControl` temp directory cleanup (flutter/flutter#195913)
2026-11-06 [email protected] Adds guideline tests to flutter create samples (flutter/flutter#195827)
2026-11-06 [email protected] refactor(flutter_tools): unify OptionDescriptor identity and addTo (flutter/flutter#196076)
2026-11-06 [email protected] Roll pub packages (flutter/flutter#196114)
2026-11-06 [email protected] Roll Skia from 5ce64e63a0e7 to 452b9c1e5db6 (5 revisions) (flutter/flutter#196111)
2026-11-06 [email protected] Add PlatformDispatcher.onAlwaysUse24HourFormatChanged callback (flutter/flutter#194670)
2026-11-06 [email protected] Roll Packages from 0478162 to 63881f9 (10 revisions) (flutter/flutter#196108)
2026-11-06 [email protected] Roll Skia from 793b8ac73d4b to 5ce64e63a0e7 (4 revisions) (flutter/flutter#196107)

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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD missing-tests test-exempt Exempt from tests. Overrides `missing-tests` label tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants