Commit 0905e8ed authored by Laurent Montel's avatar Laurent Montel 😁

Add unittest for mergecontactjob

parent 42d5cd7b
......@@ -21,6 +21,7 @@
#include <KABC/Addressee>
#include <QTabBar>
#include <QDebug>
using namespace KABMergeContacts;
......@@ -53,6 +54,8 @@ void MergeContactShowResultTabWidget::setContacts(const Akonadi::Item::List &lst
MergeContactInfoWidget *infoWidget = new MergeContactInfoWidget;
infoWidget->setContact(item);
addTab(infoWidget, address.name());
} else {
qDebug()<<" don't have address";
}
}
updateTabWidget();
......
......@@ -37,16 +37,23 @@ MergeContactsJob::~MergeContactsJob()
}
void MergeContactsJob::start()
bool MergeContactsJob::canStart()
{
if (!mCollection.isValid()) {
qDebug()<<" mCollection is not valid !";
Q_EMIT finished(mCreatedContact);
deleteLater();
return;
return false;
}
if (mListItem.isEmpty()) {
qDebug()<<" list item is empty !";
return false;
}
return true;
}
void MergeContactsJob::start()
{
if (!canStart()) {
Q_EMIT finished(mCreatedContact);
deleteLater();
return;
......
......@@ -36,6 +36,7 @@ public:
void setDestination(const Akonadi::Collection &collection);
bool canStart();
Q_SIGNALS:
void finished(const Akonadi::Item &item);
......
......@@ -12,7 +12,7 @@ endmacro()
kaddressbook_merge(mergecontactwidgettest.cpp)
kaddressbook_merge(mergecontacttest.cpp)
kaddressbook_merge(mergecontactjobtest.cpp)
include(AkonadiMacros)
set(KDEPIMLIBS_RUN_ISOLATED_TESTS TRUE)
......
/*
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 "mergecontactjobtest.h"
#include <qtest_kde.h>
MergeContactJobTest::MergeContactJobTest(QObject *parent)
: QObject(parent)
{
}
MergeContactJobTest::~MergeContactJobTest()
{
}
QTEST_KDEMAIN(MergeContactJobTest, 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 MERGECONTACTJOBTEST_H
#define MERGECONTACTJOBTEST_H
#include <QObject>
class MergeContactJobTest : public QObject
{
Q_OBJECT
public:
explicit MergeContactJobTest(QObject *parent = 0);
~MergeContactJobTest();
};
#endif // MERGECONTACTJOBTEST_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