diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2018-02-21 17:09:50 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-02-22 13:58:56 +0000 |
commit | 2659c308792967322564b5088e0e21bb371e0283 (patch) | |
tree | 5252d9b9f259b412483f6e8ef3d70014ea90fe73 /tests/auto | |
parent | 0975a9c892f1cb30b9e11e6becc469a3101cc2db (diff) |
Allow setting values in value type group properties in "on" assignments
Assigning to a group property inside a property value source or
interceptor as part of an "on assignment" is perfectly valid. That is
because while "color" is a value type property, the on assignment means
we're actually setting easing.type (in the example and test) on the
property value source, not the color, and that one is a QObject. The
same goes for interceptors.
Change-Id: I505a658977a578894d6dfb00bf5c65b41e42b12f
Task-number: QTBUG-56600
Reviewed-by: Michael Brasser <michael.brasser@live.com>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/groupPropertyInPropertyValueSource.qml | 11 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 17 |
2 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/data/groupPropertyInPropertyValueSource.qml b/tests/auto/qml/qqmllanguage/data/groupPropertyInPropertyValueSource.qml new file mode 100644 index 0000000000..579086fa1c --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/groupPropertyInPropertyValueSource.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +Rectangle { + ColorAnimation on color { + id: animation + from: "red" + to: "darkgray" + duration: 250 + easing.type: Easing.InOutQuad + } +} diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 195a9687a8..6a3418f1ab 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -38,6 +38,7 @@ #include <QFont> #include <QQmlFileSelector> #include <QFileSelector> +#include <QEasingCurve> #include <private/qqmlproperty_p.h> #include <private/qqmlmetatype_p.h> @@ -283,6 +284,8 @@ private slots: void thisInQmlScope(); + void valueTypeGroupPropertiesInBehavior(); + private: QQmlEngine engine; QStringList defaultImportPathList; @@ -4926,6 +4929,20 @@ void tst_qqmllanguage::thisInQmlScope() QCOMPARE(o->property("y"), QVariant(42)); } +void tst_qqmllanguage::valueTypeGroupPropertiesInBehavior() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("groupPropertyInPropertyValueSource.qml")); + VERIFY_ERRORS(0); + QScopedPointer<QObject> o(component.create()); + QVERIFY(!o.isNull()); + + QObject *animation = qmlContext(o.data())->contextProperty("animation").value<QObject*>(); + QVERIFY(animation); + + QCOMPARE(animation->property("easing").value<QEasingCurve>().type(), QEasingCurve::InOutQuad); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" |