aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp')
-rw-r--r--tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp40
1 files changed, 29 insertions, 11 deletions
diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
index 86c13065fa..3fed0fac7b 100644
--- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
+++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
@@ -140,6 +140,7 @@ private slots:
// Bugs
void crashOnValueProperty();
+ void aliasPropertyBindings_data();
void aliasPropertyBindings();
void noContext();
void assignEmptyVariantMap();
@@ -1823,23 +1824,40 @@ void tst_qqmlproperty::crashOnValueProperty()
QCOMPARE(p.read(), QVariant(20));
}
-// QTBUG-13719
+void tst_qqmlproperty::aliasPropertyBindings_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("subObject");
+
+ QTest::newRow("same object") << "aliasPropertyBindings.qml" << "";
+ QTest::newRow("different objects") << "aliasPropertyBindings2.qml" << "innerObject";
+}
+
+// QTBUG-13719, QTBUG-58271
void tst_qqmlproperty::aliasPropertyBindings()
{
- QQmlComponent component(&engine, testFileUrl("aliasPropertyBindings.qml"));
+ QFETCH(QString, file);
+ QFETCH(QString, subObject);
+
+ QQmlComponent component(&engine, testFileUrl(file));
QObject *object = component.create();
QVERIFY(object != 0);
- QCOMPARE(object->property("realProperty").toReal(), 90.);
+ // the object where realProperty lives
+ QObject *realPropertyObject = object;
+ if (!subObject.isEmpty())
+ realPropertyObject = object->property(subObject.toLatin1()).value<QObject*>();
+
+ QCOMPARE(realPropertyObject->property("realProperty").toReal(), 90.);
QCOMPARE(object->property("aliasProperty").toReal(), 90.);
object->setProperty("test", 10);
- QCOMPARE(object->property("realProperty").toReal(), 110.);
+ QCOMPARE(realPropertyObject->property("realProperty").toReal(), 110.);
QCOMPARE(object->property("aliasProperty").toReal(), 110.);
- QQmlProperty realProperty(object, QLatin1String("realProperty"));
+ QQmlProperty realProperty(realPropertyObject, QLatin1String("realProperty"));
QQmlProperty aliasProperty(object, QLatin1String("aliasProperty"));
// Check there is a binding on these two properties
@@ -1858,18 +1876,18 @@ void tst_qqmlproperty::aliasPropertyBindings()
QCOMPARE(QQmlPropertyPrivate::binding(realProperty),
QQmlPropertyPrivate::binding(aliasProperty));
- QCOMPARE(object->property("realProperty").toReal(), 96.);
+ QCOMPARE(realPropertyObject->property("realProperty").toReal(), 96.);
QCOMPARE(object->property("aliasProperty").toReal(), 96.);
// Check the old binding really has not effect any more
object->setProperty("test", 4);
- QCOMPARE(object->property("realProperty").toReal(), 96.);
+ QCOMPARE(realPropertyObject->property("realProperty").toReal(), 96.);
QCOMPARE(object->property("aliasProperty").toReal(), 96.);
object->setProperty("test2", 9);
- QCOMPARE(object->property("realProperty").toReal(), 288.);
+ QCOMPARE(realPropertyObject->property("realProperty").toReal(), 288.);
QCOMPARE(object->property("aliasProperty").toReal(), 288.);
// Revert
@@ -1880,12 +1898,12 @@ void tst_qqmlproperty::aliasPropertyBindings()
QCOMPARE(QQmlPropertyPrivate::binding(realProperty),
QQmlPropertyPrivate::binding(aliasProperty));
- QCOMPARE(object->property("realProperty").toReal(), 20.);
+ QCOMPARE(realPropertyObject->property("realProperty").toReal(), 20.);
QCOMPARE(object->property("aliasProperty").toReal(), 20.);
object->setProperty("test2", 3);
- QCOMPARE(object->property("realProperty").toReal(), 20.);
+ QCOMPARE(realPropertyObject->property("realProperty").toReal(), 20.);
QCOMPARE(object->property("aliasProperty").toReal(), 20.);
delete object;
@@ -1986,7 +2004,7 @@ void tst_qqmlproperty::warnOnInvalidBinding()
QTest::ignoreMessage(QtWarningMsg, expectedWarning.toLatin1().constData());
// V8 error message for invalid binding to anchor
- expectedWarning = testUrl.toString() + QString::fromLatin1(":14:33: Unable to assign QQuickItem_QML_6 to QQuickAnchorLine");
+ expectedWarning = testUrl.toString() + QString::fromLatin1(":14:33: Unable to assign QQuickItem_QML_8 to QQuickAnchorLine");
QTest::ignoreMessage(QtWarningMsg, expectedWarning.toLatin1().constData());
QQmlComponent component(&engine, testUrl);