Commit 970b19ed authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Continue to implement autotesting

parent 475578f8
......@@ -84,7 +84,7 @@ void ExportAddressbookJobInterfaceTest::exportAddressBookConfigTest1()
delete archiveStorage;
CompareExportFile compareExportFile;
compareExportFile.setTempFilePath(temporaryFile);
compareExportFile.setListFilePath(QStringLiteral(PIMDATAEXPORTER_DIR "/export/test1/list.txt"));
compareExportFile.setListFilePath(QStringLiteral(PIMDATAEXPORTER_DIR "/export/test1"));
compareExportFile.compareFiles();
}
......
......@@ -68,7 +68,7 @@ void ExportAkregatorJobInterfaceTest::exportAkregatorConfigTest1()
CompareExportFile compareExportFile;
compareExportFile.setTempFilePath(temporaryFile);
compareExportFile.setListFilePath(QStringLiteral(PIMDATAEXPORTER_DIR "/export/test1/list.txt"));
compareExportFile.setListFilePath(QStringLiteral(PIMDATAEXPORTER_DIR "/export/test1"));
compareExportFile.compareFiles();
}
......
......@@ -73,7 +73,7 @@ void ExportAlarmJobInterfaceTest::exportAlarmConfigTest1()
CompareExportFile compareExportFile;
compareExportFile.setTempFilePath(temporaryFile);
compareExportFile.setListFilePath(QStringLiteral(PIMDATAEXPORTER_DIR "/export/test1/list.txt"));
compareExportFile.setListFilePath(QStringLiteral(PIMDATAEXPORTER_DIR "/export/test1"));
compareExportFile.compareFiles();
}
......
......@@ -73,7 +73,7 @@ void ExportCalendarsJobInterfaceTest::exportCalendarConfigTest1()
CompareExportFile compareExportFile;
compareExportFile.setTempFilePath(temporaryFile);
compareExportFile.setListFilePath(QStringLiteral(PIMDATAEXPORTER_DIR "/export/test1/list.txt"));
compareExportFile.setListFilePath(QStringLiteral(PIMDATAEXPORTER_DIR "/export/test1"));
compareExportFile.compareFiles();
}
......
......@@ -22,6 +22,7 @@
#include "loadlistfromfile.h"
#include <QTest>
#include <QDebug>
#include <QProcess>
CompareExportFile::CompareExportFile()
{
......@@ -37,15 +38,34 @@ void CompareExportFile::compareFiles()
GenerateListFileFromArchive archive(mTempFilePath);
//qDebug() << " archive " << archive.listFile();
LoadListFromFile f(mListFilePath);
const bool equal = (f.fileList() == archive.listFile());
LoadListFromFile f(mListFilePath + QStringLiteral("/list.txt"));
const QStringList archiveList = archive.listFile();
const bool equal = (f.fileList() == archiveList);
if (!equal) {
qDebug() << "Requested : " << f.fileList();
qDebug() << "List File : " << archive.listFile();
qDebug() << "List File : " << archiveList;
}
QVERIFY(equal);
for (const QString &file : archiveList) {
qDebug() << " file " << file;
}
//TODO compare files
}
void CompareExportFile::compareFile(const QString &referenceFile, const QString &archiveFile)
{
QProcess proc;
const QStringList args = QStringList()
<< QStringLiteral("-u")
<< referenceFile
<< archiveFile;
proc.setProcessChannelMode(QProcess::ForwardedChannels);
proc.start(QStringLiteral("diff"), args);
QVERIFY(proc.waitForFinished());
QCOMPARE(proc.exitCode(), 0);
}
QString CompareExportFile::tempFilePath() const
{
return mTempFilePath;
......
......@@ -36,6 +36,7 @@ public:
void setListFilePath(const QString &listFilePath);
private:
void compareFile(const QString &referenceFile, const QString &archiveFile);
QString mTempFilePath;
QString mListFilePath;
};
......
......@@ -20,6 +20,9 @@
#include "compareimportfile.h"
#include <QProcess>
#include <QTest>
CompareImportFile::CompareImportFile()
{
......@@ -30,6 +33,19 @@ CompareImportFile::~CompareImportFile()
}
void CompareImportFile::compareFile()
{
QProcess proc;
const QStringList args = QStringList()
<< QStringLiteral("-u")
<< mReferenceFilePath
<< mTempFilePath;
proc.setProcessChannelMode(QProcess::ForwardedChannels);
proc.start(QStringLiteral("diff"), args);
QVERIFY(proc.waitForFinished());
QCOMPARE(proc.exitCode(), 0);
}
QString CompareImportFile::tempFilePath() const
{
return mTempFilePath;
......@@ -39,3 +55,13 @@ void CompareImportFile::setTempFilePath(const QString &tempFilePath)
{
mTempFilePath = tempFilePath;
}
QString CompareImportFile::referenceFilePath() const
{
return mReferenceFilePath;
}
void CompareImportFile::setReferenceFilePath(const QString &referenceFilePath)
{
mReferenceFilePath = referenceFilePath;
}
......@@ -29,11 +29,17 @@ public:
CompareImportFile();
~CompareImportFile();
void compareFile();
Q_REQUIRED_RESULT QString tempFilePath() const;
void setTempFilePath(const QString &tempFilePath);
Q_REQUIRED_RESULT QString referenceFilePath() const;
void setReferenceFilePath(const QString &referenceFilePath);
private:
QString mTempFilePath;
QString mReferenceFilePath;
};
#endif // COMPAREIMPORTFILE_H
......@@ -37,6 +37,7 @@ GenerateListFileFromArchive::~GenerateListFileFromArchive()
void GenerateListFileFromArchive::generateList()
{
mZip = new KZip(mFileName);
qDebug() << " mFileName" << mFileName;
bool result = mZip->open(QIODevice::ReadOnly);
QVERIFY(result);
const KArchiveDirectory *topDirectory = mZip->directory();
......
......@@ -96,6 +96,6 @@ void ExportMailJobInterfaceTest::exportMailConfigTest1()
CompareExportFile compareExportFile;
compareExportFile.setTempFilePath(temporaryFile);
compareExportFile.setListFilePath(QStringLiteral(PIMDATAEXPORTER_DIR "/export/test1/list.txt"));
compareExportFile.setListFilePath(QStringLiteral(PIMDATAEXPORTER_DIR "/export/test1"));
compareExportFile.compareFiles();
}
[Network]
KnownHosts=199.168.1.13
NoteHostDialogSize=596,334
Port=12
SenderID=VV
[SelectNoteFolder]
DefaultFolder=31
[$Version]
update_info=noteglobalsettings.upd:initial-noteagent-migration,noteglobalsettings.upd:selectcollection-noteagent-migration
[AgentTypeDialog]
Size=979,637
[Display]
width=260
[DownloadDialog Settings]
Height 1080=522
Width 1920=700
[Editor]
titlefont=Liberation Sans,12,-1,5,50,0,0,0,0,0,Regular
[KFileDialog Settings]
Height 1080=540
Width 1920=960
[KNoteDeleteSelectedNotesDialog]
Size=300,200
[KNoteFindDialog]
Size=461,270
[KNotePrintSelectedNotesDialog]
Size=960,656
[KNoteSimpleConfigDialog]
Size=600,400
[KNotesKeyDialog]
Size=1120,685
[KPimPrintPreviewDialog]
Size=1054,732
[Migratekde4]
Version=1
[Misc]
SystemTrayShowNotes=true
[SelectedNotefolderDialog]
Size=600,400
......@@ -79,7 +79,7 @@ void ExportNotesJobInterfaceTest::exportNoteConfigTest1()
CompareExportFile compareExportFile;
compareExportFile.setTempFilePath(temporaryFile);
compareExportFile.setListFilePath(QStringLiteral(PIMDATAEXPORTER_DIR "/export/test1/list.txt"));
compareExportFile.setListFilePath(QStringLiteral(PIMDATAEXPORTER_DIR "/export/test1"));
compareExportFile.compareFiles();
}
......
......@@ -51,7 +51,7 @@ void ImportNotesJobInterfaceTest::importNoteConfigTest1()
{
//Don't use setTestModeEnabled otherwise we can set env
//QStandardPaths::setTestModeEnabled(true);
//TODO use specific path !
qputenv("XDG_DATA_HOME", PIMDATAEXPORTER_DIR "/test1/share");
qputenv("XDG_CONFIG_HOME", PIMDATAEXPORTER_DIR "/test1/config");
......
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