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 "exportalarmjobinterfacetest.h"
0008 #include "archivestorage.h"
0009 #include "exportalarmjobinterfacetestimpl.h"
0010 #include "testexportfile.h"
0011 #include <QTest>
0012 
0013 QTEST_MAIN(ExportAlarmJobInterfaceTest)
0014 
0015 ExportAlarmJobInterfaceTest::ExportAlarmJobInterfaceTest(QObject *parent)
0016     : QObject(parent)
0017 {
0018 }
0019 
0020 void ExportAlarmJobInterfaceTest::exportAlarm_data()
0021 {
0022     QTest::addColumn<QByteArray>("configpath");
0023     QTest::addColumn<Utils::StoredTypes>("options");
0024     Utils::StoredTypes options = {Utils::StoredType::Config};
0025     const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/export/");
0026     QTest::newRow("alarmonlyconfig") << pathConfig + QByteArray("alarmonlyconfig/") << options;
0027     options = {Utils::StoredType::Config | Utils::StoredType::Resources};
0028     QTest::newRow("alarmconfigresources") << pathConfig + QByteArray("alarmconfigresources/") << options;
0029 }
0030 
0031 void ExportAlarmJobInterfaceTest::exportAlarm()
0032 {
0033     QFETCH(QByteArray, configpath);
0034     QFETCH(Utils::StoredTypes, options);
0035     std::unique_ptr<TestExportFile> file{new TestExportFile(this)};
0036     file->setPathConfig(configpath);
0037     QList<Utils::AkonadiInstanceInfo> lstInfo;
0038     Utils::AkonadiInstanceInfo info;
0039     info.identifier = QStringLiteral("akonadi_kalarm_dir_resource_1");
0040     lstInfo << info;
0041     info.identifier = QStringLiteral("akonadi_kalarm_dir_resource_2");
0042     lstInfo << info;
0043     // Add extra resource.
0044     info.identifier = QStringLiteral("akonadi_kolab_resource_2");
0045     lstInfo << info;
0046 
0047     auto exportNote = new ExportAlarmJobInterfaceTestImpl(this, options, file->archiveStorage(), 1);
0048     exportNote->setListOfResource(lstInfo);
0049     exportNote->setPathConfig(QLatin1StringView(configpath));
0050     file->setAbstractImportExportJob(exportNote);
0051     file->start();
0052     delete exportNote;
0053 }
0054 
0055 #include "moc_exportalarmjobinterfacetest.cpp"