Skip to content

Add find.backButton finder and StandardComponentType enum to find components in tests. #149349

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

Merged
merged 4 commits into from
Jul 30, 2024

Conversation

gspencergoog
Copy link
Contributor

@gspencergoog gspencergoog commented May 30, 2024

Description

This adds find.backButton() in the Common Finders to allow finding different types of standard UI elements. It works by attaching a key made from an enum value in a new enum called StandardComponentType to all of the standard widgets that perform the associated function.

I also substituted the finder in several places where it is useful in tests.

This allows writing tests that want to find the "back" button without having to know exactly which icon the back button uses under what circumstances. To do it correctly is actually quite complicated, since there are several adaptations that occur (based on platform, and whether it is web or not).

Tests

  • Added tests.

@gspencergoog gspencergoog requested a review from QuncCccccc May 30, 2024 20:11
@github-actions github-actions bot added a: tests "flutter test", flutter_test, or one of our tests framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels May 30, 2024
Copy link
Contributor

@QuncCccccc QuncCccccc left a comment

Choose a reason for hiding this comment

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

This looks good to me😄! There seems some test failures. Also just thinking whether we should name it more specifically, something like materialIconButton? Because from Material Design, the standard buttons also include other types of button, like ElevatedButton, OutlinedButton etc but MaterialButtonType seems don't have them:)

@gspencergoog
Copy link
Contributor Author

@goderbauer and I spoke about this, and decided that it's too Material specific, and not extensible enough.

Instead, I'm going to change this to use a well-known set of Keys to search for, with perhaps a convenience function for some of the really common ones (e.g. find.backButton). Then people could even write their own back button implementation, attach the well-known key to it, and be able to have it work in tests as an "official" back button.

@gspencergoog gspencergoog marked this pull request as draft June 4, 2024 16:32
@flutter-dashboard
Copy link

This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@gspencergoog gspencergoog force-pushed the material_button_finder branch from b833228 to 986668a Compare June 5, 2024 00:50
@github-actions github-actions bot added a: text input Entering text in a text field or keyboard related problems f: cupertino flutter/packages/flutter/cupertino repository labels Jun 5, 2024
@gspencergoog gspencergoog force-pushed the material_button_finder branch from 70b3408 to 3955350 Compare June 5, 2024 02:40
@gspencergoog gspencergoog changed the title Add find.materialButton finder to find "standard" Material buttons. Add find.backButton finder and StandardComponentType enum to find components. Jun 5, 2024
@gspencergoog gspencergoog changed the title Add find.backButton finder and StandardComponentType enum to find components. Add find.backButton finder and StandardComponentType enum to find components in tests. Jun 5, 2024
@gspencergoog gspencergoog force-pushed the material_button_finder branch from 2494d45 to 95cbb00 Compare June 5, 2024 15:21
@Piinks Piinks requested a review from QuncCccccc June 12, 2024 17:12
@Piinks
Copy link
Contributor

Piinks commented Jul 18, 2024

@gspencergoog is this ready for a review? It looks like there are some failing checks.

@gspencergoog gspencergoog force-pushed the material_button_finder branch from 95cbb00 to bd5b90b Compare July 19, 2024 02:20
@gspencergoog
Copy link
Contributor Author

It's close, I just needed to fix the tests. Let me see what still needs doing and I'll send it off.

@gspencergoog gspencergoog force-pushed the material_button_finder branch 4 times, most recently from 4846889 to dc21067 Compare July 25, 2024 01:15
@github-actions github-actions bot removed a: text input Entering text in a text field or keyboard related problems f: cupertino flutter/packages/flutter/cupertino repository labels Jul 25, 2024
@gspencergoog gspencergoog force-pushed the material_button_finder branch from dc21067 to feb79cc Compare July 25, 2024 01:42
@github-actions github-actions bot added a: text input Entering text in a text field or keyboard related problems f: cupertino flutter/packages/flutter/cupertino repository labels Jul 25, 2024
@gspencergoog gspencergoog force-pushed the material_button_finder branch from feb79cc to 38235e9 Compare July 25, 2024 15:37
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 31, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 31, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 31, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 31, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 31, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 31, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 1, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 1, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 1, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 1, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 1, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 2, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 2, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 2, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 2, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 2, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Aug 3, 2024
Manual roll requested by [email protected]

flutter/flutter@9d5ede0...85960d2

2024-07-30 [email protected] Fix Shortcut label for CharacterActivator does not include modifiers (flutter/flutter#152233)
2024-07-30 [email protected] [wiki] Remove text saying wiki edits do not get code reviewed (flutter/flutter#152530)
2024-07-30 [email protected] Roll Flutter Engine from cb96743cc955 to c58d87d62c20 (1 revision) (flutter/flutter#152527)
2024-07-30 [email protected] Add `find.backButton` finder and `StandardComponentType` enum to find components in tests. (flutter/flutter#149349)
2024-07-30 [email protected] Roll Flutter Engine from 49324cd0b678 to cb96743cc955 (4 revisions) (flutter/flutter#152524)
2024-07-30 [email protected] [devicelab] remove Skia specific and unused devicelab metrics. (flutter/flutter#152523)
2024-07-30 [email protected] Add Dimil Kalathiya to authors (flutter/flutter#152491)
2024-07-29 [email protected] Roll Flutter Engine from 240fb460675d to 49324cd0b678 (4 revisions) (flutter/flutter#152521)
2024-07-29 [email protected] Stop CupertinoScrollbar's track from paging the scroll view on tap (flutter/flutter#152197)
2024-07-29 [email protected] Roll Flutter Engine from 4ef0f0d988ec to 240fb460675d (1 revision) (flutter/flutter#152507)
2024-07-29 [email protected] Roll Flutter Engine from a0219f7a429c to 4ef0f0d988ec (1 revision) (flutter/flutter#152505)
2024-07-29 [email protected] [flutter_tools] remove raster stats CLI option. (flutter/flutter#152501)
2024-07-29 [email protected] Shift some mac Android tests to Mokey devices in staging (flutter/flutter#152499)
2024-07-29 [email protected] [devicelab] enable impeller in external texture test. (flutter/flutter#152502)
2024-07-29 [email protected] Roll Flutter Engine from d1995f302c4d to a0219f7a429c (2 revisions) (flutter/flutter#152500)
2024-07-29 [email protected] Roll Flutter Engine from d803bb16c8b0 to d1995f302c4d (4 revisions) (flutter/flutter#152496)
2024-07-29 [email protected] Normalize Card theme (flutter/flutter#151914)
2024-07-29 [email protected] Roll Flutter Engine from 2db47a1f3d0d to d803bb16c8b0 (1 revision) (flutter/flutter#152489)
2024-07-29 [email protected] Roll Packages from 3d358d9 to 247fb5f (8 revisions) (flutter/flutter#152488)
2024-07-29 [email protected] Update New-Android-version.md (flutter/flutter#152395)
2024-07-29 [email protected] Roll Flutter Engine from 510f19a7e629 to 2db47a1f3d0d (1 revision) (flutter/flutter#152485)
2024-07-29 [email protected] Roll Flutter Engine from 87cbf33b9028 to 510f19a7e629 (1 revision) (flutter/flutter#152473)
2024-07-29 [email protected] Roll Flutter Engine from 2cf3986cae52 to 87cbf33b9028 (2 revisions) (flutter/flutter#152469)
2024-07-29 [email protected] Add tests for deletable_chip_attributes.on_deleted.0.dart (flutter/flutter#152361)

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
TytaniumDev pushed a commit to TytaniumDev/flutter that referenced this pull request Aug 7, 2024
… components in tests. (flutter#149349)

## Description

This adds `find.backButton()` in the Common Finders to allow finding different types of standard UI elements. It works by attaching a key made from an enum value in a new enum called `StandardComponentType` to all of the standard widgets that perform the associated function.

I also substituted the finder in several places where it is useful in tests.

This allows writing tests that want to find the "back" button without having to know exactly which icon the back button uses under what circumstances.  To do it correctly is actually quite complicated, since there are several adaptations that occur (based on platform, and whether it is web or not).

## Tests
 - Added tests.
Buchimi pushed a commit to Buchimi/flutter that referenced this pull request Sep 2, 2024
… components in tests. (flutter#149349)

## Description

This adds `find.backButton()` in the Common Finders to allow finding different types of standard UI elements. It works by attaching a key made from an enum value in a new enum called `StandardComponentType` to all of the standard widgets that perform the associated function.

I also substituted the finder in several places where it is useful in tests.

This allows writing tests that want to find the "back" button without having to know exactly which icon the back button uses under what circumstances.  To do it correctly is actually quite complicated, since there are several adaptations that occur (based on platform, and whether it is web or not).

## Tests
 - Added tests.
zanderso pushed a commit that referenced this pull request Oct 11, 2024
This adds back in the doc comment references for `CommonFinders` that
caused CI issues when @gspencergoog was trying to land
#149349.

This essentially reverts
a7721fe.
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 11, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: tests "flutter test", flutter_test, or one of our tests a: text input Entering text in a text field or keyboard related problems autosubmit Merge PR when tree becomes green via auto submit App f: cupertino flutter/packages/flutter/cupertino repository 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.

3 participants