File indexing completed on 2024-12-22 05:05:25
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 "importnotesjobinterfacetest.h" 0008 #include "archivestorage.h" 0009 #include "importnotesjobinterfacetestimpl.h" 0010 #include "testimportfile.h" 0011 #include <QTest> 0012 QTEST_MAIN(ImportNotesJobInterfaceTest) 0013 0014 ImportNotesJobInterfaceTest::ImportNotesJobInterfaceTest(QObject *parent) 0015 : QObject(parent) 0016 { 0017 } 0018 0019 void ImportNotesJobInterfaceTest::importNote_data() 0020 { 0021 QTest::addColumn<QString>("zipFilePath"); 0022 QTest::addColumn<QString>("testPath"); 0023 QTest::addColumn<Utils::StoredTypes>("options"); 0024 const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/import/"); 0025 Utils::StoredTypes options = {Utils::StoredType::Config}; 0026 QTest::newRow("test1") << QString::fromLatin1(pathConfig) << QStringLiteral("/test1/") << options; 0027 options = {Utils::StoredType::Config | Utils::StoredType::Resources}; 0028 QTest::newRow("test1resource") << QString::fromLatin1(pathConfig) << QStringLiteral("/test1resource/") << options; 0029 } 0030 0031 void ImportNotesJobInterfaceTest::importNote() 0032 { 0033 QFETCH(QString, zipFilePath); 0034 QFETCH(QString, testPath); 0035 QFETCH(Utils::StoredTypes, options); 0036 const QString fullTestPath = zipFilePath + testPath; 0037 auto file = new TestImportFile(fullTestPath, this); 0038 file->setPathConfig(fullTestPath); 0039 file->setExtractPath(QDir::tempPath() + testPath); 0040 file->setExcludePath(Utils::notePath()); 0041 auto impl = new ImportNotesJobInterfaceTestImpl(this, options, file->archiveStorage(), 1); 0042 impl->setPathConfig(file->pathConfig()); 0043 impl->setExistingPathConfig(fullTestPath + QStringLiteral("/existingconfig/")); 0044 file->setAbstractImportExportJob(impl); 0045 file->setLoggingFilePath(impl->loggingFilePath()); 0046 file->start(); 0047 delete impl; 0048 delete file; 0049 } 0050 0051 #include "moc_importnotesjobinterfacetest.cpp"