Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add README
  • Loading branch information
lin-erik committed Oct 19, 2022
commit 867b0eff51821db1feed382d10746a1d694f708c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@ executable("touch-input-test-bin") {

fuchsia_test_archive("touch-input-test") {
testonly = true
deps = [ ":touch-input-test-bin" ]
deps = [
":touch-input-test-bin",

# "OOT" copies of the runners used by tests, to avoid conflicting with the
# runners in the base fuchsia image.
# TODO(fxbug.dev/106575): Fix this with subpackages.
"//flutter/shell/platform/fuchsia/flutter:oot_flutter_jit_runner",
]

binary = "$target_name"
cml_file = rebase_path("meta/$target_name.cml")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# touch-input

`touch-input-test` exercises touch through a child view (in this case, the `touch-input-view` Dart component) and asserting
the precise location of the touch event. We do this by attaching the child view, injecting touch, and validating that the view
reports the touch event back with the correct coordinates.

```shell
Injecting the tap event
[touch-input-test.cm] INFO: [portable_ui_test.cc(193)] Injecting tap at (-500, -500)

View receives the event
[flutter_jit_runner] INFO: touch-input-view.cm(flutter): touch-input-view received tap: PointerData(embedderId: 0, timeStamp: 0:01:03.623259,
change: PointerChange.add, kind: PointerDeviceKind.touch, signalKind: PointerSignalKind.none, device: -4294967295, pointerIdentifier: 0,
physicalX: 319.99998331069946, physicalY: 199.99999284744263, physicalDeltaX: 0.0, physicalDeltaY: 0.0, buttons: 0, synthesized: false,
pressure: 0.0, pressureMin: 0.0, pressureMax: 0.0, distance: 0.0, distanceMax: 0.0, size: 0.0, radiusMajor: 0.0, radiusMinor: 0.0,
radiusMin: 0.0, radiusMax: 0.0, orientation: 0.0, tilt: 0.0, platformData: 0, scrollDeltaX: 0.0, scrollDeltaY: 0.0, panX: 0.0, panY: 0.0,
panDeltaX: 0.0, panDeltaY: 0.0, scale: 0.0, rotation: 0.0)

Successfully received response from view
[touch-input-test.cm] INFO: [touch-input-test.cc(162)] Received ReportTouchInput event
[touch-input-test.cm] INFO: [touch-input-test.cc(255)] Expecting event for component touch-input-view at (320, 200)
[touch-input-test.cm] INFO: [touch-input-test.cc(257)] Received event for component touch-input-view at (320, 200), accounting for pixel scale of 1
```

Some interesting details (thanks to abrusher@):

There exists two coordinate spaces within our testing realm. The first is `touch-input-view`'s "logical" coordinate space. This
is determined based on `touch-input-view`'s size and is the space in which it sees incoming events. The second is the "injector"
coordinate space, which spans [-1000, 1000] on both axes.

The size/position of a view doesn't always match the bounds of a display exactly. As a result, Scenic has a separate coordinate space
to specify the location at which to inject a touch event. This is always fixed to the display bounds. Scenic knows how to map this
coordinate space onto the client view's space.

For example, if we inject at (-500, -500) `touch-input-view` will see a touch event at the middle of the upper-left quadrant of the screen.

## Running the Test
Start a Fuchsia package server
```shell
cd "$FUCHSIA_DIR"
fx serve
```

Start the Fuchsia emulator in a graphical environment (go/crd)
```shell
ffx emu start
```

Run the integration test
```shell
$ENGINE_DIR/flutter/tools/fuchsia/devshell/run_integration_test.sh touch-input --no-lto --skip-fuchsia-emu
```

## Playing around with `touch-input-view`

This requires `tiles-session` (//src/session/examples/tiles-session), a simple graphical session with basic window management functionality.

Build Fuchsia with `tiles-session` in the GN build args
```shell
fx set workstation_eng.qemu-x64 --with //src/session/examples/tiles-session --with-base=//src/session/bin/session_manager && fx build
```

Build flutter/engine
```shell
$ENGINE_DIR/flutter/tools/gn --fuchsia --no-lto && ninja -C $ENGINE_DIR/out/fuchsia_debug_x64 flutter/shell/platform/fuchsia/flutter/tests/
integration/touch_input:tests
```

Publish `touch-input-view`
```shell
$FUCHSIA_DIR/.jiri_root/bin/fx pm publish -a -repo $FUCHSIA_DIR/$(cat $FUCHSIA_DIR/.fx-build-dir)/amber-files -f $ENGINE_DIR/out/
fuchsia_debug_x64/gen/flutter/shell/platform/fuchsia/flutter/tests/integration/touch-input/touch-input-view/touch-input-view/touch-input-view.far
```

Launch Fuchsia emulator in a graphical environment (go/crd)
```shell
ffx emu start
```

Launch `tiles-session`
```shell
ffx session launch fuchsia-pkg://fuchsia.com/tiles-session#meta/tiles-session.cm
```

Add `touch-input-view`
```shell
ffx session add fuchsia-pkg://fuchsia.com/touch-input-view#meta/touch-input-view.cm
```
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,5 @@ fuchsia_package("package") {
testonly = true
package_name = "touch-input-view"

deps = [
":component",

# "OOT" copies of the runners used by tests, to avoid conflicting with the
# runners in the base fuchsia image.
# TODO(fxbug.dev/106575): Fix this with subpackages.
"//flutter/shell/platform/fuchsia/flutter:oot_flutter_jit_runner",
]
deps = [ ":component" ]
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class MyApp {
int nowNanos = System.clockGetMonotonic();

for (PointerData data in packet.data) {
print('two-flutter received tap: ${data.toStringFull()}');
print('touch-input-view received tap: ${data.toStringFull()}');

if (data.change == PointerChange.down) {
_touchCounter++;
Expand Down
4 changes: 3 additions & 1 deletion tools/fuchsia/devshell/run_integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ shift # past argument
# Ensure we know about the test and look up its packages.
# The first package listed here should be the main package for the test
# (the package that gets passed to `ffx test run`).
# Note: You do not need to include oot_flutter_jit_runner-0.far, the script
# automatically publishes it.
test_packages=
case $test_name in
embedder)
Expand All @@ -58,7 +60,7 @@ case $test_name in
test_packages=("text-input-test-0.far" "text-input-view.far")
;;
touch-input)
test_packages=("touch-input-test-0.far" "touch-input-view.far" "oot_flutter_jit_runner-0.far")
test_packages=("touch-input-test-0.far" "touch-input-view.far")
;;
*)
engine-error "Unknown test name $test_name. You may need to add it to $0"
Expand Down