diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-05-09 16:25:58 +0200 |
---|---|---|
committer | Gunnar Sletta <gunnar.sletta@jollamobile.com> | 2014-05-10 11:53:47 +0200 |
commit | 66646dd8c37adb488a79ab274b2396a649674e6d (patch) | |
tree | b0f5ac752a52cec3de1d47692e09295197622dcd /tests/auto/qml/qqmllanguage | |
parent | da15ea0f3b5805db657f13060c21efa78f10cde2 (diff) | |
parent | d82a17b929dd88fe76258b0f801beaa1b2ee343e (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
.qmake.conf
src/plugins/accessible/quick/quick.pro
src/quick/items/qquickpincharea.cpp
src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
src/quick/scenegraph/qsgthreadedrenderloop.cpp
Manually adjusted for TestHTTPServer constructor change:
tests/auto/quick/qquickimage/tst_qquickimage.cpp
Change-Id: I5e58a7c08ea92d6fc5e3bce98571c54f7b2ce08f
Diffstat (limited to 'tests/auto/qml/qqmllanguage')
12 files changed, 270 insertions, 26 deletions
diff --git a/tests/auto/qml/qqmllanguage/data/SubType.qml b/tests/auto/qml/qqmllanguage/data/SubType.qml new file mode 100644 index 0000000000..0698ae2349 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/SubType.qml @@ -0,0 +1,3 @@ +import QtQml 2.0 +QtObject { +} diff --git a/tests/auto/qml/qqmllanguage/data/assignNullStrings.qml b/tests/auto/qml/qqmllanguage/data/assignNullStrings.qml new file mode 100644 index 0000000000..5e1c3a9b03 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/assignNullStrings.qml @@ -0,0 +1,9 @@ +import Test 1.0 +MyTypeObject { + stringProperty: "" + byteArrayProperty: "" + function assignNullStringsFromJs() { + stringProperty = "" + byteArrayProperty = "" + } +} diff --git a/tests/auto/qml/qqmllanguage/data/customParserProperties.qml b/tests/auto/qml/qqmllanguage/data/customParserProperties.qml new file mode 100644 index 0000000000..5d72edb8e5 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/customParserProperties.qml @@ -0,0 +1,7 @@ +import Test 1.0 +import QtQml 2.0 +SimpleObjectWithCustomParser { + intProperty: 42 + property string qmlString: "Hello" + property var someObject: QtObject {} +} diff --git a/tests/auto/qml/qqmllanguage/data/idProperty.qml b/tests/auto/qml/qqmllanguage/data/idProperty.qml index bf048ea60a..dbb242804a 100644 --- a/tests/auto/qml/qqmllanguage/data/idProperty.qml +++ b/tests/auto/qml/qqmllanguage/data/idProperty.qml @@ -5,4 +5,8 @@ MyContainer { MyTypeObject { id: "myObjectId" } + + MyTypeObject { + selfGroupProperty.id: "name.with.dots" + } } diff --git a/tests/auto/qml/qqmllanguage/data/nonexistantProperty.7.errors.txt b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.7.errors.txt new file mode 100644 index 0000000000..d62dbd703d --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.7.errors.txt @@ -0,0 +1 @@ +3:5:Cannot assign to non-existent property "nonExistantGrouped" diff --git a/tests/auto/qml/qqmllanguage/data/nonexistantProperty.7.qml b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.7.qml new file mode 100644 index 0000000000..3b66a5f6c7 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.7.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyQmlObject { + nonExistantGrouped.blah: MyQmlObject {} +} diff --git a/tests/auto/qml/qqmllanguage/data/rootObjectInCreationNotForSubObjects.qml b/tests/auto/qml/qqmllanguage/data/rootObjectInCreationNotForSubObjects.qml new file mode 100644 index 0000000000..afba278ade --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/rootObjectInCreationNotForSubObjects.qml @@ -0,0 +1,7 @@ +import QtQml 2.0 +import Test 1.0 +RootObjectInCreationTester { + subObject: SubType { + property int testValue: 42; + } +} diff --git a/tests/auto/qml/qqmllanguage/data/scriptString7.qml b/tests/auto/qml/qqmllanguage/data/scriptString7.qml new file mode 100644 index 0000000000..a9d5b47e2b --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/scriptString7.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + intProperty: 100; + scriptProperty: intProperty; +} diff --git a/tests/auto/qml/qqmllanguage/data/{subdir}/Test.qml b/tests/auto/qml/qqmllanguage/data/{subdir}/Test.qml new file mode 100644 index 0000000000..f789a905f2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/{subdir}/Test.qml @@ -0,0 +1,2 @@ +import QtQuick 2.0 +Rectangle { } diff --git a/tests/auto/qml/qqmllanguage/testtypes.cpp b/tests/auto/qml/qqmllanguage/testtypes.cpp index fad5c1e65d..8ffa327cf2 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.cpp +++ b/tests/auto/qml/qqmllanguage/testtypes.cpp @@ -92,6 +92,9 @@ void registerTypes() qmlRegisterType<MyCreateableDerivedClass,1>("Test", 1, 1, "MyCreateableDerivedClass"); qmlRegisterCustomType<CustomBinding>("Test", 1, 0, "CustomBinding", new CustomBindingParser); + qmlRegisterCustomType<SimpleObjectWithCustomParser>("Test", 1, 0, "SimpleObjectWithCustomParser", new SimpleObjectCustomParser); + + qmlRegisterType<RootObjectInCreationTester>("Test", 1, 0, "RootObjectInCreationTester"); } QVariant myCustomVariantTypeConverter(const QString &data) @@ -102,9 +105,8 @@ QVariant myCustomVariantTypeConverter(const QString &data) } -QByteArray CustomBindingParser::compile(const QV4::CompiledData::QmlUnit *qmlUnit, int objectIndex, const QList<const QV4::CompiledData::Binding *> &bindings) +QByteArray CustomBindingParser::compile(const QV4::CompiledData::QmlUnit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &bindings) { - Q_UNUSED(objectIndex) QByteArray result; QDataStream ds(&result, QIODevice::WriteOnly); @@ -123,7 +125,7 @@ QByteArray CustomBindingParser::compile(const QV4::CompiledData::QmlUnit *qmlUni return result; } -void CustomBindingParser::setCustomData(QObject *object, const QByteArray &data) +void CustomBindingParser::setCustomData(QObject *object, const QByteArray &data, QQmlCompiledData*) { CustomBinding *customBinding = qobject_cast<CustomBinding*>(object); Q_ASSERT(customBinding); @@ -155,10 +157,9 @@ void CustomBinding::componentComplete() } } -QByteArray EnumSupportingCustomParser::compile(const QV4::CompiledData::QmlUnit *qmlUnit, int objectIndex, const QList<const QV4::CompiledData::Binding *> &bindings) +QByteArray EnumSupportingCustomParser::compile(const QV4::CompiledData::QmlUnit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &bindings) { Q_UNUSED(qmlUnit) - Q_UNUSED(objectIndex) if (bindings.count() != 1) { error(bindings.first(), QStringLiteral("Custom parser invoked incorrectly for unit test")); @@ -189,3 +190,35 @@ QByteArray EnumSupportingCustomParser::compile(const QV4::CompiledData::QmlUnit return QByteArray(); } + + +QByteArray SimpleObjectCustomParser::compile(const QV4::CompiledData::QmlUnit *, const QList<const QV4::CompiledData::Binding *> &bindings) +{ + return QByteArray::number(bindings.count()); +} + +void SimpleObjectCustomParser::setCustomData(QObject *object, const QByteArray &data, QQmlCompiledData*) +{ + SimpleObjectWithCustomParser *o = qobject_cast<SimpleObjectWithCustomParser*>(object); + Q_ASSERT(o); + bool ok = false; + o->setCustomBindingsCount(data.toInt(&ok)); + Q_ASSERT(ok); +} + + +MyQmlObject::MyQmlObject() + : m_value(-1) + , m_interface(0) + , m_qmlobject(0) + , m_childAddedEventCount(0) +{ + qRegisterMetaType<MyCustomVariantType>("MyCustomVariantType"); +} + +bool MyQmlObject::event(QEvent *event) +{ + if (event->type() == QEvent::ChildAdded) + m_childAddedEventCount++; + return QObject::event(event); +} diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h index a1e2b76bd1..1c13a2e21c 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.h +++ b/tests/auto/qml/qqmllanguage/testtypes.h @@ -119,7 +119,7 @@ class MyQmlObject : public QObject, public MyInterface Q_INTERFACES(MyInterface) public: - MyQmlObject() : m_value(-1), m_interface(0), m_qmlobject(0) { qRegisterMetaType<MyCustomVariantType>("MyCustomVariantType"); } + MyQmlObject(); int value() const { return m_value; } void setValue(int v) { m_value = v; } @@ -161,6 +161,8 @@ public: QJSValue qjsvalue() const { return m_qjsvalue; } void setQJSValue(const QJSValue &value) { m_qjsvalue = value; emit qjsvalueChanged(); } + int childAddedEventCount() const { return m_childAddedEventCount; } + public slots: void basicSlot() { qWarning("MyQmlObject::basicSlot"); } void basicSlotWithArgs(int v) { qWarning("MyQmlObject::basicSlotWithArgs(%d)", v); } @@ -173,6 +175,9 @@ signals: void signalWithDefaultArg(int parameter = 5); void qjsvalueChanged(); +protected: + virtual bool event(QEvent *event); + private: friend class tst_qqmllanguage; int m_value; @@ -181,6 +186,7 @@ private: MyCustomVariantType m_custom; int m_propertyWithNotify; QJSValue m_qjsvalue; + int m_childAddedEventCount; }; QML_DECLARE_TYPE(MyQmlObject) QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES) @@ -230,6 +236,7 @@ class MyTypeObject : public QObject Q_PROPERTY(MyMirroredEnum mirroredEnumProperty READ mirroredEnumProperty WRITE setMirroredEnumProperty NOTIFY mirroredEnumPropertyChanged) Q_PROPERTY(MyEnumContainer::RelatedEnum relatedEnumProperty READ relatedEnumProperty WRITE setRelatedEnumProperty) Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringPropertyChanged) + Q_PROPERTY(QByteArray byteArrayProperty READ byteArrayProperty WRITE setByteArrayProperty NOTIFY byteArrayPropertyChanged) Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty NOTIFY uintPropertyChanged) Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty NOTIFY intPropertyChanged) Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty NOTIFY realPropertyChanged) @@ -351,6 +358,15 @@ public: emit stringPropertyChanged(); } + QByteArray byteArrayPropertyValue; + QByteArray byteArrayProperty() const { + return byteArrayPropertyValue; + } + void setByteArrayProperty(const QByteArray &v) { + byteArrayPropertyValue = v; + emit byteArrayPropertyChanged(); + } + uint uintPropertyValue; uint uintProperty() const { return uintPropertyValue; @@ -564,6 +580,7 @@ signals: void qtEnumPropertyChanged(); void mirroredEnumPropertyChanged(); void stringPropertyChanged(); + void byteArrayPropertyChanged(); void uintPropertyChanged(); void intPropertyChanged(); void realPropertyChanged(); @@ -722,15 +739,15 @@ class MyCustomParserType : public QObject class MyCustomParserTypeParser : public QQmlCustomParser { public: - QByteArray compile(const QV4::CompiledData::QmlUnit *, int, const QList<const QV4::CompiledData::Binding *> &) { return QByteArray(); } - void setCustomData(QObject *, const QByteArray &) {} + QByteArray compile(const QV4::CompiledData::QmlUnit *, const QList<const QV4::CompiledData::Binding *> &) { return QByteArray(); } + void setCustomData(QObject *, const QByteArray &, QQmlCompiledData*) {} }; class EnumSupportingCustomParser : public QQmlCustomParser { public: - QByteArray compile(const QV4::CompiledData::QmlUnit *qmlUnit, int objectIndex, const QList<const QV4::CompiledData::Binding *> &bindings); - void setCustomData(QObject *, const QByteArray &) {} + QByteArray compile(const QV4::CompiledData::QmlUnit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &bindings); + void setCustomData(QObject *, const QByteArray &, QQmlCompiledData*) {} }; class MyParserStatus : public QObject, public QQmlParserStatus @@ -1100,8 +1117,52 @@ public: class CustomBindingParser : public QQmlCustomParser { - virtual QByteArray compile(const QV4::CompiledData::QmlUnit *qmlUnit, int objectIndex, const QList<const QV4::CompiledData::Binding *> &bindings); - virtual void setCustomData(QObject *object, const QByteArray &data); + virtual QByteArray compile(const QV4::CompiledData::QmlUnit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &bindings); + virtual void setCustomData(QObject *object, const QByteArray &data, QQmlCompiledData *); +}; + +class SimpleObjectWithCustomParser : public QObject +{ + Q_OBJECT + Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty) +public: + SimpleObjectWithCustomParser() + : m_intProperty(0) + , m_customBindingsCount(0) + {} + + int intProperty() const { return m_intProperty; } + void setIntProperty(int value) { m_intProperty = value; } + + void setCustomBindingsCount(int count) { m_customBindingsCount = count; } + int customBindingsCount() const { return m_customBindingsCount; } + +private: + int m_intProperty; + int m_customBindingsCount; +}; + +class SimpleObjectCustomParser : public QQmlCustomParser +{ + virtual QByteArray compile(const QV4::CompiledData::QmlUnit *, const QList<const QV4::CompiledData::Binding *> &bindings); + virtual void setCustomData(QObject *object, const QByteArray &data, QQmlCompiledData *); +}; + +class RootObjectInCreationTester : public QObject +{ + Q_OBJECT + Q_PROPERTY(QObject *subObject READ subObject WRITE setSubObject FINAL) + Q_CLASSINFO("DeferredPropertyNames", "subObject"); +public: + RootObjectInCreationTester() + : obj(0) + {} + + QObject *subObject() const { return obj; } + void setSubObject(QObject *o) { obj = o; } + +private: + QObject *obj; }; void registerTypes(); diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index cf43352c40..be417df325 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -65,6 +65,17 @@ DEFINE_BOOL_CONFIG_OPTION(qmlCheckTypes, QML_CHECK_TYPES) +static inline bool isCaseSensitiveFileSystem(const QString &path) { + Q_UNUSED(path) +#if defined(Q_OS_MAC) + return pathconf(path.toLatin1().constData(), _PC_CASE_SENSITIVE); +#elif defined(Q_OS_WIN) + return false; +#else + return true; +#endif +} + /* This test case covers QML language issues. This covers everything that does not involve evaluating ECMAScript expressions and bindings. @@ -99,6 +110,7 @@ private slots: void assignLiteralToVariant(); void assignLiteralToVar(); void assignLiteralToJSValue(); + void assignNullStrings(); void bindJSValueToVar(); void bindJSValueToVariant(); void bindJSValueToType(); @@ -218,10 +230,15 @@ private slots: void customParserBindingScopes(); void customParserEvaluateEnum(); + void customParserProperties(); void preservePropertyCacheOnGroupObjects(); void propertyCacheInSync(); + void rootObjectInCreationNotForSubObjects(); + + void noChildEvents(); + private: QQmlEngine engine; QStringList defaultImportPathList; @@ -328,6 +345,7 @@ void tst_qqmllanguage::errors_data() QTest::newRow("nonexistantProperty.4") << "nonexistantProperty.4.qml" << "nonexistantProperty.4.errors.txt" << false; QTest::newRow("nonexistantProperty.5") << "nonexistantProperty.5.qml" << "nonexistantProperty.5.errors.txt" << false; QTest::newRow("nonexistantProperty.6") << "nonexistantProperty.6.qml" << "nonexistantProperty.6.errors.txt" << false; + QTest::newRow("nonexistantProperty.7") << "nonexistantProperty.7.qml" << "nonexistantProperty.7.errors.txt" << false; QTest::newRow("wrongType (string for int)") << "wrongType.1.qml" << "wrongType.1.errors.txt" << false; QTest::newRow("wrongType (int for bool)") << "wrongType.2.qml" << "wrongType.2.errors.txt" << false; @@ -493,13 +511,11 @@ void tst_qqmllanguage::errors_data() QTest::newRow("notAvailable") << "notAvailable.qml" << "notAvailable.errors.txt" << false; QTest::newRow("singularProperty") << "singularProperty.qml" << "singularProperty.errors.txt" << false; QTest::newRow("singularProperty.2") << "singularProperty.2.qml" << "singularProperty.2.errors.txt" << false; - QTest::newRow("incorrectCase") << "incorrectCase.qml" -#if defined(Q_OS_MAC) || defined(Q_OS_WIN32) - << "incorrectCase.errors.insensitive.txt" -#else - << "incorrectCase.errors.sensitive.txt" -#endif - << false; + + const QString expectedError = isCaseSensitiveFileSystem(dataDirectory()) ? + QStringLiteral("incorrectCase.errors.sensitive.txt") : + QStringLiteral("incorrectCase.errors.insensitive.txt"); + QTest::newRow("incorrectCase") << "incorrectCase.qml" << expectedError << false; QTest::newRow("metaobjectRevision.1") << "metaobjectRevision.1.qml" << "metaobjectRevision.1.errors.txt" << false; QTest::newRow("metaobjectRevision.2") << "metaobjectRevision.2.qml" << "metaobjectRevision.2.errors.txt" << false; @@ -859,6 +875,19 @@ void tst_qqmllanguage::assignLiteralToJSValue() } } +void tst_qqmllanguage::assignNullStrings() +{ + QQmlComponent component(&engine, testFileUrl("assignNullStrings.qml")); + VERIFY_ERRORS(0); + MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY(object != 0); + QVERIFY(object->stringProperty().isNull()); + QVERIFY(object->byteArrayProperty().isNull()); + QMetaObject::invokeMethod(object, "assignNullStringsFromJs", Qt::DirectConnection); + QVERIFY(object->stringProperty().isNull()); + QVERIFY(object->byteArrayProperty().isNull()); +} + void tst_qqmllanguage::bindJSValueToVar() { QQmlComponent component(&engine, testFileUrl("assignLiteralToJSValue.qml")); @@ -1175,12 +1204,17 @@ void tst_qqmllanguage::idProperty() VERIFY_ERRORS(0); MyContainer *object = qobject_cast<MyContainer *>(component.create()); QVERIFY(object != 0); - QCOMPARE(object->getChildren()->count(), 1); + QCOMPARE(object->getChildren()->count(), 2); MyTypeObject *child = qobject_cast<MyTypeObject *>(object->getChildren()->at(0)); QVERIFY(child != 0); QCOMPARE(child->id(), QString("myObjectId")); QCOMPARE(object->property("object"), QVariant::fromValue((QObject *)child)); + + child = + qobject_cast<MyTypeObject *>(object->getChildren()->at(1)); + QVERIFY(child != 0); + QCOMPARE(child->id(), QString("name.with.dots")); } // Tests automatic connection to notify signals if "onBlahChanged" syntax is used @@ -1874,6 +1908,28 @@ void tst_qqmllanguage::scriptString() QVERIFY(object != 0); QCOMPARE(object->scriptProperty().isUndefinedLiteral(), true); } + { + QQmlComponent component(&engine, testFileUrl("scriptString7.qml")); + VERIFY_ERRORS(0); + + MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create()); + QVERIFY(object != 0); + QQmlScriptString ss = object->scriptProperty(); + + { + QQmlExpression expr(ss, /*context*/0, object); + QCOMPARE(expr.evaluate().toInt(), int(100)); + } + + { + SimpleObjectWithCustomParser testScope; + QVERIFY(testScope.metaObject()->indexOfProperty("intProperty") != object->metaObject()->indexOfProperty("intProperty")); + + testScope.setIntProperty(42); + QQmlExpression expr(ss, /*context*/0, &testScope); + QCOMPARE(expr.evaluate().toInt(), int(42)); + } + } } // Check that default property assignments are correctly spliced into explicit @@ -2208,6 +2264,11 @@ void tst_qqmllanguage::importsLocal_data() "Test {}" << (!qmlCheckTypes()?"TestType":"") << (!qmlCheckTypes()?"":"Test is ambiguous. Found in org/qtproject/Test/ and in subdir/"); + QTest::newRow("file URL survives percent-encoding") + << "import \"" + QUrl::fromLocalFile(QDir::currentPath() + "/{subdir}").toString() + "\"\n" + "Test {}" + << "QQuickRectangle" + << ""; } void tst_qqmllanguage::importsLocal() @@ -2574,12 +2635,9 @@ void tst_qqmllanguage::importIncorrectCase() QList<QQmlError> errors = component.errors(); QCOMPARE(errors.count(), 1); -#if defined(Q_OS_MAC) || defined(Q_OS_WIN) - QString expectedError = QLatin1String("File name case mismatch"); -#else - QString expectedError = QLatin1String("File not found"); -#endif - + const QString expectedError = isCaseSensitiveFileSystem(dataDirectory()) ? + QStringLiteral("File not found") : + QStringLiteral("File name case mismatch"); QCOMPARE(errors.at(0).description(), expectedError); engine.setImportPathList(defaultImportPathList); @@ -3591,6 +3649,20 @@ void tst_qqmllanguage::customParserEvaluateEnum() QVERIFY(!o.isNull()); } +void tst_qqmllanguage::customParserProperties() +{ + QQmlComponent component(&engine, testFile("customParserProperties.qml")); + VERIFY_ERRORS(0); + QScopedPointer<QObject> o(component.create()); + QVERIFY(!o.isNull()); + SimpleObjectWithCustomParser *testObject = qobject_cast<SimpleObjectWithCustomParser*>(o.data()); + QVERIFY(testObject); + QCOMPARE(testObject->customBindingsCount(), 0); + QCOMPARE(testObject->intProperty(), 42); + QCOMPARE(testObject->property("qmlString").toString(), QStringLiteral("Hello")); + QVERIFY(!testObject->property("someObject").isNull()); +} + void tst_qqmllanguage::preservePropertyCacheOnGroupObjects() { QQmlComponent component(&engine, testFile("preservePropertyCacheOnGroupObjects.qml")); @@ -3630,6 +3702,41 @@ void tst_qqmllanguage::propertyCacheInSync() QCOMPARE(anchors->property("margins").toInt(), 50); } +void tst_qqmllanguage::rootObjectInCreationNotForSubObjects() +{ + QQmlComponent component(&engine, testFile("rootObjectInCreationNotForSubObjects.qml")); + VERIFY_ERRORS(0); + QScopedPointer<QObject> o(component.create()); + QVERIFY(!o.isNull()); + + // QQmlComponent should have set this back to false anyway + QQmlData *ddata = QQmlData::get(o.data()); + QVERIFY(!ddata->rootObjectInCreation); + + QObject *subObject = qvariant_cast<QObject*>(o->property("subObject")); + QVERIFY(!subObject); + + qmlExecuteDeferred(o.data()); + + subObject = qvariant_cast<QObject*>(o->property("subObject")); + QVERIFY(subObject); + + ddata = QQmlData::get(subObject); + // This should never have been set in the first place as there is no + // QQmlComponent to set it back to false. + QVERIFY(!ddata->rootObjectInCreation); +} + +void tst_qqmllanguage::noChildEvents() +{ + QQmlComponent component(&engine); + component.setData("import QtQml 2.0; import Test 1.0; MyQmlObject { property QtObject child: QtObject {} }", QUrl()); + VERIFY_ERRORS(0); + MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->childAddedEventCount(), 0); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" |