Commit 6cafc6ab authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Reimplement backup*ResourceFile so we can autotest cod

parent 259de939
......@@ -91,7 +91,7 @@ protected:
Q_REQUIRED_RESULT bool overwriteConfigMessageBox(const QString &configName) const;
Q_REQUIRED_RESULT Akonadi::Collection::Id convertPathToId(const QString &path);
virtual void backupResourceFile(const QString &agentIdentifier, const QString &defaultPath);
void backupResourceFile(const QString &agentIdentifier, const QString &defaultPath);
Q_REQUIRED_RESULT QStringList restoreResourceFile(const QString &resourceName, const QString &defaultPath, const QString &storePath, bool overwriteResources = false);
virtual void addSpecificResourceSettings(const KSharedConfig::Ptr &resourceConfig, const QString &resourceName, QMap<QString, QVariant> &settings);
......
......@@ -103,7 +103,7 @@ void ExportAddressbookJobInterface::slotWriteNextArchiveResource()
QTimer::singleShot(0, this, &ExportAddressbookJobInterface::slotAddressbookJobTerminated);
}
} else if (identifier.contains(QLatin1String("akonadi_vcard_resource_"))) {
backupResourceFile(identifier, Utils::addressbookPath());
backupAddressBookResourceFile(identifier, Utils::addressbookPath());
QTimer::singleShot(0, this, &ExportAddressbookJobInterface::slotAddressbookJobTerminated);
} else {
QTimer::singleShot(0, this, &ExportAddressbookJobInterface::slotAddressbookJobTerminated);
......
......@@ -42,6 +42,7 @@ protected:
virtual void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) = 0;
virtual Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() = 0;
virtual Q_REQUIRED_RESULT QString resourcePath(const QString &agentIdentifier, const QString &defaultPath) const = 0;
virtual void backupAddressBookResourceFile(const QString &agentIdentifier, const QString &defaultPath) = 0;
private:
void slotCheckBackupResource();
......
......@@ -83,3 +83,9 @@ QString ExportAddressbookJobInterfaceImpl::resourcePath(const QString &agentIden
const QString url = converter.resourcePath(agentIdentifier, defaultPath);
return url;
}
void ExportAddressbookJobInterfaceImpl::backupAddressBookResourceFile(const QString &agentIdentifier, const QString &defaultPath)
{
backupResourceFile(agentIdentifier, defaultPath);
}
......@@ -38,6 +38,7 @@ protected:
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
Q_REQUIRED_RESULT QString resourcePath(const QString &agentIdentifier, const QString &defaultPath) const override;
void backupAddressBookResourceFile(const QString &agentIdentifier, const QString &defaultPath) override;
};
#endif // EXPORTADDRESSBOOKINTERFACEIMPL_H
......@@ -84,7 +84,7 @@ void ExportAlarmJobInterface::slotWriteNextArchiveResource()
QTimer::singleShot(0, this, &ExportAlarmJobInterface::slotAlarmJobTerminated);
}
} else if (identifier.contains(QLatin1String("akonadi_kalarm_resource_"))) {
backupResourceFile(identifier, Utils::alarmPath());
backupAlarmResourceFile(identifier, Utils::alarmPath());
QTimer::singleShot(0, this, &ExportAlarmJobInterface::slotAlarmJobTerminated);
} else {
QTimer::singleShot(0, this, &ExportAlarmJobInterface::slotAlarmJobTerminated);
......
......@@ -39,6 +39,7 @@ protected:
virtual void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) = 0;
virtual Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() = 0;
virtual Q_REQUIRED_RESULT QString resourcePath(const QString &identifier) const = 0;
virtual void backupAlarmResourceFile(const QString &agentIdentifier, const QString &defaultPath) = 0;
private:
void slotCheckBackupResource();
......
......@@ -71,3 +71,8 @@ QString ExportAlarmJobInterfaceImpl::resourcePath(const QString &identifier) con
const QString url = converter.resourcePath(identifier);
return url;
}
void ExportAlarmJobInterfaceImpl::backupAlarmResourceFile(const QString &agentIdentifier, const QString &defaultPath)
{
backupResourceFile(agentIdentifier, defaultPath);
}
......@@ -37,6 +37,7 @@ protected:
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
Q_REQUIRED_RESULT QString resourcePath(const QString &identifier) const override;
void backupAlarmResourceFile(const QString &agentIdentifier, const QString &defaultPath) override;
};
#endif // EXPORTALARMJOBINTERFACEIMPL_H
......@@ -24,6 +24,7 @@
#include <QDebug>
#include <QTest>
#include <saveresourceconfigtest.h>
#include <testbackupresourcefilejob.h>
QTEST_MAIN(ExportAddressbookJobInterfaceTest)
......@@ -79,6 +80,17 @@ QString ExportAddressbookJobInterfaceTestImpl::resourcePath(const QString &agent
return url;
}
void ExportAddressbookJobInterfaceTestImpl::backupAddressBookResourceFile(const QString &agentIdentifier, const QString &defaultPath)
{
TestBackupResourceFileJob *job = new TestBackupResourceFileJob(this);
job->setDefaultPath(defaultPath);
job->setIdentifier(agentIdentifier);
job->setZip(archive());
connect(job, &TestBackupResourceFileJob::error, this, &ExportAddressbookJobInterfaceTestImpl::error);
connect(job, &TestBackupResourceFileJob::info, this, &ExportAddressbookJobInterfaceTestImpl::info);
job->start();
}
ExportAddressbookJobInterfaceTest::ExportAddressbookJobInterfaceTest(QObject *parent)
: QObject(parent)
{
......@@ -135,3 +147,5 @@ void ExportAddressbookJobInterfaceTest::exportAddressBookConfigAndResource()
file->start();
delete exportNote;
}
......@@ -38,6 +38,7 @@ protected:
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
Q_REQUIRED_RESULT QString resourcePath(const QString &agentIdentifier, const QString &defaultPath = QString()) const override;
void backupAddressBookResourceFile(const QString &agentIdentifier, const QString &defaultPath) override;
};
class ExportAddressbookJobInterfaceTest : public QObject
......
......@@ -25,6 +25,7 @@
#include <QTest>
#include <QSignalSpy>
#include <saveresourceconfigtest.h>
#include <testbackupresourcefilejob.h>
QTEST_MAIN(ExportAlarmJobInterfaceTest)
......@@ -65,6 +66,17 @@ QString ExportAlarmJobInterfaceTestImpl::resourcePath(const QString &identifier)
return url;
}
void ExportAlarmJobInterfaceTestImpl::backupAlarmResourceFile(const QString &agentIdentifier, const QString &defaultPath)
{
TestBackupResourceFileJob *job = new TestBackupResourceFileJob(this);
job->setDefaultPath(defaultPath);
job->setIdentifier(agentIdentifier);
job->setZip(archive());
connect(job, &TestBackupResourceFileJob::error, this, &ExportAlarmJobInterfaceTestImpl::error);
connect(job, &TestBackupResourceFileJob::info, this, &ExportAlarmJobInterfaceTestImpl::info);
job->start();
}
ExportAlarmJobInterfaceTest::ExportAlarmJobInterfaceTest(QObject *parent)
: QObject(parent)
{
......@@ -119,3 +131,5 @@ void ExportAlarmJobInterfaceTest::exportAlarmConfigAndResource()
file->start();
delete exportNote;
}
......@@ -36,6 +36,7 @@ protected:
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
Q_REQUIRED_RESULT QString resourcePath(const QString &identifier) const override;
void backupAlarmResourceFile(const QString &agentIdentifier, const QString &defaultPath) override;
};
class ExportAlarmJobInterfaceTest : public QObject
......
......@@ -24,6 +24,7 @@
#include <QDebug>
#include <QTest>
#include <saveresourceconfigtest.h>
#include <testbackupresourcefilejob.h>
QTEST_MAIN(ExportCalendarsJobInterfaceTest)
......@@ -78,6 +79,17 @@ QString ExportCalendarsJobInterfaceTestImpl::resourcePath(const QString &identif
return url;
}
void ExportCalendarsJobInterfaceTestImpl::backupCalendarResourceFile(const QString &agentIdentifier, const QString &defaultPath)
{
TestBackupResourceFileJob *job = new TestBackupResourceFileJob(this);
job->setDefaultPath(defaultPath);
job->setIdentifier(agentIdentifier);
job->setZip(archive());
connect(job, &TestBackupResourceFileJob::error, this, &ExportCalendarsJobInterfaceTestImpl::error);
connect(job, &TestBackupResourceFileJob::info, this, &ExportCalendarsJobInterfaceTestImpl::info);
job->start();
}
ExportCalendarsJobInterfaceTest::ExportCalendarsJobInterfaceTest(QObject *parent)
: QObject(parent)
{
......
......@@ -38,6 +38,7 @@ protected:
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
Q_REQUIRED_RESULT QString resourcePath(const QString &identifier) const override;
void backupCalendarResourceFile(const QString &agentIdentifier, const QString &defaultPath) override;
};
class ExportCalendarsJobInterfaceTest : public QObject
......
......@@ -24,6 +24,7 @@
#include <QDebug>
#include <QTest>
#include <saveresourceconfigtest.h>
#include <testbackupresourcefilejob.h>
QTEST_MAIN(ExportMailJobInterfaceTest)
......@@ -106,6 +107,18 @@ QString ExportMailJobInterfaceTestImpl::resourcePath(const QString &identifier)
return url;
}
void ExportMailJobInterfaceTestImpl::backupMailResourceFile(const QString &agentIdentifier, const QString &defaultPath)
{
TestBackupResourceFileJob *job = new TestBackupResourceFileJob(this);
job->setDefaultPath(defaultPath);
job->setIdentifier(agentIdentifier);
job->setZip(archive());
connect(job, &TestBackupResourceFileJob::error, this, &ExportMailJobInterfaceTestImpl::error);
connect(job, &TestBackupResourceFileJob::info, this, &ExportMailJobInterfaceTestImpl::info);
job->start();
}
ExportMailJobInterfaceTest::ExportMailJobInterfaceTest(QObject *parent)
: QObject(parent)
{
......
......@@ -47,6 +47,7 @@ protected:
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
Q_REQUIRED_RESULT QString storeResources(KZip *archive, const QString &identifier, const QString &path) override;
Q_REQUIRED_RESULT QString resourcePath(const QString &identifier) const override;
void backupMailResourceFile(const QString &agentIdentifier, const QString &defaultPath) override;
};
class ExportMailJobInterfaceTest : public QObject
......
......@@ -72,7 +72,7 @@ void ExportCalendarJobInterface::slotWriteNextArchiveResource()
QTimer::singleShot(0, this, &ExportCalendarJobInterface::slotCalendarJobTerminated);
}
} else if (identifier.contains(QLatin1String("akonadi_ical_resource_"))) {
backupResourceFile(identifier, Utils::calendarPath());
backupCalendarResourceFile(identifier, Utils::calendarPath());
QTimer::singleShot(0, this, &ExportCalendarJobInterface::slotCalendarJobTerminated);
} else {
QTimer::singleShot(0, this, &ExportCalendarJobInterface::slotCalendarJobTerminated);
......
......@@ -42,6 +42,7 @@ protected:
virtual void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) = 0;
virtual Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() = 0;
virtual Q_REQUIRED_RESULT QString resourcePath(const QString &identifier) const = 0;
virtual void backupCalendarResourceFile(const QString &agentIdentifier, const QString &defaultPath) = 0;
private:
void slotCheckBackupResource();
......
......@@ -86,3 +86,8 @@ QString ExportCalendarJobInterfaceImpl::resourcePath(const QString &identifier)
const QString url = converter.resourcePath(identifier);
return url;
}
void ExportCalendarJobInterfaceImpl::backupCalendarResourceFile(const QString &agentIdentifier, const QString &defaultPath)
{
backupResourceFile(agentIdentifier, defaultPath);
}
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