aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml
diff options
context:
space:
mode:
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();