Commit 22e5452e authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add more autotest

parent 61364595
......@@ -6,3 +6,12 @@ add_executable( exportakregatorjobinterfacetest ${exportakregatorjobinterfacetes
add_test(NAME exportakregatorjobinterfacetest COMMAND exportakregatorjobinterfacetest)
ecm_mark_as_test(exportakregatorjobinterfacetest)
target_link_libraries(exportakregatorjobinterfacetest Qt5::Test pimdataexporterprivate KF5::ConfigCore test_resourceconverter)
#####
set( importakregatorjobinterfacetest_SRCS importakregatorjobinterfacetest.cpp)
add_executable( importakregatorjobinterfacetest ${importakregatorjobinterfacetest_SRCS})
add_test(NAME importakregatorjobinterfacetest COMMAND importakregatorjobinterfacetest)
ecm_mark_as_test(importakregatorjobinterfacetest)
target_link_libraries(importakregatorjobinterfacetest 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 "importakregatorjobinterfacetest.h"
#include "archivestorage.h"
#include "resourceconvertertest.h"
#include "testimportfile.h"
#include <QSignalSpy>
#include <QTest>
QTEST_MAIN(ImportAkregatorJobInterfaceTest)
ImportAkregatorJobInterfaceTestImpl::ImportAkregatorJobInterfaceTestImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep)
: ImportAkregatorJobInterface(parent, typeSelected, archiveStorage, numberOfStep)
{
}
ImportAkregatorJobInterfaceTestImpl::~ImportAkregatorJobInterfaceTestImpl()
{
}
Akonadi::Collection::Id ImportAkregatorJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path)
{
ResourceConverterTest resourceConverterTest;
return resourceConverterTest.convertFolderPathToCollectionId(path);
}
ImportAkregatorJobInterfaceTest::ImportAkregatorJobInterfaceTest(QObject *parent)
: QObject(parent)
{
}
void ImportAkregatorJobInterfaceTest::importCalendarConfig_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 ImportAkregatorJobInterfaceTest::importCalendarConfig()
{
QFETCH(QString, zipFilePath);
QFETCH(QString, testPath);
TestImportFile *file = new TestImportFile(zipFilePath, this);
file->setPathConfig(zipFilePath + testPath);
file->setExtractPath(QDir::tempPath() + testPath);
ImportAkregatorJobInterfaceTestImpl *impl = new ImportAkregatorJobInterfaceTestImpl(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 IMPORTAKREGATORJOBINTERFACETEST_H
#define IMPORTAKREGATORJOBINTERFACETEST_H
#include <QObject>
#include "akregator/importakregatorjobinterface.h"
class ImportAkregatorJobInterfaceTestImpl : public ImportAkregatorJobInterface
{
Q_OBJECT
public:
explicit ImportAkregatorJobInterfaceTestImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep);
~ImportAkregatorJobInterfaceTestImpl();
protected:
Q_REQUIRED_RESULT Akonadi::Collection::Id convertFolderPathToCollectionId(const QString &path) override;
};
class ImportAkregatorJobInterfaceTest : public QObject
{
Q_OBJECT
public:
explicit ImportAkregatorJobInterfaceTest(QObject *parent = nullptr);
~ImportAkregatorJobInterfaceTest() = default;
private Q_SLOTS:
void importCalendarConfig();
void importCalendarConfig_data();
};
#endif // IMPORTAKREGATORJOBINTERFACETEST_H
......@@ -6,3 +6,12 @@ add_executable( exportalarmjobinterfacetest ${exportalarmjobinterfacetest_SRCS})
add_test(NAME exportalarmjobinterfacetest COMMAND exportalarmjobinterfacetest)
ecm_mark_as_test(exportalarmjobinterfacetest)
target_link_libraries(exportalarmjobinterfacetest Qt5::Test pimdataexporterprivate KF5::ConfigCore test_resourceconverter)
#####
set( importalarmjobinterfacetest_SRCS importalarmjobinterfacetest.cpp)
add_executable( importalarmjobinterfacetest ${importalarmjobinterfacetest_SRCS})
add_test(NAME importalarmjobinterfacetest COMMAND importalarmjobinterfacetest)
ecm_mark_as_test(importalarmjobinterfacetest)
target_link_libraries(importalarmjobinterfacetest 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 "importalarmjobinterfacetest.h"
#include "archivestorage.h"
#include "resourceconvertertest.h"
#include "testimportfile.h"
#include <QSignalSpy>
#include <QTest>
QTEST_MAIN(ImportAlarmJobInterfaceTest)
ImportAlarmJobInterfaceTestImpl::ImportAlarmJobInterfaceTestImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep)
: ImportAlarmJobInterface(parent, typeSelected, archiveStorage, numberOfStep)
{
}
ImportAlarmJobInterfaceTestImpl::~ImportAlarmJobInterfaceTestImpl()
{
}
Akonadi::Collection::Id ImportAlarmJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path)
{
ResourceConverterTest resourceConverterTest;
return resourceConverterTest.convertFolderPathToCollectionId(path);
}
QString ImportAlarmJobInterfaceTestImpl::createResource(const QString &resources, const QString &name, const QMap<QString, QVariant> &settings, bool synchronizeTree)
{
//TODO
return {};
}
void ImportAlarmJobInterfaceTestImpl::synchronizeResource(const QStringList &lst)
{
//TODO
}
ImportAlarmJobInterfaceTest::ImportAlarmJobInterfaceTest(QObject *parent)
: QObject(parent)
{
}
void ImportAlarmJobInterfaceTest::importCalendarConfig_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 ImportAlarmJobInterfaceTest::importCalendarConfig()
{
QFETCH(QString, zipFilePath);
QFETCH(QString, testPath);
TestImportFile *file = new TestImportFile(zipFilePath, this);
file->setPathConfig(zipFilePath + testPath);
file->setExtractPath(QDir::tempPath() + testPath);
ImportAlarmJobInterfaceTestImpl *impl = new ImportAlarmJobInterfaceTestImpl(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 IMPORTALARMJOBINTERFACETEST_H
#define IMPORTALARMJOBINTERFACETEST_H
#include <QObject>
#include "alarm/importalarmjobinterface.h"
class ImportAlarmJobInterfaceTestImpl : public ImportAlarmJobInterface
{
Q_OBJECT
public:
explicit ImportAlarmJobInterfaceTestImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep);
~ImportAlarmJobInterfaceTestImpl();
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 ImportAlarmJobInterfaceTest : public QObject
{
Q_OBJECT
public:
explicit ImportAlarmJobInterfaceTest(QObject *parent = nullptr);
~ImportAlarmJobInterfaceTest() = default;
private Q_SLOTS:
void importCalendarConfig();
void importCalendarConfig_data();
};
#endif // IMPORTALARMJOBINTERFACETEST_H
......@@ -6,3 +6,12 @@ add_executable( exportmailjobinterfacetest ${exportmailjobinterfacetest_SRCS})
add_test(NAME exportmailjobinterfacetest COMMAND exportmailjobinterfacetest)
ecm_mark_as_test(exportmailjobinterfacetest)
target_link_libraries(exportmailjobinterfacetest Qt5::Test pimdataexporterprivate KF5::ConfigCore test_resourceconverter)
#####
set( importmailjobinterfacetest_SRCS importmailjobinterfacetest.cpp)
add_executable( importmailjobinterfacetest ${importmailjobinterfacetest_SRCS})
add_test(NAME importmailjobinterfacetest COMMAND importmailjobinterfacetest)
ecm_mark_as_test(importmailjobinterfacetest)
target_link_libraries(importmailjobinterfacetest Qt5::Test pimdataexporterprivate KF5::ConfigCore KF5::AkonadiMime 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 "importmailjobinterfacetest.h"
#include "archivestorage.h"
#include "resourceconvertertest.h"
#include "testimportfile.h"
#include <QSignalSpy>
#include <QTest>
QTEST_MAIN(ImportMailJobInterfaceTest)
ImportMailJobInterfaceTestImpl::ImportMailJobInterfaceTestImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep)
: ImportMailJobInterface(parent, typeSelected, archiveStorage, numberOfStep)
{
}
ImportMailJobInterfaceTestImpl::~ImportMailJobInterfaceTestImpl()
{
}
Akonadi::Collection::Id ImportMailJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path)
{
ResourceConverterTest resourceConverterTest;
return resourceConverterTest.convertFolderPathToCollectionId(path);
}
void ImportMailJobInterfaceTestImpl::synchronizeResource(const QStringList &lst)
{
//TODO
}
QString ImportMailJobInterfaceTestImpl::createResource(const QString &resources, const QString &name, const QMap<QString, QVariant> &settings)
{
//TODO
return {};
}
void ImportMailJobInterfaceTestImpl::registerSpecialCollection(Akonadi::SpecialMailCollections::Type type, qint64 colId)
{
}
void ImportMailJobInterfaceTestImpl::importFilters(const QVector<MailCommon::MailFilter *> &filters)
{
}
ImportMailJobInterfaceTest::ImportMailJobInterfaceTest(QObject *parent)
: QObject(parent)
{
}
void ImportMailJobInterfaceTest::importMailConfig_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 ImportMailJobInterfaceTest::importMailConfig()
{
QFETCH(QString, zipFilePath);
QFETCH(QString, testPath);
TestImportFile *file = new TestImportFile(zipFilePath, this);
file->setPathConfig(zipFilePath + testPath);
file->setExtractPath(QDir::tempPath() + testPath);
ImportMailJobInterfaceTestImpl *impl = new ImportMailJobInterfaceTestImpl(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 IMPORTMAILJOBINTERFACETEST_H
#define IMPORTMAILJOBINTERFACETEST_H
#include <QObject>
#include "mail/importmailjobinterface.h"
class ImportMailJobInterfaceTestImpl : public ImportMailJobInterface
{
Q_OBJECT
public:
explicit ImportMailJobInterfaceTestImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep);
~ImportMailJobInterfaceTestImpl();
protected:
Q_REQUIRED_RESULT Akonadi::Collection::Id convertFolderPathToCollectionId(const QString &path) override;
void synchronizeResource(const QStringList &lst) override;
Q_REQUIRED_RESULT QString createResource(const QString &resources, const QString &name, const QMap<QString, QVariant> &settings) override;
void registerSpecialCollection(Akonadi::SpecialMailCollections::Type type, qint64 colId) override;
void importFilters(const QVector<MailCommon::MailFilter *> &filters) override;
};
class ImportMailJobInterfaceTest : public QObject
{
Q_OBJECT
public:
explicit ImportMailJobInterfaceTest(QObject *parent = nullptr);
~ImportMailJobInterfaceTest() = default;
private Q_SLOTS:
void importMailConfig();
void importMailConfig_data();
};
#endif // IMPORTMAILJOBINTERFACETEST_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