Unverified Commit 8359d99e authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

have text finder convert Text.rich to plain text for comparison (#19270)

parent 698bda6a
......@@ -476,7 +476,9 @@ class _TextFinder extends MatchFinder {
bool matches(Element candidate) {
if (candidate.widget is Text) {
final Text textWidget = candidate.widget;
return textWidget.data == text;
if (textWidget.data != null)
return textWidget.data == text;
return textWidget.textSpan.toPlainText() == text;
} else if (candidate.widget is EditableText) {
final EditableText editable = candidate.widget;
return editable.controller.text == text;
......
......@@ -7,6 +7,28 @@ import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('text', () {
testWidgets('finds Text widgets', (WidgetTester tester) async {
await tester.pumpWidget(_boilerplate(
const Text('test'),
));
expect(find.text('test'), findsOneWidget);
});
testWidgets('finds Text.rich widgets', (WidgetTester tester) async {
await tester.pumpWidget(_boilerplate(
const Text.rich(
TextSpan(text: 't', children: <TextSpan>[
const TextSpan(text: 'e'),
const TextSpan(text: 'st'),
]
),
)));
expect(find.text('test'), findsOneWidget);
});
});
group('hitTestable', () {
testWidgets('excludes non-hit-testable widgets', (WidgetTester tester) async {
await tester.pumpWidget(
......
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