Fill editable_text.dart test coverage (#26793)
This commit is contained in:
parent
33cd720db6
commit
8098b5e63e
@ -1980,7 +1980,7 @@ testWidgets(
|
|||||||
expect(called, 2);
|
expect(called, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('default keyboardAppearance is resepcted', (WidgetTester tester) async {
|
testWidgets('default keyboardAppearance is respected', (WidgetTester tester) async {
|
||||||
// Regression test for https://github.com/flutter/flutter/issues/22212.
|
// Regression test for https://github.com/flutter/flutter/issues/22212.
|
||||||
|
|
||||||
final List<MethodCall> log = <MethodCall>[];
|
final List<MethodCall> log = <MethodCall>[];
|
||||||
@ -2008,7 +2008,7 @@ testWidgets(
|
|||||||
expect(setClient.arguments.last['keyboardAppearance'], 'Brightness.light');
|
expect(setClient.arguments.last['keyboardAppearance'], 'Brightness.light');
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('custom keyboardAppearance is resepcted', (WidgetTester tester) async {
|
testWidgets('custom keyboardAppearance is respected', (WidgetTester tester) async {
|
||||||
// Regression test for https://github.com/flutter/flutter/issues/22212.
|
// Regression test for https://github.com/flutter/flutter/issues/22212.
|
||||||
|
|
||||||
final List<MethodCall> log = <MethodCall>[];
|
final List<MethodCall> log = <MethodCall>[];
|
||||||
@ -2036,6 +2036,54 @@ testWidgets(
|
|||||||
expect(setClient.method, 'TextInput.setClient');
|
expect(setClient.method, 'TextInput.setClient');
|
||||||
expect(setClient.arguments.last['keyboardAppearance'], 'Brightness.dark');
|
expect(setClient.arguments.last['keyboardAppearance'], 'Brightness.dark');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets(
|
||||||
|
'Composing text is underlined and underline is cleared when losing focus',
|
||||||
|
(WidgetTester tester) async {
|
||||||
|
final TextEditingController controller = TextEditingController.fromValue(
|
||||||
|
const TextEditingValue(
|
||||||
|
text: 'text composing text',
|
||||||
|
selection: TextSelection.collapsed(offset: 14),
|
||||||
|
composing: TextRange(start: 5, end: 14),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final GlobalKey<EditableTextState> editableTextKey =
|
||||||
|
GlobalKey<EditableTextState>();
|
||||||
|
final FocusNode focusNode = FocusNode();
|
||||||
|
|
||||||
|
await tester.pumpWidget(MaterialApp( // So we can show overlays.
|
||||||
|
home: EditableText(
|
||||||
|
autofocus: true,
|
||||||
|
backgroundCursorColor: Colors.grey,
|
||||||
|
key: editableTextKey,
|
||||||
|
controller: controller,
|
||||||
|
focusNode: focusNode,
|
||||||
|
style: textStyle,
|
||||||
|
cursorColor: cursorColor,
|
||||||
|
selectionControls: materialTextSelectionControls,
|
||||||
|
keyboardType: TextInputType.text,
|
||||||
|
onEditingComplete: () {
|
||||||
|
// This prevents the default focus change behavior on submission.
|
||||||
|
},
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
assert(focusNode.hasFocus);
|
||||||
|
|
||||||
|
final RenderEditable renderEditable = findRenderEditable(tester);
|
||||||
|
// The actual text span is split into 3 parts with the middle part underlined.
|
||||||
|
expect(renderEditable.text.children.length, 3);
|
||||||
|
expect(renderEditable.text.children[1].text, 'composing');
|
||||||
|
expect(renderEditable.text.children[1].style.decoration, TextDecoration.underline);
|
||||||
|
|
||||||
|
focusNode.unfocus();
|
||||||
|
await tester.pump();
|
||||||
|
|
||||||
|
expect(renderEditable.text.children, isNull);
|
||||||
|
// Everything's just formated the same way now.
|
||||||
|
expect(renderEditable.text.text, 'text composing text');
|
||||||
|
expect(renderEditable.text.style.decoration, isNull);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class MockTextSelectionControls extends Mock implements TextSelectionControls {}
|
class MockTextSelectionControls extends Mock implements TextSelectionControls {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user