Commit e34fbebd authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add emoticontexteditselectortest

parent b52a9ac6
......@@ -251,6 +251,10 @@ endif()
ecm_qt_install_logging_categories(EXPORT KPIMTEXTEDIT FILE kpimtextedit.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR})
if(BUILD_TESTING)
add_subdirectory(emoticon/autotests)
endif()
if (BUILD_QCH)
ecm_add_qch(
KF5PimTextEdit_QCH
......
# Convenience macro to add unit tests.
macro( emoticontest _source )
set( _test ${_source} )
get_filename_component( _name ${_source} NAME_WE )
add_executable( ${_name} ${_test} )
add_test(NAME ${_name} COMMAND ${_name} )
ecm_mark_as_test(kpimtextedit-${_name})
target_link_libraries( ${_name} Qt::Test Qt::Widgets KF5::Codecs KF5PimTextEdit)
endmacro()
emoticontest(emoticontexteditselectortest.cpp)
/*
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "emoticontexteditselectortest.h"
#include "emoticon/emoticontexteditselector.h"
#include "emoticon/emoticonunicodetab.h"
#include <QHBoxLayout>
#include <QTest>
QTEST_MAIN(EmoticonTextEditSelectorTest)
EmoticonTextEditSelectorTest::EmoticonTextEditSelectorTest(QObject *parent)
: QObject(parent)
{
}
void EmoticonTextEditSelectorTest::shouldHaveDefaultValues()
{
KPIMTextEdit::EmoticonTextEditSelector w;
auto mainLayout = w.findChild<QHBoxLayout *>(QStringLiteral("mainLayout"));
QVERIFY(mainLayout);
QCOMPARE(mainLayout->contentsMargins(), {});
auto mUnicodeTab = w.findChild<KPIMTextEdit::EmoticonUnicodeTab *>(QStringLiteral("mUnicodeTab"));
QVERIFY(mUnicodeTab);
}
/*
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#pragma once
#include <QObject>
class EmoticonTextEditSelectorTest : public QObject
{
Q_OBJECT
public:
explicit EmoticonTextEditSelectorTest(QObject *parent = nullptr);
~EmoticonTextEditSelectorTest() override = default;
private Q_SLOTS:
void shouldHaveDefaultValues();
};
......@@ -15,12 +15,14 @@ using namespace KPIMTextEdit;
EmoticonTextEditSelector::EmoticonTextEditSelector(QWidget *parent)
: QWidget(parent)
, mUnicodeTab(new EmoticonUnicodeTab(this))
{
auto lay = new QHBoxLayout(this);
lay->setSpacing(0);
lay->setContentsMargins({});
mUnicodeTab = new EmoticonUnicodeTab(this);
lay->addWidget(mUnicodeTab);
auto mainLayout = new QHBoxLayout(this);
mainLayout->setObjectName(QStringLiteral("mainLayout"));
mainLayout->setSpacing(0);
mainLayout->setContentsMargins({});
mainLayout->addWidget(mUnicodeTab);
mUnicodeTab->setObjectName(QStringLiteral("mUnicodeTab"));
connect(mUnicodeTab, &EmoticonUnicodeTab::itemSelected, this, &EmoticonTextEditSelector::slotItemSelected);
}
......
......@@ -7,11 +7,12 @@
#pragma once
#include "kpimtextedit_private_export.h"
#include <QWidget>
namespace KPIMTextEdit
{
class EmoticonUnicodeTab;
class EmoticonTextEditSelector : public QWidget
class KPIMTEXTEDIT_TESTS_EXPORT EmoticonTextEditSelector : public QWidget
{
Q_OBJECT
public:
......@@ -26,7 +27,7 @@ Q_SIGNALS:
private:
void slotItemSelected(const QString &str);
EmoticonUnicodeTab *mUnicodeTab = nullptr;
EmoticonUnicodeTab *const mUnicodeTab;
};
}
Supports Markdown
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