Unverified Commit 8098b5e6 authored by xster's avatar xster Committed by GitHub

Fill editable_text.dart test coverage (#26793)

parent 33cd720d
...@@ -1980,7 +1980,7 @@ testWidgets( ...@@ -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( ...@@ -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( ...@@ -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 {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment