diff options
Diffstat (limited to 'tests/auto/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp')
-rw-r--r-- | tests/auto/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/tests/auto/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp b/tests/auto/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp index 3124211..4fae85e 100644 --- a/tests/auto/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp +++ b/tests/auto/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp @@ -99,7 +99,8 @@ private slots: void avoidUnnecessaryRehighlight(); void noContentsChangedDuringHighlight(); void rehighlight(); - + void rehighlightBlock(); + private: QTextDocument *doc; QTestDocumentLayout *lout; @@ -146,7 +147,7 @@ public: }; QT_BEGIN_NAMESPACE -static bool operator==(const QTextLayout::FormatRange &lhs, const QTextLayout::FormatRange &rhs) +bool operator==(const QTextLayout::FormatRange &lhs, const QTextLayout::FormatRange &rhs) { return lhs.start == rhs.start && lhs.length == rhs.length @@ -517,6 +518,32 @@ void tst_QSyntaxHighlighter::rehighlight() QCOMPARE(hl->callCount, 1); } +void tst_QSyntaxHighlighter::rehighlightBlock() +{ + TestHighlighter *hl = new TestHighlighter(doc); + + cursor.movePosition(QTextCursor::Start); + cursor.beginEditBlock(); + cursor.insertText("Hello"); + cursor.insertBlock(); + cursor.insertText("World"); + cursor.endEditBlock(); + + hl->callCount = 0; + hl->highlightedText.clear(); + QTextBlock block = doc->begin(); + hl->rehighlightBlock(block); + + QCOMPARE(hl->highlightedText, QString("Hello")); + QCOMPARE(hl->callCount, 1); + + hl->callCount = 0; + hl->highlightedText.clear(); + hl->rehighlightBlock(block.next()); + + QCOMPARE(hl->highlightedText, QString("World")); + QCOMPARE(hl->callCount, 1); +} QTEST_MAIN(tst_QSyntaxHighlighter) #include "tst_qsyntaxhighlighter.moc" |