Commit 43a37241 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Implement export mail autotest

parent 5570bdf5
......@@ -17,3 +17,4 @@ add_subdirectory(calendar)
add_subdirectory(addressbook)
add_subdirectory(alarm)
add_subdirectory(akregator)
add_subdirectory(mail)
add_definitions( -DPIMDATAEXPORTER_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data" )
set( exportmailjobinterfacetest_SRCS exportmailjobinterfacetest.cpp ../resourceconvertertest.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)
/*
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 "exportmailjobinterfacetest.h"
#include "archivestorage.h"
#include "../resourceconvertertest.h"
#include <QDebug>
#include <QTest>
#include <QSignalSpy>
QTEST_MAIN(ExportMailJobInterfaceTest)
ExportMailJobInterfaceTestImpl::ExportMailJobInterfaceTestImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep)
: ExportMailJobInterface(parent, typeSelected, archiveStorage, numberOfStep)
{
}
ExportMailJobInterfaceTestImpl::~ExportMailJobInterfaceTestImpl()
{
}
void ExportMailJobInterfaceTestImpl::exportArchiveResource()
{
qDebug() << " not implement yet";
}
void ExportMailJobInterfaceTestImpl::convertCollectionToRealPath(KConfigGroup &group, const QString &currentKey)
{
ResourceConverterTest resourceConverter;
resourceConverter.convertCollectionToRealPath(group, currentKey);
}
void ExportMailJobInterfaceTestImpl::convertCollectionListToRealPath(KConfigGroup &group, const QString &currentKey)
{
ResourceConverterTest resourceConverter;
resourceConverter.convertCollectionListToRealPath(group, currentKey);
}
void ExportMailJobInterfaceTestImpl::convertCollectionIdsToRealPath(KConfigGroup &group, const QString &currentKey, const QString &prefixCollection)
{
ResourceConverterTest resourceConverter;
resourceConverter.convertCollectionIdsToRealPath(group, currentKey, prefixCollection);
}
void ExportMailJobInterfaceTestImpl::backupResources()
{
qDebug() << " not implement yet";
}
ExportMailJobInterfaceTest::ExportMailJobInterfaceTest(QObject *parent)
: QObject(parent)
{
}
void ExportMailJobInterfaceTest::exportMailConfigTest1()
{
//Don't use setTestModeEnabled otherwise we can set env
//QStandardPaths::setTestModeEnabled(true);
qputenv("XDG_DATA_HOME", PIMDATAEXPORTER_DIR "/test1/share");
qputenv("XDG_CONFIG_HOME", PIMDATAEXPORTER_DIR "/test1/config");
//TODO fix file name.
const QString storeArchivePath(QStringLiteral("/tmp/foo.zip"));
ArchiveStorage *archiveStorage = new ArchiveStorage(storeArchivePath, this);
Q_ASSERT(archiveStorage->openArchive(true));
Utils::addVersion(archiveStorage->archive());
Utils::storeDataExportInfo(storeArchivePath, archiveStorage->archive());
ExportMailJobInterfaceTestImpl *exportNote = new ExportMailJobInterfaceTestImpl(this, {Utils::StoredType::Config}, archiveStorage, 1);
QSignalSpy finish(exportNote, &ExportMailJobInterfaceTestImpl::jobFinished);
QSignalSpy error(exportNote, &ExportMailJobInterfaceTestImpl::error);
exportNote->start();
QVERIFY(finish.wait());
QCOMPARE(error.count(), 0);
delete exportNote;
delete archiveStorage;
}
/*
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 EXPORTMAILJOBINTERFACETEST_H
#define EXPORTMAILJOBINTERFACETEST_H
#include <QObject>
#include "mail/exportmailjobinterface.h"
class ExportMailJobInterfaceTestImpl : public ExportMailJobInterface
{
Q_OBJECT
public:
explicit ExportMailJobInterfaceTestImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep);
~ExportMailJobInterfaceTestImpl();
protected:
void exportArchiveResource() override;
protected:
void convertCollectionToRealPath(KConfigGroup &group, const QString &currentKey) override;
void convertCollectionListToRealPath(KConfigGroup &group, const QString &currentKey) override;
void convertCollectionIdsToRealPath(KConfigGroup &group, const QString &currentKey, const QString &prefixCollection) override;
void backupResources() override;
};
class ExportMailJobInterfaceTest : public QObject
{
Q_OBJECT
public:
explicit ExportMailJobInterfaceTest(QObject *parent = nullptr);
~ExportMailJobInterfaceTest() = default;
private Q_SLOTS:
void exportMailConfigTest1();
};
#endif // EXPORTMAILJOBINTERFACETEST_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