Commit 5f08dde9 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add importaddressbookjobinterfacetest

parent 08cec623
......@@ -6,3 +6,11 @@ add_executable( exportaddressbookjobinterfacetest ${exportaddressbookjobinterfac
add_test(NAME exportaddressbookjobinterfacetest COMMAND exportaddressbookjobinterfacetest)
ecm_mark_as_test(exportaddressbookjobinterfacetest)
target_link_libraries(exportaddressbookjobinterfacetest Qt5::Test pimdataexporterprivate KF5::ConfigCore test_resourceconverter)
#####
set( importaddressbookjobinterfacetest_SRCS importaddressbookjobinterfacetest.cpp)
add_executable( importaddressbookjobinterfacetest ${importaddressbookjobinterfacetest_SRCS})
add_test(NAME importaddressbookjobinterfacetest COMMAND importaddressbookjobinterfacetest)
ecm_mark_as_test(importaddressbookjobinterfacetest)
target_link_libraries(importaddressbookjobinterfacetest Qt5::Test pimdataexporterprivate KF5::ConfigCore test_resourceconverter)
/*
Copyright (C) 2020 Laurent Montel <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 as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
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; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "importaddressbookjobinterfacetest.h"
#include "archivestorage.h"
#include "resourceconvertertest.h"
#include "testimportfile.h"
#include <QSignalSpy>
#include <QTest>
QTEST_MAIN(ImportAddressbookJobInterfaceTest)
ImportAddressbookJobInterfaceTestImpl::ImportAddressbookJobInterfaceTestImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep)
: ImportAddressbookJobInterface(parent, typeSelected, archiveStorage, numberOfStep)
{
}
ImportAddressbookJobInterfaceTestImpl::~ImportAddressbookJobInterfaceTestImpl()
{
}
Akonadi::Collection::Id ImportAddressbookJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path)
{
ResourceConverterTest resourceConverterTest;
return resourceConverterTest.convertFolderPathToCollectionId(path);
}
QString ImportAddressbookJobInterfaceTestImpl::createResource(const QString &resources, const QString &name, const QMap<QString, QVariant> &settings, bool synchronizeTree)
{
//TODO
return {};
}
void ImportAddressbookJobInterfaceTestImpl::synchronizeResource(const QStringList &lst)
{
//TODO
}
ImportAddressbookJobInterfaceTest::ImportAddressbookJobInterfaceTest(QObject *parent)
: QObject(parent)
{
}
void ImportAddressbookJobInterfaceTest::importAddressbookConfig_data()
{
QTest::addColumn<QString>("zipFilePath");
QTest::addColumn<QString>("testPath");
const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/import/");
QTest::newRow("test1") << QString::fromLatin1(pathConfig) << QStringLiteral("/test1/");
}
void ImportAddressbookJobInterfaceTest::importAddressbookConfig()
{
QFETCH(QString, zipFilePath);
QFETCH(QString, testPath);
TestImportFile *file = new TestImportFile(zipFilePath, this);
file->setPathConfig(zipFilePath + testPath);
file->setExtractPath(QDir::tempPath() + testPath);
ImportAddressbookJobInterfaceTestImpl *impl = new ImportAddressbookJobInterfaceTestImpl(this, {Utils::StoredType::Config}, file->archiveStorage(), 1);
file->setAbstractImportExportJob(impl);
file->start();
delete impl;
delete file;
}
/*
Copyright (C) 2020 Laurent Montel <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 as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
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; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef IMPORTADDRESSBOOKJOBINTERFACETEST_H
#define IMPORTADDRESSBOOKJOBINTERFACETEST_H
#include <QObject>
#include "addressbook/importaddressbookjobinterface.h"
class ImportAddressbookJobInterfaceTestImpl : public ImportAddressbookJobInterface
{
Q_OBJECT
public:
explicit ImportAddressbookJobInterfaceTestImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep);
~ImportAddressbookJobInterfaceTestImpl();
protected:
Q_REQUIRED_RESULT Akonadi::Collection::Id convertFolderPathToCollectionId(const QString &path) override;
Q_REQUIRED_RESULT QString createResource(const QString &resources, const QString &name, const QMap<QString, QVariant> &settings, bool synchronizeTree) override;
void synchronizeResource(const QStringList &lst) override;
};
class ImportAddressbookJobInterfaceTest : public QObject
{
Q_OBJECT
public:
explicit ImportAddressbookJobInterfaceTest(QObject *parent = nullptr);
~ImportAddressbookJobInterfaceTest() = default;
private Q_SLOTS:
void importAddressbookConfig();
void importAddressbookConfig_data();
};
#endif // IMPORTADDRESSBOOKJOBINTERFACETEST_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