summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-12-07 10:58:01 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-12-07 10:58:01 (GMT)
commit0a4f8a73165da5ec274409dffa1de921421d9bb1 (patch)
treea9209a8d091da93155c6b01e1ecd093838ec72c6 /tests
parent47008b211fe3b972077466e593a2a9016446bab2 (diff)
parent599ffaef76eb92af2bbce6e5baff539958bfdd14 (diff)
downloadQt-0a4f8a73165da5ec274409dffa1de921421d9bb1.zip
Qt-0a4f8a73165da5ec274409dffa1de921421d9bb1.tar.gz
Qt-0a4f8a73165da5ec274409dffa1de921421d9bb1.tar.bz2
Merge remote branch 'staging/4.6' into 4.6
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qtextcursor/tst_qtextcursor.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/auto/qtextcursor/tst_qtextcursor.cpp b/tests/auto/qtextcursor/tst_qtextcursor.cpp
index d910c8d..d0c2afd 100644
--- a/tests/auto/qtextcursor/tst_qtextcursor.cpp
+++ b/tests/auto/qtextcursor/tst_qtextcursor.cpp
@@ -149,6 +149,8 @@ private slots:
void adjustCursorsOnInsert();
+ void cursorPositionWithBlockUndoAndRedo();
+
private:
int blockCount();
@@ -1747,9 +1749,33 @@ void tst_QTextCursor::adjustCursorsOnInsert()
QCOMPARE(selection.anchor(), posAfter);
doc->undo();
+}
+void tst_QTextCursor::cursorPositionWithBlockUndoAndRedo()
+{
+ cursor.insertText("AAAABBBBCCCCDDDD");
+ cursor.beginEditBlock();
+ cursor.setPosition(12);
+ int cursorPositionBefore = cursor.position();
+ cursor.insertText("*");
+ cursor.setPosition(8);
+ cursor.insertText("*");
+ cursor.setPosition(4);
+ cursor.insertText("*");
+ cursor.setPosition(0);
+ cursor.insertText("*");
+ int cursorPositionAfter = cursor.position();
+ cursor.endEditBlock();
+ QVERIFY(doc->toPlainText() == "*AAAA*BBBB*CCCC*DDDD");
+ QCOMPARE(12, cursorPositionBefore);
+ QCOMPARE(1, cursorPositionAfter);
-
+ doc->undo(&cursor);
+ QVERIFY(doc->toPlainText() == "AAAABBBBCCCCDDDD");
+ QCOMPARE(cursor.position(), cursorPositionBefore);
+ doc->redo(&cursor);
+ QVERIFY(doc->toPlainText() == "*AAAA*BBBB*CCCC*DDDD");
+ QCOMPARE(cursor.position(), cursorPositionAfter);
}
QTEST_MAIN(tst_QTextCursor)