summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtextcursor/tst_qtextcursor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qtextcursor/tst_qtextcursor.cpp')
-rw-r--r--tests/auto/qtextcursor/tst_qtextcursor.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/auto/qtextcursor/tst_qtextcursor.cpp b/tests/auto/qtextcursor/tst_qtextcursor.cpp
index 99babac..41835bb 100644
--- a/tests/auto/qtextcursor/tst_qtextcursor.cpp
+++ b/tests/auto/qtextcursor/tst_qtextcursor.cpp
@@ -151,6 +151,7 @@ private slots:
void cursorPositionWithBlockUndoAndRedo();
void cursorPositionWithBlockUndoAndRedo2();
+ void cursorPositionWithBlockUndoAndRedo3();
private:
int blockCount();
@@ -1756,9 +1757,9 @@ void tst_QTextCursor::adjustCursorsOnInsert()
void tst_QTextCursor::cursorPositionWithBlockUndoAndRedo()
{
cursor.insertText("AAAABBBBCCCCDDDD");
- cursor.beginEditBlock();
cursor.setPosition(12);
int cursorPositionBefore = cursor.position();
+ cursor.beginEditBlock();
cursor.insertText("*");
cursor.setPosition(8);
cursor.insertText("*");
@@ -1814,5 +1815,20 @@ void tst_QTextCursor::cursorPositionWithBlockUndoAndRedo2()
QCOMPARE(cursor.position(), cursorPositionBefore);
}
+void tst_QTextCursor::cursorPositionWithBlockUndoAndRedo3()
+{
+ // verify that it's the position of the beginEditBlock that counts, and not the last edit position
+ cursor.insertText("AAAABBBB");
+ int cursorPositionBefore = cursor.position();
+ cursor.beginEditBlock();
+ cursor.setPosition(4);
+ QVERIFY(cursor.position() != cursorPositionBefore);
+ cursor.insertText("*");
+ cursor.endEditBlock();
+ QCOMPARE(cursor.position(), 5);
+ doc->undo(&cursor);
+ QCOMPARE(cursor.position(), cursorPositionBefore);
+}
+
QTEST_MAIN(tst_QTextCursor)
#include "tst_qtextcursor.moc"