aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml
diff options
context:
space:
mode:
authorMatthew Vogt <matthew.vogt@nokia.com>2012-03-27 14:58:19 +1000
committerQt by Nokia <qt-info@nokia.com>2012-03-28 04:35:52 +0200
commit4d3ccce54a5e58bab878170b1552acd0d4a20cec (patch)
tree102740e5a9bc144a5dd1c9e8fb2483e6ed2b6b25 /tests/auto/qml
parent0ad4550ac0946540f2c76008765d69c62adeed54 (diff)
Warn on incompatible v4 binding object type
For QObject-derived properties, verify that the type of the source object is convertible to the type of the target object, and report an error for incompatible assignment attempts. Task-number: QTBUG-24986 Change-Id: Ieece29a017222e48351cd433c1b2f9e2d93a5fd7 Reviewed-by: Chris Adams <christopher.adams@nokia.com> Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com> Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'tests/auto/qml')
-rw-r--r--tests/auto/qml/qqmlproperty/data/invalidBinding.qml14
-rw-r--r--tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp20
2 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlproperty/data/invalidBinding.qml b/tests/auto/qml/qqmlproperty/data/invalidBinding.qml
new file mode 100644
index 0000000000..58e83070ee
--- /dev/null
+++ b/tests/auto/qml/qqmlproperty/data/invalidBinding.qml
@@ -0,0 +1,14 @@
+import QtQuick 2.0
+
+Item {
+ property Text text: myText
+
+ property Rectangle rectangle1: myText
+ property Rectangle rectangle2: getMyText()
+
+ function getMyText() { return myText; }
+
+ Text {
+ id: myText
+ }
+}
diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
index 5ef8937dc1..2dde5f003d 100644
--- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
+++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
@@ -133,6 +133,7 @@ private slots:
void aliasPropertyBindings();
void noContext();
void assignEmptyVariantMap();
+ void warnOnInvalidBinding();
void copy();
private:
@@ -1708,6 +1709,25 @@ void tst_qqmlproperty::assignEmptyVariantMap()
delete obj;
}
+void tst_qqmlproperty::warnOnInvalidBinding()
+{
+ QUrl testUrl(testFileUrl("invalidBinding.qml"));
+ QString expectedWarning;
+
+ // V4 error message for property-to-property binding
+ expectedWarning = testUrl.toString() + QString::fromLatin1(":6:36: Unable to assign QQuickText to QQuickRectangle");
+ QTest::ignoreMessage(QtWarningMsg, expectedWarning.toLatin1().constData());
+
+ // V8 error message for function-to-property binding
+ expectedWarning = testUrl.toString() + QString::fromLatin1(":7:36: Unable to assign QQuickText to QQuickRectangle");
+ QTest::ignoreMessage(QtWarningMsg, expectedWarning.toLatin1().constData());
+
+ QQmlComponent component(&engine, testUrl);
+ QObject *obj = component.create();
+ QVERIFY(obj);
+ delete obj;
+}
+
void tst_qqmlproperty::initTestCase()
{
QQmlDataTest::initTestCase();