File indexing completed on 2025-01-12 04:52:07

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 "importalarmjobinterfacetest.h"
0008 #include "archivestorage.h"
0009 #include "importalarmjobinterfacetestimpl.h"
0010 #include "testimportfile.h"
0011 #include <QTest>
0012 QTEST_MAIN(ImportAlarmJobInterfaceTest)
0013 
0014 ImportAlarmJobInterfaceTest::ImportAlarmJobInterfaceTest(QObject *parent)
0015     : QObject(parent)
0016 {
0017 }
0018 
0019 void ImportAlarmJobInterfaceTest::importAlarmConfig_data()
0020 {
0021     QTest::addColumn<QString>("zipFilePath");
0022     QTest::addColumn<QString>("testPath");
0023     QTest::addColumn<Utils::StoredTypes>("options");
0024     Utils::StoredTypes options = {Utils::StoredType::Config};
0025     const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/import/");
0026     QTest::newRow("alarmonlyconfig") << QString::fromLatin1(pathConfig) << QStringLiteral("/alarmonlyconfig/") << options;
0027     // TODO fix me
0028     //    options = {Utils::StoredType::Config | Utils::StoredType::Resources};
0029     //    QTest::newRow("alarmconfigresources") << QString::fromLatin1(pathConfig) << QStringLiteral("/alarmconfigresources/") << options;
0030 }
0031 
0032 void ImportAlarmJobInterfaceTest::importAlarmConfig()
0033 {
0034     QFETCH(QString, zipFilePath);
0035     QFETCH(QString, testPath);
0036     QFETCH(Utils::StoredTypes, options);
0037     const QString fullTestPath = zipFilePath + testPath;
0038     auto file = new TestImportFile(fullTestPath, this);
0039     file->setPathConfig(fullTestPath);
0040     file->setExtractPath(QDir::tempPath() + testPath);
0041     file->setExcludePath(Utils::alarmPath());
0042     auto impl = new ImportAlarmJobInterfaceTestImpl(this, options, file->archiveStorage(), 1);
0043     impl->setPathConfig(file->pathConfig());
0044     impl->setExtractPath(file->extractPath());
0045     impl->setTempDirName(file->extractPath());
0046     impl->setExistingPathConfig(fullTestPath + QStringLiteral("/existingconfig/"));
0047     file->setAbstractImportExportJob(impl);
0048     file->setLoggingFilePath(impl->loggingFilePath());
0049     file->start();
0050     delete impl;
0051     delete file;
0052 }
0053 
0054 #include "moc_importalarmjobinterfacetest.cpp"