Skip to content

Remove InputInjector workaround once winappCli #587 (send-keys/drag/scroll verbs) ships #652

Description

@azchohfi

Background

PR #650 migrated the E2E harness from WinAppDriver/Appium to Microsoft's winapp ui CLI. At the time, winapp ui (v0.3.2) had no keyboard typing and no drag, so we kept a thin Win32 SendInput fallback — tests/Reactor.AppTests/Infrastructure/InputInjector.cs — used only by the input-injection tests.

winappCli PR #587 adds the native ui send-keys, ui drag, and ui scroll --wheel verbs. Once #587 ships in a released winapp build, InputInjector can be deleted entirely and its call sites repointed at the native verbs.

This issue tracks that swap-out. The mapping below was verified against #587 HEAD (65c4c93) — every InputInjector primitive the tests call has a native equivalent, and the gaps we worried about earlier are all closed.

Verified mapping (InputInjector → native verb)

InputInjector primitive Native verb (#587) Notes
Foreground(hwnd) (none needed) Every verb foregrounds + verifies internally (SetForegroundWindow + ForegroundGuard.TryEnsureForeground). Drop these calls.
Click(x,y) click <selector> All call sites click an element center found by id; click computes the center itself. Prefer passing the selector, not coords.
Drag(points[]) (multi-waypoint) drag <from> <to> MouseInput.Drag interpolates 20 steps internally (MouseInput.cs:77), streaming continuous WM_MOUSEMOVE and crossing WinUI's 4-DIP drag threshold. Our hand-rolled 5–6 waypoints become unnecessary.
DragTearOffMerge(grab, drop) drag <grab> <drop> --dwell-ms <N> --dwell-ms was added explicitly for drop targets / merge overlays that arm from a sustained hover latch.
PressHoldRelease(x,y, holdMs) (long-press) drag <x,y> <x,y> --hold-ms <N> from == to (no movement) performs a pure long-press.
DragPath(...) (path builder) (obsolete) CLI interpolates; no builder needed.
TypeKeys(text) (per-keystroke) send-keys "<text>" --via send-input Default --via post-message only raises TextChanged; send-input raises a real per-character KeyDown — required by Interactive_OnKeyDown_Captures_Keys and Immediate_FiresOnEveryKeystroke_BeforeBlur.
ClearViaKeyboard() send-keys "ctrl+a delete"
CollapseSelectionToEnd() send-keys "end"
Tab() / ShiftTab() send-keys "tab" / send-keys "shift+tab"

Previously-identified gaps — all closed in #587

  • Drag threshold-crossing — closed by the internal 20-step interpolation (crosses the 4-DIP threshold on the first step).
  • Merge-overlay latch — closed by --dwell-ms.
  • Long-press — closed by --hold-ms with from == to.
  • Per-keystroke KeyDown — closed by --via send-input.

One nuance (not a blocker)

#587's drag interpolates a straight line from→to. Reactor's DragDrop_CancelledDrag_LeavesSourceIntact currently uses a non-collinear L-shaped path, but WinUI DnD resolves the drop at the release point (empty space → still "cancelled"), so the outcome is unchanged. All other drag paths are collinear, so the straight interpolation passes through the same points. No current test outcome depends on a true polyline. If a future test ever needs to route through a specific intermediate target mid-drag, #587 has no multi-waypoint drag — file a follow-up against winappCli at that point.

Work to do (reactor-side, gated on #587 being released)

  • Add two thin wrappers to WinAppUi: SendKeys(selector, keys, viaSendInput) and Drag(from, to, holdMs, dwellMs) shelling to the new verbs. Prefer passing selectors over screen coords — the CLI re-resolves + stabilizes the element (strictly better than our pre-captured .Rect).
  • Repoint call sites: UiElement.Type/Clear, DragDropTests, DockingInputTests, DockingTearOffE2ETests, GestureTests, EventHandlerTests, WinFormsTestBase. Drop the now-redundant Foreground() calls.
  • Delete tests/Reactor.AppTests/Infrastructure/InputInjector.cs.
  • Delete its unit tests in InfrastructureHelperTests.cs that cover workaround internals (NormalizeAbsoluteCoordinates, DragPath, TryMapKeyToken) — they retire with the helper.
  • Bump the pinned winapp CLI version in bootstrap.ps1 / CI to the release that includes build(deps): bump ws in /tests/stress_perf_rn/VirtualList #587.
  • Remove the [Retry(3)] attributes + per-file rationale comments on the input-injection tests if the native verbs prove less flaky (re-evaluate after a few CI runs; keep if still needed).
  • Update the code comments that reference winappCli Prepare 0.1.0-preview.4 release #562/Reactor core has hard type references to Charting (and Docking) — violates control-family isolation, leaks ~7.8 KB into AOT retail #498 as "pending".

Pointers

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions