Skip to content

Apply TestSemantics fixes to the material copy of semantics_tester - #192164

Closed
Sanaullah49 wants to merge 1 commit into
flutter:masterfrom
Sanaullah49:material-semantics-tester-parity
Closed

Sanaullah49 wants to merge 1 commit into
flutter:masterfrom
Sanaullah49:material-semantics-tester-parity

Conversation

@Sanaullah49

Copy link
Copy Markdown
Contributor

packages/flutter/test/material/semantics_tester.dart is a copy of packages/flutter/test/widgets/semantics_tester.dart, kept so material tests do not cross-import from widgets. It did not receive the fixes from #191938, so the two copies had drifted by exactly those four bugs:

  • controlsNodes != controlsNodes compares the field to itself, so the setEquals check is unreachable and the expectation never runs
  • the locale comparison reads second[i] on both sides instead of first[i], so mismatched locales compare equal
  • the minValue/maxValue checks sit in assert()'s message slot rather than its condition, so they gate nothing
  • attributedLabel, attributedValue, attributedHint and hint were missing from that assert's condition, so passing any one of them alone tripped it

After this change the two files are byte-identical again:

diff packages/flutter/test/widgets/semantics_tester.dart \
     packages/flutter/test/material/semantics_tester.dart

Also adds packages/flutter/test/material/semantics_tester_test.dart covering each fix, mirroring the widgets test file. There was no test file for the material copy previously.

Testing

flutter test packages/flutter/test/material/semantics_tester_test.dart packages/flutter/test/widgets/semantics_tester_test.dart passes 12/12.

Follow-up to #191938.

packages/flutter/test/material/semantics_tester.dart is a copy of
packages/flutter/test/widgets/semantics_tester.dart, kept so material
tests do not cross-import from widgets. It did not receive the fixes
from flutter#191938, so the two copies had drifted:

- `controlsNodes != controlsNodes` compares the field to itself, so the
  setEquals check is unreachable and the expectation never runs
- the locale comparison reads `second[i]` on both sides instead of
  `first[i]`, so mismatched locales compare equal
- the `minValue`/`maxValue` checks sit in assert()'s message slot rather
  than its condition, so they gate nothing
- `attributedLabel`, `attributedValue`, `attributedHint` and `hint` were
  missing from that assert's condition, so passing any one alone tripped it

The two files are now byte-identical again. Adds a test file covering
each fix, mirroring the widgets one.
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

This pull request contains changes to Material or Cupertino, which are currently frozen in this repository.

Changes should be made in material_ui and/or cupertino_ui in the flutter/packages repository.

Please refer to #188444 for instructions.

@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) labels Sep 2, 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 fixes self-comparison bugs in SemanticsTester for controlsNodes and LocaleStringAttribute.locale comparisons. It also expands the _IncludesNodeWith matcher's assertion to include fields like attributedLabel, attributedValue, hint, attributedHint, minValue, and maxValue, accompanied by a detailed assertion error message. Additionally, a new test suite is added to verify these semantics checks. There are no review comments, and I have no feedback to provide.

@Sanaullah49

Copy link
Copy Markdown
Contributor Author

Closing in favour of flutter/packages#12722, which ports these fixes to packages/material_ui/test/semantics_tester.dart.

packages/flutter/test/material is frozen here, so this belongs in flutter/packages per #188444. All four bugs are present in the copied file there, and the ported PR adds the same regression tests plus a ## NEXT changelog entry.

@Sanaullah49 Sanaullah49 closed this Sep 2, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Oct 14, 2026
…#12722)

`packages/material_ui/test/semantics_tester.dart` carries four bugs that make parts of the helper silently ineffective:

- `controlsNodes != controlsNodes` compares the field to itself, so the `setEquals` check is unreachable and the `controlsNodes` expectation never runs
- the locale comparison reads `second[i]` on both sides instead of `first[i]`, so mismatched locales compare equal
- the `minValue`/`maxValue` checks sit in `assert()`'s message slot rather than its condition, so they gate nothing
- `attributedLabel`, `attributedValue`, `attributedHint` and `hint` were missing from that assert's condition, so passing any one of them alone tripped it

Adds `packages/material_ui/test/semantics_tester_test.dart` covering each fix. There was no test file for this helper previously.

## Context

Ported from flutter/flutter#192164, which cannot land there because `packages/flutter/test/material` is frozen (flutter/flutter#188444). The same four fixes landed for the `widgets` copy of this helper in flutter/flutter#191938.

## Testing

`flutter test test/semantics_tester_test.dart` in `packages/material_ui` passes 4/4, and `dart analyze` is clean, against Flutter 3.47.2.

Changelog uses `## NEXT` since this is test-only and does not affect the published package.
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) framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant