Unverified Commit 09fd46a1 authored by Han van Venrooij's avatar Han van Venrooij Committed by GitHub

Widen getText support for RichText with multiple text spans in driver (#75603)

parent a178bba5
...@@ -390,9 +390,10 @@ mixin CommandHandlerFactory { ...@@ -390,9 +390,10 @@ mixin CommandHandlerFactory {
text = (widget as Text).data; text = (widget as Text).data;
} else if (widget.runtimeType == RichText) { } else if (widget.runtimeType == RichText) {
final RichText richText = widget as RichText; final RichText richText = widget as RichText;
if (richText.text.runtimeType == TextSpan) { text = richText.text.toPlainText(
text = (richText.text as TextSpan).text; includeSemanticsLabels: false,
} includePlaceholders: false,
);
} else if (widget.runtimeType == TextField) { } else if (widget.runtimeType == TextField) {
text = (widget as TextField).controller?.text; text = (widget as TextField).controller?.text;
} else if (widget.runtimeType == TextFormField) { } else if (widget.runtimeType == TextFormField) {
......
...@@ -599,6 +599,18 @@ void main() { ...@@ -599,6 +599,18 @@ void main() {
controller: TextEditingController(text: 'Hello5'), controller: TextEditingController(text: 'Hello5'),
), ),
), ),
Container(
height: 25.0,
child: RichText(
key: const ValueKey<String>('text6'),
text: const TextSpan(children: <TextSpan>[
TextSpan(text: 'Hello'),
TextSpan(text: ', '),
TextSpan(text: 'World'),
TextSpan(text: '!'),
]),
),
),
], ],
)) ))
) )
...@@ -609,6 +621,7 @@ void main() { ...@@ -609,6 +621,7 @@ void main() {
expect(await getTextInternal(ByValueKey('text3')), 'Hello3'); expect(await getTextInternal(ByValueKey('text3')), 'Hello3');
expect(await getTextInternal(ByValueKey('text4')), 'Hello4'); expect(await getTextInternal(ByValueKey('text4')), 'Hello4');
expect(await getTextInternal(ByValueKey('text5')), 'Hello5'); expect(await getTextInternal(ByValueKey('text5')), 'Hello5');
expect(await getTextInternal(ByValueKey('text6')), 'Hello, World!');
// Check if error thrown for other types // Check if error thrown for other types
final Map<String, String> arguments = GetText(ByValueKey('column'), timeout: const Duration(seconds: 1)).serialize(); final Map<String, String> arguments = GetText(ByValueKey('column'), timeout: const Duration(seconds: 1)).serialize();
......
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