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