summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@gmail.com>2009-07-13 09:03:42 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-07-13 09:03:42 (GMT)
commit9a46bc5f02866134fb66ff1a03863d09382f7d40 (patch)
treeb25823b11f082907cb0a47fa8719439795d944b5
parente8e6e8c1722618a48cb4a2e46b24ecad4b056270 (diff)
downloadQt-9a46bc5f02866134fb66ff1a03863d09382f7d40.zip
Qt-9a46bc5f02866134fb66ff1a03863d09382f7d40.tar.gz
Qt-9a46bc5f02866134fb66ff1a03863d09382f7d40.tar.bz2
Added QSyntaxHighlighter::rehighlightBlock() auto test
Merge-request: 379 Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com>
-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 22e9455..1699e72 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"