Commit 1fab06c4 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Reduce duplicate code here too

parent 336627bb
......@@ -110,35 +110,21 @@ ExportAddressbookJobInterfaceTest::ExportAddressbookJobInterfaceTest(QObject *pa
{
}
void ExportAddressbookJobInterfaceTest::exportAddressBookConfig_data()
void ExportAddressbookJobInterfaceTest::exportAddressBook_data()
{
QTest::addColumn<QByteArray>("configpath");
QTest::addColumn<Utils::StoredTypes>("options");
const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/export/");
QTest::newRow("addressbookonlyconfig") << pathConfig + QByteArray("addressbookonlyconfig/");
Utils::StoredTypes options = {Utils::StoredType::Config};
QTest::newRow("addressbookonlyconfig") << pathConfig + QByteArray("addressbookonlyconfig/") << options;
options = {Utils::StoredType::Config | Utils::StoredType::Resources};
QTest::newRow("addressbookconfigandresources") << pathConfig + QByteArray("addressbookconfigandresources/") << options;
}
void ExportAddressbookJobInterfaceTest::exportAddressBookConfig()
{
QFETCH(QByteArray, configpath);
TestExportFile *file = new TestExportFile(this);
file->setPathConfig(configpath);
ExportAddressbookJobInterfaceTestImpl *exportNote = new ExportAddressbookJobInterfaceTestImpl(this, {Utils::StoredType::Config}, file->archiveStorage(), 1);
exportNote->setPathConfig(QLatin1String(configpath));
file->setAbstractImportExportJob(exportNote);
file->start();
delete exportNote;
}
void ExportAddressbookJobInterfaceTest::exportAddressBookConfigAndResource_data()
{
QTest::addColumn<QByteArray>("configpath");
const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/export/");
QTest::newRow("addressbookconfigandresources") << pathConfig + QByteArray("addressbookconfigandresources/");
}
void ExportAddressbookJobInterfaceTest::exportAddressBookConfigAndResource()
void ExportAddressbookJobInterfaceTest::exportAddressBook()
{
QFETCH(QByteArray, configpath);
QFETCH(Utils::StoredTypes, options);
TestExportFile *file = new TestExportFile(this);
file->setPathConfig(configpath);
QVector<Utils::AkonadiInstanceInfo> lstInfo;
......@@ -154,7 +140,7 @@ void ExportAddressbookJobInterfaceTest::exportAddressBookConfigAndResource()
info.identifier = QStringLiteral("akonadi_kolab_resource_2");
lstInfo << info;
ExportAddressbookJobInterfaceTestImpl *exportNote = new ExportAddressbookJobInterfaceTestImpl(this, {Utils::StoredType::Config|Utils::StoredType::Resources}, file->archiveStorage(), 1);
ExportAddressbookJobInterfaceTestImpl *exportNote = new ExportAddressbookJobInterfaceTestImpl(this, options, file->archiveStorage(), 1);
exportNote->setListOfResource(lstInfo);
exportNote->setPathConfig(QLatin1String(configpath));
file->setAbstractImportExportJob(exportNote);
......
......@@ -50,10 +50,8 @@ public:
explicit ExportAddressbookJobInterfaceTest(QObject *parent = nullptr);
~ExportAddressbookJobInterfaceTest() = default;
private Q_SLOTS:
void exportAddressBookConfig();
void exportAddressBookConfig_data();
void exportAddressBookConfigAndResource_data();
void exportAddressBookConfigAndResource();
void exportAddressBook();
void exportAddressBook_data();
};
#endif // EXPORTADDRESSBOOKJOBINTERFACETEST_H
......@@ -77,43 +77,26 @@ void ImportAddressbookJobInterfaceTest::importAddressbook_data()
{
QTest::addColumn<QString>("zipFilePath");
QTest::addColumn<QString>("testPath");
QTest::addColumn<Utils::StoredTypes>("options");
const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/import/");
QTest::newRow("addressbookonlyconfig") << QString::fromLatin1(pathConfig) << QStringLiteral("/addressbookonlyconfig/");
}
void ImportAddressbookJobInterfaceTest::importAddressbookConfig()
{
QFETCH(QString, zipFilePath);
QFETCH(QString, testPath);
TestImportFile *file = new TestImportFile(zipFilePath + testPath, this);
file->setPathConfig(zipFilePath + testPath);
file->setExtractPath(QDir::tempPath() + testPath);
file->setExcludePath(Utils::addressbookPath());
ImportAddressbookJobInterfaceTestImpl *impl = new ImportAddressbookJobInterfaceTestImpl(this, {Utils::StoredType::Config}, file->archiveStorage(), 1);
file->setAbstractImportExportJob(impl);
file->setLoggingFilePath(impl->loggingFilePath());
file->start();
delete impl;
delete file;
}
Utils::StoredTypes options = {Utils::StoredType::Config};
void ImportAddressbookJobInterfaceTest::importAddressbookConfigAndResources_data()
{
QTest::addColumn<QString>("zipFilePath");
QTest::addColumn<QString>("testPath");
const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/import/");
QTest::newRow("addressbookconfigandresources") << QString::fromLatin1(pathConfig) << QStringLiteral("/addressbookconfigandresources/");
QTest::newRow("addressbookonlyconfig") << QString::fromLatin1(pathConfig) << QStringLiteral("/addressbookonlyconfig/") << options;
options = {Utils::StoredType::Config| Utils::StoredType::Resources};
QTest::newRow("addressbookconfigandresources") << QString::fromLatin1(pathConfig) << QStringLiteral("/addressbookconfigandresources/") << options;
}
void ImportAddressbookJobInterfaceTest::importAddressbookConfigAndResources()
void ImportAddressbookJobInterfaceTest::importAddressbook()
{
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() + testPath);
file->setExcludePath(Utils::addressbookPath());
ImportAddressbookJobInterfaceTestImpl *impl = new ImportAddressbookJobInterfaceTestImpl(this, {Utils::StoredType::Config | Utils::StoredType::Resources}, file->archiveStorage(), 1);
ImportAddressbookJobInterfaceTestImpl *impl = new ImportAddressbookJobInterfaceTestImpl(this, options, file->archiveStorage(), 1);
file->setAbstractImportExportJob(impl);
file->setLoggingFilePath(impl->loggingFilePath());
file->start();
......
......@@ -47,10 +47,8 @@ public:
explicit ImportAddressbookJobInterfaceTest(QObject *parent = nullptr);
~ImportAddressbookJobInterfaceTest() = default;
private Q_SLOTS:
void importAddressbookConfig();
void importAddressbookConfig_data();
void importAddressbookConfigAndResources();
void importAddressbookConfigAndResources_data();
void importAddressbook();
void importAddressbook_data();
};
#endif // IMPORTADDRESSBOOKJOBINTERFACETEST_H
......@@ -96,36 +96,21 @@ ExportAlarmJobInterfaceTest::ExportAlarmJobInterfaceTest(QObject *parent)
{
}
void ExportAlarmJobInterfaceTest::exportAlarmConfig_data()
void ExportAlarmJobInterfaceTest::exportAlarm_data()
{
QTest::addColumn<QByteArray>("configpath");
QTest::addColumn<Utils::StoredTypes>("options");
Utils::StoredTypes options = {Utils::StoredType::Config};
const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/export/");
QTest::newRow("alarmonlyconfig") << pathConfig + QByteArray("alarmonlyconfig/");
options = {Utils::StoredType::Config|Utils::StoredType::Resources};
QTest::newRow("alarmonlyconfig") << pathConfig + QByteArray("alarmconfigresources/") << options;
}
void ExportAlarmJobInterfaceTest::exportAlarmConfig()
{
QFETCH(QByteArray, configpath);
TestExportFile *file = new TestExportFile(this);
file->setPathConfig(configpath);
ExportAlarmJobInterfaceTestImpl *impl = new ExportAlarmJobInterfaceTestImpl(this, {Utils::StoredType::Config}, file->archiveStorage(), 1);
file->setAbstractImportExportJob(impl);
impl->setPathConfig(QLatin1String(configpath));
file->start();
delete impl;
}
void ExportAlarmJobInterfaceTest::exportAlarmConfigAndResource_data()
{
QTest::addColumn<QByteArray>("configpath");
const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/export/");
//QTest::newRow("test1resource") << pathConfig + QByteArray("test1resource/");
QTest::newRow("alarmonlyconfig") << pathConfig + QByteArray("alarmonlyconfig/");
}
void ExportAlarmJobInterfaceTest::exportAlarmConfigAndResource()
void ExportAlarmJobInterfaceTest::exportAlarm()
{
QFETCH(QByteArray, configpath);
QFETCH(Utils::StoredTypes, options);
TestExportFile *file = new TestExportFile(this);
file->setPathConfig(configpath);
QVector<Utils::AkonadiInstanceInfo> lstInfo;
......@@ -138,7 +123,7 @@ void ExportAlarmJobInterfaceTest::exportAlarmConfigAndResource()
info.identifier = QStringLiteral("akonadi_kolab_resource_2");
lstInfo << info;
ExportAlarmJobInterfaceTestImpl *exportNote = new ExportAlarmJobInterfaceTestImpl(this, {Utils::StoredType::Config|Utils::StoredType::Resources}, file->archiveStorage(), 1);
ExportAlarmJobInterfaceTestImpl *exportNote = new ExportAlarmJobInterfaceTestImpl(this, options, file->archiveStorage(), 1);
exportNote->setListOfResource(lstInfo);
exportNote->setPathConfig(QLatin1String(configpath));
file->setAbstractImportExportJob(exportNote);
......
......@@ -48,11 +48,8 @@ public:
explicit ExportAlarmJobInterfaceTest(QObject *parent = nullptr);
~ExportAlarmJobInterfaceTest() = default;
private Q_SLOTS:
void exportAlarmConfig();
void exportAlarmConfig_data();
void exportAlarmConfigAndResource_data();
void exportAlarmConfigAndResource();
void exportAlarm();
void exportAlarm_data();
};
#endif // ExportAlarmJobInterfaceTest_H
......@@ -82,7 +82,7 @@ ImportMailJobInterfaceTest::ImportMailJobInterfaceTest(QObject *parent)
{
}
void ImportMailJobInterfaceTest::importMailConfig_data()
void ImportMailJobInterfaceTest::importMail_data()
{
QTest::addColumn<QString>("zipFilePath");
QTest::addColumn<QString>("testPath");
......@@ -92,7 +92,7 @@ void ImportMailJobInterfaceTest::importMailConfig_data()
QTest::newRow("mailonlyconfig") << QString::fromLatin1(pathConfig) << QStringLiteral("/mailonlyconfig/") << options;
}
void ImportMailJobInterfaceTest::importMailConfig()
void ImportMailJobInterfaceTest::importMail()
{
QFETCH(QString, zipFilePath);
QFETCH(QString, testPath);
......
......@@ -51,8 +51,8 @@ public:
explicit ImportMailJobInterfaceTest(QObject *parent = nullptr);
~ImportMailJobInterfaceTest() = default;
private Q_SLOTS:
void importMailConfig();
void importMailConfig_data();
void importMail();
void importMail_data();
};
#endif // IMPORTMAILJOBINTERFACETEST_H
......@@ -91,35 +91,22 @@ ExportNotesJobInterfaceTest::ExportNotesJobInterfaceTest(QObject *parent)
{
}
void ExportNotesJobInterfaceTest::exportNoteConfig_data()
void ExportNotesJobInterfaceTest::exportNote_data()
{
QTest::addColumn<QByteArray>("configpath");
QTest::addColumn<Utils::StoredTypes>("options");
const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/export/");
QTest::newRow("test1") << pathConfig + QByteArray("test1/");
QTest::newRow("full") << pathConfig + QByteArray("full/");
Utils::StoredTypes options = {Utils::StoredType::Config};
QTest::newRow("test1") << pathConfig + QByteArray("test1/") << options;
QTest::newRow("full") << pathConfig + QByteArray("full/") << options;
options = {Utils::StoredType::Config|Utils::StoredType::Resources};
QTest::newRow("noteconfigandresource") << pathConfig + QByteArray("noteconfigandresource/") << options;
}
void ExportNotesJobInterfaceTest::exportNoteConfig()
{
QFETCH(QByteArray, configpath);
TestExportFile *file = new TestExportFile(this);
file->setPathConfig(configpath);
ExportNotesJobInterfaceTestImpl *exportNote = new ExportNotesJobInterfaceTestImpl(this, {Utils::StoredType::Config}, file->archiveStorage(), 1);
file->setAbstractImportExportJob(exportNote);
file->start();
delete exportNote;
}
void ExportNotesJobInterfaceTest::exportNoteConfigAndResource_data()
{
QTest::addColumn<QByteArray>("configpath");
const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/export/");
QTest::newRow("noteconfigandresource") << pathConfig + QByteArray("noteconfigandresource/");
}
void ExportNotesJobInterfaceTest::exportNoteConfigAndResource()
void ExportNotesJobInterfaceTest::exportNote()
{
QFETCH(QByteArray, configpath);
QFETCH(Utils::StoredTypes, options);
TestExportFile *file = new TestExportFile(this);
file->setPathConfig(configpath);
QVector<Utils::AkonadiInstanceInfo> lstInfo;
......@@ -132,7 +119,7 @@ void ExportNotesJobInterfaceTest::exportNoteConfigAndResource()
info.identifier = QStringLiteral("akonadi_kontact_resource_2");
lstInfo << info;
ExportNotesJobInterfaceTestImpl *exportNote = new ExportNotesJobInterfaceTestImpl(this, {Utils::StoredType::Config|Utils::StoredType::Resources}, file->archiveStorage(), 1);
ExportNotesJobInterfaceTestImpl *exportNote = new ExportNotesJobInterfaceTestImpl(this, options, file->archiveStorage(), 1);
exportNote->setListOfResource(lstInfo);
exportNote->setPathConfig(QLatin1String(configpath));
file->setAbstractImportExportJob(exportNote);
......
......@@ -48,12 +48,9 @@ class ExportNotesJobInterfaceTest : public QObject
public:
explicit ExportNotesJobInterfaceTest(QObject *parent = nullptr);
~ExportNotesJobInterfaceTest() = default;
void exportNoteConfig_data();
void exportNoteConfig();
private Q_SLOTS:
void exportNoteConfigAndResource();
void exportNoteConfigAndResource_data();
void exportNote_data();
void exportNote();
};
#endif // EXPORTNOTESJOBINTERFACETEST_H
......@@ -74,47 +74,28 @@ ImportNotesJobInterfaceTest::ImportNotesJobInterfaceTest(QObject *parent)
{
}
void ImportNotesJobInterfaceTest::importNoteConfig_data()
void ImportNotesJobInterfaceTest::importNote_data()
{
QTest::addColumn<QString>("zipFilePath");
QTest::addColumn<QString>("testPath");
QTest::addColumn<Utils::StoredTypes>("options");
const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/import/");
QTest::newRow("test1") << QString::fromLatin1(pathConfig) << QStringLiteral("/test1/");
Utils::StoredTypes options = {Utils::StoredType::Config};
QTest::newRow("test1") << QString::fromLatin1(pathConfig) << QStringLiteral("/test1/") << options;
options = {Utils::StoredType::Config|Utils::StoredType::Resources};
QTest::newRow("test1resource") << QString::fromLatin1(pathConfig) << QStringLiteral("/test1resource/") << options;
}
void ImportNotesJobInterfaceTest::importNoteConfig()
void ImportNotesJobInterfaceTest::importNote()
{
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() + testPath);
file->setExcludePath(Utils::notePath());
ImportNotesJobInterfaceTestImpl *impl = new ImportNotesJobInterfaceTestImpl(this, {Utils::StoredType::Config}, file->archiveStorage(), 1);
file->setAbstractImportExportJob(impl);
file->setLoggingFilePath(impl->loggingFilePath());
file->start();
delete impl;
delete file;
}
void ImportNotesJobInterfaceTest::importNoteConfigAndResources_data()
{
QTest::addColumn<QString>("zipFilePath");
QTest::addColumn<QString>("testPath");
const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/import/");
QTest::newRow("test1resource") << QString::fromLatin1(pathConfig) << QStringLiteral("/test1resource/");
}
void ImportNotesJobInterfaceTest::importNoteConfigAndResources()
{
QFETCH(QString, zipFilePath);
QFETCH(QString, testPath);
TestImportFile *file = new TestImportFile(zipFilePath + testPath, this);
file->setPathConfig(zipFilePath + testPath);
file->setExtractPath(QDir::tempPath() + testPath);
file->setExcludePath(Utils::notePath());
ImportNotesJobInterfaceTestImpl *impl = new ImportNotesJobInterfaceTestImpl(this, {Utils::StoredType::Config|Utils::StoredType::Resources}, file->archiveStorage(), 1);
ImportNotesJobInterfaceTestImpl *impl = new ImportNotesJobInterfaceTestImpl(this, options, file->archiveStorage(), 1);
file->setAbstractImportExportJob(impl);
file->setLoggingFilePath(impl->loggingFilePath());
file->start();
......
......@@ -47,10 +47,8 @@ public:
explicit ImportNotesJobInterfaceTest(QObject *parent = nullptr);
~ImportNotesJobInterfaceTest() = default;
private Q_SLOTS:
void importNoteConfig();
void importNoteConfig_data();
void importNoteConfigAndResources();
void importNoteConfigAndResources_data();
void importNote();
void importNote_data();
};
#endif // IMPORTNOTESJOBINTERFACETEST_H
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