Files
vdm/gui/tests/tst_schedulerdialog.cpp
samiandClaude Sonnet 5 de83ee3cce gui: Options, Scheduler, Speed Limiter, Batch, Grabber, and the tray icon
Continues the build order past the Add-URL/File-Info/Progress dialog flow.

- OptionsDialog: General/Save To/Connection/Downloads/Proxy/Sounds tabs, every
  control bound to a real settings.* key (contracts/schema/types/Settings.
  schema.json). The spec's File Types and Site Logins tabs have no settings.*
  backing (categories go through category.upsert, credentials through the
  Secret Service) so they don't exist here — a tab either binds to a real key
  or isn't shipped. diffChanged() sends only what actually changed, matching
  settings.set's "changed[] names exactly what took effect" contract.
- SchedulerDialog: per-queue schedule (schedule.get/set) plus maxConcurrent/
  onComplete (queue.upsert), Start Now/Stop. Queue.schema.json already carries
  the schedule so queue.list alone seeds the window.
- SpeedLimiterDialog: the live global limiter (limiter.get/set) — a different
  thing from Options' downloads.speedLimit* default. buildParams() enforces
  the schema's "0 with enabled true must not be offered".
- BatchDialog: clipboard-blob and {start..end}-wildcard tabs sharing one
  category/queue/start-mode footer into download.addBatch.
- GrabberWizard: 4-step QWizard (project label -> start URL/depth/filters ->
  file-type filter -> review), grabber.start feeding a poll+event.grabber.
  progress-driven review page, Finish = grabber.harvest for the checked files.
- TrayIcon: active-count tooltip, Show/Add URL/Pause All/Resume All/Speed
  Limiter submenu/Quit. Quit only closes the GUI — there is no RPC to stop
  veloxd itself, filed as a new gap in daemon-requests-m1.md. MainWindow now
  also hides to tray instead of closing when general.minimizeToTray is set.

Every dialog's non-widget logic (diffChanged, buildSchedule, buildParams,
parseUrlBlob/expandWildcard/buildAddBatchParams, buildFileTypes/
buildStartParams/buildHarvestParams) is a static pure function with its own
test, same shape as FileInfoDialog::buildSpec from the previous round.

Verified end-to-end against a running mockd under ASan+UBSan: all five
surfaces render real data (settings.get values, queue.list's two seeded
queues, limiter.get, a live grabber.start/status crawl returning 3 files) with
no sanitizer reports. gui-check (non-ASan) and dev (ASan+UBSan) presets both
build the whole repo clean; all gui-labeled ctest targets pass.

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

63 lines
2.3 KiB
C++

// SchedulerDialog::buildSchedule unit tests. Lane GUI.
//
// Red when unchecking "use a schedule" stops sending JSON null (Schedule.schema.json:
// null clears it and leaves the queue under manual control), "run until it drains" stops
// nulling stopTime, or daysOfWeek/onceDate leak into the mode that ignores them.
#include <QJsonArray>
#include <QtTest>
#include "dialogs/SchedulerDialog.hpp"
using velox::gui::SchedulerDialog;
class TstSchedulerDialog : public QObject {
Q_OBJECT
private slots:
void disabledIsNull();
void periodicIncludesDaysNotOnceDate();
void onceIncludesOnceDateNotDays();
void runUntilDrainsNullsStopTime();
void explicitStopTimeIsKept();
};
void TstSchedulerDialog::disabledIsNull() {
const QJsonValue v =
SchedulerDialog::buildSchedule(false, "once", "09:00", true, "17:00", {}, "2026-01-01");
QVERIFY(v.isNull());
}
void TstSchedulerDialog::periodicIncludesDaysNotOnceDate() {
const QJsonValue v = SchedulerDialog::buildSchedule(true, "periodic", "09:00", true, "17:00",
{1, 3, 5}, "2026-01-01");
QVERIFY(v.isObject());
const QJsonObject s = v.toObject();
QCOMPARE(s.value("mode").toString(), QStringLiteral("periodic"));
QCOMPARE(s.value("daysOfWeek").toArray().size(), 3);
QVERIFY(!s.contains("onceDate"));
}
void TstSchedulerDialog::onceIncludesOnceDateNotDays() {
const QJsonValue v = SchedulerDialog::buildSchedule(true, "once", "09:00", true, "17:00",
{1, 3, 5}, "2026-01-01");
const QJsonObject s = v.toObject();
QCOMPARE(s.value("onceDate").toString(), QStringLiteral("2026-01-01"));
QVERIFY(!s.contains("daysOfWeek"));
}
void TstSchedulerDialog::runUntilDrainsNullsStopTime() {
const QJsonValue v =
SchedulerDialog::buildSchedule(true, "once", "09:00", true, "17:00", {}, "2026-01-01");
QVERIFY(v.toObject().value("stopTime").isNull());
}
void TstSchedulerDialog::explicitStopTimeIsKept() {
const QJsonValue v =
SchedulerDialog::buildSchedule(true, "once", "09:00", false, "17:00", {}, "2026-01-01");
QCOMPARE(v.toObject().value("stopTime").toString(), QStringLiteral("17:00"));
}
QTEST_MAIN(TstSchedulerDialog)
#include "tst_schedulerdialog.moc"