Skip to content

Remove semantics_tester cross-import from segmented_button_test.dart#185250

Merged
auto-submit[bot] merged 3 commits into
flutter:masterfrom
spandan3001:fix-segmented-button-cross-import
May 6, 2026
Merged

Remove semantics_tester cross-import from segmented_button_test.dart#185250
auto-submit[bot] merged 3 commits into
flutter:masterfrom
spandan3001:fix-segmented-button-cross-import

Conversation

@spandan3001

Copy link
Copy Markdown
Contributor

Removes the cross-import of semantics_tester.dart from material/segmented_button_test.dart.

Duplicated semantics_tester.dart locally into the material test folder to remove the dependency on widgets test utilities. This is part of the effort to decouple Material and Cupertino from the widgets library.

Fixes part of #182636

@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) labels Apr 18, 2026
@google-cla

google-cla Bot commented Apr 18, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@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 the semantics_tester.dart utility to the material package and updates segmented_button_test.dart to use it. The review identified several critical logical errors, including self-comparison typos in controlsNodes and LocaleStringAttribute checks, and an incorrectly structured assertion in the _IncludesNodeWith matcher. Additionally, feedback was provided to correct a documentation inconsistency regarding rootRect dimensions and a typo in a semantic error message.

);
}

if (controlsNodes != controlsNodes && !setEquals(controlsNodes, node.controlsNodes)) {

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.

high

The condition controlsNodes != controlsNodes is always false, which means the controlsNodes check is effectively skipped. This is likely a typo and should be changed to controlsNodes != null or simply removed if setEquals handles nulls as expected for your test logic.

Suggested change
if (controlsNodes != controlsNodes && !setEquals(controlsNodes, node.controlsNodes)) {
if (controlsNodes != null && !setEquals(controlsNodes, node.controlsNodes)) {

Comment on lines +718 to +719
(second[i] as LocaleStringAttribute).locale !=
(second[i] as LocaleStringAttribute).locale)) {

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.

high

The comparison (second[i] as LocaleStringAttribute).locale != (second[i] as LocaleStringAttribute).locale is always false because it compares the same object's property to itself. It should compare the locale of the first attribute with the second attribute.

Suggested change
(second[i] as LocaleStringAttribute).locale !=
(second[i] as LocaleStringAttribute).locale)) {
(first[i] as LocaleStringAttribute).locale !=
(second[i] as LocaleStringAttribute).locale)) {

Comment on lines +1199 to +1200
final double? scrollPosition;
final double? scrollExtentMax;

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.

high

The assert in the _IncludesNodeWith constructor incorrectly passes minValue != null || maxValue != null as the second argument to the assert function, which is treated as the error message. These conditions should be part of the first argument (the condition) to ensure that the matcher is not created without at least one property to check.

            inputType != null ||
            minValue != null ||
            maxValue != null,

/// The [rect] field is required and has no default. Convenient values are
/// available:
///
/// * [TestSemantics.rootRect]: 2400x1600, the test screen's size in physical

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.

medium

The documentation states that rootRect is 2400x1600, but the actual constant value defined on line 252 is 2400x1800. This should be updated for consistency.

Suggested change
/// * [TestSemantics.rootRect]: 2400x1600, the test screen's size in physical
/// * [TestSemantics.rootRect]: 2400x1800, the test screen's size in physical

}
if (scrollChildren != null && scrollChildren != nodeData.scrollChildCount) {
return fail(
'expected node id $id to have scrollIndex $scrollChildren but found scrollIndex ${nodeData.scrollChildCount}.',

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.

medium

The error message incorrectly refers to scrollIndex instead of scrollChildren (or scrollChildCount).

Suggested change
'expected node id $id to have scrollIndex $scrollChildren but found scrollIndex ${nodeData.scrollChildCount}.',
'expected node id $id to have scrollChildren $scrollChildren but found scrollChildren ${nodeData.scrollChildCount}.',

@chunhtai chunhtai 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

@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 👍

Recently there was a discussion about what to do with TestSemantics and the conclusion was that duplicating it is what we want, because we don't want to encourage its use in user tests by putting it in flutter_test publicly.

@spandan3001 spandan3001 force-pushed the fix-segmented-button-cross-import branch from e17daca to 7a4e8c2 Compare April 30, 2026 21:26
@victorsanni victorsanni added CICD Run CI/CD override code freeze Override an active code freeze. labels Apr 30, 2026
@victorsanni victorsanni added CICD Run CI/CD override code freeze Override an active code freeze. autosubmit Merge PR when tree becomes green via auto submit App and removed CICD Run CI/CD override code freeze Override an active code freeze. labels Apr 30, 2026
@auto-submit

auto-submit Bot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/185250, because - The status or check suite Check Code Freeze has failed. Please fix the issues identified (or deflake) before re-applying this label.

  • The status or check suite Check Code Freeze has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 30, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label May 1, 2026
@justinmc justinmc added the CICD Run CI/CD label May 1, 2026
@justinmc

justinmc commented May 1, 2026

Copy link
Copy Markdown
Contributor

The code freeze override has been buggy recently. I pushed a merge commit to try to fix it. If not then a rebase should work (I should have done that but misclicked).

@dkwingsmt dkwingsmt added the autosubmit Merge PR when tree becomes green via auto submit App label May 6, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue May 6, 2026
Merged via the queue into flutter:master with commit 21b827a May 6, 2026
89 of 90 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Test cross-imports Review Queue May 6, 2026
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 6, 2026
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) CICD Run CI/CD f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. override code freeze Override an active code freeze.

Projects

Development

Successfully merging this pull request may close these issues.

5 participants