diff options
Diffstat (limited to 'tests/auto/qml/qqmllanguage')
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/SelfInstantiation.errors.txt | 1 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/SelfInstantiation.qml | 5 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/SelfReference.qml | 8 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/alias.14.errors.txt | 1 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/alias.18.errors.txt | 1 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/alias.18.qml | 9 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/fuzzed.2.qml | bin | 404 -> 404 bytes | |||
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/fuzzed.3.errors.txt | 2 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/fuzzed.3.qml | bin | 0 -> 4777 bytes | |||
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt | 2 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/selfreferencingsingletonmodule/TestSingleton.qml | 7 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/selfreferencingsingletonmodule/qmldir | 1 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 93 |
13 files changed, 119 insertions, 11 deletions
diff --git a/tests/auto/qml/qqmllanguage/data/SelfInstantiation.errors.txt b/tests/auto/qml/qqmllanguage/data/SelfInstantiation.errors.txt new file mode 100644 index 0000000000..dfd077941e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/SelfInstantiation.errors.txt @@ -0,0 +1 @@ +3:29:SelfInstantiation is instantiated recursively diff --git a/tests/auto/qml/qqmllanguage/data/SelfInstantiation.qml b/tests/auto/qml/qqmllanguage/data/SelfInstantiation.qml new file mode 100644 index 0000000000..b2e4e453a0 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/SelfInstantiation.qml @@ -0,0 +1,5 @@ +import QtQml 2.0 +QtObject { + property QtObject self: SelfInstantiation { + } +} diff --git a/tests/auto/qml/qqmllanguage/data/SelfReference.qml b/tests/auto/qml/qqmllanguage/data/SelfReference.qml new file mode 100644 index 0000000000..129a171d77 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/SelfReference.qml @@ -0,0 +1,8 @@ +import QtQml 2.0 +QtObject { + property SelfReference self + signal blah(selfParam: SelfReference) + function returnSelf() : SelfReference { + return this; + } +} diff --git a/tests/auto/qml/qqmllanguage/data/alias.14.errors.txt b/tests/auto/qml/qqmllanguage/data/alias.14.errors.txt deleted file mode 100644 index 90a3ea4317..0000000000 --- a/tests/auto/qml/qqmllanguage/data/alias.14.errors.txt +++ /dev/null @@ -1 +0,0 @@ -10:34:References to other aliases within the same object are not supported at the moment diff --git a/tests/auto/qml/qqmllanguage/data/alias.18.errors.txt b/tests/auto/qml/qqmllanguage/data/alias.18.errors.txt new file mode 100644 index 0000000000..dda3e7a174 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/alias.18.errors.txt @@ -0,0 +1 @@ +7:24:Duplicate alias name diff --git a/tests/auto/qml/qqmllanguage/data/alias.18.qml b/tests/auto/qml/qqmllanguage/data/alias.18.qml new file mode 100644 index 0000000000..a9be937975 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/alias.18.qml @@ -0,0 +1,9 @@ +import QtQml 2.14 + +QtObject { + id: root + property QtObject o1: QtObject { + property alias a: root + property alias a: root + } +} diff --git a/tests/auto/qml/qqmllanguage/data/fuzzed.2.qml b/tests/auto/qml/qqmllanguage/data/fuzzed.2.qml Binary files differindex e726f6783c..f164ec98ea 100644 --- a/tests/auto/qml/qqmllanguage/data/fuzzed.2.qml +++ b/tests/auto/qml/qqmllanguage/data/fuzzed.2.qml diff --git a/tests/auto/qml/qqmllanguage/data/fuzzed.3.errors.txt b/tests/auto/qml/qqmllanguage/data/fuzzed.3.errors.txt new file mode 100644 index 0000000000..da17dc5599 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/fuzzed.3.errors.txt @@ -0,0 +1,2 @@ +3:2:Unexpected token `version number' +1:1:Expected a qualified name id or a string literal diff --git a/tests/auto/qml/qqmllanguage/data/fuzzed.3.qml b/tests/auto/qml/qqmllanguage/data/fuzzed.3.qml Binary files differnew file mode 100644 index 0000000000..6861ebf8a9 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/fuzzed.3.qml diff --git a/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt index 043f714636..887d87b9fb 100644 --- a/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt +++ b/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt @@ -1 +1 @@ -4:18:Can not assign value of type "MyTypeObject" to property "x", expecting "int" +4:18:Cannot assign value of type "MyTypeObject" to property "x", expecting "int" diff --git a/tests/auto/qml/qqmllanguage/data/selfreferencingsingletonmodule/TestSingleton.qml b/tests/auto/qml/qqmllanguage/data/selfreferencingsingletonmodule/TestSingleton.qml new file mode 100644 index 0000000000..f70a3b1fea --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/selfreferencingsingletonmodule/TestSingleton.qml @@ -0,0 +1,7 @@ +import QtQml 2.0 +import selfreferencingsingletonmodule 1.0 +pragma Singleton +QtObject { + property SelfReferencingSingleton self + property int dummy: 42 +} diff --git a/tests/auto/qml/qqmllanguage/data/selfreferencingsingletonmodule/qmldir b/tests/auto/qml/qqmllanguage/data/selfreferencingsingletonmodule/qmldir new file mode 100644 index 0000000000..617861b00b --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/selfreferencingsingletonmodule/qmldir @@ -0,0 +1 @@ +singleton SelfReferencingSingleton 1.0 TestSingleton.qml diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index e2032c3b86..7fff982cde 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -306,6 +306,9 @@ private slots: void extendedForeignTypes(); + void selfReference(); + void selfReferencingSingleton(); + private: QQmlEngine engine; QStringList defaultImportPathList; @@ -624,12 +627,15 @@ void tst_qqmllanguage::errors_data() QTest::newRow("fuzzed.1") << "fuzzed.1.qml" << "fuzzed.1.errors.txt" << false; QTest::newRow("fuzzed.2") << "fuzzed.2.qml" << "fuzzed.2.errors.txt" << false; + QTest::newRow("fuzzed.3") << "fuzzed.3.qml" << "fuzzed.3.errors.txt" << false; QTest::newRow("bareQmlImport") << "bareQmlImport.qml" << "bareQmlImport.errors.txt" << false; QTest::newRow("typeAnnotations.2") << "typeAnnotations.2.qml" << "typeAnnotations.2.errors.txt" << false; QTest::newRow("propertyUnknownType") << "propertyUnknownType.qml" << "propertyUnknownType.errors.txt" << false; + + QTest::newRow("selfInstantiation") << "SelfInstantiation.qml" << "SelfInstantiation.errors.txt" << false; } void tst_qqmllanguage::errors() @@ -1955,7 +1961,6 @@ void tst_qqmllanguage::aliasProperties() // "Nested" aliases within an object that require iterative resolution { - // This is known to fail at the moment. QQmlComponent component(&engine, testFileUrl("alias.14.qml")); VERIFY_ERRORS(0); @@ -2054,6 +2059,11 @@ void tst_qqmllanguage::aliasProperties() auto text = myText->property("text").toString(); QCOMPARE(text, "alias:\n20"); } + + { + QQmlComponent component(&engine, testFileUrl("alias.18.qml")); + VERIFY_ERRORS("alias.18.errors.txt"); + } } // QTBUG-13374 Test that alias properties and signals can coexist @@ -4728,11 +4738,13 @@ static void beginDeferredOnce(QQmlEnginePrivate *enginePriv, typedef QMultiHash<int, const QV4::CompiledData::Binding *> QV4PropertyBindingHash; auto it = std::reverse_iterator<QV4PropertyBindingHash::iterator>(range.second); auto last = std::reverse_iterator<QV4PropertyBindingHash::iterator>(range.first); + state->creator->beginPopulateDeferred(deferData->context); while (it != last) { - if (!state->creator->populateDeferredBinding(property, deferData, *it)) - state->errors << state->creator->errors; + state->creator->populateDeferredBinding(property, deferData->deferredIdx, *it); ++it; } + state->creator->finalizePopulateDeferred(); + state->errors << state->creator->errors; deferredState->constructionStates += state; @@ -4957,24 +4969,24 @@ void tst_qqmllanguage::instanceof_data() // assert that basic types don't convert to QObject QTest::newRow("1 instanceof QtObject") << testFileUrl("instanceof_qtqml.qml") - << QVariant("TypeError: Type error"); + << QVariant(false); QTest::newRow("true instanceof QtObject") << testFileUrl("instanceof_qtqml.qml") - << QVariant("TypeError: Type error"); + << QVariant(false); QTest::newRow("\"foobar\" instanceof QtObject") << testFileUrl("instanceof_qtqml.qml") - << QVariant("TypeError: Type error"); + << QVariant(false); // assert that Managed don't either QTest::newRow("new String(\"foobar\") instanceof QtObject") << testFileUrl("instanceof_qtqml.qml") - << QVariant("TypeError: Type error"); + << QVariant(false); QTest::newRow("new Object() instanceof QtObject") << testFileUrl("instanceof_qtqml.qml") - << QVariant("TypeError: Type error"); + << QVariant(false); QTest::newRow("new Date() instanceof QtObject") << testFileUrl("instanceof_qtqml.qml") - << QVariant("TypeError: Type error"); + << QVariant(false); // test that simple QtQml comparisons work QTest::newRow("qtobjectInstance instanceof QtObject") @@ -5274,6 +5286,69 @@ void tst_qqmllanguage::extendedForeignTypes() QCOMPARE(o->property("foreignExtendedObjectName").toString(), QLatin1String("foreignExtended")); } +void tst_qqmllanguage::selfReference() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("SelfReference.qml")); + VERIFY_ERRORS(0); + QScopedPointer<QObject> o(component.create()); + QVERIFY(!o.isNull()); + + QQmlComponentPrivate *componentPrivate = QQmlComponentPrivate::get(&component); + auto compilationUnit = componentPrivate->compilationUnit; + QVERIFY(compilationUnit); + + const QMetaObject *metaObject = o->metaObject(); + QMetaProperty selfProperty = metaObject->property(metaObject->indexOfProperty("self")); + QCOMPARE(selfProperty.userType(), compilationUnit->metaTypeId); + + QByteArray typeName = selfProperty.typeName(); + QVERIFY(typeName.endsWith('*')); + typeName = typeName.chopped(1); + QCOMPARE(typeName, metaObject->className()); + + QMetaMethod selfFunction = metaObject->method(metaObject->indexOfMethod("returnSelf()")); + QVERIFY(selfFunction.isValid()); + QCOMPARE(selfFunction.returnType(), compilationUnit->metaTypeId); + + QMetaMethod selfSignal; + + for (int i = metaObject->methodOffset(); i < metaObject->methodCount(); ++i) { + QMetaMethod method = metaObject->method(i); + if (method.isValid() && method.name().startsWith("blah")) { + selfSignal = method; + break; + } + } + + QVERIFY(selfSignal.isValid()); + QCOMPARE(selfSignal.parameterCount(), 1); + QCOMPARE(selfSignal.parameterType(0), compilationUnit->metaTypeId); +} + +void tst_qqmllanguage::selfReferencingSingleton() +{ + QQmlEngine engine; + engine.addImportPath(dataDirectory()); + + QPointer<QObject> singletonPointer; + { + QQmlComponent component(&engine); + component.setData(QByteArray(R"(import QtQml 2.0 + import selfreferencingsingletonmodule 1.0 + QtObject { + property SelfReferencingSingleton singletonPointer: SelfReferencingSingleton + })"), QUrl()); + VERIFY_ERRORS(0); + QScopedPointer<QObject> o(component.create()); + QVERIFY(!o.isNull()); + singletonPointer = o->property("singletonPointer").value<QObject*>(); + } + + QVERIFY(!singletonPointer.isNull()); + QCOMPARE(singletonPointer->property("dummy").toInt(), 42); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" |