File indexing completed on 2024-04-21 03:52:42

0001 /*
0002  *  SPDX-FileCopyrightText: 2022 Glen Ditchfield <GJDitchfield@acm.org>
0003  *  SPDX-License-Identifier: LGPL-2.0-or-later
0004  */
0005 
0006 #include "event.h"
0007 #include "incidence.h"
0008 #include "journal.h"
0009 #include "todo.h"
0010 
0011 #include <QTest>
0012 
0013 using namespace KCalendarCore;
0014 
0015 class TestStatus: public QObject
0016 {
0017     Q_OBJECT
0018 private Q_SLOTS:
0019 
0020     void testOnlyValidStatusAllowed_data()
0021     {
0022         QTest::addColumn<Incidence::Status>("status");
0023         QTest::addColumn<bool>("okForEvent");
0024         QTest::addColumn<bool>("okForTodo");
0025         QTest::addColumn<bool>("okForJournal");
0026 
0027         QTest::newRow("StatusNone") << Incidence::StatusNone << true << true << true;
0028         QTest::newRow("StatusTentative") << Incidence::StatusTentative << true << false << false;
0029         QTest::newRow("StatusConfirmed") << Incidence::StatusConfirmed << true << false << false;
0030         QTest::newRow("StatusCompleted") << Incidence::StatusCompleted << false << true << false;
0031         QTest::newRow("StatusNeedsAction") << Incidence::StatusNeedsAction << false << true << false;
0032         QTest::newRow("StatusCanceled") << Incidence::StatusCanceled << true << true << true;
0033         QTest::newRow("StatusInProcess") << Incidence::StatusInProcess << false << true << false;
0034         QTest::newRow("StatusDraft") << Incidence::StatusDraft << false << false << true;
0035         QTest::newRow("StatusFinal") << Incidence::StatusFinal << false << false << true;
0036         QTest::newRow("StatusX") << Incidence::StatusX << false << false << false;
0037     }
0038 
0039     void testOnlyValidStatusAllowed()
0040     {
0041         QFETCH(Incidence::Status, status);
0042         QFETCH(bool, okForEvent);
0043         QFETCH(bool, okForTodo);
0044         QFETCH(bool, okForJournal);
0045 
0046         Event e;
0047         e.setStatus(status);
0048         QVERIFY( (e.status() == status) == okForEvent);
0049 
0050         Todo t;
0051         t.setStatus(status);
0052         QVERIFY( (t.status() == status) == okForTodo);
0053 
0054         Journal j;
0055         j.setStatus(status);
0056         QVERIFY( (j.status() == status) == okForJournal);
0057     }
0058 };
0059 
0060 QTEST_MAIN(TestStatus)
0061 #include "teststatus.moc"
0062