Skip to content

Add script-driven UI test harness for internal builds - #1890

Merged
Randalphwa merged 2 commits into
mainfrom
internal_dbg_ui
Oct 8, 2026
Merged

Randalphwa merged 2 commits into
mainfrom
internal_dbg_ui

Conversation

@Randalphwa

@Randalphwa Randalphwa commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Summary

Add a debug-only script-driven harness that can drive the running editor's UI from a command file, for automated UI testing under a debugger.

Motivation

An external agent/debugger needs to exercise editor UI actions (menu commands, context-menu commands, selection, undo/redo) against a live wxUiEditor instance, observe results, and answer modal dialogs — without a human at the keyboard. Synthetic wxKeyEvents bypass wxWidgets accelerator processing, so the harness drives real menu/undo code paths directly.

Changes

Core: UI harness (src/internal/ui_harness.cpp/.h, compiled only in INTERNAL_BLD_TESTING builds)

  • ui_harness::Start(script, log) appends commands to a script file; a 100 ms timer reads it and executes at most one command per tick, so a breakpoint in ExecuteOne() yields exactly one debugger stop per command.
  • Verbs: menu (by id or case-insensitive label / Menu/Sub/Item path, with ambiguity reporting; optional checked/unchecked state), key (resolved from the live menu bar's accelerator text rather than a synthetic key event), navmenu (builds a NavPopupMenu, runs UpdateUI so per-item preconditions apply, invokes by id or label), select, undo, redo, func (registry extension point for non-menu actions), dialogs (scripted modal answers), dump tree|menubar|navmenu|undo|selection, marker, quit.
  • Node addressing via canonical /0/1/2 index paths or declared names (names are not unique, so canonical paths are emitted); . or empty resolves to the current selection.
  • UTF-8 log written with flush-per-line so an agent can read results while the process is paused at a breakpoint; falls back to stderr if the log file can't open. Dialog interceptions are logged via an observer; commented lines and CRLF tolerated.

Enabling changes

  • src/panels/navpopupmenu.{h,cpp}: new NavPopupMenu::InvokeCommand(int) — resolves the item by walking the item list recursively (wxMenu::FindItem does not reliably descend into submenus), rejects separators/disabled items, and dispatches synchronously via ProcessEvent so effects are immediately observable.
  • src/utils/cli_ui_guard.{h,cpp}: debug-only SetScriptedDialogAnswer() (a modal-hook Enter() override returns the scripted answer instead of showing the dialog) and SetDialogObserver() to record each intercepted dialog's message and answer; wxID_NONE restores previous behavior.
  • src/mainapp.cpp: hidden --dbg-ui-script / --dbg-ui-log options (log defaults to <script>.log); ui_harness::Start() is called after the main frame is shown.

Adds a debug-only UI command harness (src/internal/ui_harness.cpp) that
drives the editor from a script, compiled into internal-testing builds
via cmake/internal.cmake and launched by mainapp behind the
INTERNAL_TESTING guard.

NavPopupMenu::InvokeCommand lets scripts fire menu commands
programmatically by recursively locating items and dispatching them
synchronously.

CLI UI guard gains scripted dialog hooks: SetScriptedDialogAnswer
returns a fixed answer for intercepted modal dialogs and
SetDialogObserver reports each dialog's message, enabling unattended
scripted runs. Release builds are unaffected.
@Randalphwa
Randalphwa marked this pull request as ready for review October 8, 2026 05:33
@Randalphwa
Randalphwa merged commit 37c74b1 into main Oct 8, 2026
7 checks passed
@Randalphwa
Randalphwa deleted the internal_dbg_ui branch October 8, 2026 05:34
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