Files
vdm/gui/tests/CMakeLists.txt
T
samiandClaude Sonnet 5 a71d904a1f gui: finish Add URL -> File Info -> Progress dialog flow
Wires up the three dialogs from build order step 5 (docs/03-gui-spec.md
§§2-3) and the MainWindow slots that were declared but never implemented:

- AddUrlDialog: clipboard prefill is the explicit path docs/06 R2 calls
  for (no passive monitoring, not advertised).
- FileInfoDialog: async download.probe never blocks the UI; ends by
  calling download.add itself (Now / Later / Add to Queue). buildSpec()
  is a pure static so the optional-field-omission logic is unit-testable
  without touching a widget.
- ProgressDialog: non-modal, WA_DeleteOnClose, driven by the taskProgress/
  taskStateChanged signals RpcClient already re-broadcasts; download.get
  seeds state once for a dialog opened mid-transfer. Hosts SegmentBarsWidget
  and SpeedGraphWidget.

MainWindow: openAddUrlDialog/openPropertiesForSelection/showTableContextMenu
now have bodies; category.list/queue.list responses are cached so File Info
can populate its category combo and queue menu without a second round trip.
The row context menu covers what already exists (Resume/Pause/Stop/Delete/
Properties) and deliberately leaves out Open/Open With/Move-Rename/
Redownload/Add to Queue — those need dialogs later build-order steps haven't
reached yet.

util/Format.hpp: pulled the bytes/rate/eta formatting out of MainWindow and
DownloadTableModel once the dialogs wanted the same strings a third time.

Verified end-to-end against a running mockd (category.list/queue.list,
download.probe, download.add, download.get, and live event.task.progress/
event.task.state) under ASan+UBSan: all three dialogs render correctly
against real fixture data and the flow runs clean with no leaks or
sanitizer reports.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NSCdCWFXBTSBBK3MzWtJiC
2026-09-11 12:11:13 +04:00

93 lines
5.0 KiB
CMake

# GUI unit tests. Lane GUI.
#
# 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_downloadfilterproxy — the category-tree filter.
# Red when: a node stops filtering to its own rows, the Finished/Unfinished split
# misclassifies a state, or the filter stops being dynamic.
add_executable(tst_downloadfilterproxy tst_downloadfilterproxy.cpp)
target_compile_features(tst_downloadfilterproxy PRIVATE cxx_std_23)
target_compile_options(tst_downloadfilterproxy PRIVATE -Wall -Wextra -Wpedantic -Werror)
target_link_libraries(tst_downloadfilterproxy PRIVATE velox-gui-lib Qt6::Test)
add_test(NAME gui_downloadfilterproxy COMMAND tst_downloadfilterproxy)
set_tests_properties(gui_downloadfilterproxy 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")
# tst_segmentbarswidget — the per-connection bar grid.
# Red when: a determinate segment stops rendering its percentage, an unknown-length
# segment stops falling back to the indeterminate range, a shrinking segment set
# destroys rows instead of hiding them, or rows start getting rebuilt per tick.
add_executable(tst_segmentbarswidget tst_segmentbarswidget.cpp)
target_compile_features(tst_segmentbarswidget PRIVATE cxx_std_23)
target_compile_options(tst_segmentbarswidget PRIVATE -Wall -Wextra -Wpedantic -Werror)
target_link_libraries(tst_segmentbarswidget PRIVATE velox-gui-lib Qt6::Widgets Qt6::Test)
add_test(NAME gui_segmentbarswidget COMMAND tst_segmentbarswidget)
set_tests_properties(gui_segmentbarswidget PROPERTIES
LABELS "gui"
ENVIRONMENT "QT_QPA_PLATFORM=offscreen")
# tst_speedgraphwidget — the 60 s rolling speed graph.
# Red when: addSample stops throttling bursts to 1 Hz, the bucket count stops
# incrementing on genuinely separated samples, clear() leaves stale state, or painting
# crashes before two samples exist.
add_executable(tst_speedgraphwidget tst_speedgraphwidget.cpp)
target_compile_features(tst_speedgraphwidget PRIVATE cxx_std_23)
target_compile_options(tst_speedgraphwidget PRIVATE -Wall -Wextra -Wpedantic -Werror)
target_link_libraries(tst_speedgraphwidget PRIVATE velox-gui-lib Qt6::Widgets Qt6::Test)
add_test(NAME gui_speedgraphwidget COMMAND tst_speedgraphwidget)
set_tests_properties(gui_speedgraphwidget PROPERTIES
LABELS "gui"
ENVIRONMENT "QT_QPA_PLATFORM=offscreen")
# tst_fileinfodialog — FileInfoDialog::buildSpec, the pure DownloadSpec builder.
# Red when: an empty optional field starts getting sent instead of omitted, or the
# queueId stops being dropped for a startMode other than "queue".
add_executable(tst_fileinfodialog tst_fileinfodialog.cpp)
target_compile_features(tst_fileinfodialog PRIVATE cxx_std_23)
target_compile_options(tst_fileinfodialog PRIVATE -Wall -Wextra -Wpedantic -Werror)
target_link_libraries(tst_fileinfodialog PRIVATE velox-gui-lib Qt6::Widgets Qt6::Test)
add_test(NAME gui_fileinfodialog COMMAND tst_fileinfodialog)
set_tests_properties(gui_fileinfodialog 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")