diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-09-14 22:02:55 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-10-09 13:06:35 +0000 |
commit | 8e7d1a91196197eee4e45bbfa9886ab935e2b67c (patch) | |
tree | 9bc7bb0e99dfa5216a6b71941171b2251c77bd38 /tests | |
parent | d9541bde71f1adc81753283dc40ea6a8af009d8a (diff) |
Make QML composite types inherit attached properties
Change-Id: Ic06af4805da987dd08e361f2668e7a1788d3eefe
Task-number: QTBUG-43581
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'tests')
4 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/data/CompositeTypeWithAttachedProperty.qml b/tests/auto/qml/qqmllanguage/data/CompositeTypeWithAttachedProperty.qml new file mode 100644 index 0000000000..6a14e72a31 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/CompositeTypeWithAttachedProperty.qml @@ -0,0 +1,4 @@ +import Test 1.0 + +MyCompositeBaseType { +} diff --git a/tests/auto/qml/qqmllanguage/data/registeredCompositeTypeWithAttachedProperty.qml b/tests/auto/qml/qqmllanguage/data/registeredCompositeTypeWithAttachedProperty.qml new file mode 100644 index 0000000000..d34e4650b3 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/registeredCompositeTypeWithAttachedProperty.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +RegisteredCompositeTypeWithAttachedProperty { + RegisteredCompositeTypeWithAttachedProperty.objectName: "test" + property string attachedProperty: RegisteredCompositeTypeWithAttachedProperty.objectName +} diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h index 985acc2539..c64fda5ea1 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.h +++ b/tests/auto/qml/qqmllanguage/testtypes.h @@ -1086,6 +1086,7 @@ class MyCompositeBaseType : public QObject public: enum CompositeEnum { EnumValue0, EnumValue42 = 42 }; + static QObject *qmlAttachedProperties(QObject *parent) { return new QObject(parent); } }; Q_DECLARE_METATYPE(MyEnum2Class::EnumB) @@ -1100,6 +1101,7 @@ QML_DECLARE_TYPE(MyRevisionedSubclass) QML_DECLARE_TYPE(MySubclass) QML_DECLARE_TYPE(MyReceiversTestObject) QML_DECLARE_TYPE(MyCompositeBaseType) +QML_DECLARE_TYPEINFO(MyCompositeBaseType, QML_HAS_ATTACHED_PROPERTIES) class CustomBinding : public QObject, public QQmlParserStatus { diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index b48f3640f4..54e9c361e4 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -160,6 +160,7 @@ private slots: void receivers(); void registeredCompositeType(); void registeredCompositeTypeWithEnum(); + void registeredCompositeTypeWithAttachedProperty(); void implicitImportsLast(); void basicRemote_data(); @@ -3176,6 +3177,7 @@ void tst_qqmllanguage::initTestCase() qmlRegisterType(testFileUrl("CompositeType.DoesNotExist.qml"), "Test", 1, 0, "RegisteredCompositeType2"); qmlRegisterType(testFileUrl("invalidRoot.1.qml"), "Test", 1, 0, "RegisteredCompositeType3"); qmlRegisterType(testFileUrl("CompositeTypeWithEnum.qml"), "Test", 1, 0, "RegisteredCompositeTypeWithEnum"); + qmlRegisterType(testFileUrl("CompositeTypeWithAttachedProperty.qml"), "Test", 1, 0, "RegisteredCompositeTypeWithAttachedProperty"); // Registering the TestType class in other modules should have no adverse effects qmlRegisterType<TestType>("org.qtproject.TestPre", 1, 0, "Test"); @@ -3367,6 +3369,20 @@ void tst_qqmllanguage::registeredCompositeTypeWithEnum() delete o; } +// QTBUG-43581 +void tst_qqmllanguage::registeredCompositeTypeWithAttachedProperty() +{ + QQmlComponent component(&engine, testFileUrl("registeredCompositeTypeWithAttachedProperty.qml")); + + VERIFY_ERRORS(0); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("attachedProperty").toString(), QStringLiteral("test")); + + delete o; +} + // QTBUG-18268 void tst_qqmllanguage::remoteLoadCrash() { |