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 all 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
1 change: 1 addition & 0 deletions shell/platform/fuchsia/flutter/tests/integration/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ group("integration") {
testonly = true
deps = [
"embedder:tests",
"mouse-input:tests",
"text-input:tests",
"touch-input:tests",
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

assert(is_fuchsia)

import("//build/fuchsia/sdk.gni")
import("//flutter/tools/fuchsia/fuchsia_archive.gni")
import("//flutter/tools/fuchsia/gn-sdk/package.gni")

group("tests") {
testonly = true
deps = [ ":mouse-input-test" ]
}

executable("mouse-input-test-bin") {
testonly = true
output_name = "mouse-input-test"
sources = [ "mouse-input-test.cc" ]

# This is needed for //third_party/googletest for linking zircon symbols.
libs = [ "$fuchsia_sdk_path/arch/$target_cpu/sysroot/lib/libzircon.so" ]

deps = [
"$fuchsia_sdk_root/fidl:fuchsia.accessibility.semantics",
"$fuchsia_sdk_root/fidl:fuchsia.buildinfo",
"$fuchsia_sdk_root/fidl:fuchsia.component",
"$fuchsia_sdk_root/fidl:fuchsia.fonts",
"$fuchsia_sdk_root/fidl:fuchsia.intl",
"$fuchsia_sdk_root/fidl:fuchsia.kernel",
"$fuchsia_sdk_root/fidl:fuchsia.memorypressure",
"$fuchsia_sdk_root/fidl:fuchsia.metrics",
"$fuchsia_sdk_root/fidl:fuchsia.net.interfaces",
"$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.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",
"mouse-input-view:package",
"//build/fuchsia/fidl:fuchsia.ui.gfx",
"//flutter/fml",
"//flutter/shell/platform/fuchsia/flutter/tests/integration/utils:portable_ui_test",
"//third_party/googletest:gtest",
"//third_party/googletest:gtest_main",
]
}

fuchsia_test_archive("mouse-input-test") {
testonly = true
deps = [
":mouse-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")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# mouse-input

`mouse-input-test` exercises mouse input through a child view (in this case, the `mouse-input-view` Dart component) and
asserting the location as well as what button was used (mouse down, mouse up, wheel, etc) during the event. We do this by
attaching the child view, injecting mouse input, and validating that the view reports the event back with the expected
payload.

```shell
Injecting the mouse input
[mouse-input-test.cm] INFO: [portable_ui_test.cc(227)] Injecting mouse input

View receives the event
[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)

Successfully received response from view
[mouse-input-test.cm] INFO: [mouse-input-test.cc(120)] Received MouseInput event
[mouse-input-test.cm] INFO: [mouse-input-test.cc(207)] Client received mouse change at (641.466, 402.931) with buttons 0.
[mouse-input-test.cm] INFO: [mouse-input-test.cc(211)] Expected mouse change is at approximately (641, 402) with buttons 0.
```

## Running the Test

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`

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

Build Fuchsia with `workstation_eng.qemu-x64`
```shell
fx set workstation_eng.qemu-x64 && 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/mouse_input:tests
```

Start a Fuchsia package server
```shell
cd "$FUCHSIA_DIR"
fx serve
```

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/mouse-input/mouse-input-view/mouse-input-view/mouse-input-view.far
```

Launch Fuchsia emulator in a graphical environment
```shell
ffx emu start
```

**Before proceeding, make sure you have successfully completed the "Set a Password" screen**

Add `mouse-input-view`
```shell
ffx session add fuchsia-pkg://fuchsia.com/mouse-input-view#meta/mouse-input-view.cm
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
{
program: {
runner: "gtest_runner",
},
capabilities: [
{ protocol: "fuchsia.test.Suite" },
],
expose: [
{
protocol: "fuchsia.test.Suite",
from: "self",
},
],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
{
include: [
"gtest_runner.shard.cml",
"sys/component/realm_builder_absolute.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.MouseInputListener",
]
}
],
offer: [
{
// Offer capabilities needed by components in this test realm.
// Keep it minimal, describe only what's actually needed.
protocol: [
"fuchsia.kernel.RootJobForInspect",
"fuchsia.kernel.Stats",
"fuchsia.logger.LogSink",
"fuchsia.scheduler.ProfileProvider",
"fuchsia.sysmem.Allocator",
"fuchsia.tracing.provider.Registry",
"fuchsia.ui.input.ImeService",
"fuchsia.vulkan.loader.Loader",
"fuchsia.ui.scenic.Scenic",
"fuchsia.ui.composition.Allocator",
"fuchsia.ui.composition.Flatland",
"fuchsia.ui.test.input.MouseInputListener",
"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",
},
],
}
Loading