Skip to content

Remove trivial test utility cross-imports from material and cupertino…#184295

Merged
auto-submit[bot] merged 3 commits into
flutter:masterfrom
xfce0:fix-trivial-test-utils-cross-imports
May 1, 2026
Merged

Remove trivial test utility cross-imports from material and cupertino…#184295
auto-submit[bot] merged 3 commits into
flutter:masterfrom
xfce0:fix-trivial-test-utils-cross-imports

Conversation

@xfce0

@xfce0 xfce0 commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

Removes cross-directory test imports of four trivial test utilities from material and cupertino tests.

Part of #182636.

All four utilities are small (20-40 lines) with trivial implementations, so duplication is the appropriate strategy per the issue guidelines:

  • test_border.dart (36 lines) → test/material/ (1 file updated)
  • sliver_test_utils.dart (20 lines) → test/material/ (1 file updated)
  • process_text_utils.dart (40 lines) → test/material/ (2 files updated)
  • list_tile_tester.dart (30 lines) → test/cupertino/ (1 file updated)

Pre-launch Checklist

@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: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. f: cupertino flutter/packages/flutter/cupertino repository labels Mar 28, 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 introduces several new test utility files and relocates existing ones within the packages/flutter/test directory to improve test organization. Specifically, it adds list_tile_tester.dart, process_text_utils.dart, sliver_test_utils.dart, and test_border.dart, while updating relevant import statements in existing test files. Review feedback highlights multiple instances where new public members—including classes, constants, and fields—lack the documentation required by the repository's style guide.

Comment thread packages/flutter/test/cupertino/list_tile_tester.dart
Comment thread packages/flutter/test/material/process_text_utils.dart
Comment thread packages/flutter/test/material/process_text_utils.dart
Comment thread packages/flutter/test/material/process_text_utils.dart
Comment thread packages/flutter/test/material/process_text_utils.dart
Comment thread packages/flutter/test/material/test_border.dart
Comment thread packages/flutter/test/material/test_border.dart
Comment thread packages/flutter/test/material/test_border.dart

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

Should these duplicated classes have duplicated tests as well?

Comment on lines +7 to +8
/// A minimal ListTile widget for testing purposes to avoid relying on
/// widgets from material.dart.

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
/// A minimal ListTile widget for testing purposes to avoid relying on
/// widgets from material.dart.
/// A minimal ListTile widget for testing purposes.

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.

Isn't ListTile a Material widget? Should the equivalent in Cupertino be based on CupertinoListTile instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, simplified the doc comment. Thank you!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good question! TestListTile is not actually a Material ListTile — it is a minimal widget (only depends on package:flutter/widgets.dart) that was created specifically as a lightweight tap target for semantics testing (see #177415). The test here checks MergeSemantics + CupertinoSwitch behavior, not list tile behavior itself.

Replacing it with CupertinoListTile would introduce a heavier StatefulWidget with animations and background color changes, which could make this unrelated semantics test more fragile. So I think keeping the minimal TestListTile is the safer choice here.

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.

I think you should replace the words "ListTile" with "CupertinoListTile" here in the docs, even though it's not based on either. That's what this class should be approximating here in Cupertino.

Comment thread packages/flutter/test/cupertino/list_tile_tester.dart
Comment thread packages/flutter/test/material/test_border.dart
Comment thread packages/flutter/test/material/test_border.dart
Comment thread packages/flutter/test/material/test_border.dart
@victorsanni

Copy link
Copy Markdown
Contributor

Hi @xfce0, this PR is currently targeting main, can you repurpose it to target master? Thanks.

@xfce0 xfce0 changed the base branch from main to master April 2, 2026 08:48
@xfce0 xfce0 force-pushed the fix-trivial-test-utils-cross-imports branch from d7b7f4b to 55060f9 Compare April 2, 2026 08:56
@xfce0

xfce0 commented Apr 2, 2026

Copy link
Copy Markdown
Contributor Author

Done, retargeted to master. Thank you!

@xfce0

xfce0 commented Apr 3, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest master.

@xfce0 xfce0 force-pushed the fix-trivial-test-utils-cross-imports branch from 55060f9 to 0973b99 Compare April 3, 2026 10:13
@github-actions github-actions Bot removed the f: scrolling Viewports, list views, slivers, etc. label Apr 3, 2026
justinmc
justinmc previously approved these changes Apr 3, 2026

@justinmc justinmc 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 with a nit about saying "CupertinoListTile" instead of "ListTile".

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

victorsanni
victorsanni previously approved these changes Apr 4, 2026
@xfce0 xfce0 force-pushed the fix-trivial-test-utils-cross-imports branch from 07afa50 to d0e7dcc Compare April 4, 2026 05:43
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 4, 2026
@victorsanni victorsanni added the CICD Run CI/CD label Apr 7, 2026
victorsanni
victorsanni previously approved these changes Apr 7, 2026
@victorsanni victorsanni requested a review from justinmc April 7, 2026 17:13
justinmc
justinmc previously approved these changes Apr 7, 2026

@justinmc justinmc 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 👍 . Thanks for adding all of the docs even though they didn't exist before.


import 'package:flutter/widgets.dart';

/// A minimal CupertinoListTile widget for testing purposes.

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.

Nit: Link [CupertinoListTile].

@justinmc

justinmc commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

@xfce0 Heads up there is an analyzer failure.

@victorsanni victorsanni added the CICD Run CI/CD label Apr 10, 2026
@victorsanni

Copy link
Copy Markdown
Contributor

Thanks for the work here. This PR is blocked by the Material/Cupertino code freeze: #184093. I will convert it to a draft to take it off our review queue, and when the code freeze is over, find a way to port it to the new packages. Thanks once again!

@victorsanni victorsanni marked this pull request as draft April 20, 2026 18:01
@victorsanni

Copy link
Copy Markdown
Contributor

Actually @justinmc just let me know we will be able to land this with an exception label. So we can go ahead here.

@victorsanni victorsanni marked this pull request as ready for review April 20, 2026 18:38

@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 TestListTile, MockProcessTextHandler, and TestBorder testing utilities and updates related imports across several test files. Feedback recommends using Dart 3 pattern matching in MockProcessTextHandler for safer argument extraction and adding logging to the scale method in TestBorder to maintain consistency with other methods.

Comment on lines +37 to +48
final args = call.arguments as List<dynamic>;
final actionId = args[0] as String;
final textToProcess = args[1] as String;
lastCalledActionId = actionId;
lastTextToProcess = textToProcess;

if (actionId == fakeAction1Id) {
// Simulates an action that returns a transformed text.
return '$textToProcess!!!';
}
// Simulates an action that failed or does not transform text.
return null;

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 current implementation uses unsafe casts which could throw a TypeError or RangeError if the MethodCall arguments do not match the expected structure. Using Dart 3 pattern matching provides a more robust and readable way to extract these arguments, adhering to the principle of optimizing for readability.

Suggested change
final args = call.arguments as List<dynamic>;
final actionId = args[0] as String;
final textToProcess = args[1] as String;
lastCalledActionId = actionId;
lastTextToProcess = textToProcess;
if (actionId == fakeAction1Id) {
// Simulates an action that returns a transformed text.
return '$textToProcess!!!';
}
// Simulates an action that failed or does not transform text.
return null;
if (call.arguments case [final String actionId, final String textToProcess]) {
lastCalledActionId = actionId;
lastTextToProcess = textToProcess;
if (actionId == fakeAction1Id) {
// Simulates an action that returns a transformed text.
return '$textToProcess!!!';
}
}
// Simulates an action that failed or does not transform text.
return null;
References
  1. Optimize for readability: Code is read more often than it is written. (link)

EdgeInsetsGeometry get dimensions => const EdgeInsetsDirectional.only(start: 1.0);

@override
ShapeBorder scale(double t) => TestBorder(onLog);

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

To be consistent with other methods in TestBorder (like getInnerPath, getOuterPath, and paint), the scale method should log its call. This ensures that tests can verify if the border was scaled as expected, following the principle of doing things right when they are written.

  ShapeBorder scale(double t) {
    onLog('scale $t');
    return TestBorder(onLog);
  }
References
  1. Write what you need and no more, but when you write it, do it right. (link)

@justinmc justinmc added the override code freeze Override an active code freeze. label Apr 23, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 23, 2026

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

Re LGTM 👍

@justinmc justinmc added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 29, 2026
@justinmc justinmc moved this from Todo to Done in Test cross-imports Review Queue Apr 29, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 29, 2026
@auto-submit

auto-submit Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/184295, because - The status or check suite Check Code Freeze has failed. Please fix the issues identified (or deflake) before re-applying this label.

@justinmc justinmc force-pushed the fix-trivial-test-utils-cross-imports branch from ed7a6e2 to 0cad5d4 Compare April 30, 2026 20:39
@justinmc justinmc added the CICD Run CI/CD label Apr 30, 2026
@AbdeMohlbi AbdeMohlbi added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 30, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue May 1, 2026
Merged via the queue into flutter:master with commit a51da69 May 1, 2026
90 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 1, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request May 1, 2026
Roll Flutter from 81bc3d69535f to 707dbc0420a3 (85 revisions)

flutter/flutter@81bc3d6...707dbc0

2026-05-01 [email protected] Removing TODOs from the WebParagraph code and addressing technical debts. (flutter/flutter#185168)
2026-05-01 [email protected] Ensure that vulkan_interface.h gets included before vk_mem_alloc.h (flutter/flutter#185777)
2026-05-01 [email protected] [flutter_tools] Bump dwds dependency to v27.1.1 (flutter/flutter#185357)
2026-05-01 [email protected] Roll Dart SDK from 6d4a319cbdac to 9aa7097f2e3e (3 revisions) (flutter/flutter#185888)
2026-05-01 [email protected] Roll Skia from fa1dcb289709 to 7ac6d42f2fd0 (1 revision) (flutter/flutter#185887)
2026-05-01 [email protected] Roll Skia from 54cc00adde38 to fa1dcb289709 (3 revisions) (flutter/flutter#185880)
2026-05-01 [email protected] [iOS] Migrate to FlutterFMLTaskRunner(s) (flutter/flutter#185815)
2026-05-01 [email protected] Remove material imports from navigator_on_did_remove_page_test and scrollable_in_overlay_test (flutter/flutter#182546)
2026-05-01 [email protected] Roll Skia from 2e279266f06a to 54cc00adde38 (3 revisions) (flutter/flutter#185872)
2026-05-01 [email protected] dev: Remove unused parameters (flutter/flutter#185345)
2026-05-01 [email protected] Roll Fuchsia Linux SDK from HN5VYzftnf_B8T-n9... to VnzuUefDQR0UhQ1L1... (flutter/flutter#185870)
2026-05-01 [email protected] Use g_free when using glib memory allocation (flutter/flutter#185519)
2026-05-01 [email protected] Roll Dart SDK from d30df3428f2e to 6d4a319cbdac (2 revisions) (flutter/flutter#185862)
2026-05-01 [email protected] Remove trivial test utility cross-imports from material and cupertino… (flutter/flutter#184295)
2026-05-01 [email protected] Inline test callback painter in tab scaffold test (flutter/flutter#184851)
2026-05-01 [email protected] [a11y] Add support for high contrast themes in the a11y assessments app  (flutter/flutter#185801)
2026-05-01 [email protected] [a11y assessment app] Use default color for banner (flutter/flutter#185804)
2026-04-30 [email protected] Added name to AUTHORS (flutter/flutter#185586)
2026-04-30 [email protected] Remove semantics_tester import from raw_material_button_test.dart (flutter/flutter#184806)
2026-04-30 [email protected] Remove semantics_tester import from user_accounts_drawer_header_test.dart (flutter/flutter#184809)
2026-04-30 [email protected] Roll Skia from 7b88c5c281e5 to 2e279266f06a (5 revisions) (flutter/flutter#185854)
2026-04-30 [email protected] Handle symmetric rectangular and elliptical round super ellipses in the uber SDF renderer  (flutter/flutter#185695)
2026-04-30 [email protected] Match on process name before killing for SwiftPM (flutter/flutter#185774)
2026-04-30 [email protected] Sync CHANGELOG.md from stable (flutter/flutter#185838)
2026-04-30 [email protected] Roll Dart SDK from 25910e31a6d2 to d30df3428f2e (5 revisions) (flutter/flutter#185839)
2026-04-30 [email protected] Check cross imports test subfolders (flutter/flutter#185493)
2026-04-30 [email protected] test: inline TestCallbackPainter in cupertino/picker_test.dart (flutter/flutter#185398)
2026-04-30 [email protected] Update customer testing version (flutter/flutter#185830)
2026-04-30 [email protected] Adapt the Metal shader library output list for debug versus release mode (flutter/flutter#185798)
2026-04-30 [email protected] [Impeller] Port a recent Vulkan swapchain fence waiting fix to the AHB version of the swapchain (flutter/flutter#185763)
2026-04-30 [email protected] Roll Skia from 26a59aa71eff to 7b88c5c281e5 (1 revision) (flutter/flutter#185821)
2026-04-30 [email protected] Roll Skia from 6b4167b4e204 to 26a59aa71eff (4 revisions) (flutter/flutter#185808)
2026-04-30 [email protected] [a11y] Mark SemanticsNode dirty when customSemanticsActions change  (flutter/flutter#185707)
2026-04-30 [email protected] Roll Skia from 1bd2f1cc2746 to 6b4167b4e204 (8 revisions) (flutter/flutter#185799)
2026-04-30 [email protected] [iOS] Extract FlutterVSyncClient from vsync_waiter_ios (flutter/flutter#185737)
2026-04-30 [email protected] Roll Fuchsia Linux SDK from nnv8-SSam6yE8dw4z... to HN5VYzftnf_B8T-n9... (flutter/flutter#185782)
2026-04-29 [email protected] [iOS] Soften TaskRunner.postTask(delay:task:) delay check (flutter/flutter#185729)
2026-04-29 [email protected] Add reportErrors to ImageStreamListener (flutter/flutter#180327)
2026-04-29 [email protected] Roll Skia from f5c781c083c7 to 1bd2f1cc2746 (5 revisions) (flutter/flutter#185761)
2026-04-29 [email protected] Update merge semantics logic to merge sibling nodes (flutter/flutter#183745)
2026-04-29 [email protected] Roll Packages from ba80f8f to cde5b36 (12 revisions) (flutter/flutter#185748)
2026-04-29 [email protected] examples: Remove unused parameters (flutter/flutter#185346)
2026-04-29 [email protected] Update TickerMode.getValuesNotifier to handle initialization during State.dispose (flutter/flutter#185248)
2026-04-29 [email protected] Update triage links (flutter/flutter#185714)
2026-04-29 [email protected] Add support for high contrast and color inversion on Android (flutter/flutter#182263)
2026-04-29 [email protected] Roll Skia from 05251260fda6 to f5c781c083c7 (2 revisions) (flutter/flutter#185743)
...
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: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. override code freeze Override an active code freeze.

Projects

Development

Successfully merging this pull request may close these issues.

5 participants