aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp')
-rw-r--r--tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp
index 64e32dcdfd..3b46019f64 100644
--- a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp
+++ b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp
@@ -75,6 +75,7 @@ private slots:
void innerBehaviorOverwritten();
void oneWay();
void safeToDelete();
+ void targetProperty();
};
void tst_qquickbehaviors::simpleBehavior()
@@ -656,6 +657,27 @@ void tst_qquickbehaviors::safeToDelete()
QVERIFY(c.create());
}
+Q_DECLARE_METATYPE(QQmlProperty)
+void tst_qquickbehaviors::targetProperty()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("targetProperty.qml"));
+ QScopedPointer<QQuickItem> item(qobject_cast<QQuickItem*>(c.create()));
+ QVERIFY2(!item.isNull(), qPrintable(c.errorString()));
+
+ QQuickBehavior* xBehavior =
+ qobject_cast<QQuickBehavior*>(item->findChild<QQuickBehavior*>("xBehavior"));
+ QCOMPARE(xBehavior->property("targetProperty").value<QQmlProperty>(), QQmlProperty(item.data(), "x"));
+ QCOMPARE(item->property("xBehaviorObject").value<QObject*>(), item.data());
+ QCOMPARE(item->property("xBehaviorName").toString(), "x");
+
+ QQuickBehavior* emptyBehavior =
+ qobject_cast<QQuickBehavior*>(item->findChild<QQuickBehavior*>("emptyBehavior"));
+ QCOMPARE(emptyBehavior->property("targetProperty").value<QQmlProperty>().isValid(), false);
+ QCOMPARE(item->property("emptyBehaviorObject").value<QObject*>(), nullptr);
+ QCOMPARE(item->property("emptyBehaviorName").toString(), "");
+}
+
QTEST_MAIN(tst_qquickbehaviors)