Unverified Commit 25d2f90a authored by Tomasz Gucio's avatar Tomasz Gucio Committed by GitHub

Avoid catching errors in TextPainter tests (#127307)

parent 11cb2917
...@@ -368,15 +368,14 @@ void main() { ...@@ -368,15 +368,14 @@ void main() {
test('TextPainter error test', () { test('TextPainter error test', () {
final TextPainter painter = TextPainter(textDirection: TextDirection.ltr); final TextPainter painter = TextPainter(textDirection: TextDirection.ltr);
Object? e;
try {
painter.paint(MockCanvas(), Offset.zero);
} catch (exception) {
e = exception;
}
expect( expect(
e.toString(), () => painter.paint(MockCanvas(), Offset.zero),
contains('TextPainter.paint called when text geometry was not yet calculated'), throwsA(isA<StateError>().having(
(StateError error) => error.message,
'message',
contains('TextPainter.paint called when text geometry was not yet calculated'),
)),
); );
painter.dispose(); painter.dispose();
}); });
...@@ -1310,15 +1309,13 @@ void main() { ...@@ -1310,15 +1309,13 @@ void main() {
PlaceholderDimensions(size: Size(50, 30), alignment: ui.PlaceholderAlignment.bottom), PlaceholderDimensions(size: Size(50, 30), alignment: ui.PlaceholderAlignment.bottom),
]); ]);
Object? e;
try {
painter.paint(MockCanvas(), Offset.zero);
} catch (exception) {
e = exception;
}
expect( expect(
e.toString(), () => painter.paint(MockCanvas(), Offset.zero),
contains('TextPainter.paint called when text geometry was not yet calculated'), throwsA(isA<StateError>().having(
(StateError error) => error.message,
'message',
contains('TextPainter.paint called when text geometry was not yet calculated'),
)),
); );
painter.dispose(); painter.dispose();
}, skip: isBrowser && !isCanvasKit); // https://github.com/flutter/flutter/issues/56308 }, skip: isBrowser && !isCanvasKit); // https://github.com/flutter/flutter/issues/56308
...@@ -1348,16 +1345,14 @@ void main() { ...@@ -1348,16 +1345,14 @@ void main() {
PlaceholderDimensions(size: Size(50, 30), alignment: ui.PlaceholderAlignment.bottom), PlaceholderDimensions(size: Size(50, 30), alignment: ui.PlaceholderAlignment.bottom),
]); ]);
Object? e;
try {
painter.paint(MockCanvas(), Offset.zero);
} catch (exception) {
e = exception;
}
// In tests, paint() will throw an UnimplementedError due to missing drawParagraph method. // In tests, paint() will throw an UnimplementedError due to missing drawParagraph method.
expect( expect(
e.toString(), () => painter.paint(MockCanvas(), Offset.zero),
isNot(contains('TextPainter.paint called when text geometry was not yet calculated')), isNot(throwsA(isA<StateError>().having(
(StateError error) => error.message,
'message',
contains('TextPainter.paint called when text geometry was not yet calculated'),
))),
); );
painter.dispose(); painter.dispose();
}, skip: isBrowser && !isCanvasKit); // https://github.com/flutter/flutter/issues/56308 }, skip: isBrowser && !isCanvasKit); // https://github.com/flutter/flutter/issues/56308
......
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