Commit c8de8743 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix import/export class

parent 33cb30b8
......@@ -13,6 +13,7 @@ add_library(test_resourceconverter STATIC
compareexportfile.cpp
compareimportfile.cpp
testexportfile.cpp
testimportfile.cpp
)
target_link_libraries(test_resourceconverter PUBLIC KF5::ConfigCore pimdataexporterprivate KF5::Archive Qt5::Test)
......
......@@ -30,8 +30,8 @@
TestExportFile::TestExportFile(QObject *parent)
: QObject(parent)
{
const QString temporaryFile = QDir::tempPath() + QStringLiteral("/archive.zip");
mArchiveStorage = new ArchiveStorage(temporaryFile, this);
mTemporaryFile = QDir::tempPath() + QStringLiteral("/archive.zip");
mArchiveStorage = new ArchiveStorage(mTemporaryFile, this);
Q_ASSERT(mArchiveStorage->openArchive(true));
}
......@@ -67,9 +67,7 @@ void TestExportFile::start()
qputenv("XDG_CONFIG_HOME", mPathConfig + "/config");
//TODO fix file name.
const QString temporaryFile = QDir::tempPath() + QStringLiteral("/archive.zip");
Utils::addVersion(mArchiveStorage->archive());
//qDebug() << " temporaryFile " << temporaryFile;
Utils::storeDataExportInfo(mArchiveStorage->archive());
QSignalSpy finish(mAbstractImportExportJob, &AbstractImportExportJob::jobFinished);
......@@ -81,10 +79,10 @@ void TestExportFile::start()
mArchiveStorage = nullptr;
CompareExportFile compareExportFile;
compareExportFile.setTempFilePath(temporaryFile);
compareExportFile.setTempFilePath(mTemporaryFile);
compareExportFile.setListFilePath(QLatin1String(mPathConfig));
compareExportFile.compareFiles();
QVERIFY(QFile(temporaryFile).remove());
QVERIFY(QFile(mTemporaryFile).remove());
}
ArchiveStorage *TestExportFile::archiveStorage() const
......
......@@ -44,6 +44,7 @@ private:
QByteArray mPathConfig;
AbstractImportExportJob *mAbstractImportExportJob = nullptr;
ArchiveStorage *mArchiveStorage = nullptr;
QString mTemporaryFile;
};
#endif // TESTEXPORTFILE_H
/*
Copyright (C) 2020 Laurent Montel <montel@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "testimportfile.h"
#include "archivestorage.h"
#include "abstractimportexportjob.h"
#include "compareexportfile.h"
#include <QSignalSpy>
#include <QTest>
TestImportFile::TestImportFile(const QString &archivePath, QObject *parent)
: QObject(parent)
, mArchivePath(archivePath)
{
mArchiveStorage = new ArchiveStorage(archivePath, this);
Q_ASSERT(mArchiveStorage->openArchive(false));
}
TestImportFile::~TestImportFile()
{
}
void TestImportFile::start()
{
QSignalSpy finish(mAbstractImportExportJob, &AbstractImportExportJob::jobFinished);
QSignalSpy error(mAbstractImportExportJob, &AbstractImportExportJob::error);
mAbstractImportExportJob->start();
QVERIFY(finish.wait());
QCOMPARE(error.count(), 0);
delete mArchiveStorage;
mArchiveStorage = nullptr;
CompareExportFile compareExportFile;
compareExportFile.setTempFilePath(mArchivePath);
compareExportFile.setListFilePath(mPathConfig);
compareExportFile.compareFiles();
}
AbstractImportExportJob *TestImportFile::abstractImportExportJob() const
{
return mAbstractImportExportJob;
}
void TestImportFile::setAbstractImportExportJob(AbstractImportExportJob *abstractImportExportJob)
{
mAbstractImportExportJob = abstractImportExportJob;
}
ArchiveStorage *TestImportFile::archiveStorage() const
{
return mArchiveStorage;
}
void TestImportFile::setArchiveStorage(ArchiveStorage *archiveStorage)
{
mArchiveStorage = archiveStorage;
}
QString TestImportFile::pathConfig() const
{
return mPathConfig;
}
void TestImportFile::setPathConfig(const QString &pathConfig)
{
mPathConfig = pathConfig;
}
/*
Copyright (C) 2020 Laurent Montel <montel@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef TESTIMPORTFILE_H
#define TESTIMPORTFILE_H
#include <QObject>
class ArchiveStorage;
class AbstractImportExportJob;
class TestImportFile : public QObject
{
Q_OBJECT
public:
explicit TestImportFile(const QString &archivePath, QObject *parent = nullptr);
~TestImportFile();
void start();
Q_REQUIRED_RESULT AbstractImportExportJob *abstractImportExportJob() const;
void setAbstractImportExportJob(AbstractImportExportJob *abstractImportExportJob);
Q_REQUIRED_RESULT ArchiveStorage *archiveStorage() const;
void setArchiveStorage(ArchiveStorage *archiveStorage);
Q_REQUIRED_RESULT QString pathConfig() const;
void setPathConfig(const QString &pathConfig);
private:
AbstractImportExportJob *mAbstractImportExportJob = nullptr;
ArchiveStorage *mArchiveStorage = nullptr;
QString mArchivePath;
QString mPathConfig;
};
#endif // TESTIMPORTFILE_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment