diff --git a/core/autotests/addressbook/exportaddressbookjobinterfacetestimpl.cpp b/core/autotests/addressbook/exportaddressbookjobinterfacetestimpl.cpp index 2abc624..b995d12 100644 --- a/core/autotests/addressbook/exportaddressbookjobinterfacetestimpl.cpp +++ b/core/autotests/addressbook/exportaddressbookjobinterfacetestimpl.cpp @@ -1,101 +1,100 @@ /* Copyright (C) 2020 Laurent Montel 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 "exportaddressbookjobinterfacetestimpl.h" #include "archivestorage.h" #include "resourceconvertertest.h" #include "saveresourceconfigtest.h" #include "testbackupresourcefilejob.h" -#include ExportAddressbookJobInterfaceTestImpl::ExportAddressbookJobInterfaceTestImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep) : ExportAddressbookJobInterface(parent, typeSelected, archiveStorage, numberOfStep) { } ExportAddressbookJobInterfaceTestImpl::~ExportAddressbookJobInterfaceTestImpl() { } Akonadi::Collection::Id ExportAddressbookJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path) { ResourceConverterTest resourceConverterTest; resourceConverterTest.setTestPath(mPathConfig); return resourceConverterTest.convertFolderPathToCollectionId(path); } void ExportAddressbookJobInterfaceTestImpl::exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) { SaveResourceConfigTest saveResourceConfig; saveResourceConfig.setArchive(mArchiveStorage->archive()); saveResourceConfig.exportResourceToArchive(archivePath, url, identifier, Utils::resourceAddressbookArchiveName(), { QLatin1String("akonadi_vcarddir_resource_"), QLatin1String("akonadi_contacts_resource_") }); slotAddressbookJobTerminated(); } QVector ExportAddressbookJobInterfaceTestImpl::listOfResource() { return mListAkonadiInstanceInfo; } void ExportAddressbookJobInterfaceTestImpl::convertCollectionToRealPath(KConfigGroup &group, const QString ¤tKey) { ResourceConverterTest resourceConverter; resourceConverter.setTestPath(mPathConfig); resourceConverter.convertCollectionToRealPath(group, currentKey); } void ExportAddressbookJobInterfaceTestImpl::convertCollectionListToRealPath(KConfigGroup &group, const QString ¤tKey) { ResourceConverterTest resourceConverter; resourceConverter.setTestPath(mPathConfig); resourceConverter.convertCollectionListToRealPath(group, currentKey); } QString ExportAddressbookJobInterfaceTestImpl::adaptNewResourceUrl(bool overwriteResources, const KSharedConfig::Ptr &resourceConfig, const QString &storePath) { ResourceConverterTest resourceConverterTest; resourceConverterTest.setTestPath(mPathConfig); return resourceConverterTest.adaptNewResourceUrl(overwriteResources, resourceConfig, storePath); } QString ExportAddressbookJobInterfaceTestImpl::createResource(const QString &resources, const QString &name, const QMap &settings, bool synchronizeTree) { Q_UNREACHABLE(); return {}; } QString ExportAddressbookJobInterfaceTestImpl::resourcePath(const QString &agentIdentifier, const QString &defaultPath) const { ResourceConverterTest converter; converter.setTestPath(mPathConfig); const QString url = converter.resourcePath(agentIdentifier, defaultPath); return url; } void ExportAddressbookJobInterfaceTestImpl::backupAddressBookResourceFile(const QString &agentIdentifier, const QString &defaultPath) { TestBackupResourceFileJob *job = new TestBackupResourceFileJob(this); job->setDefaultPath(defaultPath); job->setIdentifier(agentIdentifier); job->setTestPath(mPathConfig); job->setZip(archive()); connect(job, &TestBackupResourceFileJob::error, this, &ExportAddressbookJobInterfaceTestImpl::error); connect(job, &TestBackupResourceFileJob::info, this, &ExportAddressbookJobInterfaceTestImpl::info); job->start(); } diff --git a/core/autotests/addressbook/importaddressbookjobinterfacetest.cpp b/core/autotests/addressbook/importaddressbookjobinterfacetest.cpp index 0e485ac..2e79b84 100644 --- a/core/autotests/addressbook/importaddressbookjobinterfacetest.cpp +++ b/core/autotests/addressbook/importaddressbookjobinterfacetest.cpp @@ -1,63 +1,62 @@ /* Copyright (C) 2020 Laurent Montel 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 "importaddressbookjobinterfacetestimpl.h" #include "testimportfile.h" -#include #include QTEST_MAIN(ImportAddressbookJobInterfaceTest) ImportAddressbookJobInterfaceTest::ImportAddressbookJobInterfaceTest(QObject *parent) : QObject(parent) { } void ImportAddressbookJobInterfaceTest::importAddressbook_data() { QTest::addColumn("zipFilePath"); QTest::addColumn("testPath"); QTest::addColumn("options"); const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/import/"); Utils::StoredTypes options = {Utils::StoredType::Config}; QTest::newRow("addressbookonlyconfig") << QString::fromLatin1(pathConfig) << QStringLiteral("/addressbookonlyconfig/") << options; options = {Utils::StoredType::Config| Utils::StoredType::Resources}; QTest::newRow("addressbookconfigandresources") << QString::fromLatin1(pathConfig) << QStringLiteral("/addressbookconfigandresources/") << options; } void ImportAddressbookJobInterfaceTest::importAddressbook() { QFETCH(QString, zipFilePath); QFETCH(QString, testPath); QFETCH(Utils::StoredTypes, options); TestImportFile *file = new TestImportFile(zipFilePath + testPath, this); file->setPathConfig(zipFilePath + testPath); file->setExtractPath(QDir::tempPath() + testPath); file->setExcludePath(Utils::addressbookPath()); ImportAddressbookJobInterfaceTestImpl *impl = new ImportAddressbookJobInterfaceTestImpl(this, options, file->archiveStorage(), 1); impl->setPathConfig(file->pathConfig()); impl->setExtractPath(file->extractPath()); file->setAbstractImportExportJob(impl); file->setLoggingFilePath(impl->loggingFilePath()); file->start(); delete impl; delete file; } diff --git a/core/autotests/akregator/exportakregatorjobinterfacetest.cpp b/core/autotests/akregator/exportakregatorjobinterfacetest.cpp index 4e73241..83d77ea 100644 --- a/core/autotests/akregator/exportakregatorjobinterfacetest.cpp +++ b/core/autotests/akregator/exportakregatorjobinterfacetest.cpp @@ -1,57 +1,55 @@ /* Copyright (C) 2020 Laurent Montel 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 "exportakregatorjobinterfacetest.h" #include "exportakregatorjobinterfacetestimpl.h" #include "archivestorage.h" #include "testexportfile.h" -#include #include -#include QTEST_MAIN(ExportAkregatorJobInterfaceTest) ExportAkregatorJobInterfaceTest::ExportAkregatorJobInterfaceTest(QObject *parent) : QObject(parent) { } void ExportAkregatorJobInterfaceTest::exportAkregator_data() { QTest::addColumn("configpath"); QTest::addColumn("options"); const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/export/"); Utils::StoredTypes options = {Utils::StoredType::Config}; //TODO options = {Utils::StoredType::Config | Utils::StoredType::Resources}; QTest::newRow("fullresource") << pathConfig + QByteArray("fullresource/") << options; } void ExportAkregatorJobInterfaceTest::exportAkregator() { QFETCH(QByteArray, configpath); QFETCH(Utils::StoredTypes, options); TestExportFile *file = new TestExportFile(this); file->setPathConfig(configpath); ExportAkregatorJobInterfaceTestImpl *exportAkregator = new ExportAkregatorJobInterfaceTestImpl(this, options, file->archiveStorage(), 1); file->setAbstractImportExportJob(exportAkregator); file->start(); delete exportAkregator; } diff --git a/core/autotests/akregator/importakregatorjobinterfacetest.cpp b/core/autotests/akregator/importakregatorjobinterfacetest.cpp index 870f7c3..b14a06d 100644 --- a/core/autotests/akregator/importakregatorjobinterfacetest.cpp +++ b/core/autotests/akregator/importakregatorjobinterfacetest.cpp @@ -1,58 +1,57 @@ /* Copyright (C) 2020 Laurent Montel 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 "importakregatorjobinterfacetestimpl.h" #include "archivestorage.h" #include "testimportfile.h" -#include #include QTEST_MAIN(ImportAkregatorJobInterfaceTest) ImportAkregatorJobInterfaceTest::ImportAkregatorJobInterfaceTest(QObject *parent) : QObject(parent) { } void ImportAkregatorJobInterfaceTest::importAkegator_data() { QTest::addColumn("zipFilePath"); QTest::addColumn("testPath"); QTest::addColumn("options"); const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/import/"); Utils::StoredTypes options = {Utils::StoredType::Config}; QTest::newRow("test1") << QString::fromLatin1(pathConfig) << QStringLiteral("/akregatorconfig/") << options; options = {Utils::StoredType::Config|Utils::StoredType::Resources}; QTest::newRow("test1resource") << QString::fromLatin1(pathConfig) << QStringLiteral("/akregatorresource/") << options; } void ImportAkregatorJobInterfaceTest::importAkegator() { QFETCH(QString, zipFilePath); QFETCH(QString, testPath); QFETCH(Utils::StoredTypes, options); TestImportFile *file = new TestImportFile(zipFilePath + testPath, this); file->setPathConfig(zipFilePath + testPath); file->setExtractPath(QDir::tempPath() + testPath); ImportAkregatorJobInterfaceTestImpl *impl = new ImportAkregatorJobInterfaceTestImpl(this, options, file->archiveStorage(), 1); file->setAbstractImportExportJob(impl); file->start(); delete impl; delete file; } diff --git a/core/autotests/alarm/exportalarmjobinterfacetest.cpp b/core/autotests/alarm/exportalarmjobinterfacetest.cpp index 8ca2bae..8f0a969 100644 --- a/core/autotests/alarm/exportalarmjobinterfacetest.cpp +++ b/core/autotests/alarm/exportalarmjobinterfacetest.cpp @@ -1,68 +1,66 @@ /* Copyright (C) 2020 Laurent Montel 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 "exportalarmjobinterfacetest.h" #include "exportalarmjobinterfacetestimpl.h" #include "archivestorage.h" #include "testexportfile.h" -#include #include -#include QTEST_MAIN(ExportAlarmJobInterfaceTest) ExportAlarmJobInterfaceTest::ExportAlarmJobInterfaceTest(QObject *parent) : QObject(parent) { } void ExportAlarmJobInterfaceTest::exportAlarm_data() { QTest::addColumn("configpath"); QTest::addColumn("options"); Utils::StoredTypes options = {Utils::StoredType::Config}; const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/export/"); QTest::newRow("alarmonlyconfig") << pathConfig + QByteArray("alarmonlyconfig/") << options; options = {Utils::StoredType::Config|Utils::StoredType::Resources}; QTest::newRow("alarmconfigresources") << pathConfig + QByteArray("alarmconfigresources/") << options; } void ExportAlarmJobInterfaceTest::exportAlarm() { QFETCH(QByteArray, configpath); QFETCH(Utils::StoredTypes, options); TestExportFile *file = new TestExportFile(this); file->setPathConfig(configpath); QVector lstInfo; Utils::AkonadiInstanceInfo info; info.identifier = QLatin1String("akonadi_kalarm_dir_resource_1"); lstInfo << info; info.identifier = QLatin1String("akonadi_kalarm_dir_resource_2"); lstInfo << info; //Add extra resource. info.identifier = QStringLiteral("akonadi_kolab_resource_2"); lstInfo << info; ExportAlarmJobInterfaceTestImpl *exportNote = new ExportAlarmJobInterfaceTestImpl(this, options, file->archiveStorage(), 1); exportNote->setListOfResource(lstInfo); exportNote->setPathConfig(QLatin1String(configpath)); file->setAbstractImportExportJob(exportNote); file->start(); delete exportNote; } diff --git a/core/autotests/alarm/exportalarmjobinterfacetestimpl.cpp b/core/autotests/alarm/exportalarmjobinterfacetestimpl.cpp index 742f802..daa1ddc 100644 --- a/core/autotests/alarm/exportalarmjobinterfacetestimpl.cpp +++ b/core/autotests/alarm/exportalarmjobinterfacetestimpl.cpp @@ -1,94 +1,93 @@ /* Copyright (C) 2020 Laurent Montel 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 "exportalarmjobinterfacetestimpl.h" #include "archivestorage.h" #include "resourceconvertertest.h" #include "testbackupresourcefilejob.h" #include "saveresourceconfigtest.h" -#include ExportAlarmJobInterfaceTestImpl::ExportAlarmJobInterfaceTestImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep) : ExportAlarmJobInterface(parent, typeSelected, archiveStorage, numberOfStep) { } ExportAlarmJobInterfaceTestImpl::~ExportAlarmJobInterfaceTestImpl() { } QVector ExportAlarmJobInterfaceTestImpl::listOfResource() { return mListAkonadiInstanceInfo; } Akonadi::Collection::Id ExportAlarmJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path) { ResourceConverterTest resourceConverterTest; resourceConverterTest.setTestPath(mPathConfig); return resourceConverterTest.convertFolderPathToCollectionId(path); } void ExportAlarmJobInterfaceTestImpl::exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) { SaveResourceConfigTest saveResourceConfig; saveResourceConfig.setArchive(mArchiveStorage->archive()); saveResourceConfig.exportResourceToArchive(archivePath, url, identifier, Utils::resourceAlarmArchiveName(), { QLatin1String("akonadi_kalarm_dir_resource_")}); slotAlarmJobTerminated(); } QString ExportAlarmJobInterfaceTestImpl::resourcePath(const QString &identifier) const { ResourceConverterTest converter; converter.setTestPath(mPathConfig); const QString url = converter.resourcePath(identifier); return url; } void ExportAlarmJobInterfaceTestImpl::backupAlarmResourceFile(const QString &agentIdentifier, const QString &defaultPath) { TestBackupResourceFileJob *job = new TestBackupResourceFileJob(this); job->setDefaultPath(defaultPath); job->setIdentifier(agentIdentifier); job->setTestPath(mPathConfig); job->setZip(archive()); connect(job, &TestBackupResourceFileJob::error, this, &ExportAlarmJobInterfaceTestImpl::error); connect(job, &TestBackupResourceFileJob::info, this, &ExportAlarmJobInterfaceTestImpl::info); job->start(); } QString ExportAlarmJobInterfaceTestImpl::adaptNewResourceUrl(bool overwriteResources, const KSharedConfig::Ptr &resourceConfig, const QString &storePath) { ResourceConverterTest resourceConverterTest; resourceConverterTest.setTestPath(mPathConfig); return resourceConverterTest.adaptNewResourceUrl(overwriteResources, resourceConfig, storePath); } void ExportAlarmJobInterfaceTestImpl::convertCollectionIdsToRealPath(KConfigGroup &selectFolderNoteGroup, const QString &selectFolderNoteGroupStr) { ResourceConverterTest resourceConverterTest; resourceConverterTest.setTestPath(mPathConfig); return resourceConverterTest.convertCollectionIdsToRealPath(selectFolderNoteGroup, selectFolderNoteGroupStr); } QString ExportAlarmJobInterfaceTestImpl::createResource(const QString &resources, const QString &name, const QMap &settings, bool synchronizeTree) { Q_UNREACHABLE(); return {}; } diff --git a/core/autotests/alarm/importalarmjobinterfacetest.cpp b/core/autotests/alarm/importalarmjobinterfacetest.cpp index 4188288..32038cd 100644 --- a/core/autotests/alarm/importalarmjobinterfacetest.cpp +++ b/core/autotests/alarm/importalarmjobinterfacetest.cpp @@ -1,61 +1,60 @@ /* Copyright (C) 2020 Laurent Montel 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 "importalarmjobinterfacetestimpl.h" #include "archivestorage.h" #include "testimportfile.h" -#include #include QTEST_MAIN(ImportAlarmJobInterfaceTest) ImportAlarmJobInterfaceTest::ImportAlarmJobInterfaceTest(QObject *parent) : QObject(parent) { } void ImportAlarmJobInterfaceTest::importAlarmConfig_data() { QTest::addColumn("zipFilePath"); QTest::addColumn("testPath"); QTest::addColumn("options"); Utils::StoredTypes options = {Utils::StoredType::Config}; const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/import/"); QTest::newRow("alarmonlyconfig") << QString::fromLatin1(pathConfig) << QStringLiteral("/alarmonlyconfig/") << options; options = {Utils::StoredType::Config|Utils::StoredType::Resources}; QTest::newRow("alarmconfigresources") << QString::fromLatin1(pathConfig) << QStringLiteral("/alarmconfigresources/") << options; } void ImportAlarmJobInterfaceTest::importAlarmConfig() { QFETCH(QString, zipFilePath); QFETCH(QString, testPath); QFETCH(Utils::StoredTypes, options); TestImportFile *file = new TestImportFile(zipFilePath + testPath, this); file->setPathConfig(zipFilePath + testPath); file->setExtractPath(QDir::tempPath() + testPath); file->setExcludePath(Utils::alarmPath()); ImportAlarmJobInterfaceTestImpl *impl = new ImportAlarmJobInterfaceTestImpl(this, options, file->archiveStorage(), 1); impl->setPathConfig(file->pathConfig()); file->setAbstractImportExportJob(impl); file->setLoggingFilePath(impl->loggingFilePath()); file->start(); delete impl; delete file; } diff --git a/core/autotests/calendar/exportcalendarsjobinterfacetest.cpp b/core/autotests/calendar/exportcalendarsjobinterfacetest.cpp index dfb52aa..c9077e4 100644 --- a/core/autotests/calendar/exportcalendarsjobinterfacetest.cpp +++ b/core/autotests/calendar/exportcalendarsjobinterfacetest.cpp @@ -1,69 +1,68 @@ /* Copyright (C) 2020 Laurent Montel 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 "exportcalendarsjobinterfacetest.h" #include "exportcalendarsjobinterfacetestimpl.h" #include "archivestorage.h" #include "testexportfile.h" -#include #include QTEST_MAIN(ExportCalendarsJobInterfaceTest) ExportCalendarsJobInterfaceTest::ExportCalendarsJobInterfaceTest(QObject *parent) : QObject(parent) { } void ExportCalendarsJobInterfaceTest::exportCalendar_data() { QTest::addColumn("configpath"); QTest::addColumn("options"); Utils::StoredTypes options = {Utils::StoredType::Config}; const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/export/"); QTest::newRow("calendaronlyconfig") << pathConfig + QByteArray("calendaronlyconfig/") << options; options = {Utils::StoredType::Config|Utils::StoredType::Resources}; QTest::newRow("calendarconfigandresources") << pathConfig + QByteArray("calendarconfigandresources/") << options; } void ExportCalendarsJobInterfaceTest::exportCalendar() { QFETCH(QByteArray, configpath); QFETCH(Utils::StoredTypes, options); TestExportFile *file = new TestExportFile(this); file->setPathConfig(configpath); QVector lstInfo; Utils::AkonadiInstanceInfo info; info.identifier = QLatin1String("akonadi_icaldir_resource_1"); lstInfo << info; info.identifier = QLatin1String("akonadi_ical_resource_2"); lstInfo << info; //Add extra resource. info.identifier = QLatin1String("akonadi_contacts_resource_1"); lstInfo << info; info.identifier = QStringLiteral("akonadi_kontact_resource_2"); lstInfo << info; ExportCalendarsJobInterfaceTestImpl *exportNote = new ExportCalendarsJobInterfaceTestImpl(this, options, file->archiveStorage(), 1); exportNote->setListOfResource(lstInfo); exportNote->setPathConfig(QLatin1String(configpath)); file->setAbstractImportExportJob(exportNote); file->start(); delete exportNote; } diff --git a/core/autotests/calendar/importcalendarjobinterfacetest.cpp b/core/autotests/calendar/importcalendarjobinterfacetest.cpp index 4b7c5dd..fd284cf 100644 --- a/core/autotests/calendar/importcalendarjobinterfacetest.cpp +++ b/core/autotests/calendar/importcalendarjobinterfacetest.cpp @@ -1,62 +1,61 @@ /* Copyright (C) 2020 Laurent Montel 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 "importcalendarjobinterfacetest.h" #include "importcalendarjobinterfacetestimpl.h" #include "archivestorage.h" #include "testimportfile.h" -#include #include QTEST_MAIN(ImportCalendarJobInterfaceTest) ImportCalendarJobInterfaceTest::ImportCalendarJobInterfaceTest(QObject *parent) : QObject(parent) { } void ImportCalendarJobInterfaceTest::importCalendar_data() { QTest::addColumn("zipFilePath"); QTest::addColumn("testPath"); QTest::addColumn("options"); Utils::StoredTypes options = {Utils::StoredType::Config}; const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/import/"); QTest::newRow("calendaronlyconfig") << QString::fromLatin1(pathConfig) << QStringLiteral("/calendaronlyconfig/") << options; options = {Utils::StoredType::Config|Utils::StoredType::Resources}; QTest::newRow("calendarconfigandresource") << QString::fromLatin1(pathConfig) << QStringLiteral("/calendarconfigandresource/") << options; } void ImportCalendarJobInterfaceTest::importCalendar() { QFETCH(QString, zipFilePath); QFETCH(QString, testPath); QFETCH(Utils::StoredTypes, options); TestImportFile *file = new TestImportFile(zipFilePath + testPath, this); file->setPathConfig(zipFilePath + testPath); file->setExtractPath(QDir::tempPath() + testPath); file->setExcludePath(Utils::calendarPath()); ImportCalendarJobInterfaceTestImpl *impl = new ImportCalendarJobInterfaceTestImpl(this, options, file->archiveStorage(), 1); impl->setPathConfig(file->pathConfig()); file->setAbstractImportExportJob(impl); file->setLoggingFilePath(impl->loggingFilePath()); file->start(); delete impl; delete file; } diff --git a/core/autotests/compareexportfile.cpp b/core/autotests/compareexportfile.cpp index ae7c78a..0bb91a4 100644 --- a/core/autotests/compareexportfile.cpp +++ b/core/autotests/compareexportfile.cpp @@ -1,115 +1,114 @@ /* Copyright (C) 2020 Laurent Montel 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 "compareexportfile.h" #include "generatelistfilefromarchive.h" #include "loadlistfromfile.h" #include "comparefilehelper.h" #include #include -#include #include #define KEEP_TEMPORARY_FILES 1 CompareExportFile::CompareExportFile() { } CompareExportFile::~CompareExportFile() { delete mZip; mZip = nullptr; delete mTempDir; mTempDir = nullptr; } void CompareExportFile::compareFiles() { GenerateListFileFromArchive archive(mTempFilePath); //qDebug() << " archive " << archive.listFile(); LoadListFromFile f(mListFilePath + QStringLiteral("/list.txt")); const QStringList archiveList = archive.listFile(); const bool equal = (f.fileList() == archiveList); if (!equal) { qDebug() << "Requested : " << f.fileList(); qDebug() << "List File : " << archiveList; } QVERIFY(equal); mZip = new KZip(mTempFilePath); //qDebug() << " mFileName" << mFileName; const bool result = mZip->open(QIODevice::ReadOnly); QVERIFY(result); const KArchiveDirectory *topDirectory = mZip->directory(); for (const QString &file : archiveList) { if (file == QLatin1String("information/VERSION_2") || file == QLatin1String("information/exportdatatype.xml")) { continue; } const KArchiveEntry *currentEntry = topDirectory->entry(file); if (currentEntry && currentEntry->isFile()) { if (!mTempDir) { mTempDir = new QTemporaryDir; #ifdef KEEP_TEMPORARY_FILES mTempDir->setAutoRemove(false); #endif } const KArchiveFile *currentFile = static_cast(currentEntry); QString adaptFile = file; //We store in zip as configs, but we extract in config/ adaptFile.replace(QStringLiteral("configs/"), QStringLiteral("config/")); const QString fileName = mTempDir->path() + QLatin1Char('/') + adaptFile; //create path const QFileInfo fileInfo(fileName); QDir().mkpath(fileInfo.dir().path()); QFile f(fileName); //qDebug() << " fileName" << fileName; QVERIFY(f.open(QIODevice::WriteOnly)); //Store data. const QByteArray data = currentFile->data(); QCOMPARE(f.write(data), data.length()); f.close(); CompareFileHelper::compareFile(mListFilePath + QStringLiteral("/references/") + adaptFile, fileName); } } } QString CompareExportFile::tempFilePath() const { return mTempFilePath; } void CompareExportFile::setTempFilePath(const QString &tempFilePath) { mTempFilePath = tempFilePath; } QString CompareExportFile::listFilePath() const { return mListFilePath; } void CompareExportFile::setListFilePath(const QString &listFilePath) { mListFilePath = listFilePath; } diff --git a/core/autotests/compareimportfile.cpp b/core/autotests/compareimportfile.cpp index f70bc19..7ca62c6 100644 --- a/core/autotests/compareimportfile.cpp +++ b/core/autotests/compareimportfile.cpp @@ -1,105 +1,104 @@ /* Copyright (C) 2020 Laurent Montel 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 "compareimportfile.h" #include "generatelistfilefromarchive.h" #include "loadlistfromfile.h" #include "comparefilehelper.h" -#include #include CompareImportFile::CompareImportFile() { } CompareImportFile::~CompareImportFile() { } void CompareImportFile::compareFile() { GenerateListFileFromArchive archive(mArchiveFilePath); //qDebug() << " archive " << archive.listFile(); LoadListFromFile f(mListFilePath + QStringLiteral("/list.txt")); const QStringList archiveList = archive.listFile(); const bool equal = (f.fileList() == archiveList); if (!equal) { qDebug() << "Requested : " << f.fileList(); qDebug() << "List File : " << archiveList; } QVERIFY(equal); for (QString file : archiveList) { file.replace(QStringLiteral("configs/"), QStringLiteral("config/")); if (file == QLatin1String("information/exportdatatype.xml") || file == QLatin1String("information/VERSION_2")) { continue; } if (file.endsWith(QLatin1String("ui.rc"))) { //TODO customize it file.replace(QLatin1String("config/"), QLatin1String("share/kxmlgui5/kaddressbook/")); } //file.replace(QStringLiteral("identities/"), QStringLiteral("config/")); file.replace(QStringLiteral("transports/"), QStringLiteral("config/")); //Allow to remove some file from resources path if (file.startsWith(mExcludePath)) { continue; } CompareFileHelper::compareFile(mListFilePath + QStringLiteral("/references/") + file, mInstallPath + QLatin1Char('/') + file); } } QString CompareImportFile::archiveFilePath() const { return mArchiveFilePath; } void CompareImportFile::setArchiveFilePath(const QString &archiveFilePath) { mArchiveFilePath = archiveFilePath; } QString CompareImportFile::listFilePath() const { return mListFilePath; } void CompareImportFile::setListFilePath(const QString &listFilePath) { mListFilePath = listFilePath; } QString CompareImportFile::installPath() const { return mInstallPath; } void CompareImportFile::setInstallPath(const QString &installPath) { mInstallPath = installPath; } QString CompareImportFile::excludePath() const { return mExcludePath; } void CompareImportFile::setExcludePath(const QString &excludePath) { mExcludePath = excludePath; } diff --git a/core/autotests/logcreatingressource.cpp b/core/autotests/logcreatingressource.cpp index f4f800f..f194b9a 100644 --- a/core/autotests/logcreatingressource.cpp +++ b/core/autotests/logcreatingressource.cpp @@ -1,76 +1,75 @@ /* Copyright (C) 2020 Laurent Montel 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 "logcreatingressource.h" #include #include -#include LogCreatingResource::LogCreatingResource(QObject *parent) : QObject(parent) { mTmpLogFile = new QTemporaryFile(this); mTmpLogFile->open(); } LogCreatingResource::~LogCreatingResource() { } void LogCreatingResource::appendText(const QString &str) { QTextStream stream(mTmpLogFile); stream << str << '\n'; stream << "--------------------------\n"; } void LogCreatingResource::logSynchronizeResource(const QStringList &lst) { if (!lst.isEmpty()) { appendText(lst.join(QLatin1Char('\n'))); } } void LogCreatingResource::logRegisterSpecialCollection(Akonadi::SpecialMailCollections::Type type, qint64 colId) { QTextStream stream(mTmpLogFile); stream << "Special Collection : " << type << " colId " << colId << '\n'; stream << "--------------------------\n"; } QString LogCreatingResource::logPath() const { return mTmpLogFile->fileName(); } QString LogCreatingResource::logCreateResource(const QString &resources, const QString &name, const QMap &settings, bool synchronizeTree) { QTextStream stream(mTmpLogFile); stream << resources << '\n'; stream << name << '\n'; QMapIterator i(settings); while (i.hasNext()) { i.next(); stream << i.key() << ' ' << i.value().toString() << '\n'; } stream << synchronizeTree << '\n'; stream << "--------------------------\n"; return resources + QStringLiteral("_new_resource_") + QString::number(mResourceIndex++); } diff --git a/core/autotests/mail/exportmailjobinterfacetest.cpp b/core/autotests/mail/exportmailjobinterfacetest.cpp index aee204f..d0d73eb 100644 --- a/core/autotests/mail/exportmailjobinterfacetest.cpp +++ b/core/autotests/mail/exportmailjobinterfacetest.cpp @@ -1,74 +1,73 @@ /* Copyright (C) 2020 Laurent Montel 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 "exportmailjobinterfacetest.h" #include "exportmailjobinterfacetestimpl.h" #include "archivestorage.h" #include "testexportfile.h" -#include #include QTEST_MAIN(ExportMailJobInterfaceTest) ExportMailJobInterfaceTest::ExportMailJobInterfaceTest(QObject *parent) : QObject(parent) { } void ExportMailJobInterfaceTest::exportMail_data() { QTest::addColumn("configpath"); QTest::addColumn("options"); const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/export/"); Utils::StoredTypes options = {Utils::StoredType::Config}; QTest::newRow("mailonlyconfig") << pathConfig + QByteArray("mailonlyconfig/") << options; options = {Utils::StoredType::Config|Utils::StoredType::Resources}; QTest::newRow("mailconfigandresource") << pathConfig + QByteArray("mailconfigandresource/") << options; options = {Utils::StoredType::MailTransport}; QTest::newRow("mailtransport") << pathConfig + QByteArray("mailtransport/") << options; options = {Utils::StoredType::Identity}; QTest::newRow("identities") << pathConfig + QByteArray("identities/") << options; } void ExportMailJobInterfaceTest::exportMail() { QFETCH(QByteArray, configpath); QFETCH(Utils::StoredTypes, options); TestExportFile *file = new TestExportFile(this); file->setPathConfig(configpath); QVector lstInfo; Utils::AkonadiInstanceInfo info; info.identifier = QLatin1String("akonadi_mbox_resource_1"); lstInfo << info; info.identifier = QLatin1String("akonadi_maildir_resource_1"); lstInfo << info; info.identifier = QLatin1String("akonadi_mixedmaildir_resource_1"); lstInfo << info; //Add extra resource. info.identifier = QStringLiteral("akonadi_kolab_resource_2"); lstInfo << info; ExportMailJobInterfaceTestImpl *exportNote = new ExportMailJobInterfaceTestImpl(this, options, file->archiveStorage(), 1); exportNote->setListOfResource(lstInfo); exportNote->setPathConfig(QLatin1String(configpath)); file->setAbstractImportExportJob(exportNote); file->start(); delete exportNote; } diff --git a/core/autotests/mail/exportmailjobinterfacetestimpl.cpp b/core/autotests/mail/exportmailjobinterfacetestimpl.cpp index 6703d13..9dd600a 100644 --- a/core/autotests/mail/exportmailjobinterfacetestimpl.cpp +++ b/core/autotests/mail/exportmailjobinterfacetestimpl.cpp @@ -1,140 +1,139 @@ /* Copyright (C) 2020 Laurent Montel 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 "exportmailjobinterfacetestimpl.h" #include "archivestorage.h" #include "resourceconvertertest.h" #include "saveresourceconfigtest.h" #include "testbackupresourcefilejob.h" #include -#include ExportMailJobInterfaceTestImpl::ExportMailJobInterfaceTestImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep) : ExportMailJobInterface(parent, typeSelected, archiveStorage, numberOfStep) { } ExportMailJobInterfaceTestImpl::~ExportMailJobInterfaceTestImpl() { } void ExportMailJobInterfaceTestImpl::convertCollectionToRealPath(KConfigGroup &group, const QString ¤tKey) { ResourceConverterTest resourceConverter; resourceConverter.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR)); resourceConverter.convertCollectionToRealPath(group, currentKey); } void ExportMailJobInterfaceTestImpl::convertCollectionListToRealPath(KConfigGroup &group, const QString ¤tKey) { ResourceConverterTest resourceConverter; resourceConverter.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR)); resourceConverter.convertCollectionListToRealPath(group, currentKey); } void ExportMailJobInterfaceTestImpl::convertCollectionIdsToRealPath(KConfigGroup &group, const QString ¤tKey, const QString &prefixCollection) { ResourceConverterTest resourceConverter; resourceConverter.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR)); resourceConverter.convertCollectionIdsToRealPath(group, currentKey, prefixCollection); } Akonadi::Collection::Id ExportMailJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path) { ResourceConverterTest resourceConverterTest; resourceConverterTest.setTestPath(mPathConfig); return resourceConverterTest.convertFolderPathToCollectionId(path); } QVector ExportMailJobInterfaceTestImpl::filters() { qDebug() << " not implement yet ExportMailJobInterfaceTestImpl::filters()"; //TODO implement it return {}; } void ExportMailJobInterfaceTestImpl::exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) { SaveResourceConfigTest saveResourceConfig; saveResourceConfig.setArchive(mArchiveStorage->archive()); saveResourceConfig.exportResourceToArchive(archivePath, url, identifier, Utils::resourceMailArchiveName(), { QLatin1String("akonadi_maildir_resource_"), QLatin1String("akonadi_mixedmaildir_resource_")}); slotMailsJobTerminated(); } QVector ExportMailJobInterfaceTestImpl::listOfResource() { return mListAkonadiInstanceInfo; } QString ExportMailJobInterfaceTestImpl::storeResources(KZip *archive, const QString &identifier, const QString &path) { ResourceConverterTest converter; return converter.storeResources(archive, identifier, path); } QString ExportMailJobInterfaceTestImpl::convertToFullCollectionPath(const qlonglong collectionValue) { ResourceConverterTest converter; converter.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR)); return converter.convertToFullCollectionPath(collectionValue); } QString ExportMailJobInterfaceTestImpl::resourcePath(const QString &identifier) const { ResourceConverterTest converter; converter.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR)); const QString url = converter.resourcePath(identifier); return url; } void ExportMailJobInterfaceTestImpl::exportFilters() { qDebug() << " void ExportMailJobInterfaceTestImpl::exportFilters() not implemented yet"; } void ExportMailJobInterfaceTestImpl::backupMailResourceFile(const QString &agentIdentifier, const QString &defaultPath) { TestBackupResourceFileJob *job = new TestBackupResourceFileJob(this); job->setDefaultPath(defaultPath); job->setIdentifier(agentIdentifier); job->setTestPath(mPathConfig); job->setZip(archive()); connect(job, &TestBackupResourceFileJob::error, this, &ExportMailJobInterfaceTestImpl::error); connect(job, &TestBackupResourceFileJob::info, this, &ExportMailJobInterfaceTestImpl::info); job->start(); } QString ExportMailJobInterfaceTestImpl::adaptNewResourceUrl(bool overwriteResources, const KSharedConfig::Ptr &resourceConfig, const QString &storePath) { ResourceConverterTest resourceConverterTest; resourceConverterTest.setTestPath(mPathConfig); return resourceConverterTest.adaptNewResourceUrl(overwriteResources, resourceConfig, storePath); } QString ExportMailJobInterfaceTestImpl::createResource(const QString &resources, const QString &name, const QMap &settings, bool synchronizeTree) { Q_UNREACHABLE(); return {}; } QVector ExportMailJobInterfaceTestImpl::listIdentityUoid() const { return {10, 11, 12, 13, 14}; } diff --git a/core/autotests/mail/importmailjobinterfacetest.cpp b/core/autotests/mail/importmailjobinterfacetest.cpp index 92eef0c..7337cdf 100644 --- a/core/autotests/mail/importmailjobinterfacetest.cpp +++ b/core/autotests/mail/importmailjobinterfacetest.cpp @@ -1,68 +1,67 @@ /* Copyright (C) 2020 Laurent Montel 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 "importmailjobinterfacetestimpl.h" #include "archivestorage.h" #include "testimportfile.h" #include "utils.h" -#include #include QTEST_MAIN(ImportMailJobInterfaceTest) ImportMailJobInterfaceTest::ImportMailJobInterfaceTest(QObject *parent) : QObject(parent) { } void ImportMailJobInterfaceTest::importMail_data() { QTest::addColumn("zipFilePath"); QTest::addColumn("testPath"); QTest::addColumn("options"); Utils::StoredTypes options = {Utils::StoredType::Config}; const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/import/"); QTest::newRow("mailonlyconfig") << QString::fromLatin1(pathConfig) << QStringLiteral("/mailonlyconfig/") << options; options = {Utils::StoredType::Config|Utils::StoredType::Resources}; QTest::newRow("mailconfigandresource") << QString::fromLatin1(pathConfig) << QStringLiteral("mailconfigandresource/") << options; options = {Utils::StoredType::MailTransport}; QTest::newRow("mailtransport") << QString::fromLatin1(pathConfig) << QStringLiteral("mailtransport/") << options; options = {Utils::StoredType::Identity}; QTest::newRow("identities") << QString::fromLatin1(pathConfig) << QStringLiteral("identities/") << options; } void ImportMailJobInterfaceTest::importMail() { QFETCH(QString, zipFilePath); QFETCH(QString, testPath); QFETCH(Utils::StoredTypes, options); TestImportFile *file = new TestImportFile(zipFilePath + testPath, this); file->setPathConfig(zipFilePath + testPath); file->setExtractPath(QDir::tempPath() + QLatin1Char('/') + testPath); file->setExcludePath(Utils::mailsPath()); // ??? ImportMailJobInterfaceTestImpl *impl = new ImportMailJobInterfaceTestImpl(this, options, file->archiveStorage(), 1); impl->setPathConfig(file->pathConfig()); impl->setExtractPath(file->extractPath()); file->setAbstractImportExportJob(impl); file->setLoggingFilePath(impl->loggingFilePath()); file->start(); delete impl; delete file; } diff --git a/core/autotests/mail/importmailjobinterfacetestimpl.cpp b/core/autotests/mail/importmailjobinterfacetestimpl.cpp index c2edf91..6996a1b 100644 --- a/core/autotests/mail/importmailjobinterfacetestimpl.cpp +++ b/core/autotests/mail/importmailjobinterfacetestimpl.cpp @@ -1,124 +1,123 @@ /* Copyright (C) 2020 Laurent Montel 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 "importmailjobinterfacetestimpl.h" #include "archivestorage.h" #include "resourceconvertertest.h" #include "testimportfile.h" #include "utils.h" #include "mail/smtpmailtransport.h" #include #include -#include #include ImportMailJobInterfaceTestImpl::ImportMailJobInterfaceTestImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep) : ImportMailJobInterface(parent, typeSelected, archiveStorage, numberOfStep) { } ImportMailJobInterfaceTestImpl::~ImportMailJobInterfaceTestImpl() { //Clean up temp repo. FIXME ! QVERIFY(QDir(extractPath()).removeRecursively()); } void ImportMailJobInterfaceTestImpl::start() { QDir().mkpath(extractPath()); //Create temporary file for identities ImportMailJobInterface::start(); } Akonadi::Collection::Id ImportMailJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path) { ResourceConverterTest resourceConverterTest; resourceConverterTest.setTestPath(mPathConfig); return resourceConverterTest.convertFolderPathToCollectionId(path); } void ImportMailJobInterfaceTestImpl::synchronizeResource(const QStringList &lst) { mLogCreateResource->logSynchronizeResource(lst); slotNextStep(); } QString ImportMailJobInterfaceTestImpl::createResource(const QString &resources, const QString &name, const QMap &settings, bool synchronizeTree) { return mLogCreateResource->logCreateResource(resources, name, settings, synchronizeTree); } void ImportMailJobInterfaceTestImpl::registerSpecialCollection(Akonadi::SpecialMailCollections::Type type, qint64 colId) { mLogCreateResource->logRegisterSpecialCollection(type, colId); } void ImportMailJobInterfaceTestImpl::importFilters(const QVector &filters) { qDebug() << " void ImportMailJobInterfaceTestImpl::importFilters(const QVector &filters)"; } QString ImportMailJobInterfaceTestImpl::adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData) { ResourceConverterTest resourceConverterTest; resourceConverterTest.setTestPath(mPathConfig); return resourceConverterTest.adaptResourcePath(resourceConfig, storedData); } QString ImportMailJobInterfaceTestImpl::adaptNewResourceUrl(bool overwriteResources, const KSharedConfig::Ptr &resourceConfig, const QString &storePath) { ResourceConverterTest resourceConverterTest; resourceConverterTest.setTestPath(mPathConfig); return resourceConverterTest.adaptNewResourceUrl(overwriteResources, resourceConfig, storePath); } void ImportMailJobInterfaceTestImpl::addNewIdentity(const QString &name, KConfigGroup &group, int defaultIdentities, int oldUid) { qDebug() << " void ImportMailJobInterfaceTestImpl::addNewIdentity(const QString &name, KConfigGroup &group, int defaultIdentities, int oldUid) not implemented yet" << oldUid << " name " << name; KIdentityManagement::Identity identity; identity.setUoid(mIdentityUoid++); group.writeEntry(QStringLiteral("Name"), name); group.sync(); identity.readConfig(group); if (oldUid != -1) { mHashIdentity.insert(oldUid, identity.uoid()); if (oldUid == defaultIdentities) { //TODO //mIdentityManager->setAsDefault(identity->uoid()); } } // identity.writeConfig(); //TODO write identity ? //TODO log it. //mIdentityManager->commit(); } void ImportMailJobInterfaceTestImpl::importCustomMailTransport(const QString &identifierValue, const KConfigGroup &group, int defaultTransport, int transportId) { qDebug() << "importCustomMailTransport(const QString &identifierValue, const KConfigGroup &group, int defaultTransport, int transportId) not implemented yet"; } void ImportMailJobInterfaceTestImpl::importSmtpMailTransport(const KConfigGroup &group, int defaultTransport, int transportId) { SmtpMailTransport smtpMailTransport(group); qDebug() << "ImportMailJobInterfaceTestImpl::importSmtpMailTransport(const KConfigGroup &group, int defaultTransport, int transportId) not implement yet"; qDebug() << " defaultTransport " << defaultTransport << " transportId " << transportId; } diff --git a/core/autotests/notes/exportnotesjobinterfacetest.cpp b/core/autotests/notes/exportnotesjobinterfacetest.cpp index d60909f..56d3978 100644 --- a/core/autotests/notes/exportnotesjobinterfacetest.cpp +++ b/core/autotests/notes/exportnotesjobinterfacetest.cpp @@ -1,69 +1,67 @@ /* Copyright (C) 2020 Laurent Montel 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 "exportnotesjobinterfacetest.h" #include "exportnotesjobinterfacetestimpl.h" #include "archivestorage.h" #include "testexportfile.h" -#include -#include #include QTEST_MAIN(ExportNotesJobInterfaceTest) ExportNotesJobInterfaceTest::ExportNotesJobInterfaceTest(QObject *parent) : QObject(parent) { } void ExportNotesJobInterfaceTest::exportNote_data() { QTest::addColumn("configpath"); QTest::addColumn("options"); const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/export/"); Utils::StoredTypes options = {Utils::StoredType::Config}; QTest::newRow("test1") << pathConfig + QByteArray("test1/") << options; QTest::newRow("full") << pathConfig + QByteArray("full/") << options; options = {Utils::StoredType::Config|Utils::StoredType::Resources}; QTest::newRow("noteconfigandresource") << pathConfig + QByteArray("noteconfigandresource/") << options; } void ExportNotesJobInterfaceTest::exportNote() { QFETCH(QByteArray, configpath); QFETCH(Utils::StoredTypes, options); TestExportFile *file = new TestExportFile(this); file->setPathConfig(configpath); QVector lstInfo; Utils::AkonadiInstanceInfo info; info.identifier = QStringLiteral("akonadi_akonotes_resource_1"); lstInfo << info; info.identifier = QStringLiteral("akonadi_akonotes_resource_2"); lstInfo << info; //Add extra resource. info.identifier = QStringLiteral("akonadi_kontact_resource_2"); lstInfo << info; ExportNotesJobInterfaceTestImpl *exportNote = new ExportNotesJobInterfaceTestImpl(this, options, file->archiveStorage(), 1); exportNote->setListOfResource(lstInfo); exportNote->setPathConfig(QLatin1String(configpath)); file->setAbstractImportExportJob(exportNote); file->start(); delete exportNote; } diff --git a/core/autotests/notes/exportnotesjobinterfacetestimpl.cpp b/core/autotests/notes/exportnotesjobinterfacetestimpl.cpp index 3a4758e..67c51c1 100644 --- a/core/autotests/notes/exportnotesjobinterfacetestimpl.cpp +++ b/core/autotests/notes/exportnotesjobinterfacetestimpl.cpp @@ -1,82 +1,80 @@ /* Copyright (C) 2020 Laurent Montel 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 "exportnotesjobinterfacetestimpl.h" #include "archivestorage.h" #include "resourceconvertertest.h" #include "saveresourceconfigtest.h" #include -#include -#include ExportNotesJobInterfaceTestImpl::ExportNotesJobInterfaceTestImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep) : ExportNotesJobInterface(parent, typeSelected, archiveStorage, numberOfStep) { } ExportNotesJobInterfaceTestImpl::~ExportNotesJobInterfaceTestImpl() { } void ExportNotesJobInterfaceTestImpl::convertCollectionIdsToRealPath(KConfigGroup &selectFolderNoteGroup, const QString &selectFolderNoteGroupStr) { ResourceConverterTest resourceConverterTest; resourceConverterTest.setTestPath(mPathConfig); resourceConverterTest.convertCollectionIdsToRealPath(selectFolderNoteGroup, selectFolderNoteGroupStr); } QVector ExportNotesJobInterfaceTestImpl::listOfResource() { return mListAkonadiInstanceInfo; } void ExportNotesJobInterfaceTestImpl::exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) { SaveResourceConfigTest saveResourceConfig; saveResourceConfig.setArchive(mArchiveStorage->archive()); saveResourceConfig.exportResourceToArchive(archivePath, url, identifier, Utils::resourceNoteArchiveName(), {QLatin1String("akonadi_akonotes_resource_")}); slotNoteJobTerminated(); } Akonadi::Collection::Id ExportNotesJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path) { ResourceConverterTest resourceConverterTest; resourceConverterTest.setTestPath(mPathConfig); return resourceConverterTest.convertFolderPathToCollectionId(path); } QString ExportNotesJobInterfaceTestImpl::resourcePath(const QString &identifier) const { ResourceConverterTest converter; converter.setTestPath(mPathConfig); const QString url = converter.resourcePath(identifier); return url; } QString ExportNotesJobInterfaceTestImpl::adaptNewResourceUrl(bool overwriteResources, const KSharedConfig::Ptr &resourceConfig, const QString &storePath) { ResourceConverterTest resourceConverterTest; resourceConverterTest.setTestPath(mPathConfig); return resourceConverterTest.adaptNewResourceUrl(overwriteResources, resourceConfig, storePath); } QString ExportNotesJobInterfaceTestImpl::createResource(const QString &resources, const QString &name, const QMap &settings, bool synchronizeTree) { Q_UNREACHABLE(); return {}; } diff --git a/core/autotests/notes/importnotesjobinterfacetest.cpp b/core/autotests/notes/importnotesjobinterfacetest.cpp index 6a89da2..6c4c82d 100644 --- a/core/autotests/notes/importnotesjobinterfacetest.cpp +++ b/core/autotests/notes/importnotesjobinterfacetest.cpp @@ -1,61 +1,60 @@ /* Copyright (C) 2020 Laurent Montel 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 "importnotesjobinterfacetest.h" #include "importnotesjobinterfacetestimpl.h" #include "archivestorage.h" #include "testimportfile.h" -#include #include QTEST_MAIN(ImportNotesJobInterfaceTest) ImportNotesJobInterfaceTest::ImportNotesJobInterfaceTest(QObject *parent) : QObject(parent) { } void ImportNotesJobInterfaceTest::importNote_data() { QTest::addColumn("zipFilePath"); QTest::addColumn("testPath"); QTest::addColumn("options"); const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/import/"); Utils::StoredTypes options = {Utils::StoredType::Config}; QTest::newRow("test1") << QString::fromLatin1(pathConfig) << QStringLiteral("/test1/") << options; options = {Utils::StoredType::Config|Utils::StoredType::Resources}; QTest::newRow("test1resource") << QString::fromLatin1(pathConfig) << QStringLiteral("/test1resource/") << options; } void ImportNotesJobInterfaceTest::importNote() { QFETCH(QString, zipFilePath); QFETCH(QString, testPath); QFETCH(Utils::StoredTypes, options); TestImportFile *file = new TestImportFile(zipFilePath + testPath, this); file->setPathConfig(zipFilePath + testPath); file->setExtractPath(QDir::tempPath() + testPath); file->setExcludePath(Utils::notePath()); ImportNotesJobInterfaceTestImpl *impl = new ImportNotesJobInterfaceTestImpl(this, options, file->archiveStorage(), 1); impl->setPathConfig(file->pathConfig()); file->setAbstractImportExportJob(impl); file->setLoggingFilePath(impl->loggingFilePath()); file->start(); delete impl; delete file; } diff --git a/core/autotests/testbackupresourcefilejob.cpp b/core/autotests/testbackupresourcefilejob.cpp index 2729f72..7d6e6f6 100644 --- a/core/autotests/testbackupresourcefilejob.cpp +++ b/core/autotests/testbackupresourcefilejob.cpp @@ -1,43 +1,42 @@ /* Copyright (C) 2020 Laurent Montel 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 "testbackupresourcefilejob.h" #include "resourceconvertertest.h" -#include TestBackupResourceFileJob::TestBackupResourceFileJob(QObject *parent) : BackupResourceFileJobBase(parent) { } TestBackupResourceFileJob::~TestBackupResourceFileJob() { } QString TestBackupResourceFileJob::resourcePath(const QString &identifier) const { ResourceConverterTest converter; converter.setTestPath(mTestPath); const QString url = converter.resourcePath(identifier); return url; } void TestBackupResourceFileJob::setTestPath(const QString &str) { mTestPath = str; }