|
| 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 | +``` |
0 commit comments