summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-05-22 07:44:45 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2014-05-22 07:46:17 +0200
commit508b95899d4764d879a01b3990e44ce849cd9abc (patch)
tree3dbb215480c98ee75b5aacc5e3d691e04d8ce8c8 /tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
parentf2891be00808c82f5069661d60d8727fe28774b7 (diff)
parent5d2939344eb8fbd3c2115f52a7a8d47365bdf820 (diff)
Merge remote-tracking branch 'origin/stable' into dev
Diffstat (limited to 'tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp')
-rw-r--r--tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
index 61eb390fd3..c47f7b1ff6 100644
--- a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
+++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
@@ -154,6 +154,7 @@ private slots:
void findBackwardWithRegExp();
void findWithRegExpReturnsFalseIfNoMoreResults();
#endif
+ void layoutAfterMultiLineRemove();
private:
void createSelection();
@@ -1567,5 +1568,49 @@ void tst_QPlainTextEdit::findWithRegExpReturnsFalseIfNoMoreResults()
}
#endif
+void tst_QPlainTextEdit::layoutAfterMultiLineRemove()
+{
+ ed->setVisible(true); // The widget must be visible to reproduce this bug.
+
+ QString contents;
+ for (int i = 0; i < 5; ++i)
+ contents.append("\ttest\n");
+
+ ed->setPlainText(contents);
+
+ /*
+ * Remove the tab from the beginning of lines 2-4, in an edit block. The
+ * edit block is required for the bug to be reproduced.
+ */
+
+ QTextCursor curs = ed->textCursor();
+ curs.movePosition(QTextCursor::Start);
+ curs.movePosition(QTextCursor::NextBlock);
+
+ curs.beginEditBlock();
+ for (int i = 0; i < 3; ++i) {
+ curs.deleteChar();
+ curs.movePosition(QTextCursor::NextBlock);
+ }
+ curs.endEditBlock();
+
+ /*
+ * Now, we're going to perform the following actions:
+ *
+ * - Move to the beginning of the document.
+ * - Move down three times - this should put us at the front of block 3.
+ * - Move to the end of the line.
+ *
+ * At this point, if the document layout is behaving correctly, we should
+ * still be positioned on block 3. Verify that this is the case.
+ */
+
+ curs.movePosition(QTextCursor::Start);
+ curs.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, 3);
+ curs.movePosition(QTextCursor::EndOfLine);
+
+ QCOMPARE(curs.blockNumber(), 3);
+}
+
QTEST_MAIN(tst_QPlainTextEdit)
#include "tst_qplaintextedit.moc"