diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-10-24 01:01:06 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-10-24 15:42:35 +0200 |
commit | 328b97a0acdf294f6ba3c902d23ece374a0f11ba (patch) | |
tree | 3a005d1948a91bfaacda69dc0dfba1b66d491714 /tests | |
parent | 1e94466b06190061a86e9918c5e45279171e600f (diff) | |
parent | 45652a0491aa32ecdf1d05c236501f78bcea71f8 (diff) |
Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts:
src/qml/qml/qqmlpropertyvalidator.cpp
tests/auto/qml/qmlmin/tst_qmlmin.cpp
Change-Id: I920c133e839d980ed32c179a0bc4fa44c46e2296
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qjsengine/tst_qjsengine.cpp | 1 | ||||
-rw-r--r-- | tests/auto/qml/qmlcachegen/data/parameterAdjustment.qml | 7 | ||||
-rw-r--r-- | tests/auto/qml/qmlcachegen/qmlcachegen.pro | 3 | ||||
-rw-r--r-- | tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp | 10 | ||||
-rw-r--r-- | tests/auto/qml/qmlmin/tst_qmlmin.cpp | 1 | ||||
-rw-r--r-- | tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp | 25 | ||||
-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/tst_qqmllanguage.cpp | 1 | ||||
-rw-r--r-- | tests/auto/qml/qqmlproperty/data/interfaceBinding.qml | 27 | ||||
-rw-r--r-- | tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp | 79 |
12 files changed, 149 insertions, 9 deletions
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 1c895eb793..f1ff396d4f 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -4888,6 +4888,7 @@ void tst_QJSEngine::interrupt_data() QTest::addRow("labeled continue / %s", mode) << i << "a: while (true) { for (;;) { continue a; } }"; QTest::addRow("labeled break / %s", mode) << i << "while (true) { a: for (;;) { break a; } }"; QTest::addRow("tail call / %s", mode) << i << "'use strict';\nfunction x() { return x(); }; x();"; + QTest::addRow("huge array join / %s", mode) << i << "Array(1E9)|1"; } } diff --git a/tests/auto/qml/qmlcachegen/data/parameterAdjustment.qml b/tests/auto/qml/qmlcachegen/data/parameterAdjustment.qml new file mode 100644 index 0000000000..2128a54d81 --- /dev/null +++ b/tests/auto/qml/qmlcachegen/data/parameterAdjustment.qml @@ -0,0 +1,7 @@ +import QtQml 2.12 + +QtObject { + signal testSignal(string a, int b, string c, bool d, bool e, real f, real g, bool h, int i, int j, string k, int l, string m, string n) + onTestSignal: {} + Component.onCompleted: testSignal("a", 1, "b", true, true, 0.1, 0.1, true, 1, 1, "a", 1, "a", "a") +} diff --git a/tests/auto/qml/qmlcachegen/qmlcachegen.pro b/tests/auto/qml/qmlcachegen/qmlcachegen.pro index 1a334b68ce..452bd7d04a 100644 --- a/tests/auto/qml/qmlcachegen/qmlcachegen.pro +++ b/tests/auto/qml/qmlcachegen/qmlcachegen.pro @@ -17,7 +17,8 @@ RESOURCES += \ data/jsmoduleimport.qml \ data/script.mjs \ data/module.mjs \ - data/utils.mjs + data/utils.mjs \ + data/parameterAdjustment.qml workerscripts_test.files = \ data/worker.js \ diff --git a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp index 5d87c319f3..f940f9c476 100644 --- a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp +++ b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp @@ -73,6 +73,8 @@ private slots: void reproducibleCache_data(); void reproducibleCache(); + + void parameterAdjustment(); }; // A wrapper around QQmlComponent to ensure the temporary reference counts @@ -664,6 +666,14 @@ void tst_qmlcachegen::reproducibleCache() QCOMPARE(contents1, contents2); } +void tst_qmlcachegen::parameterAdjustment() +{ + QQmlEngine engine; + CleanlyLoadingComponent component(&engine, QUrl("qrc:///data/parameterAdjustment.qml")); + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); // Doesn't crash +} + QTEST_GUILESS_MAIN(tst_qmlcachegen) #include "tst_qmlcachegen.moc" diff --git a/tests/auto/qml/qmlmin/tst_qmlmin.cpp b/tests/auto/qml/qmlmin/tst_qmlmin.cpp index 79a73299a4..e7498a8583 100644 --- a/tests/auto/qml/qmlmin/tst_qmlmin.cpp +++ b/tests/auto/qml/qmlmin/tst_qmlmin.cpp @@ -130,6 +130,7 @@ void tst_qmlmin::initTestCase() invalidFiles << "tests/auto/qml/qjsengine/script/com/trolltech/syntaxerror/__init__.js"; invalidFiles << "tests/auto/qml/debugger/qqmlpreview/data/broken.qml"; invalidFiles << "tests/auto/qml/qqmllanguage/data/fuzzed.2.qml"; + invalidFiles << "tests/auto/qml/qqmllanguage/data/fuzzed.3.qml"; invalidFiles << "tests/auto/qml/qqmllanguage/data/requiredProperties.2.qml"; invalidFiles << "tests/auto/qml/qqmllanguage/data/requiredProperties.3.qml"; // generatorFunction.qml is not invalid per se, but the minifier cannot handle yield statements diff --git a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp index d9cb6673df..6754f22049 100644 --- a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp +++ b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp @@ -895,16 +895,27 @@ void tst_qqmlcontext::contextObjectHierarchy() void tst_qqmlcontext::destroyContextProperty() { - QQmlEngine engine; - QQmlContext context(&engine); - + QScopedPointer<QQmlContext> context; + QScopedPointer<QObject> objectThatOutlivesEngine(new QObject); { - QObject object; - context.setContextProperty(QLatin1String("a"), &object); - QCOMPARE(qvariant_cast<QObject *>(context.contextProperty(QLatin1String("a"))), &object); + QQmlEngine engine; + context.reset(new QQmlContext(&engine)); + + { + QObject object; + context->setContextProperty(QLatin1String("a"), &object); + QCOMPARE(qvariant_cast<QObject *>(context->contextProperty(QLatin1String("a"))), &object); + } + + QCOMPARE(qvariant_cast<QObject *>(context->contextProperty(QLatin1String("a"))), nullptr); + context->setContextProperty(QLatin1String("b"), objectThatOutlivesEngine.data()); } - QCOMPARE(qvariant_cast<QObject *>(context.contextProperty(QLatin1String("a"))), nullptr); + // dropDestroyedObject() should not crash, even if the engine is gone. + objectThatOutlivesEngine.reset(); + + // We're not allowed to call context->contextProperty("b") anymore. + // TODO: Or are we? } QTEST_MAIN(tst_qqmlcontext) 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/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 4b7e643a26..380925ded8 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -627,6 +627,7 @@ 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; diff --git a/tests/auto/qml/qqmlproperty/data/interfaceBinding.qml b/tests/auto/qml/qqmlproperty/data/interfaceBinding.qml new file mode 100644 index 0000000000..4e72a75f42 --- /dev/null +++ b/tests/auto/qml/qqmlproperty/data/interfaceBinding.qml @@ -0,0 +1,27 @@ +import QtQuick 2.12 +import io.qt.bugreports 1.0 +Item { + InterfaceConsumer { + objectName: "a1" + i: A { + property int i: 42 + } + } + + InterfaceConsumer { + objectName: "a2" + property A a: A { + property int i: 43 + } + i: a + } + + InterfaceConsumer { + objectName: "a3" + property A a: A { + id : aa + property int i: 44 + } + i: aa + } +} diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp index 1a5927fa74..51267f1662 100644 --- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp +++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp @@ -40,6 +40,7 @@ #endif #include <QtCore/private/qobject_p.h> #include "../../shared/util.h" +#include "qobject.h" #include <QDebug> class MyQmlObject : public QObject @@ -148,6 +149,7 @@ private slots: void readOnlyDynamicProperties(); void aliasToIdWithMatchingQmlFileNameOnCaseInsensitiveFileSystem(); void nullPropertyBinding(); + void interfaceBinding(); void floatToStringPrecision_data(); void floatToStringPrecision(); @@ -2083,6 +2085,83 @@ void tst_qqmlproperty::nullPropertyBinding() QMetaObject::invokeMethod(root.get(), "tog"); } +struct Interface { +}; + +QT_BEGIN_NAMESPACE +#define MyInterface_iid "io.qt.bugreports.Interface" +Q_DECLARE_INTERFACE(Interface, MyInterface_iid); +QT_END_NAMESPACE + +class A : public QObject, Interface { + Q_OBJECT + Q_INTERFACES(Interface) +}; + +class B : public QObject, Interface { + Q_OBJECT + Q_INTERFACES(Interface) +}; + +class C : public QObject { + Q_OBJECT +}; + +class InterfaceConsumer : public QObject { + Q_OBJECT + Q_PROPERTY(Interface* i READ interface WRITE setInterface NOTIFY interfaceChanged) + Q_PROPERTY(int testValue READ testValue NOTIFY testValueChanged) + + +public: + + Interface* interface() const + { + return m_interface; + } + void setInterface(Interface* interface) + { + QObject* object = reinterpret_cast<QObject*>(interface); + m_testValue = object->property("i").toInt(); + emit testValueChanged(); + if (m_interface == interface) + return; + + m_interface = interface; + emit interfaceChanged(); + } + + int testValue() { + return m_testValue; + } + +signals: + void interfaceChanged(); + void testValueChanged(); + +private: + Interface* m_interface = nullptr; + int m_testValue = 0; +}; +void tst_qqmlproperty::interfaceBinding() +{ + + qmlRegisterInterface<Interface>("Interface"); + qmlRegisterType<A>("io.qt.bugreports", 1, 0, "A"); + qmlRegisterType<B>("io.qt.bugreports", 1, 0, "B"); + qmlRegisterType<C>("io.qt.bugreports", 1, 0, "C"); + qmlRegisterType<InterfaceConsumer>("io.qt.bugreports", 1, 0, "InterfaceConsumer"); + + const QUrl url = testFileUrl("interfaceBinding.qml"); + QQmlEngine engine; + QQmlComponent component(&engine, url); + QScopedPointer<QObject> root(component.create()); + QVERIFY(root); + QCOMPARE(root->findChild<QObject*>("a1")->property("testValue").toInt(), 42); + QCOMPARE(root->findChild<QObject*>("a2")->property("testValue").toInt(), 43); + QCOMPARE(root->findChild<QObject*>("a3")->property("testValue").toInt(), 44); +} + void tst_qqmlproperty::floatToStringPrecision_data() { QTest::addColumn<QString>("propertyName"); |