feat(mobile): support installed ArkUI apps on local HarmonyOS phones

FR
1d ago
+388-77

What

Run a screen-based test against an installed ArkUI app on one local HarmonyOS phone:

{ engine: mobile({ platform: 'harmonyos' }), app: { bundleId: 'com.example.e2ecounter' } }

Why

agent-device already drives a physical phone over HDC. The mobile target lets a suite use the same app launch, locators, assertions and screenshot artifacts as its other device tests.

How it works

  1. The pool resolves a phone name or HDC serial, then the worker binds strictly to that serial. If the phone disconnects, worker startup fails. See packages/mobile/src/pool.ts:94.
  2. The engine declares taps and screenshots for the local target. ArkUI text and button captions reach screen locators, and HDC JPEG captures are converted to PNG before masking or saving. See packages/mobile/src/engine.ts:32, packages/mobile/src/nodes.ts:728 and packages/mobile/src/png.ts:27.
  3. The physical-device guide includes the target configuration and counter test. Select a phone with --device <serial> when several are connected.

Issue

Closes #2174.

Verified

Ran it locally: yes.

  • Huawei Mate X5 (ALT-AL10), API 26, agent-device 0.21.44, e2e 0.25.0. With two phones connected, ran the config and test from the guide against the local npm tarball using e2e run --device <X5 serial> --repeat-each 3. All three runs launched the counter at 0, tapped the increment button, asserted 1, and saved a 2224 × 2496 PNG. OCR read the updated count in all three images.
  • An earlier implementation also passed the launch, tap and counter assertions on a Mate 70 Air (API 26, agent-device 0.21.42).
  • Mobile package build, typecheck, lint and all 729 tests passed. Regression tests cover a second phone named after the disconnected phone's serial and check the PNG file written by the engine when the driver supplies JPEG bytes.

Checklist

  • Added a changeset for the mobile package and bundled CLI guide.
  • Updated the mobile guide, package README, reference, and bundled skill.
  • Checked the mobile platform types at compilation and tested runtime device selection.

Summary by CodeRabbit

  • New Features
    • Run mobile tests on local HarmonyOS phones with an installed ArkUI app. Select a connected phone by HDC serial or name, then interact with and assert on its interface.
    • HarmonyOS screenshots and button and text content are available for UI testing.
  • Documentation
    • Added HarmonyOS setup guidance, including HDC requirements, app configuration, and device selection.
  • Limitations
    • HarmonyOS supports tapping, screenshots, and session restart. App installation and other device operations are unavailable.