Skip to content

Conversation

@mattkae
Copy link
Contributor

@mattkae mattkae commented Nov 21, 2025

What's new?

  • While coming up with a scheme for testing multi-window, I realize that issuing taps in testWidgets across views was not working because the view was always being set to 0
  • The fix is to resolve the view when we can, and provide an optional view in the other methods

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.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@github-actions github-actions bot added a: tests "flutter test", flutter_test, or one of our tests framework flutter/packages/flutter repository. See also f: labels. labels Nov 21, 2025
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 adds viewId parameters to various testing APIs to support multi-window testing. The changes correctly pipe the viewId through TestPointer and WidgetController methods, which is a good improvement for multi-view testing scenarios. I've found a couple of issues: one method has an unused parameter, and another has a bug where the view ID is not correctly resolved from the provided Finder. The rest of the changes look solid.

… TestPointer so that clicks wind up on the right view
@mattkae mattkae force-pushed the flutter_test_view_tapping branch from f30c5a1 to 3eb2264 Compare November 21, 2025 19:53
@mattkae mattkae requested a review from loic-sharma November 24, 2025 15:21
@knopp
Copy link
Member

knopp commented Nov 24, 2025

I am wondering a bit whether viewId couldn't be a property on TestPointer instead of being specified in each method?

@mattkae
Copy link
Contributor Author

mattkae commented Nov 24, 2025

@loic-sharma In tests, I get:

10:04 +11784 ~34 -6: /b/s/w/ir/x/w/flutter/packages/flutter/test/gestures/pointer_router_test.dart: Supports re-entrant cancellation [E]
  Binding has not yet been initialized.
  The "instance" getter on the WidgetsBinding binding mixin is only available once that binding has been initialized.
  Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After calling that method, the "instance" getter will return the binding.
  In a test, one can call "TestWidgetsFlutterBinding.ensureInitialized()" as the first line in the test's "main()" method to initialize the binding.
  If WidgetsBinding is a custom binding mixin, there must also be a custom binding class, like WidgetsFlutterBinding, but that mixes in the selected binding, and that is the class that must be constructed before using the "instance" getter.
  package:flutter/src/foundation/binding.dart 314:9  BindingBase.checkInstance.<fn>
  package:flutter/src/foundation/binding.dart 401:6  BindingBase.checkInstance
  package:flutter/src/widgets/binding.dart 477:53    WidgetsBinding.instance
  package:flutter_test/src/test_pointer.dart 138:46  TestPointer.down
  test/gestures/pointer_router_test.dart 43:27       main.<fn>

I think others were using 0 there because it was a safe-ish value. Do I ensureInitialized() or should I just put it back to 0?

@loic-sharma
Copy link
Member

loic-sharma commented Nov 24, 2025

EDIT: Updated after more digging.

@mattkae What do you think of:

  1. Update TestPointer to switch from WidgetsFlutterBinding.instance to TestWidgetsFlutterBinding.instance
  2. Update those test/gestures/pointer_router_test.dart tests to call TestWidgetsFlutterBinding.ensureInitialized().

I am wondering a bit whether viewId couldn't be a property on TestPointer instead of being specified in each method?

This might make it less convenient to write a test for a pointer interaction that spans multiple views. For example, I might want to check the content of two tooltips in two separate views. Let me ask the team for additional opinions though!

@chunhtai chunhtai self-requested a review November 24, 2025 21:52
@github-actions github-actions bot added f: routes Navigator, Router, and related APIs. f: gestures flutter/packages/flutter/gestures repository. labels Nov 25, 2025
Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

overall lgtm, just a minor comment

Copy link
Member

@loic-sharma loic-sharma left a comment

Choose a reason for hiding this comment

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

Looks good to me once pending comments are addressed!

@mattkae mattkae added this pull request to the merge queue Dec 1, 2025
Merged via the queue into flutter:master with commit a99fb28 Dec 1, 2025
69 checks passed
@mattkae mattkae deleted the flutter_test_view_tapping branch December 1, 2025 19:03
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 2, 2025
…er and the TestPointer so that clicks wind up on the right view (flutter/flutter#178941)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 2, 2025
…er and the TestPointer so that clicks wind up on the right view (flutter/flutter#178941)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 2, 2025
…er and the TestPointer so that clicks wind up on the right view (flutter/flutter#178941)
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Dec 2, 2025
flutter/flutter@05d6005...5545bb3

2025-12-02 [email protected] Roll Skia from 4371ed0ce49e to 45337c4e919d (1 revision) (flutter/flutter#179342)
2025-12-02 [email protected] Roll Fuchsia Linux SDK from sTk6OB7a4yudbfdZg... to l0DvmZrMHlF12frrX... (flutter/flutter#179338)
2025-12-02 [email protected] Unfocus search anchor bar when the view is closed (flutter/flutter#178910)
2025-12-02 [email protected] Directly generate a Mach-O dynamic library using gen_snapshot. [reland] (flutter/flutter#174870)
2025-12-02 [email protected] Roll Skia from 1fc59bf5cbb1 to 4371ed0ce49e (3 revisions) (flutter/flutter#179326)
2025-12-02 [email protected] [win32] Replace threadpool timer with custom background thread timer (flutter/flutter#179249)
2025-12-02 [email protected] Roll Skia from 61257a1036fb to 1fc59bf5cbb1 (1 revision) (flutter/flutter#179321)
2025-12-02 [email protected] Roll Skia from ef52cf952211 to 61257a1036fb (2 revisions) (flutter/flutter#179319)
2025-12-02 [email protected] Roll Skia from 8887653a773e to ef52cf952211 (1 revision) (flutter/flutter#179316)
2025-12-02 [email protected] Roll pub packages (flutter/flutter#179313)
2025-12-02 [email protected] Update customer tests (flutter/flutter#179309)
2025-12-01 [email protected] Marks Linux_pixel_7pro new_gallery__transition_perf to be unflaky (flutter/flutter#176339)
2025-12-01 [email protected] Fix typo (flutter/flutter#179200)
2025-12-01 49699333+dependabot[bot]@users.noreply.github.com Bump actions/checkout from 5.0.1 to 6.0.0 in the all-github-actions group (flutter/flutter#179308)
2025-12-01 [email protected] Roll Dart SDK from c54108eeb2c1 to eb743a1d4ade (1 revision) (flutter/flutter#179304)
2025-12-01 [email protected] Roll pub packages (flutter/flutter#179280)
2025-12-01 [email protected] Roll Skia from 68cc3257e734 to 8887653a773e (4 revisions) (flutter/flutter#179302)
2025-12-01 [email protected] Support round caps for the fast arc stroke generator (flutter/flutter#178269)
2025-12-01 [email protected] Fix for PR #174374 - Fix - TalkBack does not announce list information (flutter/flutter#177622)
2025-12-01 [email protected] Small cleanup in `‎AccessibilityBridge.java‎` (flutter/flutter#179226)
2025-12-01 [email protected] Roll Skia from 925c311f4b37 to 68cc3257e734 (44 revisions) (flutter/flutter#179294)
2025-12-01 [email protected] [ Widget Preview ] Ignore changes under `ios/.symlinks` (flutter/flutter#179290)
2025-12-01 [email protected] Delete unecessary lockfile (flutter/flutter#179052)
2025-12-01 [email protected] Resolving and piping the view ID  through the WidgetController and the TestPointer so that clicks wind up on the right view (flutter/flutter#178941)
2025-12-01 [email protected] Fix link specified as plain text `FlutterApplication.java‎` (flutter/flutter#178573)
2025-12-01 [email protected] Update some comments to reflect theme normalization (flutter/flutter#179013)
2025-12-01 [email protected] Roll Dart SDK from 51fe8cd01fbe to c54108eeb2c1 (1 revision) (flutter/flutter#179267)
2025-12-01 [email protected] Explicitly use FreeType font scanner with Fuchsia (flutter/flutter#179055)

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] 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
mboetger pushed a commit to mboetger/flutter that referenced this pull request Dec 2, 2025
… TestPointer so that clicks wind up on the right view (flutter#178941)

## What's new?
- While coming up with a scheme for testing multi-window, I realize that
issuing taps in `testWidgets` across views was not working because the
view was always being set to `0`
- The fix is to resolve the view when we can, and provide an optional
view in the other methods

## 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.
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
… TestPointer so that clicks wind up on the right view (flutter#178941)

## What's new?
- While coming up with a scheme for testing multi-window, I realize that
issuing taps in `testWidgets` across views was not working because the
view was always being set to `0`
- The fix is to resolve the view when we can, and provide an optional
view in the other methods

## 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: tests "flutter test", flutter_test, or one of our tests f: gestures flutter/packages/flutter/gestures repository. f: routes Navigator, Router, and related APIs. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants