File indexing completed on 2024-12-22 05:05:23

0001 /*
0002    SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "exportaddressbookjobinterfacetest.h"
0008 #include "exportaddressbookjobinterfacetestimpl.h"
0009 #include "testexportfile.h"
0010 #include <QTest>
0011 
0012 QTEST_MAIN(ExportAddressbookJobInterfaceTest)
0013 
0014 ExportAddressbookJobInterfaceTest::ExportAddressbookJobInterfaceTest(QObject *parent)
0015     : QObject(parent)
0016 {
0017 }
0018 
0019 void ExportAddressbookJobInterfaceTest::exportAddressBook_data()
0020 {
0021     QTest::addColumn<QByteArray>("configpath");
0022     QTest::addColumn<Utils::StoredTypes>("options");
0023     const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/export/");
0024     Utils::StoredTypes options = {Utils::StoredType::Config};
0025     QTest::newRow("addressbookonlyconfig") << pathConfig + QByteArray("addressbookonlyconfig/") << options;
0026     options = {Utils::StoredType::Config | Utils::StoredType::Resources};
0027     QTest::newRow("addressbookconfigandresources") << pathConfig + QByteArray("addressbookconfigandresources/") << options;
0028 }
0029 
0030 void ExportAddressbookJobInterfaceTest::exportAddressBook()
0031 {
0032     QFETCH(QByteArray, configpath);
0033     QFETCH(Utils::StoredTypes, options);
0034     std::unique_ptr<TestExportFile> file{new TestExportFile(this)};
0035     file->setPathConfig(configpath);
0036     QList<Utils::AkonadiInstanceInfo> lstInfo;
0037     Utils::AkonadiInstanceInfo info;
0038 
0039     info.identifier = QStringLiteral("akonadi_vcarddir_resource_1");
0040     lstInfo << info;
0041     info.identifier = QStringLiteral("akonadi_contacts_resource_1");
0042     lstInfo << info;
0043     info.identifier = QStringLiteral("akonadi_vcard_resource_1");
0044     lstInfo << info;
0045     // Add extra resource.
0046     info.identifier = QStringLiteral("akonadi_kolab_resource_2");
0047     lstInfo << info;
0048 
0049     auto exportNote = new ExportAddressbookJobInterfaceTestImpl(this, options, file->archiveStorage(), 1);
0050     exportNote->setListOfResource(lstInfo);
0051     exportNote->setPathConfig(QLatin1StringView(configpath));
0052     file->setAbstractImportExportJob(exportNote);
0053     file->start();
0054     delete exportNote;
0055 }
0056 
0057 #include "moc_exportaddressbookjobinterfacetest.cpp"