Unverified Commit 1b5899a4 authored by Tomasz Gucio's avatar Tomasz Gucio Committed by GitHub

Avoid catching FlutterError in TextPainter tests (#127604)

parent 90afc5e8
......@@ -1253,34 +1253,34 @@ void main() {
..text = const TextSpan(text: 'TEXT')
..textDirection = TextDirection.ltr;
FlutterError? exception;
try {
painter.getPositionForOffset(Offset.zero);
} on FlutterError catch (e) {
exception = e;
}
expect(exception?.message, contains('The TextPainter has never been laid out.'));
exception = null;
try {
painter.layout();
painter.getPositionForOffset(Offset.zero);
} on FlutterError catch (e) {
exception = e;
}
expect(exception, isNull);
exception = null;
expect(
() => painter.getPositionForOffset(Offset.zero),
throwsA(isA<FlutterError>().having(
(FlutterError error) => error.message,
'message',
contains('The TextPainter has never been laid out.'),
)),
);
try {
painter.markNeedsLayout();
painter.getPositionForOffset(Offset.zero);
} on FlutterError catch (e) {
exception = e;
}
expect(
() {
painter.layout();
painter.getPositionForOffset(Offset.zero);
},
returnsNormally,
);
expect(exception?.message, contains('The calls that first invalidated the text layout were:'));
exception = null;
expect(
() {
painter.markNeedsLayout();
painter.getPositionForOffset(Offset.zero);
},
throwsA(isA<FlutterError>().having(
(FlutterError error) => error.message,
'message',
contains('The calls that first invalidated the text layout were:'),
)),
);
painter.dispose();
});
......
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