diff --git a/core/autotests/alarm/importalarmjobinterfacetest.cpp b/core/autotests/alarm/importalarmjobinterfacetest.cpp index 32038cd..56675ec 100644 --- a/core/autotests/alarm/importalarmjobinterfacetest.cpp +++ b/core/autotests/alarm/importalarmjobinterfacetest.cpp @@ -1,60 +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 "importalarmjobinterfacetest.h" #include "importalarmjobinterfacetestimpl.h" #include "archivestorage.h" #include "testimportfile.h" #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()); + impl->setExtractPath(file->extractPath()); file->setAbstractImportExportJob(impl); file->setLoggingFilePath(impl->loggingFilePath()); file->start(); delete impl; delete file; } diff --git a/core/autotests/alarm/importalarmjobinterfacetestimpl.cpp b/core/autotests/alarm/importalarmjobinterfacetestimpl.cpp index 496177c..b71e3f3 100644 --- a/core/autotests/alarm/importalarmjobinterfacetestimpl.cpp +++ b/core/autotests/alarm/importalarmjobinterfacetestimpl.cpp @@ -1,68 +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 "importalarmjobinterfacetestimpl.h" #include "archivestorage.h" #include "resourceconvertertest.h" #include #include ImportAlarmJobInterfaceTestImpl::ImportAlarmJobInterfaceTestImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep) : ImportAlarmJobInterface(parent, typeSelected, archiveStorage, numberOfStep) { } ImportAlarmJobInterfaceTestImpl::~ImportAlarmJobInterfaceTestImpl() { //Clean up temp repo - QVERIFY(QDir(QDir::tempPath() + QLatin1Char('/') + Utils::storeAlarm()).removeRecursively()); + QVERIFY(QDir(extractPath()).removeRecursively()); } Akonadi::Collection::Id ImportAlarmJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path) { ResourceConverterTest resourceConverterTest; resourceConverterTest.setTestPath(mPathConfig); return resourceConverterTest.convertFolderPathToCollectionId(path); } QString ImportAlarmJobInterfaceTestImpl::createResource(const QString &resources, const QString &name, const QMap &settings, bool synchronizeTree) { return mLogCreateResource->logCreateResource(resources, name, settings, synchronizeTree); } void ImportAlarmJobInterfaceTestImpl::synchronizeResource(const QStringList &lst) { mLogCreateResource->logSynchronizeResource(lst); slotNextStep(); } QString ImportAlarmJobInterfaceTestImpl::adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData) { ResourceConverterTest resourceConverterTest; resourceConverterTest.setTestPath(mPathConfig); return resourceConverterTest.adaptResourcePath(resourceConfig, storedData); } QString ImportAlarmJobInterfaceTestImpl::adaptNewResourceUrl(bool overwriteResources, const KSharedConfig::Ptr &resourceConfig, const QString &storePath) { ResourceConverterTest resourceConverterTest; resourceConverterTest.setTestPath(mPathConfig); return resourceConverterTest.adaptNewResourceUrl(overwriteResources, resourceConfig, storePath); } diff --git a/core/autotests/calendar/importcalendarjobinterfacetest.cpp b/core/autotests/calendar/importcalendarjobinterfacetest.cpp index fd284cf..2c82808 100644 --- a/core/autotests/calendar/importcalendarjobinterfacetest.cpp +++ b/core/autotests/calendar/importcalendarjobinterfacetest.cpp @@ -1,61 +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 "importcalendarjobinterfacetest.h" #include "importcalendarjobinterfacetestimpl.h" #include "archivestorage.h" #include "testimportfile.h" #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()); + impl->setExtractPath(file->extractPath()); file->setAbstractImportExportJob(impl); file->setLoggingFilePath(impl->loggingFilePath()); file->start(); delete impl; delete file; } diff --git a/core/autotests/calendar/importcalendarjobinterfacetestimpl.cpp b/core/autotests/calendar/importcalendarjobinterfacetestimpl.cpp index bc26721..3800fea 100644 --- a/core/autotests/calendar/importcalendarjobinterfacetestimpl.cpp +++ b/core/autotests/calendar/importcalendarjobinterfacetestimpl.cpp @@ -1,66 +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 "importcalendarjobinterfacetestimpl.h" #include "archivestorage.h" #include "resourceconvertertest.h" #include ImportCalendarJobInterfaceTestImpl::ImportCalendarJobInterfaceTestImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep) : ImportCalendarJobInterface(parent, typeSelected, archiveStorage, numberOfStep) { } ImportCalendarJobInterfaceTestImpl::~ImportCalendarJobInterfaceTestImpl() { //Clean up temp repo - QVERIFY(QDir(QDir::tempPath() + QLatin1Char('/') + Utils::storeCalendar()).removeRecursively()); + QVERIFY(QDir(extractPath()).removeRecursively()); } Akonadi::Collection::Id ImportCalendarJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path) { ResourceConverterTest resourceConverterTest; resourceConverterTest.setTestPath(mPathConfig); return resourceConverterTest.convertFolderPathToCollectionId(path); } QString ImportCalendarJobInterfaceTestImpl::createResource(const QString &resources, const QString &name, const QMap &settings, bool synchronizeTree) { return mLogCreateResource->logCreateResource(resources, name, settings, synchronizeTree); } void ImportCalendarJobInterfaceTestImpl::synchronizeResource(const QStringList &lst) { mLogCreateResource->logSynchronizeResource(lst); slotNextStep(); } QString ImportCalendarJobInterfaceTestImpl::adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData) { ResourceConverterTest resourceConverterTest; resourceConverterTest.setTestPath(mPathConfig); return resourceConverterTest.adaptResourcePath(resourceConfig, storedData); } QString ImportCalendarJobInterfaceTestImpl::adaptNewResourceUrl(bool overwriteResources, const KSharedConfig::Ptr &resourceConfig, const QString &storePath) { ResourceConverterTest resourceConverterTest; resourceConverterTest.setTestPath(mPathConfig); return resourceConverterTest.adaptNewResourceUrl(overwriteResources, resourceConfig, storePath); } diff --git a/core/autotests/mail/importmailjobinterfacetestimpl.cpp b/core/autotests/mail/importmailjobinterfacetestimpl.cpp index c4b324a..e1256ff 100644 --- a/core/autotests/mail/importmailjobinterfacetestimpl.cpp +++ b/core/autotests/mail/importmailjobinterfacetestimpl.cpp @@ -1,138 +1,137 @@ /* 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 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) { const QString uniqueName = uniqueIdentityName(name); 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"), uniqueName); 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(); } QString ImportMailJobInterfaceTestImpl::uniqueIdentityName(const QString &name) { QString newName(name); int i = 0; const QStringList existingIdentityNames{QStringLiteral("identity1"), QStringLiteral("identity2")}; while (!existingIdentityNames.contains(newName)) { newName = QStringLiteral("%1_%2").arg(name).arg(i); ++i; } return newName; } 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; }