Commit c67b0e13 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix import autotest

parent b0c92bf7
......@@ -29,7 +29,6 @@
#include <QFile>
#include <QDir>
#include <QStandardPaths>
#include <resourceconverterimpl.h>
namespace {
inline const QString storeAddressbook()
{
......@@ -194,8 +193,7 @@ void ImportAddressbookJobInterface::restoreResources()
KSharedConfig::Ptr resourceConfig = KSharedConfig::openConfig(copyToDirName + QLatin1Char('/') + resourceName);
//TODO fix default path
ResourceConverterImpl converter;
const QString newUrl = converter.adaptResourcePath(resourceConfig, QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/contacts"));
const QString newUrl = adaptResourcePath(resourceConfig, QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/contacts"));
QFileInfo newUrlInfo(newUrl);
const QString dataFile = value.akonadiResources;
const KArchiveEntry *dataResouceEntry = mArchiveDirectory->entry(dataFile);
......
......@@ -38,6 +38,7 @@ protected:
void slotNextStep() override;
virtual void synchronizeResource(const QStringList &lst) = 0;
virtual Q_REQUIRED_RESULT QString createResource(const QString &resources, const QString &name, const QMap<QString, QVariant> &settings, bool synchronizeTree) = 0;
virtual Q_REQUIRED_RESULT QString adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData) = 0;
void restoreResources();
private:
......
......@@ -58,3 +58,9 @@ QString ImportAddressbookJobInterfaceImpl::createResource(const QString &resourc
{
return mCreateResource->createResource(resources, name, settings, synchronizeTree);
}
QString ImportAddressbookJobInterfaceImpl::adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData)
{
ResourceConverterImpl converter;
return converter.adaptResourcePath(resourceConfig, storedData);
}
......@@ -36,6 +36,7 @@ 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, bool synchronizeTree) override;
Q_REQUIRED_RESULT QString adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData) override;
};
#endif // IMPORTADDRESSBOOKJOBINTERFACEIMPL_H
......@@ -32,7 +32,6 @@
#include <QFile>
#include <QStandardPaths>
#include <QTimer>
#include <resourceconverterimpl.h>
namespace {
inline const QString storeAlarm()
......@@ -147,8 +146,7 @@ void ImportAlarmJobInterface::restoreResources()
KSharedConfig::Ptr resourceConfig = KSharedConfig::openConfig(copyToDirName + QLatin1Char('/') + resourceName);
ResourceConverterImpl converter;
const QString newUrl = converter.adaptResourcePath(resourceConfig, storeAlarm());
const QString newUrl = adaptResourcePath(resourceConfig, storeAlarm());
QFileInfo newUrlInfo(newUrl);
const QString dataFile = value.akonadiResources;
const KArchiveEntry *dataResouceEntry = mArchiveDirectory->entry(dataFile);
......
......@@ -37,6 +37,7 @@ protected:
void slotNextStep() override;
virtual void synchronizeResource(const QStringList &lst) = 0;
virtual Q_REQUIRED_RESULT QString createResource(const QString &resources, const QString &name, const QMap<QString, QVariant> &settings, bool synchronizeTree) = 0;
virtual Q_REQUIRED_RESULT QString adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData) = 0;
void restoreResources();
private:
......
......@@ -50,6 +50,12 @@ Akonadi::Collection::Id ImportAlarmJobInterfaceImpl::convertFolderPathToCollecti
return converter.convertFolderPathToCollectionId(path);
}
QString ImportAlarmJobInterfaceImpl::adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData)
{
ResourceConverterImpl converter;
return converter.adaptResourcePath(resourceConfig, storedData);
}
QString ImportAlarmJobInterfaceImpl::createResource(const QString &resources, const QString &name, const QMap<QString, QVariant> &settings, bool synchronizeTree)
{
return mCreateResource->createResource(resources, name, settings, synchronizeTree);
......
......@@ -33,6 +33,7 @@ public:
protected:
void restoreResources();
Q_REQUIRED_RESULT Akonadi::Collection::Id convertFolderPathToCollectionId(const QString &path) override;
Q_REQUIRED_RESULT QString adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData) override;
void synchronizeResource(const QStringList &lst) override;
Q_REQUIRED_RESULT QString createResource(const QString &resources, const QString &name, const QMap<QString, QVariant> &settings, bool synchronizeTree) override;
};
......
......@@ -54,6 +54,13 @@ void ImportAddressbookJobInterfaceTestImpl::synchronizeResource(const QStringLis
slotNextStep();
}
QString ImportAddressbookJobInterfaceTestImpl::adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData)
{
ResourceConverterTest resourceConverterTest;
resourceConverterTest.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
return resourceConverterTest.adaptResourcePath(resourceConfig, storedData);
}
ImportAddressbookJobInterfaceTest::ImportAddressbookJobInterfaceTest(QObject *parent)
: QObject(parent)
{
......
......@@ -36,6 +36,7 @@ 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;
Q_REQUIRED_RESULT QString adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData) override;
};
class ImportAddressbookJobInterfaceTest : public QObject
......
......@@ -54,6 +54,13 @@ void ImportAlarmJobInterfaceTestImpl::synchronizeResource(const QStringList &lst
slotNextStep();
}
QString ImportAlarmJobInterfaceTestImpl::adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData)
{
ResourceConverterTest resourceConverterTest;
resourceConverterTest.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
return resourceConverterTest.adaptResourcePath(resourceConfig, storedData);
}
ImportAlarmJobInterfaceTest::ImportAlarmJobInterfaceTest(QObject *parent)
: QObject(parent)
{
......
......@@ -36,6 +36,7 @@ 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;
Q_REQUIRED_RESULT QString adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData) override;
};
class ImportAlarmJobInterfaceTest : public QObject
......
......@@ -54,6 +54,13 @@ void ImportCalendarJobInterfaceTestImpl::synchronizeResource(const QStringList &
slotNextStep();
}
QString ImportCalendarJobInterfaceTestImpl::adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData)
{
ResourceConverterTest resourceConverterTest;
resourceConverterTest.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
return resourceConverterTest.adaptResourcePath(resourceConfig, storedData);
}
ImportCalendarJobInterfaceTest::ImportCalendarJobInterfaceTest(QObject *parent)
: QObject(parent)
{
......
......@@ -36,6 +36,7 @@ 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;
Q_REQUIRED_RESULT QString adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData) override;
};
class ImportCalendarJobInterfaceTest : public QObject
......
......@@ -64,6 +64,13 @@ void ImportMailJobInterfaceTestImpl::importFilters(const QVector<MailCommon::Mai
{
}
QString ImportMailJobInterfaceTestImpl::adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData)
{
ResourceConverterTest resourceConverterTest;
resourceConverterTest.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
return resourceConverterTest.adaptResourcePath(resourceConfig, storedData);
}
ImportMailJobInterfaceTest::ImportMailJobInterfaceTest(QObject *parent)
: QObject(parent)
{
......@@ -90,3 +97,5 @@ void ImportMailJobInterfaceTest::importMailConfig()
delete impl;
delete file;
}
......@@ -39,6 +39,8 @@ protected:
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;
Q_REQUIRED_RESULT QString adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData) override;
};
class ImportMailJobInterfaceTest : public QObject
......
......@@ -56,6 +56,13 @@ void ImportNotesJobInterfaceTestImpl::synchronizeResource(const QStringList &lst
slotNextStep();
}
QString ImportNotesJobInterfaceTestImpl::adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData)
{
ResourceConverterTest resourceConverterTest;
resourceConverterTest.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
return resourceConverterTest.adaptResourcePath(resourceConfig, storedData);
}
ImportNotesJobInterfaceTest::ImportNotesJobInterfaceTest(QObject *parent)
: QObject(parent)
{
......
......@@ -36,6 +36,7 @@ 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;
Q_REQUIRED_RESULT QString adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData) override;
};
class ImportNotesJobInterfaceTest : public QObject
......
......@@ -18,7 +18,6 @@
*/
#include "importcalendarjobinterface.h"
#include "resourceconverterimpl.h"
#include "archivestorage.h"
#include <KLocalizedString>
......@@ -285,8 +284,7 @@ void ImportCalendarJobInterface::restoreResources()
KSharedConfig::Ptr resourceConfig = KSharedConfig::openConfig(copyToDirName + QLatin1Char('/') + resourceName);
ResourceConverterImpl converter;
const QString newUrl = converter.adaptResourcePath(resourceConfig, storeCalendar());
const QString newUrl = adaptResourcePath(resourceConfig, storeCalendar());
QFileInfo newUrlInfo(newUrl);
const QString dataFile = value.akonadiResources;
......
......@@ -37,7 +37,8 @@ public:
protected:
void slotNextStep() override;
virtual Q_REQUIRED_RESULT QString createResource(const QString &resources, const QString &name, const QMap<QString, QVariant> &settings, bool synchronizeTree) = 0;
virtual void synchronizeResource(const QStringList &lst) = 0;
virtual void synchronizeResource(const QStringList &lst) = 0;
virtual Q_REQUIRED_RESULT QString adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData) = 0;
private:
Q_REQUIRED_RESULT bool isAConfigFile(const QString &name) const override;
......
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