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

Add autotest

parent c18ba121
......@@ -238,6 +238,7 @@ if (BUILD_TESTING)
add_subdirectory(texttospeech/tests)
add_subdirectory(composer-ng/autotests)
add_subdirectory(composer-ng/tests)
add_subdirectory(grantleebuilder/autotests)
endif()
if(BUILD_DESIGNERPLUGIN)
......
ecm_add_tests(texthtmlbuildertest.cpp
NAME_PREFIX "kpimtextedit-grantleebuilder-"
LINK_LIBRARIES KF5::PimTextEdit Qt5::Test Qt5::Widgets Grantlee5::TextDocument
)
/*
Copyright (C) 2020 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 "texthtmlbuildertest.h"
#include "grantleebuilder/texthtmlbuilder.h"
#include <QRegularExpression>
#include <QTest>
#include <QTextDocument>
#include <grantlee/markupdirector.h>
QTEST_MAIN(TextHTMLBuilderTest)
TextHTMLBuilderTest::TextHTMLBuilderTest(QObject *parent)
: QObject(parent)
{
}
void TextHTMLBuilderTest::testHtmlText()
{
auto doc = new QTextDocument();
doc->setHtml(
QStringLiteral("A <a href=\"http://www.kde.org\">link</a> to KDE."));
auto hb = new KPIMTextEdit::TextHTMLBuilder();
auto md = new Grantlee::MarkupDirector(hb);
md->processDocument(doc);
auto result = hb->getResult();
const QRegularExpression regex(QStringLiteral(
"^<p>A <a href=\"http://www.kde.org\">link</a> to KDE.</p>\\n$"));
QVERIFY(regex.match(result).hasMatch());
delete md;
delete hb;
delete doc;
}
/*
Copyright (C) 2020 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 TEXTHTMLBUILDERTEST_H
#define TEXTHTMLBUILDERTEST_H
#include <QObject>
class TextHTMLBuilderTest : public QObject
{
Q_OBJECT
public:
explicit TextHTMLBuilderTest(QObject *parent = nullptr);
~TextHTMLBuilderTest() = default;
private Q_SLOTS:
void testHtmlText();
};
#endif // TEXTHTMLBUILDERTEST_H
......@@ -45,7 +45,10 @@ TextHTMLBuilder::TextHTMLBuilder()
{
}
TextHTMLBuilder::~TextHTMLBuilder() { delete d_ptr; }
TextHTMLBuilder::~TextHTMLBuilder()
{
delete d_ptr;
}
void TextHTMLBuilder::beginStrong()
{
......
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