Commit 85693646 authored by Laurent Montel's avatar Laurent Montel 😁

Add unit test for attribute

parent e7a8a3cc
......@@ -214,7 +214,7 @@ set_target_properties(mailcommon PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVER
install(TARGETS mailcommon ${INSTALL_TARGETS_DEFAULT_ARGS})
add_subdirectory(filter/filterimporter/tests)
add_subdirectory(collectionpage/autotests)
#install(FILES viewer/viewer.h viewer/attachmentstrategy.h header/headerstrategy.h messageviewer_export.h DESTINATION ${INCLUDE_INSTALL_DIR}/messageviewer COMPONENT devel)
if (QT_QTDESIGNER_FOUND)
......
set( mailcommon_newmailnotifierattribute_source newmailnotifierattributetest.cpp ../newmailnotifierattribute.cpp)
kde4_add_unit_test( newmailnotifierattributetest ${mailcommon_newmailnotifierattribute_source})
target_link_libraries( newmailnotifierattributetest ${QT_QTTEST_LIBRARY} ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${KDEPIMLIBS_AKONADI_LIBS})
set( mailcommon_collectionannotationsattributetest_source collectionannotationsattributetest.cpp ../collectionannotationsattribute.cpp)
kde4_add_unit_test( collectionannotationsattributetest ${mailcommon_collectionannotationsattributetest_source})
target_link_libraries( collectionannotationsattributetest ${QT_QTTEST_LIBRARY} ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${KDEPIMLIBS_AKONADI_LIBS})
/*
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 "collectionannotationsattributetest.h"
#include "../collectionannotationsattribute.h"
#include <qtest_kde.h>
CollectionAnnotationsAttributeTest::CollectionAnnotationsAttributeTest(QObject *parent)
: QObject(parent)
{
}
CollectionAnnotationsAttributeTest::~CollectionAnnotationsAttributeTest()
{
}
void CollectionAnnotationsAttributeTest::shouldHaveDefaultValue()
{
MailCommon::CollectionAnnotationsAttribute attr;
QVERIFY(attr.annotations().isEmpty());
}
void CollectionAnnotationsAttributeTest::shouldAssignAttribute()
{
QMap<QByteArray, QByteArray> annotations;
annotations.insert("foo", "foo");
annotations.insert("bla", "bla");
annotations.insert("foo2", "bli");
MailCommon::CollectionAnnotationsAttribute attr(annotations);
QCOMPARE(attr.annotations(), annotations);
}
void CollectionAnnotationsAttributeTest::shouldDeserializedAttribute()
{
QMap<QByteArray, QByteArray> annotations;
annotations.insert("foo", "foo");
annotations.insert("bla", "bla");
annotations.insert("foo2", "bli");
MailCommon::CollectionAnnotationsAttribute attr(annotations);
const QByteArray ba = attr.serialized();
MailCommon::CollectionAnnotationsAttribute result;
result.deserialize(ba);
QVERIFY(attr == result);
}
QTEST_KDEMAIN(CollectionAnnotationsAttributeTest, NoGUI)
/*
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
*/
#ifndef COLLECTIONANNOTATIONSATTRIBUTETEST_H
#define COLLECTIONANNOTATIONSATTRIBUTETEST_H
#include <QObject>
class CollectionAnnotationsAttributeTest : public QObject
{
Q_OBJECT
public:
explicit CollectionAnnotationsAttributeTest(QObject *parent = 0);
~CollectionAnnotationsAttributeTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldAssignAttribute();
void shouldDeserializedAttribute();
};
#endif // COLLECTIONANNOTATIONSATTRIBUTETEST_H
/*
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 "newmailnotifierattributetest.h"
#include "../newmailnotifierattribute.h"
#include <qtest_kde.h>
NewMailNotifierAttributeTest::NewMailNotifierAttributeTest(QObject *parent)
: QObject(parent)
{
}
NewMailNotifierAttributeTest::~NewMailNotifierAttributeTest()
{
}
void NewMailNotifierAttributeTest::shouldHaveDefaultValue()
{
MailCommon::NewMailNotifierAttribute attr;
QVERIFY(!attr.ignoreNewMail());
}
void NewMailNotifierAttributeTest::shouldSetIgnoreNotification()
{
MailCommon::NewMailNotifierAttribute attr;
bool ignore = false;
attr.setIgnoreNewMail(ignore);
QCOMPARE(attr.ignoreNewMail(), ignore);
ignore = true;
attr.setIgnoreNewMail(ignore);
QCOMPARE(attr.ignoreNewMail(), ignore);
}
void NewMailNotifierAttributeTest::shouldSerializedData()
{
MailCommon::NewMailNotifierAttribute attr;
attr.setIgnoreNewMail(true);
QByteArray ba = attr.serialized();
MailCommon::NewMailNotifierAttribute result;
result.deserialize(ba);
QVERIFY(attr == result);
}
QTEST_KDEMAIN(NewMailNotifierAttributeTest, NoGUI)
/*
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
*/
#ifndef NEWMAILNOTIFIERATTRIBUTETEST_H
#define NEWMAILNOTIFIERATTRIBUTETEST_H
#include <QObject>
class NewMailNotifierAttributeTest : public QObject
{
Q_OBJECT
public:
explicit NewMailNotifierAttributeTest(QObject *parent = 0);
~NewMailNotifierAttributeTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldSetIgnoreNotification();
void shouldSerializedData();
};
#endif // NEWMAILNOTIFIERATTRIBUTETEST_H
......@@ -96,3 +96,8 @@ void CollectionAnnotationsAttribute::deserialize( const QByteArray &data )
}
}
}
bool CollectionAnnotationsAttribute::operator==(const CollectionAnnotationsAttribute &other) const
{
return mAnnotations == other.annotations();
}
......@@ -40,6 +40,8 @@ public:
QByteArray serialized() const;
void deserialize( const QByteArray &data );
bool operator==(const CollectionAnnotationsAttribute &other) const;
private:
QMap<QByteArray, QByteArray> mAnnotations;
};
......
......@@ -80,4 +80,9 @@ void NewMailNotifierAttribute::setIgnoreNewMail(bool b)
{
d->ignoreNewMail = b;
}
bool NewMailNotifierAttribute::operator==(const NewMailNotifierAttribute &other) const
{
return d->ignoreNewMail == other.ignoreNewMail();
}
}
......@@ -38,6 +38,7 @@ public:
bool ignoreNewMail() const;
void setIgnoreNewMail(bool b);
bool operator==(const NewMailNotifierAttribute &other) const;
private:
friend class NewMailNotifierAttributePrivate;
......
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