[go: nahoru, domu]

Skip to content
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

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

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

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.

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

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

None yet

2 participants