summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtextcursor/tst_qtextcursor.cpp
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-04-13 23:31:53 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-04-13 23:31:53 (GMT)
commit6ee86ddfcf5ff5fe0aadc835101c1e6f46b2a126 (patch)
treec7847f428c83592747b62cef82906d458bc136c9 /tests/auto/qtextcursor/tst_qtextcursor.cpp
parent9416f29a3ee7511c182eaa68f5523132ff64921d (diff)
parenta5e9e86a6daddde6fb906cbf09bf562e50b17698 (diff)
downloadQt-6ee86ddfcf5ff5fe0aadc835101c1e6f46b2a126.zip
Qt-6ee86ddfcf5ff5fe0aadc835101c1e6f46b2a126.tar.gz
Qt-6ee86ddfcf5ff5fe0aadc835101c1e6f46b2a126.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'tests/auto/qtextcursor/tst_qtextcursor.cpp')
-rw-r--r--tests/auto/qtextcursor/tst_qtextcursor.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/qtextcursor/tst_qtextcursor.cpp b/tests/auto/qtextcursor/tst_qtextcursor.cpp
index f55b8db..d44ce72 100644
--- a/tests/auto/qtextcursor/tst_qtextcursor.cpp
+++ b/tests/auto/qtextcursor/tst_qtextcursor.cpp
@@ -150,6 +150,7 @@ private slots:
void adjustCursorsOnInsert();
void cursorPositionWithBlockUndoAndRedo();
+ void cursorPositionWithBlockUndoAndRedo2();
private:
int blockCount();
@@ -1778,5 +1779,38 @@ void tst_QTextCursor::cursorPositionWithBlockUndoAndRedo()
QCOMPARE(cursor.position(), cursorPositionAfter);
}
+void tst_QTextCursor::cursorPositionWithBlockUndoAndRedo2()
+{
+ cursor.insertText("AAAABBBB");
+ int cursorPositionBefore = cursor.position();
+ cursor.setPosition(0, QTextCursor::KeepAnchor);
+ cursor.beginEditBlock();
+ cursor.removeSelectedText();
+ cursor.insertText("AAAABBBBCCCCDDDD");
+ cursor.endEditBlock();
+ doc->undo(&cursor);
+ QVERIFY(doc->toPlainText() == "AAAABBBB");
+ QCOMPARE(cursor.position(), cursorPositionBefore);
+
+ cursor.insertText("CCCC");
+ QVERIFY(doc->toPlainText() == "AAAABBBBCCCC");
+
+ cursorPositionBefore = cursor.position();
+ cursor.setPosition(0, QTextCursor::KeepAnchor);
+ cursor.beginEditBlock();
+ cursor.removeSelectedText();
+ cursor.insertText("AAAABBBBCCCCDDDD");
+ cursor.endEditBlock();
+
+ /* this undo now implicitely reinserts two segments, first "CCCCC", then
+ "AAAABBBB". The test ensures that the two are combined in order to
+ reconstruct the correct cursor position */
+ doc->undo(&cursor);
+
+
+ QVERIFY(doc->toPlainText() == "AAAABBBBCCCC");
+ QCOMPARE(cursor.position(), cursorPositionBefore);
+}
+
QTEST_MAIN(tst_QTextCursor)
#include "tst_qtextcursor.moc"