aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2014-11-17 12:36:30 +0100
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2015-01-08 18:18:15 +0100
commit5fa4e1d0981cbe52392f474d0297678915bc48f5 (patch)
treee0e0fd647a9f0e78774a3028f50cf9ee56c12adf /tests
parent5cfe7d2074306a72909ea20718c1c4bebeb27bad (diff)
TextEdit: fix construction time text cache
QQuickTextEdit does not apply cached text to the underlying document until component construction is complete. However, if text() was called during the construction (eg. because of a binding), it would blindly overwrite the cached text with (still) empty document content. Task-number: QTBUG-41583 Change-Id: I6c5c1b6283d70d8a5ec2c8bd986095ee3c35a14c Reviewed-by: Pierre Rossi <pierre.rossi@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
index 4f10b4ce82..c61504ef99 100644
--- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -201,6 +201,7 @@ private slots:
void emptytags_QTBUG_22058();
void cursorRectangle_QTBUG_38947();
+ void textCached_QTBUG_41583();
private:
void simulateKeys(QWindow *window, const QList<Key> &keys);
@@ -5302,6 +5303,17 @@ void tst_qquicktextedit::cursorRectangle_QTBUG_38947()
QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, to);
}
+void tst_qquicktextedit::textCached_QTBUG_41583()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nTextEdit { property int margin: 10; text: \"TextEdit\"; textMargin: margin; property bool empty: !text; }", QUrl());
+ QQuickTextEdit *textedit = qobject_cast<QQuickTextEdit*>(component.create());
+ QVERIFY(textedit);
+ QCOMPARE(textedit->textMargin(), qreal(10.0));
+ QCOMPARE(textedit->text(), QString("TextEdit"));
+ QVERIFY(!textedit->property("empty").toBool());
+}
+
QTEST_MAIN(tst_qquicktextedit)
#include "tst_qquicktextedit.moc"