summaryrefslogtreecommitdiffstats
path: root/tests/auto/qplaintextedit
diff options
context:
space:
mode:
authormae <qt-info@nokia.com>2011-04-26 13:41:21 (GMT)
committermae <qt-info@nokia.com>2011-04-26 13:41:21 (GMT)
commit5d144faf3c524ab557b88f69c4b755e20237e846 (patch)
tree0b5ba98a9601db36c5f3513bc33ea5f4c30db016 /tests/auto/qplaintextedit
parentcc3bcc003048760a501debe49b6fcebffaac3cef (diff)
downloadQt-5d144faf3c524ab557b88f69c4b755e20237e846.zip
Qt-5d144faf3c524ab557b88f69c4b755e20237e846.tar.gz
Qt-5d144faf3c524ab557b88f69c4b755e20237e846.tar.bz2
Fix insert and scroll to bottom case
When using QtextCursor::insert() with a large text followed by setting the vertical scrollbar to its maximum value (scroll to bottom), QPlainTextEdit would not behave properly if a document size change was triggered by the insertion due to line wrapping. This was visible in Qt Creator. Auto test included. Reviewed-by: con
Diffstat (limited to 'tests/auto/qplaintextedit')
-rw-r--r--tests/auto/qplaintextedit/tst_qplaintextedit.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/qplaintextedit/tst_qplaintextedit.cpp
index d3e4fd0..8da5ba5 100644
--- a/tests/auto/qplaintextedit/tst_qplaintextedit.cpp
+++ b/tests/auto/qplaintextedit/tst_qplaintextedit.cpp
@@ -150,6 +150,7 @@ private slots:
void lineWrapProperty();
void selectionChanged();
void blockCountChanged();
+ void insertAndScrollToBottom();
private:
void createSelection();
@@ -1504,5 +1505,22 @@ void tst_QPlainTextEdit::blockCountChanged()
}
+void tst_QPlainTextEdit::insertAndScrollToBottom()
+{
+ ed->setPlainText("First Line");
+ ed->show();
+ QString text;
+ for(int i = 0; i < 2000; ++i) {
+ text += QLatin1String("this is another line of text to be appended. It is quite long and will probably wrap around, meaning the number of lines is larger than the number of blocks in the text.\n");
+ }
+ QTextCursor cursor = ed->textCursor();
+ cursor.beginEditBlock();
+ cursor.insertText(text);
+ cursor.endEditBlock();
+ ed->verticalScrollBar()->setValue(ed->verticalScrollBar()->maximum());
+ QCOMPARE(ed->verticalScrollBar()->value(), ed->verticalScrollBar()->maximum());
+}
+
+
QTEST_MAIN(tst_QPlainTextEdit)
#include "tst_qplaintextedit.moc"