Skip to content

Conversation

@bleroux
Copy link
Contributor

@bleroux bleroux commented Oct 31, 2024

Description

This PR introduces some utility functions to simplify some DropdownMenu tests.
The main purpose is to centralize and document how tests should find menu items, because it is tricky as there are two occurrences of each widgets and using '.last' is mandatory:

  Finder findMenuItemButton(String label) {
    // For each menu items there are two MenuItemButton widgets.
    // The last one is the real button item in the menu.
    // The first one is not visible, it is part of _DropdownMenuBody
    // which is used to compute the dropdown width.
    return find.widgetWithText(MenuItemButton, label).last;
  }

Related Issue

This is extracted from #157496.

Tests

Refactors many existing tests.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Oct 31, 2024
@bleroux bleroux requested a review from QuncCccccc October 31, 2024 09:09
@bleroux
Copy link
Contributor Author

bleroux commented Oct 31, 2024

@QuncCccccc I extracted this PR from #157496 because I think those refactorings are valuable whether we move forward or not on #157496.

@nate-thegrate nate-thegrate added the refactor Improving readability/efficiency without behavioral changes label Nov 1, 2024
@bleroux bleroux requested a review from justinmc November 4, 2024 18:43
Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Thanks for cleaning this up.

import 'package:flutter_test/flutter_test.dart';

void main() {
Finder findMenuItemButton(String label) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Sometimes I'll create a utils file to share methods like these that are used in multiple test files (e.g. editable_text_utils.dart). Probably not worth it in this case but up to you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great reminder 🙏
I have 3 DropdownMenu/MenuAnchor PRs on the work, I will try to figure out if such a utils file is possible.

@bleroux bleroux added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 5, 2024
@auto-submit auto-submit bot merged commit 338555b into flutter:master Nov 5, 2024
76 checks passed
@bleroux bleroux deleted the refactor_DropdownMenu_tests branch November 5, 2024 06:17
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 5, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 5, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 5, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 5, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 5, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Nov 5, 2024
flutter/flutter@8591d0c...29d40f7

2024-11-05 [email protected] increase subsharding for `Windows build_tests` from 8 to 9 (flutter/flutter#158146)
2024-11-05 [email protected] Reland2: Revert "Revert "Add a warning/additional handlers for parsing`synthetic-package`."" (flutter/flutter#158184)
2024-11-05 [email protected] Reland1:  "Revert "Add and plumb `useImplicitPubspecResolution` across `flutter_tools`."" (flutter/flutter#158126)
2024-11-05 [email protected] Roll Packages from 796afa3 to 7219431 (11 revisions) (flutter/flutter#158179)
2024-11-05 [email protected] Make native asset integration test more robust, thereby allowing smooth auto-update of packages via `flutter update-packages` (flutter/flutter#158170)
2024-11-05 [email protected] Readability change to `flutter.groovy`, align on null assignment, reduce unused scope for some methods, apply static where possible (flutter/flutter#157471)
2024-11-05 [email protected] Roll Flutter Engine from 7207a8fbec93 to f56401062e42 (1 revision) (flutter/flutter#158169)
2024-11-05 [email protected] Add test for `raw_scrollbar.shape.0.dart` (flutter/flutter#158094)
2024-11-05 [email protected] Roll Flutter Engine from 418609dd5b58 to 7207a8fbec93 (1 revision) (flutter/flutter#158156)
2024-11-05 [email protected] Refactor DropdownMenu tests (flutter/flutter#157913)
2024-11-05 [email protected] Roll Flutter Engine from 6271a92a376f to 418609dd5b58 (3 revisions) (flutter/flutter#158152)
2024-11-05 [email protected] Marks Linux_pixel_7pro flavors_test to be flaky (flutter/flutter#156956)
2024-11-05 [email protected] Further remove web-only considerations that are no longer necessary (flutter/flutter#158143)
2024-11-05 [email protected] Add optional parameter to FlutterTesterDevices. (flutter/flutter#158133)
2024-11-05 [email protected] Roll Flutter Engine from 75acceedca41 to 6271a92a376f (2 revisions) (flutter/flutter#158148)
2024-11-05 [email protected] Extract and restore a test that a blank native assets project still builds (flutter/flutter#158141)
2024-11-04 [email protected] Remove references to the HTML renderer in public docs. (flutter/flutter#158035)
2024-11-04 [email protected] Roll Flutter Engine from f880b56b6ede to 75acceedca41 (1 revision) (flutter/flutter#158137)
2024-11-04 [email protected] Fix `WidgetStateProperty` documentation (flutter/flutter#154298)
2024-11-04 [email protected] Roll Flutter Engine from 25c7e471e2ef to f880b56b6ede (5 revisions) (flutter/flutter#158132)
2024-11-04 [email protected] Roll Flutter Engine from 05cb5d7f7939 to 25c7e471e2ef (12 revisions) (flutter/flutter#158127)
2024-11-04 [email protected] Remove use_modular_headers! from Swift Podfiles (flutter/flutter#156257)
2024-11-04 [email protected] Disable failing native assets test (flutter/flutter#158119)
2024-11-04 [email protected] Fix `NestedScrollView` inner position logic (flutter/flutter#157756)
2024-11-04 [email protected] Add benchmarks for single-threaded Skwasm. (flutter/flutter#158027)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 12, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. refactor Improving readability/efficiency without behavioral changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants