Repository navigation
Apply TestSemantics fixes to the material copy of semantics_tester - #192164
Sanaullah49 wants to merge 1 commit into
Conversation
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.
|
This pull request contains changes to Material or Cupertino, which are currently frozen in this repository. Changes should be made in Please refer to #188444 for instructions. |
There was a problem hiding this comment.
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.
|
Closing in favour of flutter/packages#12722, which ports these fixes to
|
…#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.
packages/flutter/test/material/semantics_tester.dartis a copy ofpackages/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 != controlsNodescompares the field to itself, so thesetEqualscheck is unreachable and the expectation never runssecond[i]on both sides instead offirst[i], so mismatched locales compare equalminValue/maxValuechecks sit inassert()'s message slot rather than its condition, so they gate nothingattributedLabel,attributedValue,attributedHintandhintwere missing from that assert's condition, so passing any one of them alone tripped itAfter this change the two files are byte-identical again:
Also adds
packages/flutter/test/material/semantics_tester_test.dartcovering 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.dartpasses 12/12.Follow-up to #191938.