Repository navigation
Add script-driven UI test harness for internal builds - #1890
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 inINTERNAL_BLD_TESTINGbuilds)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 inExecuteOne()yields exactly one debugger stop per command.menu(by id or case-insensitive label /Menu/Sub/Itempath, with ambiguity reporting; optionalchecked/uncheckedstate),key(resolved from the live menu bar's accelerator text rather than a synthetic key event),navmenu(builds aNavPopupMenu, runsUpdateUIso 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./0/1/2index paths or declared names (names are not unique, so canonical paths are emitted);.or empty resolves to the current selection.Enabling changes
src/panels/navpopupmenu.{h,cpp}: newNavPopupMenu::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 viaProcessEventso effects are immediately observable.src/utils/cli_ui_guard.{h,cpp}: debug-onlySetScriptedDialogAnswer()(a modal-hookEnter()override returns the scripted answer instead of showing the dialog) andSetDialogObserver()to record each intercepted dialog's message and answer;wxID_NONErestores previous behavior.src/mainapp.cpp: hidden--dbg-ui-script/--dbg-ui-logoptions (log defaults to<script>.log);ui_harness::Start()is called after the main frame is shown.