Skip to content

Make sure that a CupertinoDesktopTextSelectionToolbarButton doesn't c… #173894

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ahmedsameha1
Copy link
Contributor

This is my attempt to handle #6537 for the CupertinoDesktopTextSelectionToolbarButton 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: cupertino flutter/packages/flutter/cupertino repository labels Aug 16, 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 for an issue where CupertinoDesktopTextSelectionToolbarButton would crash when rendered in a zero-sized area. The added test correctly reproduces the scenario. My feedback focuses on improving the test's robustness by adding an assertion, as recommended by the Flutter testing guidelines.

Comment on lines +134 to +140
await tester.pumpWidget(
const CupertinoApp(
home: SizedBox.shrink(
child: CupertinoDesktopTextSelectionToolbarButton(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

While this test is great for catching crashes, it's missing an assertion. The Flutter testing guide states that every test should have at least one expect call.1 This ensures the test is actually verifying what it's supposed to and doesn't pass vacuously if the widget isn't rendered at all.

Adding a simple expect to check for the widget's presence would make this test more complete.

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

Style Guide References

Footnotes

  1. Flutter Style Guide, line 10: Writing Effective Tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

Either way is good IMO.

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 👍

Comment on lines +134 to +140
await tester.pumpWidget(
const CupertinoApp(
home: SizedBox.shrink(
child: CupertinoDesktopTextSelectionToolbarButton(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.

Either way is good IMO.

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: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants