Skip to content

refactor: remove material import froma sliver_main_axis_group_test, sliver_semantics_test, semantics_role_checks_test, sliver_fill_remaining_test, tap_region_test#185567

Merged
auto-submit[bot] merged 4 commits into
flutter:masterfrom
rkishan516:simple-cross-imports-9
May 1, 2026

Conversation

@rkishan516

Copy link
Copy Markdown
Contributor

This PR removes Material imports from

  • sliver_main_axis_group_test
  • sliver_semantics_test
  • semantics_role_checks_test
  • sliver_fill_remaining_test
  • tap_region_test

part of: #177415

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) f: scrolling Viewports, list views, slivers, etc. labels Apr 25, 2026
@rkishan516 rkishan516 added the CICD Run CI/CD label Apr 25, 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 refactors several widget tests to eliminate dependencies on the Material library, replacing components like MaterialApp, Scaffold, and SliverAppBar with TestWidgetsApp and custom SliverPersistentHeader implementations. It also replaces Material-specific widgets such as ElevatedButton and Radio with basic widgets or test-specific wrappers like TestButton and RawRadio. Feedback identifies several opportunities to further optimize the code by using ColoredBox instead of Container when only a background color is required.

Comment thread packages/flutter/test/widgets/sliver_fill_remaining_test.dart Outdated
Comment thread packages/flutter/test/widgets/sliver_fill_remaining_test.dart Outdated
Comment thread packages/flutter/test/widgets/sliver_fill_remaining_test.dart Outdated
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/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.

@rkishan516 Nice to see that you're trying to tackle this test.

I do have some feedback on this specific one, though.

IIRC the last time I looked at it, there were some issues:

  1. There is also sliversemantics_test.dart
    I don't recall if that test had duplicated stuff between itself and sliver_semantics_test.dart
  2. Both of these test files do get large (especially if you consider them both)
    We should split these tests off into sliver_semantics_1_test.dart etc. Smaller test files are easier to post to the test runner, too
  3. I think there was some usage of group(), together with a _testFoo() helper method, both seemed redundant (why not put the body of that method in void main() ?)

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.

Hey, sure. I think sliversemantics_test.dart and sliver_semantics_test.dart have different scope. Will try to migrate that also.

I think there was some usage of group(), together with a _testFoo() helper method, both seemed redundant (why not put the body of that method in void main() ?)

Yes, this pattern still exist, we can drop group() + _tests() indirection.

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.

nvm, that was already migrated.

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 agree about the 3 points above. Possibly could be done in another PR though.

@Renzo-Olivares Do you know the history of sliver_semantics_test.dart and sliversemantics_test.dart? #167300

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.

sliversemantics_test.dart tests the recent SliverSemantics widget which is a Sliver variant of the Semantics widget. It is essentially a duplicate of semantics_test.dart but for SliverSemantics.

Not as familiar with sliver_semantics_test.dart, but generally it just holds different integration tests for semantics and sliver components.

sliversemantics_test.dart and sliver_semantics_test.dart are definitely different in scope and should not be considered the same.

I'm not against splitting these files up, but it should be clear what the file is testing.

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.

I can do a follow up MR with proper naming and split.

justinmc
justinmc previously approved these changes Apr 27, 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!

Comment thread packages/flutter/test/widgets/sliver_main_axis_group_test.dart Outdated
Comment on lines -733 to +735
'SliverAppBar with floating: true, pinned: true, snap: true is painted within bounds of SliverMainAxisGroup',
'SliverPersistentHeader with floating: true, pinned: true, snap: true is painted within bounds of SliverMainAxisGroup',

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.

It looks like there's no reason to duplicate these SliverAppBar tests in Material, right? I guess it wouldn't test anything that these are not already testing at the widgets level.

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.

Yup, we don't need in Material.

Comment thread packages/flutter/test/widgets/sliver_semantics_test.dart
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/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.

I agree about the 3 points above. Possibly could be done in another PR though.

@Renzo-Olivares Do you know the history of sliver_semantics_test.dart and sliversemantics_test.dart? #167300

@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 28, 2026
@rkishan516 rkishan516 force-pushed the simple-cross-imports-9 branch from 9006266 to 89cc75a Compare April 28, 2026 01:05
@rkishan516 rkishan516 added the CICD Run CI/CD label Apr 28, 2026
victorsanni
victorsanni previously approved these changes Apr 28, 2026

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

LGTM with some nits.

Comment on lines +1157 to +1158
// Push the second page so tapRegion2 is on top of tapRegion1.
Navigator.of(tester.element(find.byKey(tapRegion1Key))).pushNamed('/second');

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.

Why do we need to do this?

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.

We want second page to be on top when doing tap outside assertion.

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.

SGTM. Previously this was done in onGenerateInitialRoutes.

},
child: Container(width: 250.0, height: 250.0, color: Colors.blue),
),
).createRoute(context),

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.

Why is this here?

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.

Since we are using TestPage, to createPageRouteBuilder we are calling this.

Comment thread packages/flutter/test/widgets/sliver_fill_remaining_test.dart Outdated
Comment thread packages/flutter/test/widgets/sliver_fill_remaining_test.dart Outdated
Comment thread packages/flutter/test/widgets/sliver_fill_remaining_test.dart Outdated
Comment thread packages/flutter/test/widgets/sliver_fill_remaining_test.dart Outdated
Comment thread packages/flutter/test/widgets/sliver_fill_remaining_test.dart Outdated
Comment thread packages/flutter/test/widgets/sliver_fill_remaining_test.dart Outdated
@rkishan516 rkishan516 force-pushed the simple-cross-imports-9 branch from 89cc75a to 3a0b1e2 Compare April 28, 2026 02:17
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 28, 2026
@rkishan516 rkishan516 added the CICD Run CI/CD label Apr 28, 2026
@rkishan516 rkishan516 force-pushed the simple-cross-imports-9 branch from 3a0b1e2 to 1238b57 Compare April 29, 2026 01:26
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 29, 2026
@rkishan516 rkishan516 added the CICD Run CI/CD label Apr 29, 2026
@rkishan516 rkishan516 force-pushed the simple-cross-imports-9 branch from 1238b57 to 56ae0e5 Compare April 30, 2026 02:15
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 30, 2026
@rkishan516 rkishan516 added the CICD Run CI/CD label May 1, 2026
rkishan516 added 2 commits May 1, 2026 19:19
…liver_semantics_test, semantics_role_checks_test, sliver_fill_remaining_test, tap_region_test

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

Comment on lines +1157 to +1158
// Push the second page so tapRegion2 is on top of tapRegion1.
Navigator.of(tester.element(find.byKey(tapRegion1Key))).pushNamed('/second');

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.

SGTM. Previously this was done in onGenerateInitialRoutes.

@rkishan516 rkishan516 added the autosubmit Merge PR when tree becomes green via auto submit App label May 1, 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 c8cbdf7 May 1, 2026
170 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 1, 2026
shivanshu877 added a commit to shivanshu877/flutter that referenced this pull request May 4, 2026
Master (flutter#185567) already merged the move/refactor of TapRegion
navigation tests off Material. This merge adopts that version of
test/widgets/tap_region_test.dart and re-applies the small
robustness improvement on top:

* Replace the two duplicated `Future<void> tapOutside(...)` local
  closures with a single top-level `_tapOutside(tester, regionKey)`
  helper that locates the visible region's RenderBox dynamically
  (renderBox.localToGlobal(Offset.zero) + Offset(200, 200)) instead
  of using a hardcoded global coordinate.

This addresses @justinmc's review feedback that the original
material/-based tapOutside was more robust than the closure with
hardcoded coords.
gabrimatic pushed a commit to gabrimatic/flutter that referenced this pull request May 15, 2026
This PR is follow up to
flutter#185567 (comment)
conversation where we want to properly name and split test files.

part of: flutter#177415

# Current Status

- Renamed `sliversemantics_test.dart` to
`sliver_semantics_widget_test.dart`

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

---------

Co-authored-by: Renzo Olivares <rmolivares@renzo-olivares.dev>
@rkishan516 rkishan516 deleted the simple-cross-imports-9 branch May 16, 2026 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) CICD Run CI/CD f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.

Projects

Development

Successfully merging this pull request may close these issues.

5 participants