[Tests] Drive item views from a playback (#7819)

QtTesting's own `currentChanged` command aborts on a one-element row list, so
pqWidgetTestEventPlayer drives views itself:

- selectRow selects a row through the selection model, the whole row, without a
  mouse event
- clickRow left-clicks the centre of a cell, so the view's own handlers run
- doubleClickRow double-clicks it, for views whose double click acts

A tree addresses a row by the path of rows leading to it ("2/0" is the first
child of the third top-level row), and a click opens a collapsed path first.
Rows are model rows, so a filtered or sorted model counts the rows it shows.

Asserting what a command did needs QtTesting's check players, which the XML
source never reached: it marked every event an action, so `modelRowCount` was
rejected as unknown. An event now carries `type="check"` to be played as a
check.

Testing/item_view_test.xml drives the grouped settings navigation through
selectRow and clickRow and asserts the page stack followed.
Testing/deck_editor_double_click_test.xml proves the difference between the two
clicks: a single click on a card database row only selects it, a double click
adds the card to the deck.
This commit is contained in:
BruebachL 2026-11-10 09:12:10 +01:00 • committed by GitHub
parent f089414f1c
commit 0498ea8907
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 279 additions and 3 deletions

View file

@ -0,0 +1,34 @@
<events>
<!--
A single click and a double click differ, and only a double click acts.
The card database view adds the card under the mouse to the deck on
double click (CardDatabaseView::actDoubleClick); a single click only
moves the current row and updates the preview. Asserting the deck's row
count after each proves the MouseButtonDblClick event really reaches the
view, which a page-index assertion in the settings tree cannot show.
The visual deck editor shows its cards in a picture grid, which is not an
item view, so the addressable list is the one in its card database dock.
Which card lands in the deck does not matter: the test asserts that a
click adds nothing and a double click adds one.
Assertions carry type="check": QtTesting only reaches its check players
with a check event.
-->
<event widget="MainWindow/tabSupervisor/stackedWidget/TabHome/homeWidget/homeActionsScrollArea/qt_scrollarea_viewport/homeButtonsBox/homeCreateNewDeckButton" command="activate" arguments="" />
<event widget="MainWindow" command="process_events" arguments="1500" />
<!-- A fresh deck starts empty -->
<event widget="MainWindow/tabSupervisor/stackedWidget/TabDeckEditorVisual/deckDock/deckDockContents/deckSplitter/deckListPane/deckView" command="modelRowCount" arguments="0" type="check" />
<!-- A single click only selects the card -->
<event widget="MainWindow/tabSupervisor/stackedWidget/TabDeckEditorVisual/databaseDisplayDock/databaseDisplayDockContents/databaseDisplayWidget/databaseView" command="clickRow" arguments="0" />
<event widget="MainWindow" command="process_events" arguments="300" />
<event widget="MainWindow/tabSupervisor/stackedWidget/TabDeckEditorVisual/deckDock/deckDockContents/deckSplitter/deckListPane/deckView" command="modelRowCount" arguments="0" type="check" />
<!-- A double click adds the card -->
<event widget="MainWindow/tabSupervisor/stackedWidget/TabDeckEditorVisual/databaseDisplayDock/databaseDisplayDockContents/databaseDisplayWidget/databaseView" command="doubleClickRow" arguments="0" />
<event widget="MainWindow" command="process_events" arguments="300" />
<event widget="MainWindow/tabSupervisor/stackedWidget/TabDeckEditorVisual/deckDock/deckDockContents/deckSplitter/deckListPane/deckView" command="modelRowCount" arguments="1" type="check" />
</events>