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 'Share' button to the selection toolbar on Android #139479
Add 'Share' button to the selection toolbar on Android #139479
Conversation
Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change). If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
FYI, the golden change for |
74b42ed
to
3e9b284
Compare
Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
@@ -671,6 +664,8 @@ void main() { | |||
selectionColor: selectionColor, | |||
cursorColor: cursorColor, | |||
child: Column( | |||
// TODO(bleroux): investigate why the test fail without setting the mainAxisAlignment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is interesting, was this test working with no changes before this PR? I don't see why this PR would cause that to change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I can confirm that this test is working on master without this change.
With this PR, I just found that another solution to make this test green is to add a call to pumpAndSettle()
on line 692, so there is probably an animation going on.
Do you think it is better to keep this TODO or to replace it with the call to pumpAndSettle? There are dozens of pumpAndSettle in this test file, so I think it makes sense to use one here, the remaining question is why was it not necesseray before? (it might be related to the toolbar content being longer than before).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a pumpAndSettle
sounds reasonable. I tried the pr out locally and found that if I change the logic in bool get shareEnabled
to the code below the test passes. I'm not at all sure why this works. I think we should we keep the switch statement and add a pumpAndSettle
since we might support other platforms.
if (defaultTargetPlatform != TargetPlatform.iOS || defaultTargetPlatform != TargetPlatform.android) {
return false;
}
return !widget.obscureText
&& !textEditingValue.selection.isCollapsed
&& textEditingValue.selection.textInside(textEditingValue.text).trim() != '';
} else { | ||
expect(find.text('Share'), findsOneWidget); | ||
await tester.tap(find.text('Share')); | ||
expect(lastShare, 'Test'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: consider moving expect(lastShare, 'Test');
out of this if statement since it is common to both branches.
@@ -144,6 +143,41 @@ void main() { | |||
return renderEditable; | |||
} | |||
|
|||
// Check that the Cupertino text selection toolbar is the expected one on iOS and macOS. | |||
// TODO(bleroux): try to merge this into text_selection_toolbar_utils.dart |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this planned for this PR, or in the future?, same for below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I plan to work on this later because it is not a blocker for this PR and it requires some careful thinking because:
- it should be implemented correctly for all platforms.
- It might make the helper functions in the 'utils' file less readable (and I wanted to keep them as readable as possible for this review and for the next PR I'm working on, the one related to [Android] Respect custom system-wide text selection toolbar buttons #139361).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me!
Thank you for the contribution @bleroux! These improvements to tests are awesome! I just had a few small comments, but this look great! |
Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after the pumpAndSettle
is added. Thanks for the contribution @bleroux
075f9dc
to
a29f89a
Compare
Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
…tter#139738) ## Description This PR adds custom system-wide text selection toolbar buttons on Android. ~~This is a WIP until flutter#139479 is merged (potential conflicts).~~ ## Related Issue Fixes flutter#139361 ## Tests Adds 5 tests.
…tter#139738) ## Description This PR adds custom system-wide text selection toolbar buttons on Android. ~~This is a WIP until flutter#139479 is merged (potential conflicts).~~ ## Related Issue Fixes flutter#139361 ## Tests Adds 5 tests.
…tter#139738) ## Description This PR adds custom system-wide text selection toolbar buttons on Android. ~~This is a WIP until flutter#139479 is merged (potential conflicts).~~ ## Related Issue Fixes flutter#139361 ## Tests Adds 5 tests.
## Description This PR adds the 'Share' button to the text selection toolbar on Android. ## Related Issue Fixes flutter#138728 ## Tests Refactor a lot of existing tests in order to: - make them more readable (avoid duplication by introducing helper functions, specify explictly check which buttons are expected). - make them more accurate (check that expected buttons are visible instead of just checking the number of buttons). For instance, previous tests contained sections such as: ```dart // Collapsed toolbar shows 3 buttons. expect( find.byType(CupertinoButton), isContextMenuProvidedByPlatform ? findsNothing : isTargetPlatformIOS ? findsNWidgets(6) : findsNWidgets(3) ); ``` Where the comment is obsolete, the two cases (6 widgets and 3 widgets) are not explicit (which buttons are expected?), and not accurate (will pass if the number of buttons is right but the buttons are the wrong ones).
…tter#139738) ## Description This PR adds custom system-wide text selection toolbar buttons on Android. ~~This is a WIP until flutter#139479 is merged (potential conflicts).~~ ## Related Issue Fixes flutter#139361 ## Tests Adds 5 tests.
## Description This PR adds the share button to text selection toolbar buttons on Android ~~and iOS~~ for `SelectableRegion` (and therefore `SelectionArea`). #139479 adds this button for `EditableText` (which is used by `TextField` and `SelectableText` but not by `SelectionArea`). **Edit**: supporting this on iOS will need more work (see #141447 (comment) and #141775). ## Related Issue Follow up for #138728 ## Tests Adds 1 test.
Description
This PR adds the 'Share' button to the text selection toolbar on Android.
Related Issue
Fixes #138728
Tests
Refactor a lot of existing tests in order to:
For instance, previous tests contained sections such as:
Where the comment is obsolete, the two cases (6 widgets and 3 widgets) are not explicit (which buttons are expected?), and not accurate (will pass if the number of buttons is right but the buttons are the wrong ones).