File indexing completed on 2024-12-22 05:05:24
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 "exportnotesjobinterfacetest.h" 0008 #include "archivestorage.h" 0009 #include "exportnotesjobinterfacetestimpl.h" 0010 #include "testexportfile.h" 0011 #include <QTest> 0012 0013 QTEST_MAIN(ExportNotesJobInterfaceTest) 0014 0015 ExportNotesJobInterfaceTest::ExportNotesJobInterfaceTest(QObject *parent) 0016 : QObject(parent) 0017 { 0018 } 0019 0020 void ExportNotesJobInterfaceTest::exportNote_data() 0021 { 0022 QTest::addColumn<QByteArray>("configpath"); 0023 QTest::addColumn<Utils::StoredTypes>("options"); 0024 const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/export/"); 0025 Utils::StoredTypes options = {Utils::StoredType::Config}; 0026 QTest::newRow("test1") << pathConfig + QByteArray("test1/") << options; 0027 QTest::newRow("full") << pathConfig + QByteArray("full/") << options; 0028 options = {Utils::StoredType::Config | Utils::StoredType::Resources}; 0029 QTest::newRow("noteconfigandresource") << pathConfig + QByteArray("noteconfigandresource/") << options; 0030 } 0031 0032 void ExportNotesJobInterfaceTest::exportNote() 0033 { 0034 QFETCH(QByteArray, configpath); 0035 QFETCH(Utils::StoredTypes, options); 0036 std::unique_ptr<TestExportFile> file{new TestExportFile(this)}; 0037 file->setPathConfig(configpath); 0038 QList<Utils::AkonadiInstanceInfo> lstInfo; 0039 Utils::AkonadiInstanceInfo info; 0040 info.identifier = QStringLiteral("akonadi_akonotes_resource_1"); 0041 lstInfo << info; 0042 info.identifier = QStringLiteral("akonadi_akonotes_resource_2"); 0043 lstInfo << info; 0044 // Add extra resource. 0045 info.identifier = QStringLiteral("akonadi_kontact_resource_2"); 0046 lstInfo << info; 0047 0048 auto exportNote = new ExportNotesJobInterfaceTestImpl(this, options, file->archiveStorage(), 1); 0049 exportNote->setListOfResource(lstInfo); 0050 exportNote->setPathConfig(QLatin1StringView(configpath)); 0051 file->setAbstractImportExportJob(exportNote); 0052 file->start(); 0053 delete exportNote; 0054 } 0055 0056 #include "moc_exportnotesjobinterfacetest.cpp"