Skip to content

test(native): gesture replay fixture loader + disabled recognizer scaffold (#78)#96

Merged
AsafMah merged 1 commit into
devfrom
feat/native-gesture-replay
Jun 12, 2026
Merged

test(native): gesture replay fixture loader + disabled recognizer scaffold (#78)#96
AsafMah merged 1 commit into
devfrom
feat/native-gesture-replay

Conversation

@AsafMah

@AsafMah AsafMah commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Part of #78 deliverable 2. This is the honest first increment: it adds the fixture/replay test harness path and documents the two native seams that block a real recognizer assertion in host CI.

What

  • tests/replay/trace_fixture.h — header-only parser + structs for TraceRecorder-style JSON fixtures.
  • tests/replay/fixtures/hello_qwerty.json — seed hello QWERTY trace (14 samples).
  • tests/replay/gesture_replay_test.cpp — 9 enabled parser/fixture tests + 1 DISABLED_GestureReplayTest.ReplayHelloQwerty scaffold.
  • CMakeLists.txt — exposes FIXTURE_DIR to host tests.

Why the recognizer assertion is disabled

The parser path is CI-ready, but a real host recognizer replay needs two explicit seams:

  1. ProximityInfo requires a live JNIEnv* — its constructor calls env->GetArrayLength(...) unconditionally. Fix: add a non-JNI constructor accepting raw arrays, or a tiny JNIEnv shim for host tests.
  2. Dictionary requires a compiled binary .dict asset — the source tree doesn't ship one. Fix: bundle/fetch a small compiled en-US dict, or generate a tiny v4 dict in the test using existing writer classes.

No fake pass: the real assertion stays disabled until those seams are solved.

Verification

Subagent ran the native host suite on Ubuntu 24.04 / g++ 13 / cmake 3.28: 76/76 enabled tests pass, 1 disabled (GestureReplayTest.ReplayHelloQwerty).

…e 2)

Add a native gesture-replay harness that can consume TraceRecorder JSON
fixtures and run inside the existing host CMake / ctest workflow.

New files:
  tests/replay/trace_fixture.h
    Header-only C++17 fixture loader (parseFixture / loadFixture).
    Parses the TraceRecorder schema (version 1) into plain structs with
    xCoordinates() / yCoordinates() / times() / pointerIds() accessors
    ready to forward to Suggest::getSuggestions once blockers are lifted.

  tests/replay/gesture_replay_test.cpp
    TraceFixtureParserTest (9 enabled tests) — cover JSON parsing,
    accessor arrays, monotonic timestamps, coordinate bounds, escape
    handling, and empty-pointer edge cases.
    DISABLED_GestureReplayTest.ReplayHelloQwerty — compile-checked
    scaffold documenting the exact API seam and two concrete blockers.

  tests/replay/fixtures/hello_qwerty.json
    Seed fixture: 14-sample "hello" trace on a 1080×310 QWERTY keyboard
    (en-US).  Consumed by TraceFixtureParserTest.LoadsHelloQwertyFromFile.

CMakeLists.txt:
  Add target_compile_definitions(FIXTURE_DIR=...) so the file-path test
  resolves the fixture directory at compile time without network access.

Blockers documented in gesture_replay_test.cpp (DISABLED_ comment block):
  1. ProximityInfo requires a live JNIEnv* — calls env->GetArrayLength()
     unconditionally in its constructor; no non-JNI overload exists.
     Fix: add a raw-pointer constructor or a fake-JNIEnv shim.
  2. Dictionary requires a compiled binary .dict asset not in the tree.
     Fix: bundle a small en_US dict via CMake FetchContent, or generate
     one programmatically using the existing v4 writer classes.

ctest result: 76/76 pass, 1 disabled (GestureReplayTest.ReplayHelloQwerty)
@AsafMah AsafMah merged commit 65846f5 into dev Jun 12, 2026
2 checks passed
@AsafMah AsafMah deleted the feat/native-gesture-replay branch June 12, 2026 16:36
AsafMah added a commit that referenced this pull request Jun 13, 2026
#78) (#104)

Follow-up proof spike after #96. Add a non-JNI ProximityInfo constructor that
accepts the same keyboard geometry as raw int/float arrays, so native host tests
can build a keyboard geometry object without a live JVM/JNIEnv.

Adds GestureReplayHostSeamTest.BuildsProximityInfoWithoutJNI: constructs a
minimal QWERTY ProximityInfo and verifies key lookup for the 'hello' trace.

Attempted to enable the full replay assertion with an in-memory dict; ASAN showed
the next blocker is more fundamental than a dict asset: the open-source tree has
no GestureSuggestPolicy implementation, only GestureSuggestPolicyFactory, whose
factory method is null in host builds. Dictionary::getSuggestions(...,
IS_GESTURE) therefore crashes at TRAVERSAL->getMaxSpatialDistance(). The disabled
replay scaffold now documents that real blocker.

Verification (WSL / ubuntu-like): native host ctest excluding the known
FormatUtils quarantine -> 77/77 enabled tests pass, 1 disabled replay assertion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant