parent
18adfbbfa4
commit
3655f6b8ed
13 changed files with 329 additions and 3 deletions
@ -0,0 +1,34 @@ |
||||
/* This file is part of the KDE project
|
||||
Copyright (C) 2019 Laurent Montel <montel@kde.org> |
||||
|
||||
This library is free software; you can redistribute it and/or |
||||
modify it under the terms of the GNU Library General Public |
||||
License as published by the Free Software Foundation; either |
||||
version 2 of the License, or (at your option) any later version. |
||||
|
||||
This library 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 |
||||
Library General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU Library General Public License |
||||
along with this library; see the file COPYING.LIB. If not, write to |
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
||||
Boston, MA 02110-1301, USA. |
||||
*/ |
||||
|
||||
#ifndef KMAILPRIVATE_EXPORT_H |
||||
#define KMAILPRIVATE_EXPORT_H |
||||
|
||||
#include "kmail_export.h" |
||||
|
||||
/* Classes which are exported only for unit tests */ |
||||
#ifdef BUILD_TESTING |
||||
#ifndef KMAILTESTS_TESTS_EXPORT |
||||
#define KMAILTESTS_TESTS_EXPORT KMAIL_EXPORT |
||||
# endif |
||||
#else /* not compiling tests */ |
||||
#define KMAILTESTS_TESTS_EXPORT |
||||
#endif |
||||
|
||||
#endif |
||||
@ -0,0 +1,10 @@ |
||||
macro(add_kmail_undosend_unittest _source) |
||||
get_filename_component(_name ${_source} NAME_WE) |
||||
ecm_add_test(${_source} |
||||
TEST_NAME ${_name} |
||||
LINK_LIBRARIES kmailprivate Qt5::Test Qt5::Widgets |
||||
) |
||||
endmacro () |
||||
|
||||
add_kmail_undosend_unittest(undosendcomboboxtest.cpp) |
||||
add_kmail_undosend_unittest(undosendcreatejobtest.cpp) |
||||
@ -0,0 +1,36 @@ |
||||
/*
|
||||
Copyright (C) 2019 Montel Laurent <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 "undosendcomboboxtest.h" |
||||
#include "undosend/undosendcombobox.h" |
||||
#include <QTest> |
||||
QTEST_MAIN(UndoSendComboboxTest) |
||||
|
||||
UndoSendComboboxTest::UndoSendComboboxTest(QObject *parent) |
||||
: QObject(parent) |
||||
{ |
||||
|
||||
} |
||||
|
||||
void UndoSendComboboxTest::shouldHaveDefaultValues() |
||||
{ |
||||
UndoSendCombobox w; |
||||
QCOMPARE(w.count(), 5); |
||||
} |
||||
@ -0,0 +1,36 @@ |
||||
/*
|
||||
Copyright (C) 2019 Montel Laurent <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 UNDOSENDCOMBOBOXTEST_H |
||||
#define UNDOSENDCOMBOBOXTEST_H |
||||
|
||||
#include <QObject> |
||||
|
||||
class UndoSendComboboxTest : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
explicit UndoSendComboboxTest(QObject *parent = nullptr); |
||||
~UndoSendComboboxTest() = default; |
||||
private Q_SLOTS: |
||||
void shouldHaveDefaultValues(); |
||||
}; |
||||
|
||||
#endif // UNDOSENDCOMBOBOXTEST_H
|
||||
@ -0,0 +1,37 @@ |
||||
/*
|
||||
Copyright (C) 2019 Montel Laurent <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 "undosendcreatejobtest.h" |
||||
#include "undosend/undosendcreatejob.h" |
||||
#include <QTest> |
||||
QTEST_MAIN(UndoSendCreateJobTest) |
||||
|
||||
UndoSendCreateJobTest::UndoSendCreateJobTest(QObject *parent) |
||||
: QObject(parent) |
||||
{ |
||||
|
||||
} |
||||
|
||||
void UndoSendCreateJobTest::shouldHaveDefaultValues() |
||||
{ |
||||
UndoSendCreateJob job; |
||||
QCOMPARE(job.akonadiIndex(), -1); |
||||
QCOMPARE(job.delay(), -1); |
||||
QVERIFY(job.subject().isEmpty()); |
||||
} |
||||
@ -0,0 +1,35 @@ |
||||
/*
|
||||
Copyright (C) 2019 Montel Laurent <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 UNDOSENDCREATEJOBTEST_H |
||||
#define UNDOSENDCREATEJOBTEST_H |
||||
|
||||
#include <QObject> |
||||
|
||||
class UndoSendCreateJobTest : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
explicit UndoSendCreateJobTest(QObject *parent = nullptr); |
||||
~UndoSendCreateJobTest() = default; |
||||
private Q_SLOTS: |
||||
void shouldHaveDefaultValues(); |
||||
}; |
||||
|
||||
#endif // UNDOSENDCREATEJOBTEST_H
|
||||
@ -0,0 +1,82 @@ |
||||
/*
|
||||
Copyright (C) 2019 Montel Laurent <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 "undosendcreatejob.h" |
||||
#include "kmail_debug.h" |
||||
|
||||
UndoSendCreateJob::UndoSendCreateJob(QObject *parent) |
||||
: QObject(parent) |
||||
{ |
||||
|
||||
} |
||||
|
||||
UndoSendCreateJob::~UndoSendCreateJob() |
||||
{ |
||||
|
||||
} |
||||
|
||||
bool UndoSendCreateJob::canStart() const |
||||
{ |
||||
if (mAkonadiIndex < 0 || mDelay <= 0) { |
||||
return false; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
bool UndoSendCreateJob::start() |
||||
{ |
||||
if (!canStart()) { |
||||
qCWarning(KMAIL_LOG) << "Impossible to start undosendcreatejob"; |
||||
deleteLater(); |
||||
return false; |
||||
} |
||||
//TODO
|
||||
return true; |
||||
} |
||||
|
||||
QString UndoSendCreateJob::subject() const |
||||
{ |
||||
return mSubject; |
||||
} |
||||
|
||||
void UndoSendCreateJob::setSubject(const QString &subject) |
||||
{ |
||||
mSubject = subject; |
||||
} |
||||
|
||||
int UndoSendCreateJob::delay() const |
||||
{ |
||||
return mDelay; |
||||
} |
||||
|
||||
void UndoSendCreateJob::setDelay(int delay) |
||||
{ |
||||
mDelay = delay; |
||||
} |
||||
|
||||
qint64 UndoSendCreateJob::akonadiIndex() const |
||||
{ |
||||
return mAkonadiIndex; |
||||
} |
||||
|
||||
void UndoSendCreateJob::setAkonadiIndex(const qint64 &akonadiIndex) |
||||
{ |
||||
mAkonadiIndex = akonadiIndex; |
||||
} |
||||
@ -0,0 +1,49 @@ |
||||
/*
|
||||
Copyright (C) 2019 Montel Laurent <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 UNDOSENDCREATEJOB_H |
||||
#define UNDOSENDCREATEJOB_H |
||||
|
||||
#include <QObject> |
||||
#include "kmail_private_export.h" |
||||
class KMAILTESTS_TESTS_EXPORT UndoSendCreateJob : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
explicit UndoSendCreateJob(QObject *parent = nullptr); |
||||
~UndoSendCreateJob(); |
||||
Q_REQUIRED_RESULT bool canStart() const; |
||||
Q_REQUIRED_RESULT bool start(); |
||||
|
||||
Q_REQUIRED_RESULT QString subject() const; |
||||
void setSubject(const QString &subject); |
||||
|
||||
Q_REQUIRED_RESULT int delay() const; |
||||
void setDelay(int delay); |
||||
|
||||
Q_REQUIRED_RESULT qint64 akonadiIndex() const; |
||||
void setAkonadiIndex(const qint64 &akonadiIndex); |
||||
|
||||
private: |
||||
QString mSubject; |
||||
qint64 mAkonadiIndex = -1; |
||||
int mDelay = -1; |
||||
}; |
||||
|
||||
#endif // UNDOSENDCREATEJOB_H
|
||||
Loading…
Reference in new issue