Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 634be55a authored by Laurent Montel's avatar Laurent Montel 😁

Add unittest for blacklistbalooemailcompletionwidget.cpp

parent a541c48c
......@@ -4,7 +4,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/libkdepim
)
set( libkdepim_blacklistbalooemailcompletiondialogtest_SRCS blacklistbalooemailcompletiondialogtest.cpp )
set( libkdepim_blacklistbalooemailcompletiondialogtest_SRCS blacklistbalooemailcompletiondialogtest.cpp ../blacklistbalooemailcompletionwidget.cpp)
kde4_add_unit_test( libkdepim_blacklistbalooemailcompletiondialogtest ${libkdepim_blacklistbalooemailcompletiondialogtest_SRCS})
target_link_libraries( libkdepim_blacklistbalooemailcompletiondialogtest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS} kdepim)
......@@ -21,3 +21,9 @@ set( libkdepim_blacklistbalooemailutiltest_SRCS blacklistbalooemailutiltest.cpp
kde4_add_unit_test( libkdepim_blacklistbalooemailutiltest ${libkdepim_blacklistbalooemailutiltest_SRCS})
target_link_libraries( libkdepim_blacklistbalooemailutiltest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS} kdepim)
set( libkdepim_blacklistbalooemailcompletionwidgettest_SRCS blacklistbalooemailcompletionwidgettest.cpp ../blacklistbalooemailcompletionwidget.cpp )
kde4_add_unit_test( libkdepim_blacklistbalooemailcompletionwidgettest ${libkdepim_blacklistbalooemailcompletionwidgettest_SRCS})
target_link_libraries( libkdepim_blacklistbalooemailcompletionwidgettest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS} kdepim)
......@@ -21,10 +21,12 @@
#include "blacklistbalooemailcompletiondialogtest.h"
#include "../blacklistbalooemailcompletiondialog.h"
#include "../blacklistbalooemaillist.h"
#include "../blacklistbalooemailcompletionwidget.h"
#include <QLabel>
#include <klineedit.h>
#include <kpushbutton.h>
#include <qtest_kde.h>
BlackListBalooEmailCompletionDialogTest::BlackListBalooEmailCompletionDialogTest(QObject *parent)
: QObject(parent)
{
......@@ -39,6 +41,7 @@ BlackListBalooEmailCompletionDialogTest::~BlackListBalooEmailCompletionDialogTes
void BlackListBalooEmailCompletionDialogTest::shouldHaveDefaultValue()
{
KPIM::BlackListBalooEmailCompletionDialog dlg;
QLabel *searchLabel = qFindChild<QLabel *>(&dlg, QLatin1String("search_label"));
QVERIFY(searchLabel);
......
/*
Copyright (c) 2015 Montel Laurent <montel@kde.org>
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 "blacklistbalooemailcompletionwidgettest.h"
#include "../blacklistbalooemailcompletionwidget.h"
#include "../blacklistbalooemaillist.h"
#include <QLabel>
#include <klineedit.h>
#include <kpushbutton.h>
#include <qtest_kde.h>
BlackListBalooEmailCompletionWidgetTest::BlackListBalooEmailCompletionWidgetTest(QObject *parent)
: QObject(parent)
{
}
BlackListBalooEmailCompletionWidgetTest::~BlackListBalooEmailCompletionWidgetTest()
{
}
void BlackListBalooEmailCompletionWidgetTest::shouldHaveDefaultValue()
{
KPIM::BlackListBalooEmailCompletionWidget widget;
QLabel *searchLabel = qFindChild<QLabel *>(&widget, QLatin1String("search_label"));
QVERIFY(searchLabel);
KLineEdit *searchLineEdit = qFindChild<KLineEdit *>(&widget, QLatin1String("search_lineedit"));
QVERIFY(searchLineEdit);
QVERIFY(searchLineEdit->isClearButtonShown());
QVERIFY(searchLineEdit->trapReturnKey());
QVERIFY(searchLineEdit->text().isEmpty());
KPushButton *seachButton = qFindChild<KPushButton *>(&widget, QLatin1String("search_button"));
QVERIFY(seachButton);
QVERIFY(!seachButton->isEnabled());
KPIM::BlackListBalooEmailList *emailList = qFindChild<KPIM::BlackListBalooEmailList *>(&widget, QLatin1String("email_list"));
QVERIFY(emailList);
KPushButton *selectButton = qFindChild<KPushButton *>(&widget, QLatin1String("select_email"));
QVERIFY(selectButton);
KPushButton *unselectButton = qFindChild<KPushButton *>(&widget, QLatin1String("unselect_email"));
QVERIFY(unselectButton);
}
void BlackListBalooEmailCompletionWidgetTest::shouldEnablePushButtonWhenTestSizeSupperiorToTwo()
{
KPIM::BlackListBalooEmailCompletionWidget widget;
KLineEdit *searchLineEdit = qFindChild<KLineEdit *>(&widget, QLatin1String("search_lineedit"));
KPushButton *seachButton = qFindChild<KPushButton *>(&widget, QLatin1String("search_button"));
QVERIFY(!seachButton->isEnabled());
searchLineEdit->setText(QLatin1String("fo"));
QVERIFY(!seachButton->isEnabled());
searchLineEdit->setText(QLatin1String("foo"));
QVERIFY(seachButton->isEnabled());
searchLineEdit->setText(QLatin1String("o "));
QVERIFY(!seachButton->isEnabled());
searchLineEdit->setText(QLatin1String(" o "));
QVERIFY(!seachButton->isEnabled());
}
QTEST_KDEMAIN(BlackListBalooEmailCompletionWidgetTest, GUI)
/*
Copyright (c) 2015 Montel Laurent <montel@kde.org>
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 BLACKLISTBALOOEMAILCOMPLETIONWIDGETTEST_H
#define BLACKLISTBALOOEMAILCOMPLETIONWIDGETTEST_H
#include <QObject>
class BlackListBalooEmailCompletionWidgetTest : public QObject
{
Q_OBJECT
public:
explicit BlackListBalooEmailCompletionWidgetTest(QObject *parent=0);
~BlackListBalooEmailCompletionWidgetTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldEnablePushButtonWhenTestSizeSupperiorToTwo();
};
#endif // BLACKLISTBALOOEMAILCOMPLETIONWIDGETTEST_H
......@@ -41,6 +41,7 @@ BlackListBalooEmailCompletionDialog::BlackListBalooEmailCompletionDialog(QWidget
setDefaultButton( Ok );
setModal( true );
mBlackListWidget = new BlackListBalooEmailCompletionWidget(this);
mBlackListWidget->setObjectName(QLatin1String("blacklistwidget"));
setMainWidget(mBlackListWidget);
connect(this, SIGNAL(okClicked()), this, SLOT(slotSave()));
......
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