Repository navigation
Add more 0x0 size tests part 13 - #191466
auto-submit[bot] merged 14 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds tests to ensure that various widgets, including Viewport, RawImage, Builder, StatefulBuilder, ColoredBox, Flow, RichText, and Wrap, do not crash when rendered with a zero-area physical size. Feedback suggests removing the redundant tests for Builder and StatefulBuilder, as they are compositional widgets that do not perform layout or painting. Additionally, it is recommended to simplify the tests for RawImage, ColoredBox, Viewport, and Flow by removing the unnecessary Directionality wrapper, as these widgets do not depend on text direction.
| testWidgets('RawImage does not crash at zero area', (WidgetTester tester) async { | ||
| tester.view.physicalSize = Size.zero; | ||
| addTearDown(tester.view.reset); | ||
| await tester.pumpWidget( | ||
| const Directionality( | ||
| textDirection: TextDirection.ltr, | ||
| child: Center(child: RawImage()), | ||
| ), | ||
| ); | ||
| expect(tester.getSize(find.byType(RawImage)), Size.zero); | ||
| }); |
There was a problem hiding this comment.
RawImage does not depend on text direction and does not require a Directionality widget. We can simplify this test by removing the unnecessary Directionality wrapper.
testWidgets('RawImage does not crash at zero area', (WidgetTester tester) async {
tester.view.physicalSize = Size.zero;
addTearDown(tester.view.reset);
await tester.pumpWidget(
const Center(child: RawImage()),
);
expect(tester.getSize(find.byType(RawImage)), Size.zero);
});References
- Suggest simplification and refactoring: Assess whether the code can be made simpler or refactored to enhance readability and maintainability. (link)
| testWidgets('ColoredBox does not crash at zero area', (WidgetTester tester) async { | ||
| tester.view.physicalSize = Size.zero; | ||
| addTearDown(tester.view.reset); | ||
| await tester.pumpWidget( | ||
| const Directionality( | ||
| textDirection: TextDirection.ltr, | ||
| child: Center( | ||
| child: ColoredBox(color: Color(0xFFAABBCC), child: Placeholder()), | ||
| ), | ||
| ), | ||
| ); | ||
| expect(tester.getSize(find.byType(ColoredBox)), Size.zero); | ||
| }); |
There was a problem hiding this comment.
ColoredBox does not depend on text direction and does not require a Directionality widget. We can simplify this test by removing the unnecessary Directionality wrapper.
testWidgets('ColoredBox does not crash at zero area', (WidgetTester tester) async {
tester.view.physicalSize = Size.zero;
addTearDown(tester.view.reset);
await tester.pumpWidget(
const Center(
child: ColoredBox(color: Color(0xFFAABBCC), child: Placeholder()),
),
);
expect(tester.getSize(find.byType(ColoredBox)), Size.zero);
});References
- Suggest simplification and refactoring: Assess whether the code can be made simpler or refactored to enhance readability and maintainability. (link)
There was a problem hiding this comment.
Not necessary, but feel free to adopt it if you feel like.
| testWidgets('Flow does not crash at zero area', (WidgetTester tester) async { | ||
| tester.view.physicalSize = Size.zero; | ||
| addTearDown(tester.view.reset); | ||
| await tester.pumpWidget( | ||
| Directionality( | ||
| textDirection: TextDirection.ltr, | ||
| child: Center( | ||
| child: Flow(delegate: OpacityFlowDelegate(0.2), children: const <Widget>[Placeholder()]), | ||
| ), | ||
| ), | ||
| ); | ||
| expect(tester.getSize(find.byType(Flow)), Size.zero); | ||
| }); |
There was a problem hiding this comment.
Flow does not depend on text direction and does not require a Directionality widget. We can simplify this test by removing the unnecessary Directionality wrapper.
testWidgets('Flow does not crash at zero area', (WidgetTester tester) async {
tester.view.physicalSize = Size.zero;
addTearDown(tester.view.reset);
await tester.pumpWidget(
Center(
child: Flow(delegate: OpacityFlowDelegate(0.2), children: const <Widget>[Placeholder()]),
),
);
expect(tester.getSize(find.byType(Flow)), Size.zero);
});References
- Suggest simplification and refactoring: Assess whether the code can be made simpler or refactored to enhance readability and maintainability. (link)
There was a problem hiding this comment.
Not necessary, but feel free to adopt it if you feel like.
|
autosubmit label was removed for flutter/flutter/191466, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR. |
|
autosubmit label was removed for flutter/flutter/191466, because - The status or check suite ci.yaml validation has failed. Please fix the issues identified (or deflake) before re-applying this label. |
d29260a
|
Can you fix the analyzer issues? |
11fda5c to
e0036b5
Compare
|
There's a leaking error: Can you take a look? |
c3338bb
This is my attempt to handle #6537 for the following widgets:
Viewport
ColoredBox
StatefulBuilder
Builder
RawImage
RichText
Flow
Wrap