Commit 07cb7498 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add export autotest

parent 7f5d0688
......@@ -103,3 +103,38 @@ void ExportAddressbookJobInterfaceTest::exportAddressBookConfig()
file->start();
delete exportNote;
}
void ExportAddressbookJobInterfaceTest::exportAddressBookConfigAndResource_data()
{
QTest::addColumn<QByteArray>("configpath");
const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/export/");
//QTest::newRow("test1resource") << pathConfig + QByteArray("test1resource/");
QTest::newRow("fullresource") << pathConfig + QByteArray("fullresource/");
}
void ExportAddressbookJobInterfaceTest::exportAddressBookConfigAndResource()
{
QFETCH(QByteArray, configpath);
TestExportFile *file = new TestExportFile(this);
file->setPathConfig(configpath);
QVector<Utils::AkonadiInstanceInfo> lstInfo;
Utils::AkonadiInstanceInfo info;
info.identifier = QLatin1String("akonadi_vcarddir_resource_1");
lstInfo << info;
info.identifier = QLatin1String("akonadi_contacts_resource_1");
lstInfo << info;
info.identifier = QLatin1String("akonadi_vcard_resource_1");
lstInfo << info;
//Add extra resource.
info.identifier = QStringLiteral("akonadi_kolab_resource_2");
lstInfo << info;
ExportAddressbookJobInterfaceTestImpl *exportNote = new ExportAddressbookJobInterfaceTestImpl(this, {Utils::StoredType::Config|Utils::StoredType::Resources}, file->archiveStorage(), 1);
exportNote->setListOfResource(lstInfo);
exportNote->setPathConfig(QLatin1String(configpath));
file->setAbstractImportExportJob(exportNote);
file->start();
delete exportNote;
}
......@@ -49,6 +49,8 @@ public:
private Q_SLOTS:
void exportAddressBookConfig();
void exportAddressBookConfig_data();
void exportAddressBookConfigAndResource_data();
void exportAddressBookConfigAndResource();
};
#endif // EXPORTADDRESSBOOKJOBINTERFACETEST_H
......@@ -59,3 +59,24 @@ void ExportAkregatorJobInterfaceTest::exportAkregatorConfig()
file->start();
delete exportNote;
}
void ExportAkregatorJobInterfaceTest::exportAkregatorConfigAndResource_data()
{
QTest::addColumn<QByteArray>("configpath");
const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/export/");
//QTest::newRow("test1resource") << pathConfig + QByteArray("test1resource/");
QTest::newRow("fullresource") << pathConfig + QByteArray("fullresource/");
}
void ExportAkregatorJobInterfaceTest::exportAkregatorConfigAndResource()
{
QFETCH(QByteArray, configpath);
TestExportFile *file = new TestExportFile(this);
file->setPathConfig(configpath);
ExportAkregatorJobInterfaceTestImpl *exportNote = new ExportAkregatorJobInterfaceTestImpl(this, {Utils::StoredType::Config|Utils::StoredType::Resources}, file->archiveStorage(), 1);
file->setAbstractImportExportJob(exportNote);
file->start();
delete exportNote;
}
......@@ -41,6 +41,8 @@ public:
private Q_SLOTS:
void exportAkregatorConfig();
void exportAkregatorConfig_data();
void exportAkregatorConfigAndResource_data();
void exportAkregatorConfigAndResource();
};
#endif // EXPORTAKREGATORJOBINTERFACETEST_H
......@@ -101,3 +101,35 @@ void ExportCalendarsJobInterfaceTest::exportCalendarConfig()
file->start();
delete impl;
}
void ExportCalendarsJobInterfaceTest::exportCalendarConfigAndResource_data()
{
QTest::addColumn<QByteArray>("configpath");
const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/export/");
//QTest::newRow("test1resource") << pathConfig + QByteArray("test1resource/");
QTest::newRow("fullresource") << pathConfig + QByteArray("fullresource/");
}
void ExportCalendarsJobInterfaceTest::exportCalendarConfigAndResource()
{
QFETCH(QByteArray, configpath);
TestExportFile *file = new TestExportFile(this);
file->setPathConfig(configpath);
QVector<Utils::AkonadiInstanceInfo> lstInfo;
Utils::AkonadiInstanceInfo info;
info.identifier = QLatin1String("akonadi_icaldir_resource_1");
lstInfo << info;
info.identifier = QLatin1String("akonadi_ical_resource_2");
lstInfo << info;
//Add extra resource.
info.identifier = QStringLiteral("akonadi_kontact_resource_2");
lstInfo << info;
ExportCalendarsJobInterfaceTestImpl *exportNote = new ExportCalendarsJobInterfaceTestImpl(this, {Utils::StoredType::Config|Utils::StoredType::Resources}, file->archiveStorage(), 1);
exportNote->setListOfResource(lstInfo);
exportNote->setPathConfig(QLatin1String(configpath));
file->setAbstractImportExportJob(exportNote);
file->start();
delete exportNote;
}
......@@ -49,6 +49,9 @@ public:
private Q_SLOTS:
void exportCalendarConfig_data();
void exportCalendarConfig();
void exportCalendarConfigAndResource_data();
void exportCalendarConfigAndResource();
};
#endif // EXPORTCALENDARSJOBINTERFACETEST_H
......@@ -82,8 +82,7 @@ void ExportMailJobInterfaceTestImpl::exportResourceToArchive(const QString &arch
QVector<Utils::AkonadiInstanceInfo> ExportMailJobInterfaceTestImpl::listOfResource()
{
//TODO
return {};
return mListAkonadiInstanceInfo;
}
QString ExportMailJobInterfaceTestImpl::storeResources(KZip *archive, const QString &identifier, const QString &path)
......@@ -92,6 +91,21 @@ QString ExportMailJobInterfaceTestImpl::storeResources(KZip *archive, const QStr
return {};
}
QString ExportMailJobInterfaceTestImpl::convertToFullCollectionPath(const qlonglong collectionValue)
{
ResourceConverterTest converter;
converter.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
return converter.convertToFullCollectionPath(collectionValue);
}
QString ExportMailJobInterfaceTestImpl::resourcePath(const QString &identifier) const
{
ResourceConverterTest converter;
converter.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
const QString url = converter.resourcePath(identifier);
return url;
}
ExportMailJobInterfaceTest::ExportMailJobInterfaceTest(QObject *parent)
: QObject(parent)
{
......@@ -116,17 +130,37 @@ void ExportMailJobInterfaceTest::exportMailConfig()
delete exportNote;
}
QString ExportMailJobInterfaceTestImpl::convertToFullCollectionPath(const qlonglong collectionValue)
void ExportMailJobInterfaceTest::exportMailConfigAndResource_data()
{
ResourceConverterTest converter;
converter.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
return converter.convertToFullCollectionPath(collectionValue);
QTest::addColumn<QByteArray>("configpath");
const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/export/");
//QTest::newRow("test1resource") << pathConfig + QByteArray("test1resource/");
QTest::newRow("fullresource") << pathConfig + QByteArray("fullresource/");
}
QString ExportMailJobInterfaceTestImpl::resourcePath(const QString &identifier) const
void ExportMailJobInterfaceTest::exportMailConfigAndResource()
{
ResourceConverterTest converter;
converter.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
const QString url = converter.resourcePath(identifier);
return url;
QFETCH(QByteArray, configpath);
TestExportFile *file = new TestExportFile(this);
file->setPathConfig(configpath);
QVector<Utils::AkonadiInstanceInfo> lstInfo;
Utils::AkonadiInstanceInfo info;
info.identifier = QLatin1String("akonadi_mbox_resource_1");
lstInfo << info;
info.identifier = QLatin1String("akonadi_maildir_resource_1");
lstInfo << info;
info.identifier = QLatin1String("akonadi_mixedmaildir_resource_1");
lstInfo << info;
//Add extra resource.
info.identifier = QStringLiteral("akonadi_kolab_resource_2");
lstInfo << info;
ExportMailJobInterfaceTestImpl *exportNote = new ExportMailJobInterfaceTestImpl(this, {Utils::StoredType::Config|Utils::StoredType::Resources}, file->archiveStorage(), 1);
exportNote->setListOfResource(lstInfo);
exportNote->setPathConfig(QLatin1String(configpath));
file->setAbstractImportExportJob(exportNote);
file->start();
delete exportNote;
}
......@@ -21,10 +21,11 @@
#define EXPORTMAILJOBINTERFACETEST_H
#include <QObject>
#include "exportimportutil.h"
#include "mail/exportmailjobinterface.h"
class ExportMailJobInterfaceTestImpl : public ExportMailJobInterface
class ExportMailJobInterfaceTestImpl : public ExportMailJobInterface, public ExportImportUtil
{
Q_OBJECT
public:
......@@ -57,6 +58,8 @@ public:
private Q_SLOTS:
void exportMailConfig();
void exportMailConfig_data();
void exportMailConfigAndResource_data();
void exportMailConfigAndResource();
};
#endif // EXPORTMAILJOBINTERFACETEST_H
......@@ -618,7 +618,7 @@ void ExportMailJobInterface::slotWriteNextArchiveResource()
QTimer::singleShot(0, this, &ExportMailJobInterface::slotMailsJobTerminated);
}
} else if (identifier.contains(QLatin1String("akonadi_mbox_resource_"))) {
backupResourceFile(identifier, Utils::addressbookPath()); //FIxME addressbookPath or MailPAth ???
backupResourceFile(identifier, Utils::mailsPath()); //FIxME addressbookPath or MailPAth ???
QTimer::singleShot(0, this, &ExportMailJobInterface::slotMailsJobTerminated);
} else {
QTimer::singleShot(0, this, &ExportMailJobInterface::slotMailsJobTerminated);
......
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