Commit 54f44790 authored by Laurent Montel's avatar Laurent Montel 😁

Add more unit test

parent 5fbdf2f2
......@@ -9,6 +9,6 @@ kde4_add_unit_test( collectionannotationsattributetest ${mailcommon_collectionan
target_link_libraries( collectionannotationsattributetest ${QT_QTTEST_LIBRARY} ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${KDEPIMLIBS_AKONADI_LIBS})
set( mailcommon_expirecollectionattributetest_source expirecollectionattributetest.cpp )
set( mailcommon_expirecollectionattributetest_source expirecollectionattributetest.cpp ../expirecollectionattribute.cpp )
kde4_add_unit_test( expirecollectionattributetest ${mailcommon_expirecollectionattributetest_source})
target_link_libraries( expirecollectionattributetest ${QT_QTTEST_LIBRARY} ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${KDEPIMLIBS_AKONADI_LIBS})
......@@ -16,6 +16,7 @@
*/
#include "expirecollectionattributetest.h"
#include "../expirecollectionattribute.h"
#include <qtest_kde.h>
ExpireCollectionAttributeTest::ExpireCollectionAttributeTest(QObject *parent)
: QObject(parent)
......@@ -28,4 +29,26 @@ ExpireCollectionAttributeTest::~ExpireCollectionAttributeTest()
}
void ExpireCollectionAttributeTest::shouldHaveDefaultValue()
{
MailCommon::ExpireCollectionAttribute attr;
QVERIFY(!attr.isAutoExpire());
QCOMPARE(attr.unreadExpireAge(), 28);
QCOMPARE(attr.readExpireAge(), 14);
QCOMPARE(attr.expireAction(), MailCommon::ExpireCollectionAttribute::ExpireDelete);
QCOMPARE(attr.unreadExpireUnits(), MailCommon::ExpireCollectionAttribute::ExpireNever);
QCOMPARE(attr.readExpireUnits(), MailCommon::ExpireCollectionAttribute::ExpireNever);
QCOMPARE(attr.expireToFolderId(), (qint64)-1);
}
void ExpireCollectionAttributeTest::shouldAssignValue_data()
{
//TODO
}
void ExpireCollectionAttributeTest::shouldAssignValue()
{
MailCommon::ExpireCollectionAttribute attr;
}
QTEST_KDEMAIN(ExpireCollectionAttributeTest, NoGUI)
......@@ -26,6 +26,10 @@ class ExpireCollectionAttributeTest : public QObject
public:
explicit ExpireCollectionAttributeTest(QObject *parent = 0);
~ExpireCollectionAttributeTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldAssignValue_data();
void shouldAssignValue();
};
#endif // EXPIRECOLLECTIONATTRIBUTETEST_H
......@@ -132,6 +132,17 @@ ExpireCollectionAttribute::ExpireUnits ExpireCollectionAttribute::readExpireUnit
return mReadExpireUnits;
}
bool ExpireCollectionAttribute::operator==(const ExpireCollectionAttribute &other) const
{
return (mExpireMessages == other.isAutoExpire()) &&
(mUnreadExpireAge == other.unreadExpireAge()) &&
(mReadExpireAge == other.readExpireAge()) &&
(mUnreadExpireUnits == other.unreadExpireUnits()) &&
(mReadExpireUnits == other.readExpireUnits()) &&
(mExpireAction == other.expireAction()) &&
(mExpireToFolderId == other.expireToFolderId());
}
int ExpireCollectionAttribute::daysToExpire( int number,
ExpireCollectionAttribute::ExpireUnits units )
{
......
......@@ -54,7 +54,6 @@ public:
QByteArray serialized() const;
void deserialize( const QByteArray &data );
static int daysToExpire( int number, ExpireCollectionAttribute::ExpireUnits units );
void daysToExpire( int &unreadDays, int &readDays );
......@@ -130,7 +129,9 @@ public:
*/
ExpireUnits readExpireUnits() const;
bool operator==(const ExpireCollectionAttribute &other) const;
private:
static int daysToExpire( int number, ExpireCollectionAttribute::ExpireUnits units );
bool mExpireMessages; // true if old messages are expired
int mUnreadExpireAge; // Given in unreadExpireUnits
int mReadExpireAge; // Given in readExpireUnits
......
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