Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 6991b397 authored by Laurent Montel's avatar Laurent Montel 😁

Add autotest

parent a2fa0f67
include(ECMAddTests)
ecm_add_tests( textutilstest.cpp editorutiltest.cpp NAME_PREFIX "kpimtextedit-" LINK_LIBRARIES Qt5::Test Qt5::Widgets KF5::Codecs KF5PimTextEdit KF5::IconThemes KF5::TextWidgets KF5::XmlGui)
ecm_add_tests( textutilstest.cpp editorutiltest.cpp emoticonlistwidgetselectortest.cpp NAME_PREFIX "kpimtextedit-" LINK_LIBRARIES Qt5::Test Qt5::Widgets KF5::Codecs KF5PimTextEdit KF5::IconThemes KF5::TextWidgets KF5::XmlGui)
ecm_add_test(slidecontainertest.cpp
TEST_NAME slidecontainertest
NAME_PREFIX kpimtextedit-widget
......
/*
Copyright (c) 2019 Montel Laurent <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.
*/
#include "emoticonlistwidgetselectortest.h"
#include "emoticon/emoticonlistwidgetselector.h"
#include <QTest>
QTEST_MAIN(EmoticonListWidgetSelectorTest)
EmoticonListWidgetSelectorTest::EmoticonListWidgetSelectorTest(QObject *parent)
: QObject(parent)
{
}
void EmoticonListWidgetSelectorTest::shouldHaveDefaultValues()
{
KPIMTextEdit::EmoticonListWidgetSelector w;
QCOMPARE(w.viewMode(), QListView::IconMode);
QCOMPARE(w.selectionMode(), QAbstractItemView::SingleSelection);
QVERIFY(!w.dragEnabled());
}
/*
Copyright (c) 2019 Montel Laurent <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 EMOTICONLISTWIDGETSELECTORTEST_H
#define EMOTICONLISTWIDGETSELECTORTEST_H
#include <QObject>
class EmoticonListWidgetSelectorTest : public QObject
{
Q_OBJECT
public:
explicit EmoticonListWidgetSelectorTest(QObject *parent = nullptr);
~EmoticonListWidgetSelectorTest() = default;
private Q_SLOTS:
void shouldHaveDefaultValues();
};
#endif // EMOTICONLISTWIDGETSELECTORTEST_H
......@@ -21,10 +21,11 @@
#define EMOTICONLISTWIDGETSELECTOR_H
#include <QListWidget>
#include "kpimtextedit_private_export.h"
namespace KPIMTextEdit {
class EmoticonTextEditItem : public QListWidgetItem
class KPIMTEXTEDIT_TESTS_EXPORT EmoticonTextEditItem : public QListWidgetItem
{
public:
explicit EmoticonTextEditItem(const QString &emoticonText, const QString &pixmapPath, QListWidget *parent);
......@@ -38,11 +39,11 @@ private:
};
class EmoticonListWidgetSelector : public QListWidget
class KPIMTEXTEDIT_TESTS_EXPORT EmoticonListWidgetSelector : public QListWidget
{
Q_OBJECT
public:
explicit EmoticonListWidgetSelector(QWidget *parent);
explicit EmoticonListWidgetSelector(QWidget *parent = nullptr);
~EmoticonListWidgetSelector();
Q_SIGNALS:
......
......@@ -17,3 +17,9 @@ target_link_libraries(slidecontainer_gui
add_executable(showemojiunicode_gui showemojiunicode_gui.cpp)
set(showemojiunicode_gui_LIBS KF5PimTextEdit Qt5::Widgets)
target_link_libraries(showemojiunicode_gui ${showemojiunicode_gui_LIBS})
add_executable(showemoticonlistwidgetselector_gui showemoticonlistwidgetselector_gui.cpp)
set(showemoticonlistwidgetselector_gui_LIBS KF5PimTextEdit Qt5::Widgets)
target_link_libraries(showemoticonlistwidgetselector_gui ${showemoticonlistwidgetselector_gui_LIBS})
/*
This file is part of KDE.
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.
*/
#include <QApplication>
#include <QWidget>
#include <QVBoxLayout>
#include <QTextEdit>
#include "textutils.h"
#include "emoticon/emoticonlistwidgetselector.h"
class Window : public QWidget
{
Q_OBJECT
public:
explicit Window(QWidget *parent = nullptr)
: QWidget(parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
KPIMTextEdit::EmoticonListWidgetSelector *w = new KPIMTextEdit::EmoticonListWidgetSelector(this);
mainLayout->addWidget(w);
const QList<uint> lstEmoji = KPIMTextEdit::TextUtils::unicodeFullEmoji();
for (uint emoji : lstEmoji) {
const QString str = QString::fromUcs4(&emoji, 1);
new KPIMTextEdit::EmoticonTextEditItem(str, w);
}
}
};
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Window window;
window.show();
return app.exec();
}
#include "showemoticonlistwidgetselector_gui.moc"
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