1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
/*
This file is part of the kcalcore library.
Copyright (C) 2007-2008 Allen Winter <winter@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "testjournal.h"
#include "journal.h"
#include <QTest>
QTEST_MAIN(JournalTest)
using namespace KCalCore;
void JournalTest::testValidity()
{
QDate dt = QDate::currentDate();
Journal *journal = new Journal();
journal->setDtStart(QDateTime(dt, {}));
journal->setAllDay(true);
journal->setSummary(QStringLiteral("Journal Summary"));
journal->setDescription(QStringLiteral("This is a description of my journal"));
journal->setLocation(QStringLiteral("the place"));
//KDE5: QVERIFY( journal->typeStr() == QStringLiteral( "journal" ) );
QVERIFY(journal->summary() == QLatin1String("Journal Summary"));
QVERIFY(journal->location() == QLatin1String("the place"));
}
void JournalTest::testCompare()
{
QDate dt = QDate::currentDate();
Journal journal1;
journal1.setDtStart(QDateTime(dt, {}));
journal1.setAllDay(true);
journal1.setSummary(QStringLiteral("Journal Summary"));
journal1.setDescription(QStringLiteral("This is a description of my journal"));
journal1.setLocation(QStringLiteral("the place"));
Journal journal2;
journal2.setDtStart(QDateTime(dt, {}).addDays(1));
journal2.setAllDay(true);
journal2.setSummary(QStringLiteral("Journal2 Summary"));
journal2.setDescription(QStringLiteral("This is a description of another journal"));
journal2.setLocation(QStringLiteral("the other place"));
QVERIFY(!(journal1 == journal2));
QVERIFY(journal2.summary() == QLatin1String("Journal2 Summary"));
}
void JournalTest::testClone()
{
QDate dt = QDate::currentDate();
Journal journal1;
journal1.setDtStart(QDateTime(dt, {}));
journal1.setAllDay(true);
journal1.setSummary(QStringLiteral("Journal1 Summary"));
journal1.setDescription(QStringLiteral("This is a description of the first journal"));
journal1.setLocation(QStringLiteral("the place"));
Journal *journal2 = journal1.clone();
QVERIFY(journal1.summary() == journal2->summary());
QVERIFY(journal1.dtStart() == journal2->dtStart());
QVERIFY(journal1.description() == journal2->description());
QVERIFY(journal1.location() == journal2->location());
}
void JournalTest::testRich()
{
QDate dt = QDate::currentDate();
Journal journal1;
journal1.setDtStart(QDateTime(dt, {}));
journal1.setAllDay(true);
journal1.setSummary(QStringLiteral("<html><b><i>Journal1 Summary</i></b></html>"), true);
journal1.setDescription(QStringLiteral("<html>This is a of the <b>first</b> journal</html>"), true);
journal1.setLocation(QStringLiteral("<qt><h1>the place</h1></qt>"), true);
QVERIFY(journal1.summaryIsRich());
QVERIFY(journal1.descriptionIsRich());
QVERIFY(journal1.locationIsRich());
}
void JournalTest::testAssign()
{
QDate dt = QDate::currentDate();
Journal journal1;
journal1.setDtStart(QDateTime(dt, {}));
journal1.setAllDay(true);
journal1.setSummary(QStringLiteral("Journal1 Summary"));
journal1.setDescription(QStringLiteral("This is a description of the first journal"));
journal1.setLocation(QStringLiteral("the place"));
Journal journal2 = journal1;
QVERIFY(journal1 == journal2);
}
void JournalTest::testSerializer_data()
{
QTest::addColumn<KCalCore::Journal::Ptr>("journal");
Journal::Ptr journal1 = Journal::Ptr(new Journal());
QTest::newRow("journal") << journal1;
}
void JournalTest::testSerializer()
{
QFETCH(KCalCore::Journal::Ptr, journal);
IncidenceBase::Ptr incidenceBase = journal.staticCast<KCalCore::IncidenceBase>();
QByteArray array;
QDataStream stream(&array, QIODevice::WriteOnly);
stream << incidenceBase;
Journal::Ptr journal2 = Journal::Ptr(new Journal());
IncidenceBase::Ptr incidenceBase2 = journal2.staticCast<KCalCore::IncidenceBase>();
QVERIFY(*journal != *journal2);
QDataStream stream2(&array, QIODevice::ReadOnly);
stream2 >> incidenceBase2;
QVERIFY(*journal == *journal2);
}
|