Skip to content

Add more 0x0 size tests part 11#186822

Merged
auto-submit[bot] merged 12 commits into
flutter:masterfrom
ahmedsameha1:add_more_0x0_size_tests_part_11
Jun 11, 2026
Merged

Add more 0x0 size tests part 11#186822
auto-submit[bot] merged 12 commits into
flutter:masterfrom
ahmedsameha1:add_more_0x0_size_tests_part_11

Conversation

@ahmedsameha1

Copy link
Copy Markdown
Contributor

This is my attempt to handle #6537 for the following widgets:
ConstrainedBox
ConstraintsTransformBox
UnconstrainedBox
FractionallySizedBox
LimitedBox
SizedOverflowBox
Offstage
AspectRatio
IntrinsicWidth
IntrinsicHeight

@github-actions github-actions Bot added the framework flutter/packages/flutter repository. See also f: labels. label May 20, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +1033 to +1043
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);
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
testWidgets('ConstraintsTransformBox does not crash at zero area', (WidgetTester tester) async {
testWidgets('does not crash at zero area', (WidgetTester tester) async {

Comment on lines +299 to +311
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);
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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
  1. Optimize for readability and follow language idioms like using const constructors where possible. (link)

@victorsanni victorsanni added the CICD Run CI/CD label May 20, 2026
victorsanni
victorsanni previously approved these changes May 20, 2026
@victorsanni victorsanni requested a review from dkwingsmt May 20, 2026 21:39
Piinks
Piinks previously approved these changes May 26, 2026

@Piinks Piinks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Piinks Piinks force-pushed the add_more_0x0_size_tests_part_11 branch from f085a67 to 9566412 Compare May 26, 2026 21:24
@github-actions github-actions Bot removed the CICD Run CI/CD label May 26, 2026
@Piinks Piinks added autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD labels May 26, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue May 26, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch May 26, 2026
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 26, 2026
@ahmedsameha1 ahmedsameha1 dismissed stale reviews from Piinks and victorsanni via 7a85ca1 May 27, 2026 14:50
@ahmedsameha1 ahmedsameha1 force-pushed the add_more_0x0_size_tests_part_11 branch from 9566412 to 7a85ca1 Compare May 27, 2026 14:50
@github-actions github-actions Bot removed the CICD Run CI/CD label May 27, 2026
@Piinks Piinks added the CICD Run CI/CD label May 27, 2026

@Piinks Piinks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still LGTM. :) Thanks for resolving that merge conflict!

@dkwingsmt dkwingsmt added the autosubmit Merge PR when tree becomes green via auto submit App label May 27, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 27, 2026
@auto-submit

auto-submit Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

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.

  • Merge guidelines: A PR needs at least one approved review if the author is already part of flutter-hackers or two member reviews if the author is not a member of flutter-hackers before re-applying the autosubmit label. Reviewers: If you left a comment approving, please use the "approve" review action instead.

@dkwingsmt dkwingsmt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you!

);
});

testWidgets('ConstraintsTransformBox does not crash at zero area', (WidgetTester tester) async {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
testWidgets('ConstraintsTransformBox does not crash at zero area', (WidgetTester tester) async {
testWidgets('does not crash at zero area', (WidgetTester tester) async {

@dkwingsmt dkwingsmt added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 11, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 11, 2026
@dkwingsmt dkwingsmt added the CICD Run CI/CD label Jun 11, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue Jun 11, 2026
Merged via the queue into flutter:master with commit 4a2498a Jun 11, 2026
94 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jun 11, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Jun 11, 2026
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
via-guy pushed a commit to via-guy/flutter that referenced this pull request Jun 26, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants