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 19 commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,19 @@ executable("touch-input-test-bin") {
"$fuchsia_sdk_root/fidl:fuchsia.tracing.provider",
"$fuchsia_sdk_root/fidl:fuchsia.ui.app",
"$fuchsia_sdk_root/fidl:fuchsia.ui.input",
"$fuchsia_sdk_root/fidl:fuchsia.ui.pointerinjector",
"$fuchsia_sdk_root/fidl:fuchsia.ui.policy",
"$fuchsia_sdk_root/fidl:fuchsia.ui.scenic",
"$fuchsia_sdk_root/fidl:fuchsia.ui.test.input",
"$fuchsia_sdk_root/fidl:fuchsia.ui.test.scene",
"$fuchsia_sdk_root/fidl:fuchsia.ui.test.scene",
"$fuchsia_sdk_root/fidl:fuchsia.web",
"$fuchsia_sdk_root/pkg:async",
"$fuchsia_sdk_root/pkg:async-loop-testing",
"$fuchsia_sdk_root/pkg:fidl_cpp",
"$fuchsia_sdk_root/pkg:scenic_cpp",
"$fuchsia_sdk_root/pkg:sys_component_cpp_testing",
"$fuchsia_sdk_root/pkg:zx",
"touch-input-view:package",
"//build/fuchsia/fidl:fuchsia.ui.gfx",
"//flutter/fml",
"//flutter/shell/platform/fuchsia/flutter/tests/integration/utils:portable_ui_test",
Expand All @@ -58,7 +59,6 @@ fuchsia_test_archive("touch-input-test") {
testonly = true
deps = [
":touch-input-test-bin",
"one-flutter:package",

# "OOT" copies of the runners used by tests, to avoid conflicting with the
# runners in the base fuchsia image.
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just curious, any reason not to have run_integration-test.sh handle this by dropping --skip-fuchsia-emu from the next command?

More generally should we point this section at https://github.com/flutter/engine/blob/main/shell/platform/fuchsia/flutter/tests/integration/README.md to avoid maintaining these instructions in two places?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The script defaults to launching a --headless emulator, which causes the test to fail.. I can add a flag to launch a graphical emulator (if this is what you meant by having the script handle it)

Good point on the documentation, I can update the README

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh shoot, I forgot about that. The Fuchsia tools tend to be graphical by default and support passing --headless for headless environments, so it's poor design that I didn't do the same.

We can also detect if we're in a headless environment with [[ -z $DISPLAY ]] I believe and use that to configure the emulator appropriately, but it might be better to be more explicit (graphical by default, pass --headless for non-graphics). We can handle this in a follow-up PR though.

```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.
Comment thread
lin-erik marked this conversation as resolved.
Outdated

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
```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 @@ -6,21 +6,24 @@
"gtest_runner.shard.cml",
"sys/component/realm_builder_absolute.shard.cml",

"syslog/client.shard.cml",
"vulkan/client.shard.cml",

// This test needs both the vulkan facet and the hermetic-tier-2 facet,
// so we are forced to make it a system test.
"sys/testing/system-test.shard.cml",
],
program: {
binary: "bin/app",
},
use: [
{
protocol: [
"fuchsia.ui.test.input.TouchInputListener",
]
}
],
offer: [
{
// Offer capabilities needed by components in this test realm.
// Keep it minimal, describe only what's actually needed.
// TODO(fxbug.dev/81446): Remove this list.
protocol: [
"fuchsia.kernel.RootJobForInspect",
"fuchsia.kernel.Stats",
Expand All @@ -30,9 +33,21 @@
"fuchsia.tracing.provider.Registry",
"fuchsia.ui.input.ImeService",
"fuchsia.vulkan.loader.Loader",
"fuchsia.ui.scenic.Scenic",
"fuchsia.ui.test.input.TouchInputListener",
"fuchsia.intl.PropertyProvider",
"fuchsia.posix.socket.Provider",
"fuchsia.ui.pointerinjector.Registry",
],
from: "parent",
to: "#realm_builder",
},
{
directory: "pkg",
subdir: "config",
as: "config-data",
from: "framework",
to: "#realm_builder",
},
],
}

This file was deleted.

This file was deleted.

Loading