[flutter_test] gestures can leak from test to test
- Dominant language
- Dart
- Stars
- 179k
- Forks
- 31.1k
- PR merge metrics
- PR metrics pending
Description
Steps to reproduce:
* Check out this revision of Flutter: https://github.com/flutter/flutter/commit/bb2d34126cc8161dbe4a1bf23c925e48b732f670
* `cd packages/flutter`
* `flutter test --reporter=expanded --test-randomize-ordering-seed=20250118 --fatal-warnings --track-widget-creation test/material/reorderable_list_test.dart`
* Observe the test passing.
* Now change the seed: `flutter test --reporter=expanded --test-randomize-ordering-seed=20250117 --fatal-warnings --track-widget-creation test/material/reorderable_list_test.dart`
* Observe the test failing.
The reason it's failing is because a test in `reorderable_list_test.dart` created a `TestGesture` but never finalized it by cancelling it or by calling `drag.up()`. Because tests that are sensitive to dangling gestures could be anywhere, this issue did not immediately reproduce until, by chance, we rolled a seed that sorts tests such that the sensitive test was run immediately after the test that leaves the gesture hanging (which took about 1 month). This was fixed in https://github.com/flutter/flutter/pull/161836. However, the issue should have been caught immediately when `reorderable_list_test.dart` was added for the first time. `flutter_test` could validate that when a test ends, there are not dangling gestures and `VelocityTrackers` left.
Contributor guide
Assessment
This issue has not been assessed yet.