Commit 2b9a9d0e authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Allow to compare list of file

parent 2825dd5d
......@@ -4,12 +4,22 @@ add_executable( utilstest ${utilstest_SRCS})
add_test(NAME utilstest COMMAND utilstest)
ecm_mark_as_test(utilstest)
target_link_libraries( utilstest Qt5::Test pimdataexporterprivate KF5::ConfigCore)
#####
add_library(test_resourceconverter STATIC
resourceconvertertest.cpp
generatelistfilefromarchive.cpp
loadlistfromfile.cpp
)
target_link_libraries(test_resourceconverter PUBLIC KF5::ConfigCore pimdataexporterprivate KF5::Archive Qt5::Test)
#####
set( resourceconverterclasstest_SRCS resourceconverterclasstest.cpp resourceconvertertest.cpp )
add_executable( resourceconverterclasstest ${resourceconverterclasstest_SRCS})
add_test(NAME resourceconverterclasstest COMMAND resourceconverterclasstest)
ecm_mark_as_test(resourceconverterclasstest)
target_link_libraries( resourceconverterclasstest Qt5::Test KF5::ConfigCore pimdataexporterprivate)
target_link_libraries( resourceconverterclasstest Qt5::Test KF5::ConfigCore test_resourceconverter)
add_subdirectory(notes)
......
add_definitions( -DPIMDATAEXPORTER_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data" )
set( exportakregatorjobinterfacetest_SRCS exportakregatorjobinterfacetest.cpp ../resourceconvertertest.cpp )
set( exportakregatorjobinterfacetest_SRCS exportakregatorjobinterfacetest.cpp)
add_executable( exportakregatorjobinterfacetest ${exportakregatorjobinterfacetest_SRCS})
add_test(NAME exportakregatorjobinterfacetest COMMAND exportakregatorjobinterfacetest)
ecm_mark_as_test(exportakregatorjobinterfacetest)
target_link_libraries(exportakregatorjobinterfacetest Qt5::Test pimdataexporterprivate KF5::ConfigCore)
target_link_libraries(exportakregatorjobinterfacetest Qt5::Test pimdataexporterprivate KF5::ConfigCore test_resourceconverter)
add_definitions( -DPIMDATAEXPORTER_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data" )
set( exportalarmjobinterfacetest_SRCS exportalarmjobinterfacetest.cpp ../resourceconvertertest.cpp )
set( exportalarmjobinterfacetest_SRCS exportalarmjobinterfacetest.cpp)
add_executable( exportalarmjobinterfacetest ${exportalarmjobinterfacetest_SRCS})
add_test(NAME exportalarmjobinterfacetest COMMAND exportalarmjobinterfacetest)
ecm_mark_as_test(exportalarmjobinterfacetest)
target_link_libraries(exportalarmjobinterfacetest Qt5::Test pimdataexporterprivate KF5::ConfigCore)
target_link_libraries(exportalarmjobinterfacetest Qt5::Test pimdataexporterprivate KF5::ConfigCore test_resourceconverter)
add_definitions( -DPIMDATAEXPORTER_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data" )
set( exportcalendarsjobinterfacetest_SRCS exportcalendarsjobinterfacetest.cpp ../resourceconvertertest.cpp )
set( exportcalendarsjobinterfacetest_SRCS exportcalendarsjobinterfacetest.cpp)
add_executable( exportcalendarsjobinterfacetest ${exportcalendarsjobinterfacetest_SRCS})
add_test(NAME exportcalendarsjobinterfacetest COMMAND exportcalendarsjobinterfacetest)
ecm_mark_as_test(exportcalendarsjobinterfacetest)
target_link_libraries(exportcalendarsjobinterfacetest Qt5::Test pimdataexporterprivate KF5::ConfigCore)
target_link_libraries(exportcalendarsjobinterfacetest Qt5::Test pimdataexporterprivate KF5::ConfigCore test_resourceconverter)
/*
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 "loadlistfromfile.h"
#include <QFile>
#include <QTest>
LoadListFromFile::LoadListFromFile(const QString &filename)
{
QFile f(filename);
QVERIFY(f.open(QIODevice::ReadOnly));
const QByteArray content = f.readAll();
f.close();
const QString contextStr = QString::fromUtf8(content);
mFileList = contextStr.split(QLatin1Char('\n'), Qt::SkipEmptyParts);
}
LoadListFromFile::~LoadListFromFile()
{
}
QStringList LoadListFromFile::fileList() const
{
return mFileList;
}
/*
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 LOADLISTFROMFILE_H
#define LOADLISTFROMFILE_H
#include <QString>
#include <QStringList>
class LoadListFromFile
{
public:
explicit LoadListFromFile(const QString &filename);
~LoadListFromFile();
Q_REQUIRED_RESULT QStringList fileList() const;
private:
QStringList mFileList;
};
#endif // LOADLISTFROMFILE_H
add_definitions( -DPIMDATAEXPORTER_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data" )
set( exportmailjobinterfacetest_SRCS exportmailjobinterfacetest.cpp ../resourceconvertertest.cpp )
set( exportmailjobinterfacetest_SRCS exportmailjobinterfacetest.cpp)
add_executable( exportmailjobinterfacetest ${exportmailjobinterfacetest_SRCS})
add_test(NAME exportmailjobinterfacetest COMMAND exportmailjobinterfacetest)
ecm_mark_as_test(exportmailjobinterfacetest)
target_link_libraries(exportmailjobinterfacetest Qt5::Test pimdataexporterprivate KF5::ConfigCore)
target_link_libraries(exportmailjobinterfacetest Qt5::Test pimdataexporterprivate KF5::ConfigCore test_resourceconverter)
add_definitions( -DPIMDATAEXPORTER_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data" )
set( exportnotesjobinterfacetest_SRCS exportnotesjobinterfacetest.cpp ../resourceconvertertest.cpp ../generatelistfilefromarchive.cpp)
set( exportnotesjobinterfacetest_SRCS exportnotesjobinterfacetest.cpp)
add_executable( exportnotesjobinterfacetest ${exportnotesjobinterfacetest_SRCS})
add_test(NAME exportnotesjobinterfacetest COMMAND exportnotesjobinterfacetest)
ecm_mark_as_test(exportnotesjobinterfacetest)
target_link_libraries( exportnotesjobinterfacetest Qt5::Test pimdataexporterprivate KF5::ConfigCore KF5::Archive)
target_link_libraries( exportnotesjobinterfacetest Qt5::Test pimdataexporterprivate test_resourceconverter KF5::ConfigCore KF5::Archive)
configs/globalnotesettings
configs/knotesrc
information/VERSION_2
information/exportdatatype.xml
......@@ -20,8 +20,9 @@
#include "exportnotesjobinterfacetest.h"
#include "notes/exportnotesjobinterface.h"
#include "archivestorage.h"
#include "../resourceconvertertest.h"
#include "../generatelistfilefromarchive.h"
#include "resourceconvertertest.h"
#include "generatelistfilefromarchive.h"
#include "loadlistfromfile.h"
#include <QDebug>
#include <QTest>
#include <QSignalSpy>
......@@ -62,7 +63,8 @@ void ExportNotesJobInterfaceTest::exportNoteConfigTest1()
qputenv("XDG_CONFIG_HOME", PIMDATAEXPORTER_DIR "/test1/config");
//TODO fix file name.
const QString storeArchivePath(QStringLiteral("/tmp/foo.zip"));
const QString temporaryFile = QStringLiteral("/tmp/foo.zip");
const QString storeArchivePath(temporaryFile);
ArchiveStorage *archiveStorage = new ArchiveStorage(storeArchivePath, this);
Q_ASSERT(archiveStorage->openArchive(true));
Utils::addVersion(archiveStorage->archive());
......@@ -77,8 +79,11 @@ void ExportNotesJobInterfaceTest::exportNoteConfigTest1()
delete exportNote;
delete archiveStorage;
GenerateListFileFromArchive archive(QStringLiteral("/tmp/foo.zip"));
qDebug() << " archive " << archive.listFile();
GenerateListFileFromArchive archive(temporaryFile);
//qDebug() << " archive " << archive.listFile();
LoadListFromFile f(QStringLiteral(PIMDATAEXPORTER_DIR "/test1/list.txt"));
QCOMPARE(f.fileList(), archive.listFile());
}
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