sendlaterinfotest.cpp 2.02 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
  Copyright (c) 2014 Montel Laurent <montel@kde.org>

  This program is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License, version 2, as
  published by the Free Software Foundation.

  This program is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  General Public License for more details.

  You should have received a copy of the GNU General Public License along
  with this program; if not, write to the Free Software Foundation, Inc.,
  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/

#include "sendlaterinfotest.h"
Laurent Montel's avatar
Laurent Montel committed
19
#include "../sendlaterinfo.h"
20
#include <qtest_kde.h>
Laurent Montel's avatar
Laurent Montel committed
21 22
#include <QDateTime>
#include <KConfigGroup>
23 24 25 26 27 28 29

SendLaterInfoTest::SendLaterInfoTest()
{
}

void SendLaterInfoTest::shouldHaveDefaultValue()
{
Laurent Montel's avatar
Laurent Montel committed
30 31 32 33 34 35 36 37 38 39
    SendLater::SendLaterInfo info;
    QCOMPARE(info.itemId(), Akonadi::Item::Id(-1));
    QCOMPARE(info.isRecurrence(), false);
    QVERIFY(!info.dateTime().isValid());
    QVERIFY(!info.lastDateTimeSend().isValid());
    QCOMPARE(info.to(), QString());
    QCOMPARE(info.subject(), QString());
    QVERIFY(!info.isValid());
    QCOMPARE(info.recurrenceUnit(), SendLater::SendLaterInfo::Days);
    QCOMPARE(info.recurrenceEachValue(), 1);
40 41
}

Laurent Montel's avatar
Laurent Montel committed
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
void SendLaterInfoTest::shouldRestoreFromSettings()
{
    SendLater::SendLaterInfo info;
    const QString to = QLatin1String("kde.org");
    info.setTo(to);
    info.setItemId(Akonadi::Item::Id(42));
    info.setSubject(QLatin1String("Subject"));
    info.setRecurrence(true);
    info.setRecurrenceEachValue(5);
    info.setRecurrenceUnit(SendLater::SendLaterInfo::Years);
    const QDate date(2014,1,1);
    info.setDateTime(QDateTime(date));
    info.setLastDateTimeSend(QDateTime(date));

    KConfigGroup grp(KGlobal::config(), "testsettings");
    info.writeConfig(grp);

    SendLater::SendLaterInfo restoreInfo(grp);
    QCOMPARE(info, restoreInfo);

}

64
QTEST_KDEMAIN(SendLaterInfoTest, NoGUI)