summaryrefslogtreecommitdiffstats
path: root/tests/auto/qsyntaxhighlighter
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qsyntaxhighlighter')
-rw-r--r--tests/auto/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/tests/auto/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp b/tests/auto/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp
index f8993de..3c2f683 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;
@@ -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"