Skip to content

Conversation

@ahmedsameha1
Copy link
Contributor

This is my attempt to handle #6537 for the DesktopTextSelectionToolbarButton UI control.

@github-actions github-actions bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Aug 15, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

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 adds a regression test to ensure DesktopTextSelectionToolbarButton doesn't crash when rendered in a zero-sized area. This is a valuable addition to prevent future regressions. My review includes a suggestion to make the new test more robust by adding an explicit assertion.

Comment on lines 49 to 57
await tester.pumpWidget(
const MaterialApp(
home: SizedBox.shrink(
child: DesktopTextSelectionToolbarButton(onPressed: null, child: Text('X')),
),
),
);
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This test correctly checks for rendering crashes. To make it more robust, consider adding an assertion to verify that the DesktopTextSelectionToolbarButton is actually rendered in the widget tree.1 This ensures the test is truly exercising the render path and would fail if the widget were, for example, optimized out of the build entirely.

    await tester.pumpWidget(
      const MaterialApp(
        home: SizedBox.shrink(
          child: DesktopTextSelectionToolbarButton(onPressed: null, child: Text('X')),
        ),
      ),
    );
    expect(find.byType(DesktopTextSelectionToolbarButton), findsOneWidget);

Style Guide References

Footnotes

  1. Tests should follow the guidance on writing effective tests. Adding an assertion to verify the widget's presence makes the test more robust and explicit about what it's verifying, beyond just the absence of a crash. (link)

@LongCatIsLooong
Copy link
Contributor

Could you also do this #173677 (comment), in this PR?

@ahmedsameha1
Copy link
Contributor Author

I think there is no need to do this, according to: #6537 (comment)

Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

LGTM 👍 I agree no takeException is needed when it's at the end of a test like this. I typically use it when it would be beneficial for the test to fail before the end of the test if there is an exception.

@justinmc
Copy link
Contributor

I guess you could expect that the size of DesktopTextSelectionToolbarButton is indeed 0x0?

@ahmedsameha1
Copy link
Contributor Author

I guess you could expect that the size of DesktopTextSelectionToolbarButton is indeed 0x0?

Do you want me to add this expectation?

Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

Yes please add that expectation. I just talked with @LongCatIsLooong about this and we agree.

@ahmedsameha1
Copy link
Contributor Author

@justinmc Could you resolve this in #6537 because, according to #6537 (comment), there is no need to add that expectation. I think that this expectation is not specific to this widget, or is it?
Please consider this: #172074 (comment)

@ahmedsameha1 ahmedsameha1 force-pushed the handle#6537-DesktopTextSelectionToolbarButton branch from f7f602b to 96bea17 Compare August 25, 2025 09:37
@ahmedsameha1
Copy link
Contributor Author

I have updated this pull request according to #6537 (comment).

Copy link
Contributor

@dkwingsmt dkwingsmt left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@ahmedsameha1 ahmedsameha1 force-pushed the handle#6537-DesktopTextSelectionToolbarButton branch from cbad6c1 to 24f659a Compare August 26, 2025 05:15
@dkwingsmt dkwingsmt self-requested a review August 27, 2025 18:34
Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Contributor

@dkwingsmt dkwingsmt left a comment

Choose a reason for hiding this comment

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

Checklist:

  • The test is in the correct file
  • The test name goes “does not crash at zero area”
  • The target widget is wrapped by Center (or is fullscreen)
  • The target widget does not have an overlay, or the overlay is tested
  • The target widget is expected to have a size of exactly Size.zero

),
),
);
expect(tester.getSize(find.byType(DesktopTextSelectionToolbarButton)).isEmpty, isTrue);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
expect(tester.getSize(find.byType(DesktopTextSelectionToolbarButton)).isEmpty, isTrue);
expect(tester.getSize(find.byType(DesktopTextSelectionToolbarButton)), Size.zero);

@dkwingsmt dkwingsmt added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 23, 2025
@auto-submit
Copy link
Contributor

auto-submit bot commented Sep 23, 2025

autosubmit label was removed for flutter/flutter/173827, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 23, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 9, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 11, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 11, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 12, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 12, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 12, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 15, 2025
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
flutter#173827)

This is my attempt to handle
flutter#6537 for the
DesktopTextSelectionToolbarButton UI control.

---------

Co-authored-by: Tong Mu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: text input Entering text in a text field or keyboard related problems f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants