From 69756bd500ce0c00e5eba512666a7f1cdb8c437b Mon Sep 17 00:00:00 2001 From: Montel Laurent Date: Mon, 2 Feb 2015 21:57:19 +0100 Subject: [PATCH] Add unit test --- .../autotests/CMakeLists.txt | 4 ++ .../potentialphishingemailwarningtest.cpp | 46 +++++++++++++++++++ .../potentialphishingemailwarningtest.h | 36 +++++++++++++++ .../potentialphishingemailwarning.cpp | 3 +- 4 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 editor/potentialphishingemail/autotests/potentialphishingemailwarningtest.cpp create mode 100644 editor/potentialphishingemail/autotests/potentialphishingemailwarningtest.h diff --git a/editor/potentialphishingemail/autotests/CMakeLists.txt b/editor/potentialphishingemail/autotests/CMakeLists.txt index 51384cd20..a71974d86 100644 --- a/editor/potentialphishingemail/autotests/CMakeLists.txt +++ b/editor/potentialphishingemail/autotests/CMakeLists.txt @@ -10,3 +10,7 @@ kde4_add_unit_test( kmail_potentialphishingdetaildialogtest ${kmail_potentialphi target_link_libraries( kmail_potentialphishingdetaildialogtest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS} ) +set( kmail_potentialphishingemailwarningtest_SRCS potentialphishingemailwarningtest.cpp ../potentialphishingemailwarning.cpp ../potentialphishingdetaildialog.cpp) +kde4_add_unit_test( kmail_potentialphishingemailwarningtest ${kmail_potentialphishingemailwarningtest_SRCS}) +target_link_libraries( kmail_potentialphishingemailwarningtest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS} ) + diff --git a/editor/potentialphishingemail/autotests/potentialphishingemailwarningtest.cpp b/editor/potentialphishingemail/autotests/potentialphishingemailwarningtest.cpp new file mode 100644 index 000000000..8fb9f1de8 --- /dev/null +++ b/editor/potentialphishingemail/autotests/potentialphishingemailwarningtest.cpp @@ -0,0 +1,46 @@ +/* + Copyright (c) 2015 Montel Laurent + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + This library 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 Library General Public + License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + +#include "potentialphishingemailwarningtest.h" +#include "../potentialphishingemailwarning.h" +#include +#include + +PotentialPhishingEmailWarningTest::PotentialPhishingEmailWarningTest(QObject *parent) + : QObject(parent) +{ + +} + +PotentialPhishingEmailWarningTest::~PotentialPhishingEmailWarningTest() +{ + +} + +void PotentialPhishingEmailWarningTest::shouldHaveDefaultValue() +{ + PotentialPhishingEmailWarning w; + QVERIFY(!w.isVisible()); + //Verify QVERIFY(w.isCloseButtonVisible()); + QAction *act = qFindChild(&w, QLatin1String("sendnow")); + QVERIFY(act); +} + +QTEST_KDEMAIN(PotentialPhishingEmailWarningTest, GUI) diff --git a/editor/potentialphishingemail/autotests/potentialphishingemailwarningtest.h b/editor/potentialphishingemail/autotests/potentialphishingemailwarningtest.h new file mode 100644 index 000000000..d4e61a12e --- /dev/null +++ b/editor/potentialphishingemail/autotests/potentialphishingemailwarningtest.h @@ -0,0 +1,36 @@ +/* + Copyright (c) 2015 Montel Laurent + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + This library 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 Library General Public + License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + +#ifndef POTENTIALPHISHINGEMAILWARNINGTEST_H +#define POTENTIALPHISHINGEMAILWARNINGTEST_H + +#include + +class PotentialPhishingEmailWarningTest : public QObject +{ + Q_OBJECT +public: + explicit PotentialPhishingEmailWarningTest(QObject *parent = 0); + ~PotentialPhishingEmailWarningTest(); +private Q_SLOTS: + void shouldHaveDefaultValue(); +}; + +#endif // POTENTIALPHISHINGEMAILWARNINGTEST_H diff --git a/editor/potentialphishingemail/potentialphishingemailwarning.cpp b/editor/potentialphishingemail/potentialphishingemailwarning.cpp index faafcfd62..976acb3cd 100644 --- a/editor/potentialphishingemail/potentialphishingemailwarning.cpp +++ b/editor/potentialphishingemail/potentialphishingemailwarning.cpp @@ -39,7 +39,8 @@ PotentialPhishingEmailWarning::PotentialPhishingEmailWarning(QWidget *parent) connect(this, SIGNAL(linkActivated(QString)), SLOT(slotShowDetails(QString))); //Add i18n in kf5 - KAction *action = new KAction(QLatin1String( "Send Now" ), this ); + QAction *action = new QAction(QLatin1String( "Send Now" ), this ); + action->setObjectName(QLatin1String("sendnow")); connect( action, SIGNAL(triggered(bool)), SIGNAL(sendNow()) ); addAction( action ); }