Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 791221c

Browse files
authored
Add test view for touch-input-test (#36879)
This PR adds a touch-input-view for use in the touch-input-test to validate touch input. The view will be attached to the test, and a touch event will be injected. The test asserts that a correct response is sent back from the view (the location of the touch as well as the name of the view).
1 parent 2987e25 commit 791221c

File tree

14 files changed

+375
-239
lines changed

14 files changed

+375
-239
lines changed

shell/platform/fuchsia/flutter/tests/integration/touch-input/BUILD.gn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,19 @@ executable("touch-input-test-bin") {
3434
"$fuchsia_sdk_root/fidl:fuchsia.tracing.provider",
3535
"$fuchsia_sdk_root/fidl:fuchsia.ui.app",
3636
"$fuchsia_sdk_root/fidl:fuchsia.ui.input",
37+
"$fuchsia_sdk_root/fidl:fuchsia.ui.pointerinjector",
3738
"$fuchsia_sdk_root/fidl:fuchsia.ui.policy",
3839
"$fuchsia_sdk_root/fidl:fuchsia.ui.scenic",
3940
"$fuchsia_sdk_root/fidl:fuchsia.ui.test.input",
4041
"$fuchsia_sdk_root/fidl:fuchsia.ui.test.scene",
41-
"$fuchsia_sdk_root/fidl:fuchsia.ui.test.scene",
4242
"$fuchsia_sdk_root/fidl:fuchsia.web",
4343
"$fuchsia_sdk_root/pkg:async",
4444
"$fuchsia_sdk_root/pkg:async-loop-testing",
4545
"$fuchsia_sdk_root/pkg:fidl_cpp",
4646
"$fuchsia_sdk_root/pkg:scenic_cpp",
4747
"$fuchsia_sdk_root/pkg:sys_component_cpp_testing",
4848
"$fuchsia_sdk_root/pkg:zx",
49+
"touch-input-view:package",
4950
"//build/fuchsia/fidl:fuchsia.ui.gfx",
5051
"//flutter/fml",
5152
"//flutter/shell/platform/fuchsia/flutter/tests/integration/utils:portable_ui_test",
@@ -58,7 +59,6 @@ fuchsia_test_archive("touch-input-test") {
5859
testonly = true
5960
deps = [
6061
":touch-input-test-bin",
61-
"one-flutter:package",
6262

6363
# "OOT" copies of the runners used by tests, to avoid conflicting with the
6464
# runners in the base fuchsia image.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# touch-input
2+
3+
`touch-input-test` exercises touch through a child view (in this case, the `touch-input-view` Dart component) and asserting
4+
the precise location of the touch event. We do this by attaching the child view, injecting touch, and validating that the view
5+
reports the touch event back with the correct coordinates.
6+
7+
```shell
8+
Injecting the tap event
9+
[touch-input-test.cm] INFO: [portable_ui_test.cc(193)] Injecting tap at (-500, -500)
10+
11+
View receives the event
12+
[flutter_jit_runner] INFO: touch-input-view.cm(flutter): touch-input-view received tap: PointerData(embedderId: 0, timeStamp: 0:01:03.623259,
13+
change: PointerChange.add, kind: PointerDeviceKind.touch, signalKind: PointerSignalKind.none, device: -4294967295, pointerIdentifier: 0,
14+
physicalX: 319.99998331069946, physicalY: 199.99999284744263, physicalDeltaX: 0.0, physicalDeltaY: 0.0, buttons: 0, synthesized: false,
15+
pressure: 0.0, pressureMin: 0.0, pressureMax: 0.0, distance: 0.0, distanceMax: 0.0, size: 0.0, radiusMajor: 0.0, radiusMinor: 0.0,
16+
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,
17+
panDeltaX: 0.0, panDeltaY: 0.0, scale: 0.0, rotation: 0.0)
18+
19+
Successfully received response from view
20+
[touch-input-test.cm] INFO: [touch-input-test.cc(162)] Received ReportTouchInput event
21+
[touch-input-test.cm] INFO: [touch-input-test.cc(255)] Expecting event for component touch-input-view at (320, 200)
22+
[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
23+
```
24+
25+
Some interesting details (thanks to abrusher@):
26+
27+
There exists two coordinate spaces within our testing realm. The first is `touch-input-view`'s "logical" coordinate space. This
28+
is determined based on `touch-input-view`'s size and is the space in which it sees incoming events. The second is the "injector"
29+
coordinate space, which spans [-1000, 1000] on both axes.
30+
31+
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
32+
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
33+
coordinate space onto the client view's space.
34+
35+
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.
36+
37+
## Running the Test
38+
39+
Reference the Flutter integration test [documentation](https://github.com/flutter/engine/blob/main/shell/platform/fuchsia/flutter/tests/integration/README.md) at //flutter/shell/platform/fuchsia/flutter/tests/integration/README.md
40+
41+
## Playing around with `touch-input-view`
42+
43+
Build Fuchsia with `workstation_eng.qemu-x64`
44+
```shell
45+
fx set workstation_eng.qemu-x64 --with-base=//src/session/bin/session_manager && fx build
46+
```
47+
48+
Build flutter/engine
49+
```shell
50+
$ENGINE_DIR/flutter/tools/gn --fuchsia --no-lto && ninja -C $ENGINE_DIR/out/fuchsia_debug_x64 flutter/shell/platform/fuchsia/flutter/tests/
51+
integration/touch_input:tests
52+
```
53+
54+
Start a Fuchsia package server
55+
```shell
56+
cd "$FUCHSIA_DIR"
57+
fx serve
58+
```
59+
60+
Publish `touch-input-view`
61+
```shell
62+
$FUCHSIA_DIR/.jiri_root/bin/fx pm publish -a -repo $FUCHSIA_DIR/$(cat $FUCHSIA_DIR/.fx-build-dir)/amber-files -f $ENGINE_DIR/out/
63+
fuchsia_debug_x64/gen/flutter/shell/platform/fuchsia/flutter/tests/integration/touch-input/touch-input-view/touch-input-view/touch-input-view.far
64+
```
65+
66+
Launch Fuchsia emulator in a graphical environment
67+
```shell
68+
ffx emu start
69+
```
70+
71+
**Before proceeding, make sure you have successfully completed the "Set a Password" screen**
72+
73+
Add `touch-input-view`
74+
```shell
75+
ffx session add fuchsia-pkg://fuchsia.com/touch-input-view#meta/touch-input-view.cm
76+
```

shell/platform/fuchsia/flutter/tests/integration/touch-input/meta/touch-input-test.cml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,24 @@
66
"gtest_runner.shard.cml",
77
"sys/component/realm_builder_absolute.shard.cml",
88

9-
"syslog/client.shard.cml",
10-
"vulkan/client.shard.cml",
11-
129
// This test needs both the vulkan facet and the hermetic-tier-2 facet,
1310
// so we are forced to make it a system test.
1411
"sys/testing/system-test.shard.cml",
1512
],
1613
program: {
1714
binary: "bin/app",
1815
},
16+
use: [
17+
{
18+
protocol: [
19+
"fuchsia.ui.test.input.TouchInputListener",
20+
]
21+
}
22+
],
1923
offer: [
2024
{
2125
// Offer capabilities needed by components in this test realm.
2226
// Keep it minimal, describe only what's actually needed.
23-
// TODO(fxbug.dev/81446): Remove this list.
2427
protocol: [
2528
"fuchsia.kernel.RootJobForInspect",
2629
"fuchsia.kernel.Stats",
@@ -30,9 +33,21 @@
3033
"fuchsia.tracing.provider.Registry",
3134
"fuchsia.ui.input.ImeService",
3235
"fuchsia.vulkan.loader.Loader",
36+
"fuchsia.ui.scenic.Scenic",
37+
"fuchsia.ui.test.input.TouchInputListener",
38+
"fuchsia.intl.PropertyProvider",
39+
"fuchsia.posix.socket.Provider",
40+
"fuchsia.ui.pointerinjector.Registry",
3341
],
3442
from: "parent",
3543
to: "#realm_builder",
3644
},
45+
{
46+
directory: "pkg",
47+
subdir: "config",
48+
as: "config-data",
49+
from: "framework",
50+
to: "#realm_builder",
51+
},
3752
],
3853
}

shell/platform/fuchsia/flutter/tests/integration/touch-input/one-flutter/lib/one-flutter.dart

Lines changed: 0 additions & 18 deletions
This file was deleted.

shell/platform/fuchsia/flutter/tests/integration/touch-input/one-flutter/meta/one-flutter-realm.cml

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)