diff options
author | Matthew Vogt <matthew.vogt@nokia.com> | 2012-04-26 11:05:41 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-30 01:52:57 +0200 |
commit | 0e8af75e877d46cb656d03cf575804f2c17ec33f (patch) | |
tree | 6b3466202d1a62b7c5d7fb5aff904599ee8d3ca5 /tests/auto/qml/qqmlvaluetypes | |
parent | 1b48bb5602bd90dc78e1ff09207f682f6a43edd2 (diff) |
Ensure external value types are initialized before write
Ensure that the logic used when writing to a property having a value
type provided by an external module matches that used for properties
of internal value types.
Change-Id: I925b8b30a211ef813e2a51134411a162b0b146b5
Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmlvaluetypes')
-rw-r--r-- | tests/auto/qml/qqmlvaluetypes/data/initializeByWrite.qml | 27 | ||||
-rw-r--r-- | tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp | 12 |
2 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlvaluetypes/data/initializeByWrite.qml b/tests/auto/qml/qqmlvaluetypes/data/initializeByWrite.qml new file mode 100644 index 0000000000..8493dd4d7e --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/initializeByWrite.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +ListView { + property bool test: false + + width: 200 + height: 200 + model: 20 + + delegate: Text { + text: qsTr(props.titleText).arg(index) + color: props.titleColor + font.pointSize: props.titlePointSize + } + + property QtObject props: QtObject { + property string titleText: "List Item %1 Title" + property color titleColor: Qt.rgba(1, 0, 0, 0) + property int titlePointSize: 18 + } + + Component.onCompleted: { + test = (props.titleText == "List Item %1 Title") && + (props.titleColor == Qt.rgba(1, 0, 0, 0)) && + (props.titlePointSize == 18) + } +} diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp index 359653caa4..0c890dea74 100644 --- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp +++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp @@ -94,6 +94,7 @@ private slots: void varAssignment(); void bindingsSpliceCorrectly(); void nonValueTypeComparison(); + void initializeByWrite(); private: QQmlEngine engine; @@ -1334,6 +1335,17 @@ void tst_qqmlvaluetypes::nonValueTypeComparison() delete object; } +void tst_qqmlvaluetypes::initializeByWrite() +{ + QQmlComponent component(&engine, testFileUrl("initializeByWrite.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; +} + QTEST_MAIN(tst_qqmlvaluetypes) #include "tst_qqmlvaluetypes.moc" |