Skip to content

Add more 0x0 size tests part 13 - #191466

Merged
auto-submit[bot] merged 14 commits into
flutter:masterfrom
ahmedsameha1:add_more_0x0_size_tests_part_13
Sep 24, 2026
Merged

auto-submit[bot] merged 14 commits into
flutter:masterfrom
ahmedsameha1:add_more_0x0_size_tests_part_13

Conversation

@ahmedsameha1

Copy link
Copy Markdown
Contributor

This is my attempt to handle #6537 for the following widgets:
Viewport
ColoredBox
StatefulBuilder
Builder
RawImage
RichText
Flow
Wrap

@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. f: scrolling Viewports, list views, slivers, etc. labels Aug 21, 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 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.

Comment thread packages/flutter/test/widgets/basic_test.dart
Comment on lines +1886 to +1896
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);
});

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

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
  1. Suggest simplification and refactoring: Assess whether the code can be made simpler or refactored to enhance readability and maintainability. (link)

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

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

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
  1. Suggest simplification and refactoring: Assess whether the code can be made simpler or refactored to enhance readability and maintainability. (link)

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.

Not necessary, but feel free to adopt it if you feel like.

Comment thread packages/flutter/test/rendering/viewport_test.dart
Comment on lines +210 to +222
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);
});

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

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
  1. Suggest simplification and refactoring: Assess whether the code can be made simpler or refactored to enhance readability and maintainability. (link)

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.

Not necessary, but feel free to adopt it if you feel like.

dkwingsmt
dkwingsmt previously approved these changes Sep 3, 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. Thank you!

victorsanni
victorsanni previously approved these changes Sep 3, 2026
@victorsanni victorsanni added CICD Run CI/CD autosubmit Merge PR when tree becomes green via auto submit App labels Sep 3, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 3, 2026
@auto-submit

auto-submit Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

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.

@auto-submit

auto-submit Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

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.

@ahmedsameha1
ahmedsameha1 dismissed stale reviews from victorsanni and dkwingsmt via d29260a September 4, 2026 09:42
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Sep 4, 2026
@dkwingsmt dkwingsmt added the CICD Run CI/CD label Sep 8, 2026
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Sep 8, 2026
@dkwingsmt dkwingsmt added the CICD Run CI/CD label Sep 8, 2026
@dkwingsmt

Copy link
Copy Markdown
Contributor

Can you fix the analyzer issues?


Analysis in progress (150s)...
Analyzing flutter...                                            

   info • Use 'const' with the constructor to improve performance. Try adding the 'const' keyword to the constructor invocation • packages/flutter/test/widgets/basic_test.dart:1921:7 • prefer_const_constructors
   info • Use 'const' with the constructor to improve performance. Try adding the 'const' keyword to the constructor invocation • packages/flutter/test/widgets/basic_test.dart:1921:7 • prefer_const_constructors
   info • Use 'const' with the constructor to improve performance. Try adding the 'const' keyword to the constructor invocation • packages/flutter/test/widgets/basic_test.dart:1921:7 • prefer_const_constructors
   info • Use 'const' with the constructor to improve performance. Try adding the 'const' keyword to the constructor invocation • packages/flutter/test/widgets/basic_test.dart:1921:7 • prefer_const_constructors
   info • Use 'const' with the constructor to improve performance. Try adding the 'const' keyword to the constructor invocation • packages/flutter/test/widgets/basic_test.dart:1922:16 • prefer_const_constructors
   info • Use 'const' with the constructor to improve performance. Try adding the 'const' keyword to the constructor invocation • packages/flutter/test/widgets/basic_test.dart:1922:16 • prefer_const_constructors
   info • Use 'const' with the constructor to improve performance. Try adding the 'const' keyword to the constructor invocation • packages/flutter/test/widgets/basic_test.dart:1922:16 • prefer_const_constructors
   info • Use 'const' with the constructor to improve performance. Try adding the 'const' keyword to the constructor invocation • packages/flutter/test/widgets/basic_test.dart:1922:16 • prefer_const_constructors
   info • Use 'const' with the constructor to improve performance. Try adding the 'const' keyword to the constructor invocation • packages/flutter/test/widgets/basic_test.dart:1922:34 • prefer_const_constructors
   info • Use 'const' with the constructor to improve performance. Try adding the 'const' keyword to the constructor invocation • packages/flutter/test/widgets/basic_test.dart:1922:34 • prefer_const_constructors
   info • Use 'const' with the constructor to improve performance. Try adding the 'const' keyword to the constructor invocation • packages/flutter/test/widgets/basic_test.dart:1922:34 • prefer_const_constructors
   info • Use 'const' with the constructor to improve performance. Try adding the 'const' keyword to the constructor invocation • packages/flutter/test/widgets/basic_test.dart:1922:34 • prefer_const_constructors
   info • Use 'const' with the constructor to improve performance. Try adding the 'const' keyword to the constructor invocation • packages/flutter/test/widgets/basic_test.dart:1922:60 • prefer_const_constructors
   info • Use 'const' with the constructor to improve performance. Try adding the 'const' keyword to the constructor invocation • packages/flutter/test/widgets/basic_test.dart:1922:60 • prefer_const_constructors
   info • Use 'const' with the constructor to improve performance. Try adding the 'const' keyword to the constructor invocation • packages/flutter/test/widgets/basic_test.dart:1922:60 • prefer_const_constructors
   info • Use 'const' with the constructor to improve performance. Try adding the 'const' keyword to the constructor invocation • packages/flutter/test/widgets/basic_test.dart:1922:60 • prefer_const_constructors

16 issues found. (ran in 174.9s)
╔═╡ERROR #1╞════════════════════════════════════════════════════════════════════
║ Command: bin/flutter analyze --flutter-repo
║ Command exited with exit code 1 but expected zero exit code.
║ Working directory: /b/s/w/ir/x/w/flutter
╚═══════════════════════════════════════════════════════════════════════════════

@ahmedsameha1
ahmedsameha1 force-pushed the add_more_0x0_size_tests_part_13 branch from 11fda5c to e0036b5 Compare September 10, 2026 15:49
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Sep 11, 2026
@dkwingsmt dkwingsmt added the CICD Run CI/CD label Sep 11, 2026
@dkwingsmt

Copy link
Copy Markdown
Contributor

There's a leaking error:


05:23 +11894 ~31 -1: C:/b/s/w/ir/x/w/flutter/packages/flutter/test/rendering/viewport_test.dart: (tearDownAll) [E]
  Expected: leak free
    Actual: <Instance of 'Leaks'>
     Which: contains leaks:
            # The text is generated by leak_tracker.
            # For leak troubleshooting tips open:
            # https://github.com/flutter/flutter/blob/main/docs/contributing/testing/Leak-tracking.md
            notDisposed:
              total: 1
              objects:
                _FixedViewportOffset:
                  test: Viewport does not crash at zero area
                  identityHashCode: 500155369
            
            
  
  package:matcher                                              expect
  package:leak_tracker_testing/src/leak_testing.dart 69:24     LeakTesting.collectedLeaksReporter.<fn>
  package:leak_tracker_flutter_testing/src/testing.dart 74:37  maybeTearDownLeakTrackingForAll
  ===== asynchronous gap ===========================
  dart:async                                                   Zone.registerBinaryCallback
  package:flutter_test/src/test_compat.dart 302:3              _tearDownForTestFile

Can you take a look?

@ahmedsameha1
ahmedsameha1 dismissed stale reviews from dkwingsmt and victorsanni via c3338bb September 16, 2026 14:33
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Sep 16, 2026
@dkwingsmt dkwingsmt added the CICD Run CI/CD label Sep 16, 2026
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Sep 16, 2026
@victorsanni victorsanni added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 24, 2026
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 f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants