summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authormae <qt-info@nokia.com>2009-06-08 10:35:20 (GMT)
committermae <qt-info@nokia.com>2009-06-08 10:45:19 (GMT)
commitfded22680a728ecba93feb87733785537c234b02 (patch)
treed25d199c3446eb0c39ea80a7728f78eb6415df09 /tests/auto
parentb5579e01a023800a6fd81193209db00e000a3620 (diff)
downloadQt-fded22680a728ecba93feb87733785537c234b02.zip
Qt-fded22680a728ecba93feb87733785537c234b02.tar.gz
Qt-fded22680a728ecba93feb87733785537c234b02.tar.bz2
Extend auto test to cover the emission order of the contentChange() and
cursorPositionChanged() singals of QTextDocument. The contentChange() signal is used for the syntax highlighter.
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qtextdocument/tst_qtextdocument.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/qtextdocument/tst_qtextdocument.cpp b/tests/auto/qtextdocument/tst_qtextdocument.cpp
index 63a172b..27be372 100644
--- a/tests/auto/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/qtextdocument/tst_qtextdocument.cpp
@@ -163,6 +163,8 @@ private slots:
void testUndoBlocks();
+ void receiveCursorPositionChangedAfterContentsChange();
+
private:
void backgroundImage_checkExpectedHtml(const QTextDocument &doc);
@@ -2453,5 +2455,35 @@ void tst_QTextDocument::testUndoBlocks()
QCOMPARE(doc->toPlainText(), QString(""));
}
+class Receiver : public QObject
+{
+ Q_OBJECT
+ public:
+ QString first;
+ public slots:
+ void cursorPositionChanged() {
+ if (first.isEmpty())
+ first = QLatin1String("cursorPositionChanged");
+ }
+
+ void contentsChange() {
+ if (first.isEmpty())
+ first = QLatin1String("contentsChanged");
+ }
+};
+
+void tst_QTextDocument::receiveCursorPositionChangedAfterContentsChange()
+{
+ QVERIFY(doc);
+ doc->setDocumentLayout(new MyAbstractTextDocumentLayout(doc));
+ Receiver rec;
+ connect(doc, SIGNAL(cursorPositionChanged(QTextCursor)),
+ &rec, SLOT(cursorPositionChanged()));
+ connect(doc, SIGNAL(contentsChange(int,int,int)),
+ &rec, SLOT(contentsChange()));
+ cursor.insertText("Hello World");
+ QCOMPARE(rec.first, QString("contentsChanged"));
+}
+
QTEST_MAIN(tst_QTextDocument)
#include "tst_qtextdocument.moc"