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

Continue to fix addressbook autotest

parent e088afd1
[General]
IsConfigured=true
Path[$e]=[TEST_PATH]/resources/akonadi_vcard_resource_1/
Path[$e]=[TEST_PATH]/resources/akonadi_vcard_resource_1/akonadi_vcard_resource_1.zip
......@@ -2,3 +2,12 @@ information/VERSION_2
information/exportdatatype.xml
configs/kaddressbookrc
configs/kaddressbookui.rc
addressbook/akonadi_contacts_resource_1/addressbook.zip
addressbook/akonadi_contacts_resource_1/agent_config_akonadi_contacts_resource_1
addressbook/akonadi_contacts_resource_1/akonadi_contacts_resource_1rc
addressbook/akonadi_vcard_resource_1/agent_config_akonadi_vcard_resource_1
addressbook/akonadi_vcard_resource_1/akonadi_vcard_resource_1.zip
addressbook/akonadi_vcard_resource_1/akonadi_vcard_resource_1rc
addressbook/akonadi_vcarddir_resource_1/addressbook.zip
addressbook/akonadi_vcarddir_resource_1/agent_config_akonadi_vcarddir_resource_1
addressbook/akonadi_vcarddir_resource_1/akonadi_vcarddir_resource_1rc
......@@ -85,6 +85,7 @@ void ExportAddressbookJobInterfaceTestImpl::backupAddressBookResourceFile(const
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);
......
......@@ -71,6 +71,7 @@ void ExportAlarmJobInterfaceTestImpl::backupAlarmResourceFile(const QString &age
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);
......
......@@ -84,6 +84,7 @@ void ExportCalendarsJobInterfaceTestImpl::backupCalendarResourceFile(const QStri
TestBackupResourceFileJob *job = new TestBackupResourceFileJob(this);
job->setDefaultPath(defaultPath);
job->setIdentifier(agentIdentifier);
job->setTestPath(mPathConfig);
job->setZip(archive());
connect(job, &TestBackupResourceFileJob::error, this, &ExportCalendarsJobInterfaceTestImpl::error);
connect(job, &TestBackupResourceFileJob::info, this, &ExportCalendarsJobInterfaceTestImpl::info);
......
......@@ -112,6 +112,7 @@ void ExportMailJobInterfaceTestImpl::backupMailResourceFile(const QString &agent
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);
......
......@@ -19,6 +19,7 @@
#include "testbackupresourcefilejob.h"
#include "resourceconvertertest.h"
#include <QDebug>
TestBackupResourceFileJob::TestBackupResourceFileJob(QObject *parent)
: BackupResourceFileJobBase(parent)
{
......@@ -31,6 +32,12 @@ 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;
}
......@@ -30,6 +30,9 @@ public:
~TestBackupResourceFileJob();
Q_REQUIRED_RESULT QString resourcePath(const QString &identifier) const override;
void setTestPath(const QString &str);
private:
QString mTestPath;
};
#endif // TESTBACKUPRESOURCEFILEJOB_H
......@@ -48,20 +48,24 @@ void BackupResourceFileJobBase::start()
const QString url = resourcePath(mIdentifier);
if (!url.isEmpty()) {
QFileInfo fi(url);
QString filename = fi.fileName();
const bool fileAdded = mZip->addLocalFile(url, archivePath + filename);
if (fileAdded) {
Q_EMIT info(i18n("\"%1\" was backed up.", filename));
StoreResourceJob *job = new StoreResourceJob(this);
connect(job, &StoreResourceJob::error, this, &BackupResourceFileJobBase::error);
connect(job, &StoreResourceJob::info, this, &BackupResourceFileJobBase::info);
job->setArchivePath(archivePath);
job->setZip(mZip);
job->setIdentifier(mIdentifier);
job->start();
if (!fi.isFile()) {
Q_EMIT info(i18n("\"%1\" is not a file.", url));
} else {
Q_EMIT error(i18n("\"%1\" file cannot be added to backup file.", filename));
const QString filename = fi.fileName();
const bool fileAdded = mZip->addLocalFile(url, archivePath + filename);
if (fileAdded) {
Q_EMIT info(i18n("\"%1\" was backed up.", filename));
StoreResourceJob *job = new StoreResourceJob(this);
connect(job, &StoreResourceJob::error, this, &BackupResourceFileJobBase::error);
connect(job, &StoreResourceJob::info, this, &BackupResourceFileJobBase::info);
job->setArchivePath(archivePath);
job->setZip(mZip);
job->setIdentifier(mIdentifier);
job->start();
} else {
Q_EMIT error(i18n("\"%1\" file cannot be added to backup file.", filename));
}
}
}
deleteLater();
......
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