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 more RenderEditable test coverage #27003

Merged
merged 12 commits into from Feb 5, 2019
Merged

Conversation

xster
Copy link
Member

@xster xster commented Jan 24, 2019

#26026

@xster
Copy link
Member Author

xster commented Jan 24, 2019

@fkorotkov: if you're still collecting data about sudden test terminations, I ran into a few instances here:
https://cirrus-ci.com/task/5451118973812736
https://cirrus-ci.com/task/6014068927234048
https://cirrus-ci.com/task/6295543903944704

@zoechi zoechi added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. labels Jan 24, 2019
@xster xster requested a review from jslavitz January 24, 2019 23:53
Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM modulo some indentation nits.

Copy link
Contributor

@jslavitz jslavitz left a comment

Choose a reason for hiding this comment

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

LGTM

@xster
Copy link
Member Author

xster commented Jan 30, 2019

Some wild indents snuck into the copypasta. Fixed

@zoechi zoechi added the a: tests "flutter test", flutter_test, or one of our tests label Jan 30, 2019
@goderbauer
Copy link
Member

Looks like Cirrus is not happy with this PR.

@@ -1516,7 +1516,7 @@ class RenderEditable extends RenderBox {
_textPainter.paint(context.canvas, effectiveOffset);

if (_selection != null && !_floatingCursorOn) {
if (_selection.isCollapsed && cursorColor != null && _hasFocus) {
Copy link
Member Author

Choose a reason for hiding this comment

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

reverted this as discussed.

@@ -565,7 +565,8 @@ class EditableText extends StatefulWidget {
/// State for a [EditableText].
class EditableTextState extends State<EditableText> with AutomaticKeepAliveClientMixin<EditableText>, WidgetsBindingObserver, TickerProviderStateMixin<EditableText> implements TextInputClient, TextSelectionDelegate {
Timer _cursorTimer;
final ValueNotifier<bool> _showCursor = ValueNotifier<bool>(false);
Copy link
Member Author

Choose a reason for hiding this comment

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

@jslavitz I refactored this since the new _showCursor is not a source of truth (which is ready to be fed into RenderEditable) but a desired destination. Split it out into another field.

}

/// Whether the blinking cursor is actually visible at this precise moment
/// (it's hidden half the time, since it blinks).
@visibleForTesting
bool get cursorCurrentlyVisible => _showCursor.value;
bool get cursorCurrentlyVisible => _cursorBlinkOpacityController.value > 0;
Copy link
Member Author

Choose a reason for hiding this comment

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

Refactored this to keep it working. Ideally we should get rid of it since it's not that useful but it's already public.

expect(renderEditable.cursorColor.alpha, 255);

await tester.pump();
await tester.pump(const Duration(milliseconds: 200));
Copy link
Member Author

Choose a reason for hiding this comment

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

@jslavitz I tweaked this a bit. In general, we want to be very with the number and durations of pumps to make sure the animation happens exactly the way we expect it to.

@xster xster merged commit 32b9c2f into flutter:master Feb 5, 2019
@xster xster deleted the render-editable-test branch February 5, 2019 08:54
kangwang1988 pushed a commit to XianyuTech/flutter that referenced this pull request Feb 12, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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 framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants