Skip to content

Move scroll_view_test.dart from widgets to material directory#181268

Closed
kazbeksultanov wants to merge 4 commits intoflutter:masterfrom
kazbeksultanov:fix-move-scroll-view-test-to-material
Closed

Move scroll_view_test.dart from widgets to material directory#181268
kazbeksultanov wants to merge 4 commits intoflutter:masterfrom
kazbeksultanov:fix-move-scroll-view-test-to-material

Conversation

@kazbeksultanov
Copy link
Contributor

ScrollView tests test Material-specific scroll behavior (MaterialApp, Scaffold, Material-specific scroll views). These Material-specific tests belong in the material test directory, not widgets.

This change:

  • Moves packages/flutter/test/widgets/scroll_view_test.dart to packages/flutter/test/material/
  • Copies states.dart helper to material directory (required by scroll_view_test.dart)
  • Removes scroll_view_test.dart from the knownWidgetsCrossImports list in check_tests_cross_imports.dart

This is part of issue #177414 to organize tests in the library they're testing.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

…tory

ScrollView tests test Material-specific scroll behavior (MaterialApp, Scaffold,
Material-specific scroll views). These Material-specific tests belong in the
material test directory, not widgets.

This change:
- Moves packages/flutter/test/widgets/scroll_view_test.dart to packages/flutter/test/material/
- Copies states.dart helper to material directory (required by scroll_view_test.dart)
- Removes scroll_view_test.dart from the knownWidgetsCrossImports list in check_tests_cross_imports.dart

This is part of issue flutter#177414 to organize tests in the library they're testing.
@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. labels Jan 21, 2026
Copy link
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 successfully moves scroll_view_test.dart from the widgets directory to the material directory, along with its dependency states.dart. The check_tests_cross_imports.dart file has been updated to reflect this change, removing the old path from the knownWidgetsCrossImports list. The changes align with the stated goal of organizing tests by the library they are testing.

// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

const List<String> kStates = <String>[
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The kStates constant is a public member and should have documentation explaining its purpose, as per the Flutter style guide. Please add a /// doc comment above its declaration.

For example:

/// A list of US states used for testing purposes.
const List<String> kStates = <String>[
  'Alabama',
  // ...
];
References
  1. All public members should have documentation. (link)
  2. Use /// for public-quality documentation, even on private members. (link)

Copy link
Contributor

Choose a reason for hiding this comment

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

Hopefully we don't end up needing this in Material at all.

Copy link
Contributor

Choose a reason for hiding this comment

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

We don't, see #181281 where I figured out that one test was in the wrong place.
I'm just waiting on the TestTextField & TestWidgetsApp to land.

I would prefer to close this PR then.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is another one that shouldn't be moved. We should try to test this CustomScrollView stuff in the Widgets library where possible. There are a lot of Material things that are here for convenience only. You'll probably find a use for TestWidgetsApp and TestTextField.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I will need TestWidgetsApp and TestTextField.
Seems like I need to wait then it will be merged to master

// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

const List<String> kStates = <String>[
Copy link
Contributor

Choose a reason for hiding this comment

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

Hopefully we don't end up needing this in Material at all.

@github-actions github-actions bot removed the f: material design flutter/packages/flutter/material repository. label Jan 23, 2026
@kazbeksultanov
Copy link
Contributor Author

I fixed all tests using only /widgets by removing the Material delegate. Everything is now green except one test:

ListView dismiss keyboard onDrag and keep dismissed on drawer opened test

This test depends on Scaffold / ScaffoldState, so it cannot live purely in /widgets.

I temporarily removed it, but we should align on the right long-term direction:

Option A — Keep it in Widgets

Refactor the test to avoid Scaffold / drawer.
Downside: It may become redundant with existing ListView keyboard dismissal tests.

Option B — Move it to Material

Restore the test under Material, since Scaffold is inherently a Material concern.
Upside: Preserves intent and respects Flutter’s layer boundaries.

I’m slightly leaning toward Option B, since this behavior is tied to Material UI semantics — but happy to follow the preferred direction.

What do you think @justinmc @navaronbracke?

@navaronbracke
Copy link
Contributor

navaronbracke commented Jan 23, 2026

@kazbeksultanov I already fixed that test in #181281 That test is in the wrong file, since it should be in the scaffold test. You can probably close this PR then, since you also duplicated the test text field etc.

@justinmc
Copy link
Contributor

Let's close this and go with #181281. I agree we should go with option B and wait for TestTextFieldto land. Sorry for the overlap @kazbeksultanov and @navaronbracke, I'm struggling to keep track of all of the work on these tests. I've updated the issues to include links to in-progress PRs in the big checklist of tests.

@justinmc justinmc closed this Jan 23, 2026
@kazbeksultanov
Copy link
Contributor Author

Got it. No problem 👍
So Test widgets are already in the master?

@navaronbracke
Copy link
Contributor

TestWidgetsApp's pull request is still in review it seems.

github-merge-queue bot pushed a commit that referenced this pull request Feb 19, 2026
This PR removes the material import from scroll_view_test.dart

Part of #177415
Closes #181268

*If you had to change anything in the [flutter/tests] repo, include a
link to the migration guide as per the [breaking change policy].*

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [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.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
ahmedsameha1 pushed a commit to ahmedsameha1/flutter that referenced this pull request Feb 27, 2026
This PR removes the material import from scroll_view_test.dart

Part of flutter#177415
Closes flutter#181268

*If you had to change anything in the [flutter/tests] repo, include a
link to the migration guide as per the [breaking change policy].*

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [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.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

4 participants