Skip to content

Remove list_tile_tester and rendering_tester cross-imports from cupertino tests#184588

Open
xfce0 wants to merge 7 commits into
flutter:masterfrom
xfce0:fix-cupertino-misc-cross-imports
Open

Remove list_tile_tester and rendering_tester cross-imports from cupertino tests#184588
xfce0 wants to merge 7 commits into
flutter:masterfrom
xfce0:fix-cupertino-misc-cross-imports

Conversation

@xfce0
Copy link
Copy Markdown
Contributor

@xfce0 xfce0 commented Apr 3, 2026

Remove cross-directory test imports of list_tile_tester.dart and rendering_tester.dart from cupertino tests by duplicating the relevant trivial test utilities locally:

  • TestListTile (~30 lines) → duplicated into test/cupertino/list_tile_tester.dart, used by cupertino/switch_test.dart
  • TestCallbackPainter (~10 lines) → duplicated into test/cupertino/rendering_test_utils.dart, used by cupertino/picker_test.dart and cupertino/tab_scaffold_test.dart

Both utilities are trivial and match the "duplicate the util" criteria from the issue.

Part of #182636.

Pre-launch Checklist

@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. f: cupertino flutter/packages/flutter/cupertino repository labels Apr 3, 2026
Copy link
Copy Markdown
Contributor

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

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 introduces two new testing utility classes, TestListTile and TestCallbackPainter, and updates import paths in existing test files. The review feedback highlights that both new classes lack required documentation for their public members, which is a violation of the project's style guide.

Comment on lines +11 to +14
const TestListTile({super.key, this.title, this.onTap});

final Widget? title;
final VoidCallback? onTap;
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

According to the Flutter style guide, all public members should have documentation. Please add documentation for the constructor and the public fields of TestListTile.

  /// Creates a [TestListTile].
  const TestListTile({super.key, this.title, this.onTap});

  /// The widget to display in the body of the list tile.
  final Widget? title;

  /// The callback to call when the list tile is tapped.
  final VoidCallback? onTap;
References
  1. All public members should have documentation. (link)

Comment on lines +9 to +11
const TestCallbackPainter({required this.onPaint});

final VoidCallback onPaint;
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

According to the Flutter style guide, all public members should have documentation. Please add documentation for the constructor and the public field of TestCallbackPainter.

Suggested change
const TestCallbackPainter({required this.onPaint});
final VoidCallback onPaint;
/// Creates a [TestCallbackPainter].
const TestCallbackPainter({required this.onPaint});
/// The callback to call when the painter paints.
final VoidCallback onPaint;
References
  1. All public members should have documentation. (link)

@xfce0
Copy link
Copy Markdown
Contributor Author

xfce0 commented Apr 3, 2026

Note: these two test files also cross-import semantics_tester.dart, which is used across ~40 files (29 material + 11 cupertino) and is ~1300 lines. Given @loic-sharma's concern about keeping duplicated utils in sync (#184519), I left the semantics_tester imports as-is for now. Would it make more sense to move SemanticsTester into flutter_test rather than duplicating it? Happy to help with either approach.

@loic-sharma
Copy link
Copy Markdown
Member

semantics_tester.dart ... is ~1300 lines. Given @loic-sharma's concern about keeping duplicated utils in sync (#184519), I left the semantics_tester imports as-is for now. Would it make more sense to move SemanticsTester into flutter_test rather than duplicating it? Happy to help with either approach.

@chunhtai What are your thoughts here? 1300 lines does indeed seem like too much logic to duplicate across widgets/material/cupertino libraries. It seems preferable to move this logic to flutter_tester - is the API "good enough" to be public though?

@chunhtai
Copy link
Copy Markdown
Contributor

It seems preferable to move this logic to flutter_tester - is the API "good enough" to be public though?

No, that test is not suitable for public, it is almost the same as semantics scuba diff, but worse. If they really want to assert the entire semantics tree, I would rather use semantics scuba.

We also discourage use of TestSemantics #184367

so in theory no new test should be using it, and that code won't change and should slowly be deprecated, I think it is ok to duplicate the tester util to 3 places.

@justinmc justinmc moved this from Todo to In Progress in Test cross-imports Review Queue Apr 29, 2026
Copy link
Copy Markdown
Contributor

@victorsanni victorsanni left a comment

Choose a reason for hiding this comment

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

Hi, can you fix the merge conflict in this PR? Thanks

@victorsanni victorsanni added the CICD Run CI/CD label Apr 30, 2026
@flutter-dashboard
Copy link
Copy Markdown

This pull request is not mergeable in its current state, likely because of a merge conflict. Pre-submit CI jobs were not triggered. Pushing a new commit to this branch that resolves the issue will result in pre-submit jobs being scheduled.

@xfce0 xfce0 force-pushed the fix-cupertino-misc-cross-imports branch from 1137133 to 2eb262b Compare May 2, 2026 22:29
@github-actions github-actions Bot removed the CICD Run CI/CD label May 2, 2026
@xfce0
Copy link
Copy Markdown
Contributor Author

xfce0 commented May 2, 2026

Hi! Sorry for the delay — I had to rebase onto the latest master and resolve a merge conflict in tab_scaffold_test.dart. The conflict was caused by upstream changes to imports in that file.

I also added the missing dartdoc to the public members of TestListTile and TestCallbackPainter as requested. All analyzer checks and local tests pass. Please let me know if anything else needs adjustment.

@dkwingsmt dkwingsmt requested a review from victorsanni May 6, 2026 18:20
Copy link
Copy Markdown
Contributor

@victorsanni victorsanni left a comment

Choose a reason for hiding this comment

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

Thanks for this PR. Can you grep all instances of TestCallbackPainter in test/cupertino and replace them with the rendering_test_utils.dart import?

import 'rendering_test_utils.dart';

/// A [CustomPainter] that calls a callback when it paints.
class TestCallbackPainter extends CustomPainter {
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.

Shouldn't this class be deleted if we are now importing from rendering_test_utils.dart?


/// A [CustomPainter] that invokes a callback when it paints.
class TestCallbackPainter extends CustomPainter {
const TestCallbackPainter({required this.onPaint});
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.

Should this public constructor have an API doc comment?

@xfce0 xfce0 force-pushed the fix-cupertino-misc-cross-imports branch from 4604e34 to df15b4f Compare May 10, 2026 16:57
@dkwingsmt dkwingsmt requested a review from victorsanni May 20, 2026 18:13
@dkwingsmt dkwingsmt added the CICD Run CI/CD label May 20, 2026
Copy link
Copy Markdown
Contributor

@victorsanni victorsanni left a comment

Choose a reason for hiding this comment

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

Can you fix linux analyze by running dart format packages/flutter/test/cupertino/picker_test.dart?

xfce0 added 6 commits May 23, 2026 13:54
…tino tests

Duplicate TestListTile into test/cupertino/list_tile_tester.dart and
TestCallbackPainter into test/cupertino/rendering_test_utils.dart to
remove cross-imports from cupertino/switch_test.dart and
cupertino/picker_test.dart.

Part of flutter#182636.
Use local rendering_test_utils.dart instead of importing from
../rendering/rendering_tester.dart.
@xfce0 xfce0 force-pushed the fix-cupertino-misc-cross-imports branch from df15b4f to f4fa57d Compare May 23, 2026 11:26
@github-actions github-actions Bot removed the CICD Run CI/CD label May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels.

Projects

Development

Successfully merging this pull request may close these issues.

6 participants