gui: real RTL + no-download-logic checks; split into velox-gui-lib

Follow-up hardening after a review noted the RTL "check" verified nothing
(a .ts stub that no test loads), matching a session-wide pattern of
checks written against what should be true rather than what would break.

- Split the non-main() code into velox-gui-lib (STATIC) so tests link the
  real widgets/models, not a reimplementation.
- tst_rtl: builds the real MainWindow, flips layoutDirection, asserts the
  direction propagates to the central widget AND that the offline-banner
  QHBoxLayout actually mirrors (label x-position LTR vs RTL differs by
  >100px). Verified it fails when the banner is pinned LtR.
- gui_no_download_logic: a ctest that greps gui/src for curl_*/pwrite/
  sqlite/QSqlDatabase/QNetworkAccessManager and fails on a hit — CLAUDE.md
  §3 as an executable check. Verified it fails when a curl_ token is added.
- Still uncovered (noted, not claimed): that the translation catalogue
  loads and the right context/strings resolve at runtime.

Not covered here because the files are PKG/QA-owned: tools/bootstrap.sh
ships a package name that does not exist on 26.04 (libqt6svg6-dev; the
real one is qt6-svg-dev), and --check validates pkg-config outcomes
rather than the apt names it would install. Both, plus the same name in
AGENT-PKG-QA.md and the README, are written up apply-ready in
gui/docs/pkg-qa-requests-m1.md.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Ne28kx4VreeBWZv82Nksd
This commit is contained in:
2026-09-10 01:12:06 +04:00
co-authored by Claude Sonnet 5
parent 2a87abe96d
commit 2959b0f707
5 changed files with 270 additions and 28 deletions
+27 -5
View File
@@ -1,22 +1,44 @@
# GUI unit tests. Lane GUI.
#
# CLAUDE.md §5: a feature with no test does not exist. The model is the piece with real
# logic that can be tested headless — the progress patch must be a narrow dataChanged and
# must never reset the model (docs/03-gui-spec.md §1).
# CLAUDE.md §5: a feature with no test does not exist. Each test below has a concrete
# failure it catches — that is the bar, not "it runs green".
set(CMAKE_AUTOMOC ON)
find_package(Qt6 REQUIRED COMPONENTS Test)
# tst_downloadtablemodel — the model's logic, headless.
# Red when: a progress patch widens past the value columns, a reset slips into
# applyProgress, applyProgress starts synthesizing rows for unknown ids, or add/remove
# stops emitting rowsInserted/rowsRemoved.
add_executable(tst_downloadtablemodel
tst_downloadtablemodel.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../src/models/DownloadTableModel.cpp
)
target_include_directories(tst_downloadtablemodel PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../src)
target_compile_features(tst_downloadtablemodel PRIVATE cxx_std_23)
target_compile_options(tst_downloadtablemodel PRIVATE -Wall -Wextra -Wpedantic -Werror)
target_link_libraries(tst_downloadtablemodel PRIVATE Qt6::Core Qt6::Test)
add_test(NAME gui_downloadtablemodel COMMAND tst_downloadtablemodel)
set_tests_properties(gui_downloadtablemodel PROPERTIES LABELS "gui")
# tst_rtl — the real RTL check the GUI DoD asks for (the .ts stub alone verifies nothing).
# Red when: the main window stops propagating Qt::RightToLeft to its children, or the
# offline-banner layout is pinned so it does not mirror under RTL.
add_executable(tst_rtl tst_rtl.cpp)
target_compile_features(tst_rtl PRIVATE cxx_std_23)
target_compile_options(tst_rtl PRIVATE -Wall -Wextra -Wpedantic -Werror)
target_link_libraries(tst_rtl PRIVATE velox-gui-lib Qt6::Widgets Qt6::Test)
add_test(NAME gui_rtl COMMAND tst_rtl)
set_tests_properties(gui_rtl PROPERTIES
LABELS "gui"
ENVIRONMENT "QT_QPA_PLATFORM=offscreen")
# gui_no_download_logic — CLAUDE.md §3 as an executable check, not a hope.
# Red when: a download-logic token (curl, raw pwrite, sqlite, QSqlDatabase) appears
# under gui/src. grep exits 0 only when it finds a match, so a hit fails the test.
add_test(NAME gui_no_download_logic
COMMAND ${CMAKE_COMMAND}
-DGUI_SRC=${CMAKE_CURRENT_SOURCE_DIR}/../src
-P ${CMAKE_CURRENT_SOURCE_DIR}/no_download_logic.cmake)
set_tests_properties(gui_no_download_logic PROPERTIES LABELS "gui")