Commit 32a8d74b authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add new unittest

parent f69321af
...@@ -138,6 +138,18 @@ QString SendLaterInfo::to() const ...@@ -138,6 +138,18 @@ QString SendLaterInfo::to() const
return mTo; return mTo;
} }
bool SendLaterInfo::operator ==(const SendLaterInfo &other) const
{
return (itemId() == other.itemId()) &&
(recurrenceUnit() == other.recurrenceUnit()) &&
(recurrenceEachValue() == other.recurrenceEachValue()) &&
(isRecurrence() == other.isRecurrence()) &&
(dateTime() == other.dateTime()) &&
(lastDateTimeSend() == other.lastDateTimeSend()) &&
(subject() == other.subject()) &&
(to() == other.to());
}
void SendLaterInfo::readConfig(const KConfigGroup &config) void SendLaterInfo::readConfig(const KConfigGroup &config)
{ {
if (config.hasKey(QLatin1String("lastDateTimeSend"))) { if (config.hasKey(QLatin1String("lastDateTimeSend"))) {
......
...@@ -70,6 +70,8 @@ public: ...@@ -70,6 +70,8 @@ public:
void setTo( const QString &to ); void setTo( const QString &to );
QString to() const; QString to() const;
bool operator ==(const SendLaterInfo &other) const;
private: private:
QString mTo; QString mTo;
QString mSubject; QString mSubject;
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#include "sendlaterinfotest.h" #include "sendlaterinfotest.h"
#include "../sendlaterinfo.h" #include "../sendlaterinfo.h"
#include <qtest_kde.h> #include <qtest_kde.h>
#include <QDateTime>
#include <KConfigGroup>
SendLaterInfoTest::SendLaterInfoTest() SendLaterInfoTest::SendLaterInfoTest()
{ {
...@@ -37,4 +39,26 @@ void SendLaterInfoTest::shouldHaveDefaultValue() ...@@ -37,4 +39,26 @@ void SendLaterInfoTest::shouldHaveDefaultValue()
QCOMPARE(info.recurrenceEachValue(), 1); QCOMPARE(info.recurrenceEachValue(), 1);
} }
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);
}
QTEST_KDEMAIN(SendLaterInfoTest, NoGUI) QTEST_KDEMAIN(SendLaterInfoTest, NoGUI)
...@@ -28,6 +28,7 @@ public: ...@@ -28,6 +28,7 @@ public:
private Q_SLOTS: private Q_SLOTS:
void shouldHaveDefaultValue(); void shouldHaveDefaultValue();
void shouldRestoreFromSettings();
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment