Skip to content

Add test for focus_node.unfocus.0.dart - #157673

Merged
auto-submit[bot] merged 2 commits into
flutter:masterfrom
ValentinVignal:flutter/api/example/Add-test-for-focus-node-unfocus
Oct 28, 2024
Merged

auto-submit[bot] merged 2 commits into
flutter:masterfrom
ValentinVignal:flutter/api/example/Add-test-for-focus-node-unfocus

Conversation

@ValentinVignal

Copy link
Copy Markdown
Contributor

Contributes to #130459

It adds a test for

  • examples/api/lib/widgets/focus_manager/focus_node.unfocus.0.dart

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: focus Focus traversal, gaining or losing focus labels Oct 26, 2024
Comment on lines +19 to +21
await tester.tap(find.byType(TextField).first); // Focuses the first text field.
await tester.pump();

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.

Suggested change
await tester.tap(find.byType(TextField).first); // Focuses the first text field.
await tester.pump();
// Focuses the first text field.
await tester.tap(find.byType(TextField).first);
await tester.pump();

Cosmetic change to use the same commenting approach than below.

@bleroux bleroux 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! with minor comments

Comment on lines +79 to +87
expect(
find.descendant(
of: find.byType(TextField).first,
matching: find.byWidgetPredicate(
(Widget focus) => focus is Focus && (focus.focusNode?.hasFocus ?? false),
),
),
findsOne,
);

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.

Not sure it is better, but if you want something shorter, the following is probably ok:

      final EditableText firstEditableText = tester.firstWidget(find.byType(EditableText));
      expect(firstEditableText.focusNode.hasFocus, true);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure ! I changed it in test: Shorter expects

Comment on lines +54 to +50
await tester.tap(find.byType(TextField).first); // Focuses the first text field.
await tester.pump();

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.

Suggested change
await tester.tap(find.byType(TextField).first); // Focuses the first text field.
await tester.pump();
// Focuses the first text field.
await tester.tap(find.byType(TextField).first);
await tester.pump();

@ValentinVignal
ValentinVignal force-pushed the flutter/api/example/Add-test-for-focus-node-unfocus branch from a3fa482 to cdee05f Compare October 28, 2024 08:34
@ValentinVignal ValentinVignal added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 28, 2024
@auto-submit
auto-submit Bot merged commit d9cb4b8 into flutter:master Oct 28, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 28, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 28, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 28, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 28, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 28, 2024
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Oct 28, 2024
flutter/flutter@5a11904...3fb95c7

2024-10-28 [email protected] Roll Flutter Engine from bf5bfeebf89f to 23b2c6d3b3b1 (3 revisions) (flutter/flutter#157736)
2024-10-28 [email protected] Avoid labeling 'context' PRs as 'text-input' (flutter/flutter#157650)
2024-10-28 [email protected] Add test for `restorable_route_future.0.dart` (flutter/flutter#157708)
2024-10-28 [email protected] Update .ci.yaml have android sdk be 35v1 (flutter/flutter#157621)
2024-10-28 [email protected] Roll Flutter Engine from 2522789c4199 to bf5bfeebf89f (1 revision) (flutter/flutter#157713)
2024-10-28 [email protected] Add test for `restoration_mixin.0.dart` (flutter/flutter#157709)
2024-10-28 [email protected] Add test for `navigator.restorable_push_replacement.0.dart` (flutter/flutter#157704)
2024-10-28 [email protected] Add test for `focus_node.unfocus.0.dart` (flutter/flutter#157673)
2024-10-28 [email protected] Roll Flutter Engine from 9226b089d634 to 2522789c4199 (2 revisions) (flutter/flutter#157710)
2024-10-28 [email protected] Add tests for `navigator_state.restorable_push.0.dart` (flutter/flutter#157667)
2024-10-28 [email protected] Roll Flutter Engine from 10e50bd42c42 to 9226b089d634 (1 revision) (flutter/flutter#157702)
2024-10-28 [email protected] Add test for `navigator_state.restorable_push_replacement.0.dart` (flutter/flutter#157668)
2024-10-28 [email protected] Remove unsafe_html lint rule (flutter/flutter#157531)
2024-10-27 [email protected] Roll Flutter Engine from 3162aaad0086 to 10e50bd42c42 (1 revision) (flutter/flutter#157690)
2024-10-27 [email protected] Fix Scaffold extend body (flutter/flutter#157441)
2024-10-26 [email protected] Roll Flutter Engine from c9b8ac96f6ce to 3162aaad0086 (3 revisions) (flutter/flutter#157681)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 12, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 7, 2025
creatorpiyush pushed a commit to creatorpiyush/packages that referenced this pull request Jun 10, 2026
flutter/flutter@5a11904...3fb95c7

2024-10-28 [email protected] Roll Flutter Engine from bf5bfeebf89f to 23b2c6d3b3b1 (3 revisions) (flutter/flutter#157736)
2024-10-28 [email protected] Avoid labeling 'context' PRs as 'text-input' (flutter/flutter#157650)
2024-10-28 [email protected] Add test for `restorable_route_future.0.dart` (flutter/flutter#157708)
2024-10-28 [email protected] Update .ci.yaml have android sdk be 35v1 (flutter/flutter#157621)
2024-10-28 [email protected] Roll Flutter Engine from 2522789c4199 to bf5bfeebf89f (1 revision) (flutter/flutter#157713)
2024-10-28 [email protected] Add test for `restoration_mixin.0.dart` (flutter/flutter#157709)
2024-10-28 [email protected] Add test for `navigator.restorable_push_replacement.0.dart` (flutter/flutter#157704)
2024-10-28 [email protected] Add test for `focus_node.unfocus.0.dart` (flutter/flutter#157673)
2024-10-28 [email protected] Roll Flutter Engine from 9226b089d634 to 2522789c4199 (2 revisions) (flutter/flutter#157710)
2024-10-28 [email protected] Add tests for `navigator_state.restorable_push.0.dart` (flutter/flutter#157667)
2024-10-28 [email protected] Roll Flutter Engine from 10e50bd42c42 to 9226b089d634 (1 revision) (flutter/flutter#157702)
2024-10-28 [email protected] Add test for `navigator_state.restorable_push_replacement.0.dart` (flutter/flutter#157668)
2024-10-28 [email protected] Remove unsafe_html lint rule (flutter/flutter#157531)
2024-10-27 [email protected] Roll Flutter Engine from 3162aaad0086 to 10e50bd42c42 (1 revision) (flutter/flutter#157690)
2024-10-27 [email protected] Fix Scaffold extend body (flutter/flutter#157441)
2024-10-26 [email protected] Roll Flutter Engine from c9b8ac96f6ce to 3162aaad0086 (3 revisions) (flutter/flutter#157681)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
bisor0627 pushed a commit to bisor0627/packages that referenced this pull request Jun 19, 2026
flutter/flutter@5a11904...3fb95c7

2024-10-28 [email protected] Roll Flutter Engine from bf5bfeebf89f to 23b2c6d3b3b1 (3 revisions) (flutter/flutter#157736)
2024-10-28 [email protected] Avoid labeling 'context' PRs as 'text-input' (flutter/flutter#157650)
2024-10-28 [email protected] Add test for `restorable_route_future.0.dart` (flutter/flutter#157708)
2024-10-28 [email protected] Update .ci.yaml have android sdk be 35v1 (flutter/flutter#157621)
2024-10-28 [email protected] Roll Flutter Engine from 2522789c4199 to bf5bfeebf89f (1 revision) (flutter/flutter#157713)
2024-10-28 [email protected] Add test for `restoration_mixin.0.dart` (flutter/flutter#157709)
2024-10-28 [email protected] Add test for `navigator.restorable_push_replacement.0.dart` (flutter/flutter#157704)
2024-10-28 [email protected] Add test for `focus_node.unfocus.0.dart` (flutter/flutter#157673)
2024-10-28 [email protected] Roll Flutter Engine from 9226b089d634 to 2522789c4199 (2 revisions) (flutter/flutter#157710)
2024-10-28 [email protected] Add tests for `navigator_state.restorable_push.0.dart` (flutter/flutter#157667)
2024-10-28 [email protected] Roll Flutter Engine from 10e50bd42c42 to 9226b089d634 (1 revision) (flutter/flutter#157702)
2024-10-28 [email protected] Add test for `navigator_state.restorable_push_replacement.0.dart` (flutter/flutter#157668)
2024-10-28 [email protected] Remove unsafe_html lint rule (flutter/flutter#157531)
2024-10-27 [email protected] Roll Flutter Engine from 3162aaad0086 to 10e50bd42c42 (1 revision) (flutter/flutter#157690)
2024-10-27 [email protected] Fix Scaffold extend body (flutter/flutter#157441)
2024-10-26 [email protected] Roll Flutter Engine from c9b8ac96f6ce to 3162aaad0086 (3 revisions) (flutter/flutter#157681)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: focus Focus traversal, gaining or losing focus framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants