Commit ffe6155f authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add more unitest. Fix bug

parent c5b703e7
......@@ -49,6 +49,7 @@ ArchiveMailDialog::ArchiveMailDialog(QWidget *parent)
mainLayout->setSpacing( KDialog::spacingHint() );
mainLayout->setMargin( KDialog::marginHint() );
mWidget = new ArchiveMailWidget(this);
mWidget->setObjectName(QLatin1String("archivemailwidget"));
connect(mWidget, SIGNAL(archiveNow(ArchiveMailInfo*)), this, SIGNAL(archiveNow(ArchiveMailInfo*)));
mainLayout->addWidget(mWidget);
setMainWidget( mainWidget );
......@@ -148,6 +149,7 @@ ArchiveMailWidget::ArchiveMailWidget( QWidget *parent )
QStringList headers;
headers<<i18n("Name")<<i18n("Last archive")<<i18n("Next archive in")<<i18n("Storage directory");
mWidget->treeWidget->setHeaderLabels(headers);
mWidget->treeWidget->setObjectName(QLatin1String("treewidget"));
mWidget->treeWidget->setSortingEnabled(true);
mWidget->treeWidget->setRootIsDecorated(false);
mWidget->treeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
......@@ -228,7 +230,11 @@ void ArchiveMailWidget::load()
for (int i = 0 ; i < numberOfCollection; ++i) {
KConfigGroup group = config->group(collectionList.at(i));
ArchiveMailInfo *info = new ArchiveMailInfo(group);
createOrUpdateItem(info);
if (info->isValid()) {
createOrUpdateItem(info);
} else {
delete info;
}
}
}
......
......@@ -4,10 +4,12 @@ remove_definitions( -DQT_NO_CAST_FROM_BYTEARRAY )
# Convenience macro to add unit tests.
macro( archivemail_agent _source )
set( _test ${_source} ../archivemailinfo.cpp)
set( _test ${_source} ../archivemailinfo.cpp ../archivemaildialog.cpp ../archivemailagentutil.cpp ../addarchivemaildialog.cpp)
kde4_add_ui_files(_test ../ui/archivemailwidget.ui )
get_filename_component( _name ${_source} NAME_WE )
kde4_add_unit_test( ${_name} TESTNAME archivemailagent-${_name} ${_test} )
target_link_libraries( ${_name} ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY} ${KDE4_KDEUI_LIBS} )
target_link_libraries( ${_name} ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY} ${KDE4_KDEUI_LIBS} mailcommon ${KDEPIMLIBS_AKONADI_LIBS} ${KDE4_KIO_LIBS})
endmacro()
archivemail_agent(archivemailinfotest.cpp)
archivemail_agent(archivemaildialogtest.cpp)
/*
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 "archivemaildialogtest.h"
#include "../archivemaildialog.h"
#include <qtest_kde.h>
ArchiveMailDialogTest::ArchiveMailDialogTest(QObject *parent)
: QObject(parent)
{
}
ArchiveMailDialogTest::~ArchiveMailDialogTest()
{
}
void ArchiveMailDialogTest::shouldHaveDefaultValue()
{
ArchiveMailDialog dlg;
ArchiveMailWidget *mailwidget = qFindChild<ArchiveMailWidget *>(&dlg, QLatin1String("archivemailwidget"));
QVERIFY(mailwidget);
QTreeWidget *treeWidget = qFindChild<QTreeWidget *>(mailwidget, QLatin1String("treewidget"));
QVERIFY(treeWidget);
QCOMPARE(treeWidget->topLevelItemCount(), 0);
}
QTEST_KDEMAIN(ArchiveMailDialogTest, 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 ARCHIVEMAILDIALOGTEST_H
#define ARCHIVEMAILDIALOGTEST_H
#include <QObject>
class ArchiveMailDialogTest : public QObject
{
Q_OBJECT
public:
explicit ArchiveMailDialogTest(QObject *parent=0);
~ArchiveMailDialogTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
};
#endif // ARCHIVEMAILDIALOGTEST_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