Cockatrice/Testing
2026-11-04 16:17:51 +01:00
..
card_actions_test.xml [Tests] Play card interactions through a Cockatrice event player (#7697) 2026-11-04 06:23:45 +01:00
deck_editor_open_test.xml [Home] Keep actions bounded and reachable at every window height 2026-11-04 16:17:51 +01:00
deck_editor_search_test.xml [Home] Keep actions bounded and reachable at every window height 2026-11-04 16:17:51 +01:00
dialog_lifecycle_test.xml [Tests] Name the menus and dialogs the shell GUI tests drive (#7695) 2026-11-04 06:23:44 +01:00
game_mechanics_test.xml [Tests] Play card interactions through a Cockatrice event player (#7697) 2026-11-04 06:23:45 +01:00
integration_test.xml [Home] Keep actions bounded and reachable at every window height 2026-11-04 16:17:51 +01:00
local_game_lifecycle_test.xml [Tests] Play card interactions through a Cockatrice event player (#7697) 2026-11-04 06:23:45 +01:00
menu_open_close_test.xml [Tests] Name the menus and dialogs the shell GUI tests drive (#7695) 2026-11-04 06:23:44 +01:00
nonmodal_manage_sets_test.xml [Tests] Name the menus and dialogs the shell GUI tests drive (#7695) 2026-11-04 06:23:44 +01:00
nonmodal_tip_test.xml [Tests] Name the menus and dialogs the shell GUI tests drive (#7695) 2026-11-04 06:23:44 +01:00
nonmodal_view_log_test.xml [Tests] Name the menus and dialogs the shell GUI tests drive (#7695) 2026-11-04 06:23:44 +01:00
README.md [Tests] Play card interactions through a Cockatrice event player (#7697) 2026-11-04 06:23:45 +01:00
run_test.sh [Tests] Replay XML test files through a headless runner (#7694) 2026-11-04 06:23:43 +01:00
settings_dialog_test.xml [Tests] Name the menus and dialogs the shell GUI tests drive (#7695) 2026-11-04 06:23:44 +01:00
settings_navigation_test.xml [Tests] Assert settings navigation through the event player (#7698) 2026-11-04 06:23:45 +01:00
settings_search_test.xml [Tests] Name the tab, home and settings widgets the GUI tests address (#7696) 2026-11-04 06:23:44 +01:00
smoke_test.xml [Tests] Replay XML test files through a headless runner (#7694) 2026-11-04 06:23:43 +01:00

GUI tests

Widget-level playback tests for the Cockatrice client, driven by QtTesting (external/qttesting, a submodule). Each *_test.xml file is a list of events that QtTesting replays against the running application; a test passes when every event is handled without error.

Running

git submodule update --init external/qttesting      # once
cmake -S . -B build/debug -DCMAKE_BUILD_TYPE=Debug -DWITH_SERVER=0 -DWITH_GUI_TEST=ON
cmake --build build/debug -j 24

./Testing/run_test.sh --all                        # headless, offscreen
./Testing/run_test.sh Testing/smoke_test.xml       # one file
./Testing/run_test.sh --visual Testing/smoke_test.xml   # shows the window

WITH_GUI_TEST is on by default; a checkout without the submodule configures with a warning and no harness. COCKATRICE_BIN points the runner at another build, and TEST_TIMEOUT (seconds, default 180) bounds a single test — a failing event inside a modal dialog can otherwise leave the process alive. The client also hard-exits a few seconds after playback returns, whatever the result.

The tests are not part of ctest: they need a card database and a developer's settings, so they stay a local loop for now.

Caveats

  • Not hermetic. The client reads the local settings and card database, so a test can pass on one machine and fail on another. Avoid asserting things that restored workspace state or user preferences decide (for example the number of open tabs).
  • English labels only. Menu entries are addressed by their (translated) text, so the tests expect the source language. Widgets are addressed by objectName paths, which are stable across translations.
  • Actions that open a dialog are followed by a pause event: playback continues in the dialog's own event loop, and the pause gives the UI time to build itself.
  • Widget paths include Qt-internal names where a QTabWidget is involved (qt_tabwidget_stackedwidget), and the deck views in a game are indexed (tabbedDeckView_0, tabbedDeckView_1).

Writing a test

A test is a <events> list. Widgets are named by their path from the main window, e.g. MainWindow/tabSupervisor/stackedWidget/TabGame/phasesMenu. Useful commands:

Command Arguments Effect
activate action or menu name triggers a QAction (menus are opened first)
key Qt key code presses that key on the focused widget
pause milliseconds waits, letting the UI settle
clickCard card,zone double click the card found in that zone (plays it from hand)
flipCard card,zone right-click → Turn Over
cardAction card,zone,label right-click → first menu entry whose label contains label (submenus included)
moveCard card,srcZone,dstZone drags the card onto the destination zone
drawArrow srcCard,srcZone,dstCard,dstZone right-drag an arrow between two cards
createToken name,color,pt creates a token as the active local player
selectItem item label selects the tree/list entry with that label
typeText text types text one key event at a time
expectProperty property,value fails playback unless the widget property matches

The card, item and property commands are pqCockatriceEventPlayer (cockatrice/src/game_graphics/pq_cockatrice_event_player.h). They resolve cards by name and zone through the QGraphicsScene and send real mouse events at the card's current viewport position, so a test does not depend on the window size or screen resolution.