diff --git a/tests/auto/qml/qmltc/tst_qmltc.cpp b/tests/auto/qml/qmltc/tst_qmltc.cpp index e26aa06e78..f9220417eb 100644 --- a/tests/auto/qml/qmltc/tst_qmltc.cpp +++ b/tests/auto/qml/qmltc/tst_qmltc.cpp @@ -82,6 +82,8 @@ #include "calqlatrbits.h" #include "propertychangeandsignalhandlers.h" +#include "testprivateproperty.h" + // Qt: #include #include @@ -94,6 +96,7 @@ #include +#include #include #ifndef QMLTC_TESTS_DISABLE_CACHE @@ -1102,11 +1105,9 @@ void tst_qmltc::defaultAlias() QSKIP("Not implemented - not supported"); } -// TODO: this just doesn't work currently void tst_qmltc::attachedProperty() { QQmlEngine e; - QSKIP("Broken in many ways."); PREPEND_NAMESPACE(attachedProperty) created(&e); TestTypeAttached *attached = qobject_cast( @@ -1145,8 +1146,6 @@ void tst_qmltc::attachedProperty() void tst_qmltc::groupedProperty() { QQmlEngine e; - QSKIP("Property index is wrong due to not picking QtQml dependency when creating group " - "property scope"); PREPEND_NAMESPACE(groupedProperty) created(&e); TestTypeGrouped *grouped = created.getGroup(); @@ -1708,9 +1707,22 @@ void tst_qmltc::keyEvents() void tst_qmltc::privateProperties() { - QSKIP("The same problem with poor QObject qmltypes is encountered here."); QQmlEngine e; PREPEND_NAMESPACE(privatePropertySubclass) created(&e); + QCOMPARE(created.dummy(), u"bar"_qs); + QCOMPARE(created.strAlias(), u"foobar"_qs); + QCOMPARE(created.smthAlias(), 42); + + auto privateCreated = static_cast(QObjectPrivate::get(&created)); + QVERIFY(privateCreated); + QCOMPARE(privateCreated->foo(), u"Smth is: 42"_qs); + + ValueTypeGroup vt = privateCreated->vt(); + QCOMPARE(vt.count(), 11); + + TestTypeGrouped *group = privateCreated->getGroup(); + QCOMPARE(group->getCount(), 43); + QCOMPARE(group->getStr(), created.strAlias()); } void tst_qmltc::calqlatrBits() diff --git a/tools/qmltc/prototype/codegenerator.cpp b/tools/qmltc/prototype/codegenerator.cpp index 5757f57d82..a79dc348ef 100644 --- a/tools/qmltc/prototype/codegenerator.cpp +++ b/tools/qmltc/prototype/codegenerator.cpp @@ -1389,6 +1389,9 @@ void CodeGenerator::compileBinding(QQmlJSAotObject ¤t, const QmlIR::Bindin std::for_each(irObject->bindingsBegin(), irObject->bindingsEnd(), compileComponent); } else { const QString attachingTypeName = propertyName; // acts as an identifier + auto attachingType = m_localTypeResolver->typeForName(attachingTypeName); + Q_ASSERT(attachingType); // an error somewhere else + QString attachedTypeName = type->attachedTypeName(); // TODO: check if == internalName? if (attachedTypeName.isEmpty()) // TODO: shouldn't happen ideally attachedTypeName = type->baseTypeName(); @@ -1401,7 +1404,7 @@ void CodeGenerator::compileBinding(QQmlJSAotObject ¤t, const QmlIR::Bindin u"nullptr"_qs); // Note: getting attached property is fairly expensive const QString getAttachedPropertyLine = u"qobject_cast<" + attachedTypeName - + u" *>(qmlAttachedPropertiesObject<" + attachedTypeName + + u" *>(qmlAttachedPropertiesObject<" + attachingType->internalName() + u">(this, /* create = */ true))"; current.endInit.body << attachedMemberName + u" = " + getAttachedPropertyLine + u";";