Skip to content

Add more 0x0 size tests, part 6#184049

Merged
auto-submit[bot] merged 14 commits into
flutter:masterfrom
ahmedsameha1:handle#6537-sixth-grouped-tests
Apr 29, 2026
Merged

Add more 0x0 size tests, part 6#184049
auto-submit[bot] merged 14 commits into
flutter:masterfrom
ahmedsameha1:handle#6537-sixth-grouped-tests

Conversation

@ahmedsameha1

Copy link
Copy Markdown
Contributor

This is my attempt to handle #6537 for the following widgets:
RotationTransition
SizeTransition
FadeTransition
DecoratedBoxTransition
AlignTransition
DefaultTextStyleTransition
ListenableBuilder
AnimatedBuilder
Title
Text

@github-actions github-actions Bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos labels Mar 24, 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 tests for several widgets to ensure they do not crash when rendered in a zero-area space. The changes involve adding a new testWidgets case to each respective widget's test file. While the tests are valuable, there is significant code duplication across the new tests. My feedback focuses on refactoring this duplicated logic into shared helper functions to improve code maintainability and readability, in line with the repository's style guide.

Comment on lines +62 to +74
testWidgets('AlignTransition does not crash at zero area', (
WidgetTester tester,
) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: SizedBox.shrink(child: example.AlignTransitionExample()),
),
),
);
expect(tester.getSize(find.byType(AlignTransition)), 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 for checking zero-area crashes is duplicated across many transition widget test files in this PR. This is a good opportunity to reduce code duplication and improve maintainability, following the repository style guide's principle to "Optimize for readability".

You could define a local helper function or a shared one for all the transition example tests. For example:

Future<void> _testDoesNotCrashAtZeroArea(
  WidgetTester tester, {
  required Widget child,
  required Finder finder,
}) async {
  await tester.pumpWidget(
    Directionality(
      textDirection: TextDirection.ltr,
      child: Center(
        child: SizedBox.shrink(child: child),
      ),
    ),
  );
  expect(tester.getSize(finder), Size.zero);
}

Then this test can be simplified to:

testWidgets('AlignTransition does not crash at zero area', (WidgetTester tester) async {
  await _testDoesNotCrashAtZeroArea(
    tester,
    child: example.AlignTransitionExample(),
    finder: find.byType(AlignTransition),
  );
});

This pattern can be applied to all the new 'zero area' tests for transition widgets in this PR.

References
  1. The repository style guide emphasizes optimizing for readability. Refactoring duplicated test logic into a helper function improves readability and maintainability by abstracting away the common setup for these 'zero area' tests. (link)

Comment thread packages/flutter/test/widgets/text_test.dart
@loic-sharma loic-sharma changed the title Handle#6537 sixth grouped tests Add more 0x0 size tests Mar 26, 2026
@victorsanni victorsanni added the CICD Run CI/CD label Mar 26, 2026
@ahmedsameha1

Copy link
Copy Markdown
Contributor Author

@loic-sharma I see that you changed the name of the PR. I think that the new name is not distinguishable from the future names if we keep this new pattern of naming the PRs of this issue.

@loic-sharma

loic-sharma commented Mar 27, 2026

Copy link
Copy Markdown
Member

@ahmedsameha1 Ah sorry. I renamed it as this showed up in my review queue but what it changed wasn't immediately obvious to me from the name alone. Please keep in mind that the Flutter team is reviewing many pull requests in parallel. Please feel free to rename the PR if you'd like!

What do you think of this name instead: Add more 0x0 size tests, part 6?

@ahmedsameha1 ahmedsameha1 changed the title Add more 0x0 size tests Add more 0x0 size tests, part 6 Mar 27, 2026

@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.

The test cases look good. But why are we adding them to the test for example files, except for /test/widgets? Is it some new convention we're adopting I don't know about?

@ahmedsameha1

Copy link
Copy Markdown
Contributor Author

The test cases look good. But why are we adding them to the test for example files, except for /test/widgets? Is it some new convention we're adopting I don't know about?

Only FadeTransition and DefaultTextStyleTransition have test files in packages/flutter/test/widgets. I think that I did not search for them and put the tests in the examples files. Do you want me to move the tests as is to the corresponding files? Note that this will add an import to the test files. The other option is rewriting them. Tell me what you prefer.
I think that the others, which are in packages/flutter/lib/src/widgets/transitions.dart do not have packages/flutter/test/widgets/___test.dart files, so I put the tests in the examples files. Do you want me to create test files in packages/flutter/test/widgets/ for those transitions that contain the zero area test only?

@victorsanni

Copy link
Copy Markdown
Contributor

Only FadeTransition and DefaultTextStyleTransition have test files in packages/flutter/test/widgets.

Add the 0x0 test for widget A to the test file in flutter/test/widgets that tests widget A. This file may not have A in its name, that is fine. But these tests should definitely not live in examples/.

If widget A is not tested, add the test to a file containing tests for similar/parent widgets.

@ahmedsameha1

Copy link
Copy Markdown
Contributor Author

Only FadeTransition and DefaultTextStyleTransition have test files in packages/flutter/test/widgets.

Add the 0x0 test for widget A to the test file in flutter/test/widgets that tests widget A. This file may not have A in its name, that is fine. But these tests should definitely not live in examples/.

If widget A is not tested, add the test to a file containing tests for similar/parent widgets.

I will work on this.

@victorsanni victorsanni 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.

@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 15, 2026
@justinmc justinmc requested a review from victorsanni April 21, 2026 22:12
victorsanni
victorsanni previously approved these changes Apr 23, 2026
@victorsanni victorsanni added the CICD Run CI/CD label Apr 23, 2026
@ahmedsameha1 ahmedsameha1 force-pushed the handle#6537-sixth-grouped-tests branch from 9d405d7 to f31b47c Compare April 23, 2026 12:54
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Apr 23, 2026
@justinmc justinmc requested a review from victorsanni April 23, 2026 19:58
@victorsanni victorsanni added the CICD Run CI/CD label Apr 24, 2026

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: text input Entering text in a text field or keyboard related problems 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