Auto test for passing QTextEdit as QSyntaxHighlighter parent
Change-Id: Ia225723de5b0b2085a72a2af26e2a563b65955d8 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
parent
468c22f673
commit
fd234c2fc6
@ -3,4 +3,5 @@ CONFIG += parallel_test
|
|||||||
TARGET = tst_qsyntaxhighlighter
|
TARGET = tst_qsyntaxhighlighter
|
||||||
SOURCES += tst_qsyntaxhighlighter.cpp
|
SOURCES += tst_qsyntaxhighlighter.cpp
|
||||||
QT += testlib
|
QT += testlib
|
||||||
|
!contains(QT_CONFIG, no-widgets) QT += widgets
|
||||||
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
|
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
|
||||||
|
@ -47,6 +47,10 @@
|
|||||||
#include <QAbstractTextDocumentLayout>
|
#include <QAbstractTextDocumentLayout>
|
||||||
#include <QSyntaxHighlighter>
|
#include <QSyntaxHighlighter>
|
||||||
|
|
||||||
|
#ifndef QT_NO_WIDGETS
|
||||||
|
#include <QTextEdit>
|
||||||
|
#endif
|
||||||
|
|
||||||
class QTestDocumentLayout : public QAbstractTextDocumentLayout
|
class QTestDocumentLayout : public QAbstractTextDocumentLayout
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -97,6 +101,9 @@ private slots:
|
|||||||
void noContentsChangedDuringHighlight();
|
void noContentsChangedDuringHighlight();
|
||||||
void rehighlight();
|
void rehighlight();
|
||||||
void rehighlightBlock();
|
void rehighlightBlock();
|
||||||
|
#ifndef QT_NO_WIDGETS
|
||||||
|
void textEditParent();
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTextDocument *doc;
|
QTextDocument *doc;
|
||||||
@ -123,6 +130,8 @@ class TestHighlighter : public QSyntaxHighlighter
|
|||||||
public:
|
public:
|
||||||
inline TestHighlighter(const QList<QTextLayout::FormatRange> &fmts, QTextDocument *parent)
|
inline TestHighlighter(const QList<QTextLayout::FormatRange> &fmts, QTextDocument *parent)
|
||||||
: QSyntaxHighlighter(parent), formats(fmts), highlighted(false), callCount(0) {}
|
: QSyntaxHighlighter(parent), formats(fmts), highlighted(false), callCount(0) {}
|
||||||
|
inline TestHighlighter(QObject *parent)
|
||||||
|
: QSyntaxHighlighter(parent) {}
|
||||||
inline TestHighlighter(QTextDocument *parent)
|
inline TestHighlighter(QTextDocument *parent)
|
||||||
: QSyntaxHighlighter(parent), highlighted(false), callCount(0) {}
|
: QSyntaxHighlighter(parent), highlighted(false), callCount(0) {}
|
||||||
|
|
||||||
@ -542,5 +551,14 @@ void tst_QSyntaxHighlighter::rehighlightBlock()
|
|||||||
QCOMPARE(hl->callCount, 1);
|
QCOMPARE(hl->callCount, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef QT_NO_WIDGETS
|
||||||
|
void tst_QSyntaxHighlighter::textEditParent()
|
||||||
|
{
|
||||||
|
QTextEdit textEdit;
|
||||||
|
TestHighlighter *hl = new TestHighlighter(&textEdit);
|
||||||
|
QCOMPARE(hl->document(), textEdit.document());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
QTEST_MAIN(tst_QSyntaxHighlighter)
|
QTEST_MAIN(tst_QSyntaxHighlighter)
|
||||||
#include "tst_qsyntaxhighlighter.moc"
|
#include "tst_qsyntaxhighlighter.moc"
|
||||||
|
Loading…
Reference in New Issue
Block a user