Commit 96af7727 authored by Laurent Montel's avatar Laurent Montel 😁

Add unittest

parent d9d4783c
......@@ -57,3 +57,4 @@ install(FILES newmailnotifieragent.desktop DESTINATION "${CMAKE_INSTALL_PREFIX}/
install(FILES akonadi_newmailnotifier_agent.notifyrc DESTINATION "${DATA_INSTALL_DIR}/akonadi_newmailnotifier_agent" )
add_subdirectory(kconf_update)
add_subdirectory(autotests)
set( newmailnotifierattribute_source newmailnotifierattributetest.cpp ../newmailnotifierattribute.cpp)
kde4_add_unit_test( newmailnotifierattributetest ${newmailnotifierattribute_source})
target_link_libraries( newmailnotifierattributetest ${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 "newmailnotifierattributetest.h"
#include "../newmailnotifierattribute.h"
#include <qtest_kde.h>
NewMailNotifierAttributeTest::NewMailNotifierAttributeTest(QObject *parent)
: QObject(parent)
{
}
NewMailNotifierAttributeTest::~NewMailNotifierAttributeTest()
{
}
void NewMailNotifierAttributeTest::shouldHaveDefaultValue()
{
NewMailNotifierAttribute attr;
QVERIFY(!attr.ignoreNewMail());
}
void NewMailNotifierAttributeTest::shouldSetIgnoreNotification()
{
NewMailNotifierAttribute attr;
bool ignore = false;
attr.setIgnoreNewMail(ignore);
QCOMPARE(attr.ignoreNewMail(), ignore);
ignore = true;
attr.setIgnoreNewMail(ignore);
QCOMPARE(attr.ignoreNewMail(), ignore);
}
void NewMailNotifierAttributeTest::shouldSerializedData()
{
NewMailNotifierAttribute attr;
attr.setIgnoreNewMail(true);
QByteArray ba = attr.serialized();
NewMailNotifierAttribute result;
result.deserialize(ba);
QVERIFY(attr == result);
}
void NewMailNotifierAttributeTest::shouldCloneAttribute()
{
NewMailNotifierAttribute attr;
attr.setIgnoreNewMail(true);
NewMailNotifierAttribute *result = attr.clone();
QVERIFY(attr == *result);
delete 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();
void shouldCloneAttribute();
};
#endif // NEWMAILNOTIFIERATTRIBUTETEST_H
......@@ -78,3 +78,8 @@ void NewMailNotifierAttribute::setIgnoreNewMail(bool b)
{
d->ignoreNewMail = b;
}
bool NewMailNotifierAttribute::operator==(const NewMailNotifierAttribute &other) const
{
return d->ignoreNewMail == other.ignoreNewMail();
}
......@@ -36,6 +36,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