
Fixes #162107 Commands that were helpful when working on this pr. `dart dev/tools/bin/generate_gradle_lockfiles.dart --no-gradle-generation` from flutter/flutter root. `./gradlew test` from packages/flutter_tools/gradle. `git add -- ":*.lockfile"` for adding only lockfile changes. `../../bin/cache/dart-sdk/bin/dart bin/test_runner.dart test -t android_java11_dependency_smoke_tests` from dev/devicelab `ktlint --editorconfig=dev/bots/test/analyze-test-input/.editorconfig --baseline=dev/bots/test/analyze-test-input/ktlint-baseline.xml packages/flutter_tools/gradle/src/ --format` formatting kotlin code. Need ktlint 1.5 ## 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.
Integration test for touch events on embedded Android views
This test verifies that the synthesized motion events that get to embedded Android view are equal to the motion events that originally hit the FlutterView.
The test app's Android code listens to MotionEvents that get to FlutterView and to an embedded Android view and sends them over a platform channel to the Dart code where the events are matched.
This is what the app looks like:
The blue part is the embedded Android view because it is positioned at the top left corner, the coordinate systems for FlutterView and for the embedded view's virtual display has the same origin (this makes the MotionEvent comparison easier as we don't need to translate the coordinates).
The app includes the following control buttons:
- RECORD - Start listening for MotionEvents for 3 seconds, matched/unmatched events are displayed in the listview as they arrive.
- CLEAR - Clears the events that were recorded so far.
- SAVE - Saves the events that hit FlutterView to a file.
- PLAY FILE - Send a list of events from a bundled asset file to FlutterView.
A recorded touch events sequence is bundled as an asset in the assets_for_android_view package which lives in the goldens repository.
When running this test with flutter drive
the record touch sequences is
replayed and the test asserts that the events that got to FlutterView are
equivalent to the ones that got to the embedded view.