Improve undosend support + add kmail_private_export.h for helping to

create autotestd
wilder
Laurent Montel 6 years ago
parent 18adfbbfa4
commit 3655f6b8ed
  1. 3
      CMakeLists.txt
  2. 2
      src/CMakeLists.txt
  3. 34
      src/kmail_private_export.h
  4. 10
      src/undosend/autotests/CMakeLists.txt
  5. 36
      src/undosend/autotests/undosendcomboboxtest.cpp
  6. 36
      src/undosend/autotests/undosendcomboboxtest.h
  7. 37
      src/undosend/autotests/undosendcreatejobtest.cpp
  8. 35
      src/undosend/autotests/undosendcreatejobtest.h
  9. 3
      src/undosend/undosendcombobox.h
  10. 82
      src/undosend/undosendcreatejob.cpp
  11. 49
      src/undosend/undosendcreatejob.h
  12. 3
      src/undosend/undosendmanager.cpp
  13. 2
      src/undosend/undosendmanager.h

@ -142,6 +142,9 @@ configure_file(config-enterprise.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-ente
include_directories(${kmail_SOURCE_DIR} ${kmail_BINARY_DIR})
configure_file(kmail-version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/kmail-version.h @ONLY)
if(BUILD_TESTING)
add_definitions(-DBUILD_TESTING)
endif()
if (EXISTS "${CMAKE_SOURCE_DIR}/.git")
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x060000)

@ -179,6 +179,7 @@ set(kmailprivate_undosend_LIB_SRCS
undosend/undosendcombobox.cpp
undosend/undosendinfowidget.cpp
undosend/undosendmanager.cpp
undosend/undosendcreatejob.cpp
)
set(kmail_common_SRCS)
@ -390,6 +391,7 @@ if(BUILD_TESTING)
add_subdirectory(editor/potentialphishingemail/autotests)
add_subdirectory(editor/warningwidgets/autotests)
add_subdirectory(sieveimapinterface/tests/)
add_subdirectory(undosend/autotests/)
endif()
########### install files ###############

@ -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

@ -21,8 +21,9 @@
#define UNDOSENDCOMBOBOX_H
#include <QComboBox>
#include "kmail_private_export.h"
class UndoSendCombobox : public QComboBox
class KMAILTESTS_TESTS_EXPORT UndoSendCombobox : public QComboBox
{
Q_OBJECT
public:

@ -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

@ -18,6 +18,7 @@
*/
#include "undosendmanager.h"
#include "undosendcreatejob.h"
UndoSendManager::UndoSendManager(QObject *parent)
: QObject(parent)
@ -39,7 +40,7 @@ void UndoSendManager::removeItem(qint64 index)
}
void UndoSendManager::addItem(qint64 index)
void UndoSendManager::addItem(qint64 index, const QString &subject, int delay)
{
//TODO
}

@ -31,7 +31,7 @@ public:
static UndoSendManager *self();
void removeItem(qint64 index);
void addItem(qint64 index);
void addItem(qint64 index, const QString &subject, int delay);
};
#endif // UNDOSENDMANAGER_H

Loading…
Cancel
Save