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 "importaddressbookjobinterfacetest.h" 0008 #include "importaddressbookjobinterfacetestimpl.h" 0009 #include "testimportfile.h" 0010 #include <QTest> 0011 QTEST_MAIN(ImportAddressbookJobInterfaceTest) 0012 0013 ImportAddressbookJobInterfaceTest::ImportAddressbookJobInterfaceTest(QObject *parent) 0014 : QObject(parent) 0015 { 0016 } 0017 0018 void ImportAddressbookJobInterfaceTest::importAddressbook_data() 0019 { 0020 QTest::addColumn<QString>("zipFilePath"); 0021 QTest::addColumn<QString>("testPath"); 0022 QTest::addColumn<Utils::StoredTypes>("options"); 0023 const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/import/"); 0024 Utils::StoredTypes options = {Utils::StoredType::Config}; 0025 0026 QTest::newRow("addressbookonlyconfig") << QString::fromLatin1(pathConfig) << QStringLiteral("/addressbookonlyconfig/") << options; 0027 options = {Utils::StoredType::Config | Utils::StoredType::Resources}; 0028 QTest::newRow("addressbookconfigandresources") << QString::fromLatin1(pathConfig) << QStringLiteral("/addressbookconfigandresources/") << options; 0029 } 0030 0031 void ImportAddressbookJobInterfaceTest::importAddressbook() 0032 { 0033 QFETCH(QString, zipFilePath); 0034 QFETCH(QString, testPath); 0035 QFETCH(Utils::StoredTypes, options); 0036 0037 auto file = new TestImportFile(zipFilePath + testPath, this); 0038 file->setPathConfig(zipFilePath + testPath); 0039 file->setExtractPath(QDir::tempPath() + testPath); 0040 file->setExcludePath(Utils::addressbookPath()); 0041 auto impl = new ImportAddressbookJobInterfaceTestImpl(this, options, file->archiveStorage(), 1); 0042 impl->setPathConfig(file->pathConfig()); 0043 impl->setExtractPath(file->extractPath()); 0044 impl->setTempDirName(file->extractPath()); 0045 file->setAbstractImportExportJob(impl); 0046 file->setLoggingFilePath(impl->loggingFilePath()); 0047 file->start(); 0048 delete impl; 0049 delete file; 0050 } 0051 0052 #include "moc_importaddressbookjobinterfacetest.cpp"