diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-24 17:21:57 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-24 17:21:57 +0200 |
| commit | bf1d7ecf687adeadc98d60395a4efc7cb306e13f (patch) | |
| tree | 1ea9db1bdbb459bbf61b8537181d15d0ff1f2e36 /tests/test_calendarwindow.cpp | |
| parent | e6a96c8b966fd060090805d9a689187e1ed28468 (diff) | |
| download | qtmaildir-bf1d7ecf687adeadc98d60395a4efc7cb306e13f.tar.gz qtmaildir-bf1d7ecf687adeadc98d60395a4efc7cb306e13f.zip | |
fix: add the toolbar New button, sync the month controls, and let a stale save be retried
Diffstat (limited to 'tests/test_calendarwindow.cpp')
| -rw-r--r-- | tests/test_calendarwindow.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/test_calendarwindow.cpp b/tests/test_calendarwindow.cpp index 26f7237..c52f245 100644 --- a/tests/test_calendarwindow.cpp +++ b/tests/test_calendarwindow.cpp @@ -19,14 +19,17 @@ #include <QtTest> #include <QAction> #include <QApplication> +#include <QComboBox> #include <QDir> #include <QFile> #include <QFileInfo> #include <QLineEdit> #include <QMessageBox> #include <QPushButton> +#include <QSpinBox> #include <QTemporaryDir> #include <QTimer> +#include <QToolBar> #include <QUndoStack> #include <memory> @@ -120,6 +123,9 @@ private slots: void saveWritesAndUndoRestoresTheOriginalBytes(); void aNewEventGoesToTheDefaultCalendar(); void aStaleSaveKeepsTheFormAndTheSyncedFile(); + void theToolbarCarriesTheNewEventAction(); + void aFreshWindowShowsTheCurrentMonth(); + void aStaleSaveCanBeRetried(); }; void TestCalendarWindow::loadsAndSelects() @@ -218,5 +224,48 @@ void TestCalendarWindow::aStaleSaveKeepsTheFormAndTheSyncedFile() QCOMPARE(w->findChild<QLineEdit *>(QStringLiteral("eventTitle"))->text(), QStringLiteral("Mine")); } +void TestCalendarWindow::theToolbarCarriesTheNewEventAction() +{ + Fixture f; + std::unique_ptr<CalendarWindow> w(f.window()); + auto *bar = w->findChild<QToolBar *>(QStringLiteral("calendarToolbar")); + QVERIFY(bar); + auto *newEvent = w->findChild<QAction *>(QStringLiteral("newEvent")); + QVERIFY(newEvent); + QVERIFY(bar->actions().contains(newEvent)); +} + +void TestCalendarWindow::aFreshWindowShowsTheCurrentMonth() +{ + Fixture f; + std::unique_ptr<CalendarWindow> w( + new CalendarWindow(f.config, { QStringLiteral("me@example.org") }, + f.dir.filePath(QStringLiteral("uistate.conf")))); + const QDate today = QDate::currentDate(); + QCOMPARE(w->findChild<QComboBox *>(QStringLiteral("monthBox"))->currentData().toInt(), + today.month()); + QCOMPARE(w->findChild<QSpinBox *>(QStringLiteral("yearSpin"))->value(), today.year()); +} + +void TestCalendarWindow::aStaleSaveCanBeRetried() +{ + Fixture f; + std::unique_ptr<CalendarWindow> w(f.window()); + w->selectEvent(QStringLiteral("one@example.org")); + editTitle(w.get(), QStringLiteral("Mine")); + // A sync pulls a server change while the form is open. + const QByteArray synced = eventText(QStringLiteral("one@example.org"), QStringLiteral("Theirs"), 22); + writeFile(f.a(), synced); + w->findChild<QPushButton *>(QStringLiteral("saveEvent"))->click(); + QCOMPARE(read(f.a()), synced); // first Save refuses, nothing clobbered + QVERIFY(w->isEditing()); + + // The user checks what arrived and saves again deliberately: the form's + // bytes were rebased on the synced file, so this one lands. + w->findChild<QPushButton *>(QStringLiteral("saveEvent"))->click(); + QVERIFY(read(f.a()).contains("SUMMARY:Mine")); + QVERIFY(!w->isEditing()); +} + QTEST_MAIN(TestCalendarWindow) #include "test_calendarwindow.moc" |
