Commit 3cf8bc91 authored by Laurent Montel's avatar Laurent Montel 😁

Add unittest

parent dcb61049
......@@ -37,3 +37,8 @@ set( kmail_createfollowupreminderonexistingmessagejobtest_source createfollowupr
kde4_add_unit_test( createfollowupreminderonexistingmessagejobtest ${kmail_createfollowupreminderonexistingmessagejobtest_source})
target_link_libraries( createfollowupreminderonexistingmessagejobtest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS} ${KDEPIMLIBS_AKONADI_LIBS} ${KDEPIMLIBS_KCALCORE_LIBS} followupreminder)
set( kmail_cryptostateindicatorwidgettest_source cryptostateindicatorwidgettest.cpp ../editor/cryptostateindicatorwidget.cpp)
kde4_add_unit_test( cryptostateindicatorwidgettest ${kmail_cryptostateindicatorwidgettest_source})
target_link_libraries( cryptostateindicatorwidgettest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS} messagecore)
/*
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 "cryptostateindicatorwidgettest.h"
#include "editor/cryptostateindicatorwidget.h"
#include <qtest_kde.h>
#include <QLabel>
CryptoStateIndicatorWidgetTest::CryptoStateIndicatorWidgetTest(QObject *parent) : QObject(parent)
{
}
CryptoStateIndicatorWidgetTest::~CryptoStateIndicatorWidgetTest()
{
}
void CryptoStateIndicatorWidgetTest::shouldHaveDefaultValue()
{
CryptoStateIndicatorWidget w;
w.show();
QTest::qWaitForWindowShown(&w);
QLabel *signature = qFindChild<QLabel *>(&w, QLatin1String("signatureindicator"));
QVERIFY(signature);
QLabel *encryption = qFindChild<QLabel *>(&w, QLatin1String("encryptionindicator"));
QVERIFY(encryption);
QVERIFY(signature->isVisible());
QVERIFY(encryption->isVisible());
}
void CryptoStateIndicatorWidgetTest::shouldBeNotVisibleWhenShowAlwaysIsFalse()
{
CryptoStateIndicatorWidget w;
w.setShowAlwaysIndicator(false);
w.show();
QTest::qWaitForWindowShown(&w);
QLabel *signature = qFindChild<QLabel *>(&w, QLatin1String("signatureindicator"));
QLabel *encryption = qFindChild<QLabel *>(&w, QLatin1String("encryptionindicator"));
QVERIFY(!signature->isVisible());
QVERIFY(!encryption->isVisible());
w.updateSignatureAndEncrypionStateIndicators(true, true);
QVERIFY(!signature->isVisible());
QVERIFY(!encryption->isVisible());
}
void CryptoStateIndicatorWidgetTest::shouldVisibleWhenChangeStatus()
{
CryptoStateIndicatorWidget w;
w.setShowAlwaysIndicator(true);
w.show();
QTest::qWaitForWindowShown(&w);
QLabel *signature = qFindChild<QLabel *>(&w, QLatin1String("signatureindicator"));
QLabel *encryption = qFindChild<QLabel *>(&w, QLatin1String("encryptionindicator"));
w.updateSignatureAndEncrypionStateIndicators(true, false);
QVERIFY(signature->isVisible());
QVERIFY(!encryption->isVisible());
w.updateSignatureAndEncrypionStateIndicators(false, true);
QVERIFY(!signature->isVisible());
QVERIFY(encryption->isVisible());
w.updateSignatureAndEncrypionStateIndicators(true, true);
QVERIFY(signature->isVisible());
QVERIFY(encryption->isVisible());
w.updateSignatureAndEncrypionStateIndicators(false, false);
QVERIFY(!signature->isVisible());
QVERIFY(!encryption->isVisible());
}
QTEST_KDEMAIN(CryptoStateIndicatorWidgetTest, GUI)
/*
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 CRYPTOSTATEINDICATORWIDGETTEST_H
#define CRYPTOSTATEINDICATORWIDGETTEST_H
#include <QObject>
class CryptoStateIndicatorWidgetTest : public QObject
{
Q_OBJECT
public:
explicit CryptoStateIndicatorWidgetTest(QObject *parent = 0);
~CryptoStateIndicatorWidgetTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldBeNotVisibleWhenShowAlwaysIsFalse();
void shouldVisibleWhenChangeStatus();
};
#endif // CRYPTOSTATEINDICATORWIDGETTEST_H
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