Skip to content

Commit 1e10c77

Browse files
lin-erikschwa423
authored andcommitted
[fuchsia] mouse-input test (flutter#37221)
Introduces the `mouse-input` test, a straight port from fuchsia.git
1 parent 399e768 commit 1e10c77

14 files changed

Lines changed: 1155 additions & 32 deletions

File tree

shell/platform/fuchsia/flutter/tests/integration/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ group("integration") {
1010
testonly = true
1111
deps = [
1212
"embedder:tests",
13+
"mouse-input:tests",
1314
"text-input:tests",
1415
"touch-input:tests",
1516
]
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Copyright 2013 The Flutter Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
assert(is_fuchsia)
6+
7+
import("//build/fuchsia/sdk.gni")
8+
import("//flutter/tools/fuchsia/fuchsia_archive.gni")
9+
import("//flutter/tools/fuchsia/gn-sdk/package.gni")
10+
11+
group("tests") {
12+
testonly = true
13+
deps = [ ":mouse-input-test" ]
14+
}
15+
16+
executable("mouse-input-test-bin") {
17+
testonly = true
18+
output_name = "mouse-input-test"
19+
sources = [ "mouse-input-test.cc" ]
20+
21+
# This is needed for //third_party/googletest for linking zircon symbols.
22+
libs = [ "$fuchsia_sdk_path/arch/$target_cpu/sysroot/lib/libzircon.so" ]
23+
24+
deps = [
25+
"$fuchsia_sdk_root/fidl:fuchsia.accessibility.semantics",
26+
"$fuchsia_sdk_root/fidl:fuchsia.buildinfo",
27+
"$fuchsia_sdk_root/fidl:fuchsia.component",
28+
"$fuchsia_sdk_root/fidl:fuchsia.fonts",
29+
"$fuchsia_sdk_root/fidl:fuchsia.intl",
30+
"$fuchsia_sdk_root/fidl:fuchsia.kernel",
31+
"$fuchsia_sdk_root/fidl:fuchsia.memorypressure",
32+
"$fuchsia_sdk_root/fidl:fuchsia.metrics",
33+
"$fuchsia_sdk_root/fidl:fuchsia.net.interfaces",
34+
"$fuchsia_sdk_root/fidl:fuchsia.tracing.provider",
35+
"$fuchsia_sdk_root/fidl:fuchsia.ui.app",
36+
"$fuchsia_sdk_root/fidl:fuchsia.ui.input",
37+
"$fuchsia_sdk_root/fidl:fuchsia.ui.pointerinjector",
38+
"$fuchsia_sdk_root/fidl:fuchsia.ui.policy",
39+
"$fuchsia_sdk_root/fidl:fuchsia.ui.scenic",
40+
"$fuchsia_sdk_root/fidl:fuchsia.ui.test.input",
41+
"$fuchsia_sdk_root/fidl:fuchsia.ui.test.scene",
42+
"$fuchsia_sdk_root/fidl:fuchsia.web",
43+
"$fuchsia_sdk_root/pkg:async",
44+
"$fuchsia_sdk_root/pkg:async-loop-testing",
45+
"$fuchsia_sdk_root/pkg:fidl_cpp",
46+
"$fuchsia_sdk_root/pkg:scenic_cpp",
47+
"$fuchsia_sdk_root/pkg:sys_component_cpp_testing",
48+
"$fuchsia_sdk_root/pkg:zx",
49+
"mouse-input-view:package",
50+
"//build/fuchsia/fidl:fuchsia.ui.gfx",
51+
"//flutter/fml",
52+
"//flutter/shell/platform/fuchsia/flutter/tests/integration/utils:portable_ui_test",
53+
"//third_party/googletest:gtest",
54+
"//third_party/googletest:gtest_main",
55+
]
56+
}
57+
58+
fuchsia_test_archive("mouse-input-test") {
59+
testonly = true
60+
deps = [
61+
":mouse-input-test-bin",
62+
63+
# "OOT" copies of the runners used by tests, to avoid conflicting with the
64+
# runners in the base fuchsia image.
65+
# TODO(fxbug.dev/106575): Fix this with subpackages.
66+
"//flutter/shell/platform/fuchsia/flutter:oot_flutter_jit_runner",
67+
]
68+
69+
binary = "$target_name"
70+
cml_file = rebase_path("meta/$target_name.cml")
71+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# mouse-input
2+
3+
`mouse-input-test` exercises mouse input through a child view (in this case, the `mouse-input-view` Dart component) and
4+
asserting the location as well as what button was used (mouse down, mouse up, wheel, etc) during the event. We do this by
5+
attaching the child view, injecting mouse input, and validating that the view reports the event back with the expected
6+
payload.
7+
8+
```shell
9+
Injecting the mouse input
10+
[mouse-input-test.cm] INFO: [portable_ui_test.cc(227)] Injecting mouse input
11+
12+
View receives the event
13+
[flutter_jit_runner] INFO: mouse-input-view.cm(flutter): mouse-input-view received input: PointerData(embedderId: 0, timeStamp: 23:18:05.031003, change: PointerChange.add, kind: PointerDeviceKind.mouse, signalKind: PointerSignalKind.none, device: 4294967295, pointerIdentifier: 0, physicalX: 641.4656372070312, physicalY: 402.9313049316406, physicalDeltaX: 0.0, physicalDeltaY: 0.0, buttons: 0, synthesized: true, 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)
14+
15+
Successfully received response from view
16+
[mouse-input-test.cm] INFO: [mouse-input-test.cc(120)] Received MouseInput event
17+
[mouse-input-test.cm] INFO: [mouse-input-test.cc(207)] Client received mouse change at (641.466, 402.931) with buttons 0.
18+
[mouse-input-test.cm] INFO: [mouse-input-test.cc(211)] Expected mouse change is at approximately (641, 402) with buttons 0.
19+
```
20+
21+
## Running the Test
22+
23+
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`
24+
25+
## Playing around with `mouse-input-view`
26+
27+
Build Fuchsia with `workstation_eng.qemu-x64`
28+
```shell
29+
fx set workstation_eng.qemu-x64 && fx build
30+
```
31+
32+
Build flutter/engine
33+
```shell
34+
$ENGINE_DIR/flutter/tools/gn --fuchsia --no-lto && ninja -C $ENGINE_DIR/out/fuchsia_debug_x64 flutter/shell/platform/fuchsia/flutter/tests/
35+
integration/mouse_input:tests
36+
```
37+
38+
Start a Fuchsia package server
39+
```shell
40+
cd "$FUCHSIA_DIR"
41+
fx serve
42+
```
43+
44+
Publish `touch-input-view`
45+
```shell
46+
$FUCHSIA_DIR/.jiri_root/bin/fx pm publish -a -repo $FUCHSIA_DIR/$(cat $FUCHSIA_DIR/.fx-build-dir)/amber-files -f $ENGINE_DIR/out/
47+
fuchsia_debug_x64/gen/flutter/shell/platform/fuchsia/flutter/tests/integration/mouse-input/mouse-input-view/mouse-input-view/mouse-input-view.far
48+
```
49+
50+
Launch Fuchsia emulator in a graphical environment
51+
```shell
52+
ffx emu start
53+
```
54+
55+
**Before proceeding, make sure you have successfully completed the "Set a Password" screen**
56+
57+
Add `mouse-input-view`
58+
```shell
59+
ffx session add fuchsia-pkg://fuchsia.com/mouse-input-view#meta/mouse-input-view.cm
60+
```
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
{
5+
program: {
6+
runner: "gtest_runner",
7+
},
8+
capabilities: [
9+
{ protocol: "fuchsia.test.Suite" },
10+
],
11+
expose: [
12+
{
13+
protocol: "fuchsia.test.Suite",
14+
from: "self",
15+
},
16+
],
17+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
{
5+
include: [
6+
"gtest_runner.shard.cml",
7+
"sys/component/realm_builder_absolute.shard.cml",
8+
9+
// This test needs both the vulkan facet and the hermetic-tier-2 facet,
10+
// so we are forced to make it a system test.
11+
"sys/testing/system-test.shard.cml",
12+
],
13+
program: {
14+
binary: "bin/app",
15+
},
16+
use: [
17+
{
18+
protocol: [
19+
"fuchsia.ui.test.input.MouseInputListener",
20+
]
21+
}
22+
],
23+
offer: [
24+
{
25+
// Offer capabilities needed by components in this test realm.
26+
// Keep it minimal, describe only what's actually needed.
27+
protocol: [
28+
"fuchsia.kernel.RootJobForInspect",
29+
"fuchsia.kernel.Stats",
30+
"fuchsia.logger.LogSink",
31+
"fuchsia.scheduler.ProfileProvider",
32+
"fuchsia.sysmem.Allocator",
33+
"fuchsia.tracing.provider.Registry",
34+
"fuchsia.ui.input.ImeService",
35+
"fuchsia.vulkan.loader.Loader",
36+
"fuchsia.ui.scenic.Scenic",
37+
"fuchsia.ui.composition.Allocator",
38+
"fuchsia.ui.composition.Flatland",
39+
"fuchsia.ui.test.input.MouseInputListener",
40+
"fuchsia.intl.PropertyProvider",
41+
"fuchsia.posix.socket.Provider",
42+
"fuchsia.ui.pointerinjector.Registry",
43+
],
44+
from: "parent",
45+
to: "#realm_builder",
46+
},
47+
{
48+
directory: "pkg",
49+
subdir: "config",
50+
as: "config-data",
51+
from: "framework",
52+
to: "#realm_builder",
53+
},
54+
],
55+
}

0 commit comments

Comments
 (0)