Add more 0x0 size tests part 11#186822
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds regression tests across several widget test files to ensure that widgets like AspectRatio, UnconstrainedBox, ConstraintsTransformBox, LimitedBox, Offstage, IntrinsicHeight, ConstrainedBox, FractionallySizedBox, IntrinsicWidth, and SizedOverflowBox do not crash when rendered with zero area. Feedback includes addressing a potential overflow error in the UnconstrainedBox test, shortening redundant test descriptions for consistency, and ensuring the use of const constructors and child widgets in ConstrainedBox tests to align with repository style guides and existing test patterns.
| testWidgets('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: UnconstrainedBox(child: Placeholder())), | ||
| ), | ||
| ); | ||
| expect(tester.getSize(find.byType(UnconstrainedBox)), Size.zero); | ||
| }); |
There was a problem hiding this comment.
The UnconstrainedBox test will likely fail in debug mode because it triggers an overflow error. UnconstrainedBox removes constraints from its child, so the Placeholder will attempt to be 400x400. Since the UnconstrainedBox itself is constrained to 0x0 by the Center widget, it will report an overflow. To fix this and ensure the test passes while still verifying the "no crash" condition, consider removing the child or using a zero-sized child like SizedBox.shrink().
testWidgets('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: UnconstrainedBox()),
),
);
expect(tester.getSize(find.byType(UnconstrainedBox)), Size.zero);
});| ); | ||
| }); | ||
|
|
||
| testWidgets('ConstraintsTransformBox does not crash at zero area', (WidgetTester tester) async { |
There was a problem hiding this comment.
The test description 'ConstraintsTransformBox does not crash at zero area' is redundant since it is already inside a group named 'ConstraintsTransformBox'. For consistency with the newly added UnconstrainedBox test in the same file, consider shortening the description.
testWidgets('does not crash at zero area', (WidgetTester tester) async {There was a problem hiding this comment.
| testWidgets('ConstraintsTransformBox does not crash at zero area', (WidgetTester tester) async { | |
| testWidgets('does not crash at zero area', (WidgetTester tester) async { |
| testWidgets('ConstrainedBox 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: ConstrainedBox(constraints: const BoxConstraints(minWidth: 200, maxWidth: 400)), | ||
| ), | ||
| ), | ||
| ); | ||
| expect(tester.getSize(find.byType(ConstrainedBox)), Size.zero); | ||
| }); |
There was a problem hiding this comment.
This test is inconsistent with the other tests added in this PR. It is missing const on the widget tree and does not include a child widget. For better consistency and to ensure the layout logic involving children is also exercised at zero size, consider adding a Placeholder child and using const for the widget tree.
testWidgets('ConstrainedBox 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: ConstrainedBox(
constraints: BoxConstraints(minWidth: 200, maxWidth: 400),
child: Placeholder(),
),
),
),
);
expect(tester.getSize(find.byType(ConstrainedBox)), Size.zero);
});References
- Optimize for readability and follow language idioms like using const constructors where possible. (link)
f085a67 to
9566412
Compare
9566412 to
7a85ca1
Compare
Piinks
left a comment
There was a problem hiding this comment.
Still LGTM. :) Thanks for resolving that merge conflict!
|
autosubmit label was removed for flutter/flutter/186822, because This PR has not met approval requirements for merging. The PR author is not a member of flutter-hackers and needs 1 more review(s) in order to merge this PR.
|
| ); | ||
| }); | ||
|
|
||
| testWidgets('ConstraintsTransformBox does not crash at zero area', (WidgetTester tester) async { |
There was a problem hiding this comment.
| testWidgets('ConstraintsTransformBox does not crash at zero area', (WidgetTester tester) async { | |
| testWidgets('does not crash at zero area', (WidgetTester tester) async { |
flutter/flutter@c0a1129...8bdce07 2026-06-11 bernaferrari2@gmail.com Make shape border lerp symmetric (flutter/flutter#187282) 2026-06-11 matt.kosarek@canonical.com Sized to content for regular and dialog windows on win32 (flutter/flutter#186829) 2026-06-11 jason-simmons@users.noreply.github.com Ensure that directory names are typed as strings in the CIPD package YAML file generated by merge_and_upload_debug_symbols.py (flutter/flutter#187813) 2026-06-11 stuartmorgan@google.com Add core-packages to ecosystem triage (flutter/flutter#187796) 2026-06-11 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from 8azSyvz57mKcPqTwk... to 2KosSR4ONUjIB7tP_... (flutter/flutter#187842) 2026-06-11 ishaquehassan@gmail.com Document moveStep direction on WidgetController.dragUntilVisible (flutter/flutter#186943) 2026-06-11 ahmedsameha1@gmail.com Add more 0x0 size tests part 11 (flutter/flutter#186822) 2026-06-10 kumarshivam72@gmail.com Fix ShapeDecoration.lerp crash when interpolating between gradient and color (flutter/flutter#187368) 2026-06-10 codedoctor@linwood.dev Reland "Add support for stylus buttons" (flutter/flutter#187629) 2026-06-10 tanyabouman@gmail.com Api docs: typo fix in Navigator (flutter/flutter#187572) 2026-06-10 engine-flutter-autoroll@skia.org Roll Packages from bd297cf to 1b56cde (4 revisions) (flutter/flutter#187784) 2026-06-10 116356835+AbdeMohlbi@users.noreply.github.com Improve docs on MediaQuery: highContrast, invertColors and disableAnimations (flutter/flutter#186614) 2026-06-10 matt.boetger@gmail.com [Android] Test to verify AnnounceSemanticsEvent deprecation warning on API 36 (flutter/flutter#187754) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC louisehsu@google.com,stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
This is my attempt to handle flutter#6537 for the following widgets: ConstrainedBox ConstraintsTransformBox UnconstrainedBox FractionallySizedBox LimitedBox SizedOverflowBox Offstage AspectRatio IntrinsicWidth IntrinsicHeight --------- Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
This is my attempt to handle #6537 for the following widgets:
ConstrainedBox
ConstraintsTransformBox
UnconstrainedBox
FractionallySizedBox
LimitedBox
SizedOverflowBox
Offstage
AspectRatio
IntrinsicWidth
IntrinsicHeight