Commit 26819f91 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Implement compareexportfile

parent 2b9a9d0e
......@@ -10,6 +10,7 @@ add_library(test_resourceconverter STATIC
resourceconvertertest.cpp
generatelistfilefromarchive.cpp
loadlistfromfile.cpp
compareexportfile.cpp
)
target_link_libraries(test_resourceconverter PUBLIC KF5::ConfigCore pimdataexporterprivate KF5::Archive Qt5::Test)
......
/*
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 "compareexportfile.h"
#include "generatelistfilefromarchive.h"
#include "loadlistfromfile.h"
#include <QTest>
#include <QDebug>
CompareExportFile::CompareExportFile()
{
}
CompareExportFile::~CompareExportFile()
{
}
void CompareExportFile::compareFiles()
{
GenerateListFileFromArchive archive(mTempFilePath);
//qDebug() << " archive " << archive.listFile();
LoadListFromFile f(mListFilePath);
const bool equal = (f.fileList() == archive.listFile());
if (!equal) {
qDebug() << "Requested : " << f.fileList();
qDebug() << "List File : " << archive.listFile();
}
QVERIFY(equal);
}
QString CompareExportFile::tempFilePath() const
{
return mTempFilePath;
}
void CompareExportFile::setTempFilePath(const QString &tempFilePath)
{
mTempFilePath = tempFilePath;
}
QString CompareExportFile::listFilePath() const
{
return mListFilePath;
}
void CompareExportFile::setListFilePath(const QString &listFilePath)
{
mListFilePath = listFilePath;
}
/*
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 COMPAREEXPORTFILE_H
#define COMPAREEXPORTFILE_H
#include <QString>
class CompareExportFile
{
public:
CompareExportFile();
~CompareExportFile();
void compareFiles();
Q_REQUIRED_RESULT QString tempFilePath() const;
void setTempFilePath(const QString &tempFilePath);
Q_REQUIRED_RESULT QString listFilePath() const;
void setListFilePath(const QString &listFilePath);
private:
QString mTempFilePath;
QString mListFilePath;
};
#endif // COMPAREEXPORTFILE_H
......@@ -21,8 +21,7 @@
#include "notes/exportnotesjobinterface.h"
#include "archivestorage.h"
#include "resourceconvertertest.h"
#include "generatelistfilefromarchive.h"
#include "loadlistfromfile.h"
#include "compareexportfile.h"
#include <QDebug>
#include <QTest>
#include <QSignalSpy>
......@@ -79,11 +78,10 @@ void ExportNotesJobInterfaceTest::exportNoteConfigTest1()
delete exportNote;
delete archiveStorage;
GenerateListFileFromArchive archive(temporaryFile);
//qDebug() << " archive " << archive.listFile();
LoadListFromFile f(QStringLiteral(PIMDATAEXPORTER_DIR "/test1/list.txt"));
QCOMPARE(f.fileList(), archive.listFile());
CompareExportFile compareExportFile;
compareExportFile.setTempFilePath(temporaryFile);
compareExportFile.setListFilePath(QStringLiteral(PIMDATAEXPORTER_DIR "/test1/list.txt"));
compareExportFile.compareFiles();
}
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