diff --git a/core/autotests/mail/data/import/identities/archive.zip b/core/autotests/mail/data/import/identities/archive.zip index 66c3e3b..874f74a 100644 Binary files a/core/autotests/mail/data/import/identities/archive.zip and b/core/autotests/mail/data/import/identities/archive.zip differ diff --git a/core/autotests/mail/data/import/mailconfigandresource/archive.zip b/core/autotests/mail/data/import/mailconfigandresource/archive.zip index 577d61c..6ce9d64 100644 Binary files a/core/autotests/mail/data/import/mailconfigandresource/archive.zip and b/core/autotests/mail/data/import/mailconfigandresource/archive.zip differ diff --git a/core/autotests/mail/data/import/mailonlyconfig/archive.zip b/core/autotests/mail/data/import/mailonlyconfig/archive.zip index 3c96d1f..5701b56 100644 Binary files a/core/autotests/mail/data/import/mailonlyconfig/archive.zip and b/core/autotests/mail/data/import/mailonlyconfig/archive.zip differ diff --git a/core/autotests/mail/data/import/mailtransport/archive.zip b/core/autotests/mail/data/import/mailtransport/archive.zip index 172f3d7..276a254 100644 Binary files a/core/autotests/mail/data/import/mailtransport/archive.zip and b/core/autotests/mail/data/import/mailtransport/archive.zip differ diff --git a/core/autotests/mail/importmailjobinterfacetest.cpp b/core/autotests/mail/importmailjobinterfacetest.cpp index 3f4dab5..53e38e2 100644 --- a/core/autotests/mail/importmailjobinterfacetest.cpp +++ b/core/autotests/mail/importmailjobinterfacetest.cpp @@ -1,154 +1,156 @@ /* 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 "archivestorage.h" #include "resourceconvertertest.h" #include "testimportfile.h" #include "utils.h" #include #include #include #include QTEST_MAIN(ImportMailJobInterfaceTest) ImportMailJobInterfaceTestImpl::ImportMailJobInterfaceTestImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep) : ImportMailJobInterface(parent, typeSelected, archiveStorage, numberOfStep) { } ImportMailJobInterfaceTestImpl::~ImportMailJobInterfaceTestImpl() { //Clean up temp repo QVERIFY(QDir(QDir::tempPath() + QLatin1Char('/') + Utils::storeMails()).removeRecursively()); } 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; + 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) { qDebug() << "ImportMailJobInterfaceTestImpl::importSmtpMailTransport(const KConfigGroup &group, int defaultTransport, int transportId) not implement yet"; + qDebug() << " defaultTransport " << defaultTransport << " transportId " << transportId; } 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()); file->setAbstractImportExportJob(impl); file->setLoggingFilePath(impl->loggingFilePath()); file->start(); delete impl; delete file; }