Skip to content

test: add more integration style tests#308

Draft
trin94 wants to merge 3 commits intomainfrom
test/application-menu-bar-interaction
Draft

test: add more integration style tests#308
trin94 wants to merge 3 commits intomainfrom
test/application-menu-bar-interaction

Conversation

@trin94
Copy link
Copy Markdown
Member

@trin94 trin94 commented Apr 25, 2026

No description provided.

trin94 added 3 commits April 25, 2026 12:54
The ApplicationWindow tangled window-shell concerns with the menu
bar, loaders, and view-model wiring, and embedded a native mpv
framebuffer object that requires a live GL surface and cannot be
re-instantiated cleanly between tests. QML tests of the menu bar
were therefore blocked: the first forces an ApplicationWindow
nested inside a TestCase Item, the second crashes on the second
instantiation under a real platform window.

Splitting the content into MpvqcApplicationContent (a plain Item)
gives tests a shell-free root to drive. Swapping the player for a
stub when the test setup defines the `mpvqcTestMode` context
property frees the FBO from test re-instantiation, so each test
starts clean under both offscreen and visible-window runs. The
stub is excluded from release builds alongside other test-only
files.
Menu items, dialogs, message boxes, and loaders need stable
handles for QML tests to drive without relying on translated
text or layout positions. Adding `objectName`s across the menu
bar (including its radio and language submenus) and onto every
dialog, message-box, and loader root gives findChild a naming-
convention-driven map of the testable surface.

A smoke test exercises Help → About end-to-end as the canonical
pattern future menu-bar tests will follow. The menu is opened
via `menu.open()` rather than mouseClick — Menu is a Popup, not
an Item, so QtTest rejects it as a click target — then the
About item is clicked and the dialog loader's loaded item is
observed by `objectName`.
The qmltestrunner setup previously lived in `test/prepare_qml.py`
alongside pytest fixtures, blurring the line between two independent
test stacks that share no scope. Splitting them into separate
top-level packages makes each runner's home obvious and lets the
QML test infra grow without polluting pytest's space.

Two pre-existing footguns get fixed in passing. Settings now go to a
per-process tempdir instead of the real user ini, so QML tests can
no longer overwrite developer preferences. A QML-callable test
bridge wraps `inject.configure(...)`, letting tests reset the
service container between runs and removing a class of state leakage
that previously had to be accepted as-is.

The `test-qml` Justfile recipe collapses from a 14-line inline-Python
heredoc to `uv run -m testqml.main`, putting the entry point on the
same lint and type-check footing as the rest of the codebase.
Comment thread testqml/main.py
from PySide6.QtQml import QQmlEngine
from PySide6.QtQuickTest import QUICK_TEST_MAIN_WITH_SETUP

import testqml.bridge # noqa: F401, registers MpvqcTestBridge
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