diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-11-24 01:00:07 +0100 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-11-24 01:00:07 +0100 |
commit | df8784fa1fc4792007393ea995756c2d490691d7 (patch) | |
tree | d4b8d6bdc855e4045c39f7710f206b7cfcf3d493 /tests/auto/qml | |
parent | b799e061a3cbf995ac7c88b315f5916e3a687162 (diff) | |
parent | 5246b910771e0dd824b4eea7c5245e5f9f3a63f0 (diff) |
Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: I57e4b762dcccf2f7f6e4b659f6fc8c40465d3322
Diffstat (limited to 'tests/auto/qml')
16 files changed, 220 insertions, 5 deletions
diff --git a/tests/auto/qml/ecmascripttests/TestExpectations b/tests/auto/qml/ecmascripttests/TestExpectations index 02cb6acf99..ed5060a77d 100644 --- a/tests/auto/qml/ecmascripttests/TestExpectations +++ b/tests/auto/qml/ecmascripttests/TestExpectations @@ -139,7 +139,6 @@ built-ins/Date/prototype/toTimeString/invalid-date.js fails built-ins/Date/prototype/toUTCString/day-names.js fails built-ins/Date/prototype/toUTCString/format.js fails built-ins/Date/prototype/toUTCString/month-names.js fails -built-ins/Date/subclassing.js fails built-ins/Function/internals/Construct/base-ctor-revoked-proxy.js fails built-ins/Function/prototype/bind/BoundFunction_restricted-properties.js fails built-ins/Function/prototype/bind/instance-name-chained.js fails @@ -177,14 +176,10 @@ built-ins/Object/prototype/toString/proxy-function.js fails built-ins/Object/prototype/valueOf/S15.2.4.4_A14.js fails built-ins/Object/values/getter-adding-key.js fails built-ins/Object/values/observable-operations.js fails -built-ins/Promise/all/ctx-ctor.js fails built-ins/Promise/prototype/catch/this-value-obj-coercible.js fails -built-ins/Promise/prototype/then/capability-executor-called-twice.js fails built-ins/Promise/prototype/then/capability-executor-not-callable.js fails built-ins/Promise/prototype/then/ctor-custom.js fails built-ins/Promise/race/ctx-ctor.js fails -built-ins/Promise/reject/ctx-ctor.js fails -built-ins/Promise/resolve/ctx-ctor.js fails built-ins/Proxy/ownKeys/return-duplicate-entries-throws.js fails built-ins/Proxy/ownKeys/return-duplicate-symbol-entries-throws.js fails built-ins/RegExp/S15.10.2.12_A2_T1.js fails diff --git a/tests/auto/qml/qmlplugindump/data/dumper/CompositeWithinSingleton/Composite.qml b/tests/auto/qml/qmlplugindump/data/dumper/CompositeWithinSingleton/Composite.qml new file mode 100644 index 0000000000..b1055b6992 --- /dev/null +++ b/tests/auto/qml/qmlplugindump/data/dumper/CompositeWithinSingleton/Composite.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property int test: 0 +} diff --git a/tests/auto/qml/qmlplugindump/data/dumper/CompositeWithinSingleton/Singleton.qml b/tests/auto/qml/qmlplugindump/data/dumper/CompositeWithinSingleton/Singleton.qml new file mode 100644 index 0000000000..e81b2b6cb5 --- /dev/null +++ b/tests/auto/qml/qmlplugindump/data/dumper/CompositeWithinSingleton/Singleton.qml @@ -0,0 +1,6 @@ +pragma Singleton +import QtQuick 2.0 + +QtObject { + property Composite test: Composite {} +} diff --git a/tests/auto/qml/qmlplugindump/data/dumper/CompositeWithinSingleton/qmldir b/tests/auto/qml/qmlplugindump/data/dumper/CompositeWithinSingleton/qmldir new file mode 100644 index 0000000000..5a9cb1bd96 --- /dev/null +++ b/tests/auto/qml/qmlplugindump/data/dumper/CompositeWithinSingleton/qmldir @@ -0,0 +1,4 @@ +module dumper.CompositeWithinSingleton +singleton Singleton 1.0 Singleton.qml +Composite 1.0 Composite.qml +depends QtQuick 2.0 diff --git a/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp b/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp index f673fca1d7..17766a89b5 100644 --- a/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp +++ b/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp @@ -45,6 +45,8 @@ private slots: void initTestCase(); void builtins(); void singleton(); + void compositeWithinSingleton(); + void plugin_data(); void plugin(); @@ -118,6 +120,21 @@ void tst_qmlplugindump::singleton() QVERIFY2(result.contains(QLatin1String("exportMetaObjectRevisions: [0]")), qPrintable(result)); } +void tst_qmlplugindump::compositeWithinSingleton() +{ + QProcess dumper; + QStringList args; + args << QLatin1String("dumper.CompositeWithinSingleton") << QLatin1String("1.0") + << QLatin1String(QT_QMLTEST_DIR "/data"); + dumper.start(qmlplugindumpPath, args); + QVERIFY2(dumper.waitForStarted(), qPrintable(dumper.errorString())); + QVERIFY2(dumper.waitForFinished(), qPrintable(dumper.errorString())); + + const QString &result = dumper.readAllStandardOutput(); + QVERIFY2(result.contains(QLatin1String("exports: [\"Composite 1.0\"]")), qPrintable(result)); + QVERIFY2(result.contains(QLatin1String("exportMetaObjectRevisions: [0]")), qPrintable(result)); +} + void tst_qmlplugindump::plugin_data() { QTest::addColumn<QString>("import"); diff --git a/tests/auto/qml/qqmltypeloader/data/CppRegisteredSingleton1.qml b/tests/auto/qml/qqmltypeloader/data/CppRegisteredSingleton1.qml new file mode 100644 index 0000000000..f4ad5e5f7a --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/CppRegisteredSingleton1.qml @@ -0,0 +1,6 @@ +pragma Singleton +import QtQuick 2.0 + +Item { + property bool ok: true +} diff --git a/tests/auto/qml/qqmltypeloader/data/CppRegisteredSingleton2.qml b/tests/auto/qml/qqmltypeloader/data/CppRegisteredSingleton2.qml new file mode 100644 index 0000000000..55dd57517f --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/CppRegisteredSingleton2.qml @@ -0,0 +1,7 @@ +pragma Singleton +import QtQuick 2.0 +import cppsingletonmodule 1.0 + +Item { + property bool ok: CppRegisteredSingleton1.ok +} diff --git a/tests/auto/qml/qqmltypeloader/data/Singleton.qml b/tests/auto/qml/qqmltypeloader/data/Singleton.qml new file mode 100644 index 0000000000..3a1b1c1493 --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/Singleton.qml @@ -0,0 +1,7 @@ +pragma Singleton +import QtQml 2.0 +import modulewithsingleton 1.0 + +QtObject { + property bool ok: true +} diff --git a/tests/auto/qml/qqmltypeloader/data/imports/multisingletonmodule/Singleton1.qml b/tests/auto/qml/qqmltypeloader/data/imports/multisingletonmodule/Singleton1.qml new file mode 100644 index 0000000000..34eca59f86 --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/imports/multisingletonmodule/Singleton1.qml @@ -0,0 +1,7 @@ +pragma Singleton +import QtQuick 2.0 +import "." + +Item { + property bool ok: true +} diff --git a/tests/auto/qml/qqmltypeloader/data/imports/multisingletonmodule/Singleton2.qml b/tests/auto/qml/qqmltypeloader/data/imports/multisingletonmodule/Singleton2.qml new file mode 100644 index 0000000000..607d85d7fb --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/imports/multisingletonmodule/Singleton2.qml @@ -0,0 +1,7 @@ +pragma Singleton +import QtQuick 2.0 +import "." + +Item { + property bool ok: Singleton1.ok +} diff --git a/tests/auto/qml/qqmltypeloader/data/imports/multisingletonmodule/qmldir b/tests/auto/qml/qqmltypeloader/data/imports/multisingletonmodule/qmldir new file mode 100644 index 0000000000..71b889a12d --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/imports/multisingletonmodule/qmldir @@ -0,0 +1,2 @@ +singleton Singleton1 1.0 Singleton1.qml +singleton Singleton2 1.0 Singleton2.qml diff --git a/tests/auto/qml/qqmltypeloader/data/multisingletonuser.qml b/tests/auto/qml/qqmltypeloader/data/multisingletonuser.qml new file mode 100644 index 0000000000..b80e2c5223 --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/multisingletonuser.qml @@ -0,0 +1,7 @@ +import QtQml 2.0 +import multisingletonmodule 1.0 +import cppsingletonmodule 1.0 + +QtObject { + property bool ok: Singleton2.ok && CppRegisteredSingleton2.ok +} diff --git a/tests/auto/qml/qqmltypeloader/data/singletonuser.qml b/tests/auto/qml/qqmltypeloader/data/singletonuser.qml new file mode 100644 index 0000000000..79ca47e12f --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/singletonuser.qml @@ -0,0 +1,6 @@ +import QtQml 2.0 +import modulewithsingleton 1.0 + +QtObject { + property bool ok: Singleton.ok +} diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp index cf3bc8b050..3745fad470 100644 --- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp +++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp @@ -31,6 +31,9 @@ #include <QtQml/qqmlnetworkaccessmanagerfactory.h> #include <QtQuick/qquickview.h> #include <QtQuick/qquickitem.h> +#if QT_CONFIG(process) +#include <QtCore/qprocess.h> +#endif #include <QtQml/private/qqmlengine_p.h> #include <QtQml/private/qqmltypeloader_p.h> #include "../../shared/testhttpserver.h" @@ -50,6 +53,8 @@ private slots: void keepRegistrations(); void intercept(); void redirect(); + void qmlSingletonWithinModule(); + void multiSingletonModule(); }; void tst_QQMLTypeLoader::testLoadComplete() @@ -428,6 +433,57 @@ void tst_QQMLTypeLoader::redirect() QTRY_COMPARE(object->property("xy").toInt(), 323232); } +void tst_QQMLTypeLoader::qmlSingletonWithinModule() +{ + qmlClearTypeRegistrations(); + QQmlEngine engine; + qmlRegisterSingletonType(testFileUrl("Singleton.qml"), "modulewithsingleton", 1, 0, "Singleton"); + + QQmlComponent component(&engine, testFileUrl("singletonuser.qml")); + QCOMPARE(component.status(), QQmlComponent::Ready); + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); + QVERIFY(obj->property("ok").toBool()); +} + +void tst_QQMLTypeLoader::multiSingletonModule() +{ + qmlClearTypeRegistrations(); + QQmlEngine engine; + engine.addImportPath(testFile("imports")); + + qmlRegisterSingletonType(testFileUrl("CppRegisteredSingleton1.qml"), "cppsingletonmodule", + 1, 0, "CppRegisteredSingleton1"); + qmlRegisterSingletonType(testFileUrl("CppRegisteredSingleton2.qml"), "cppsingletonmodule", + 1, 0, "CppRegisteredSingleton2"); + + QQmlComponent component(&engine, testFileUrl("multisingletonuser.qml")); + QCOMPARE(component.status(), QQmlComponent::Ready); + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); + QVERIFY(obj->property("ok").toBool()); + +#if QT_CONFIG(process) + const char *skipKey = "QT_TST_QQMLTYPELOADER_SKIP_MISMATCH"; + if (qEnvironmentVariableIsSet(skipKey)) + return; + for (int i = 0; i < 5; ++i) { + QProcess child; + child.setProgram(QCoreApplication::applicationFilePath()); + child.setArguments(QStringList(QLatin1String("multiSingletonModule"))); + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + env.insert(QLatin1String("QT_LOGGING_RULES"), QLatin1String("qt.qml.diskcache.debug=true")); + env.insert(QLatin1String(skipKey), QLatin1String("1")); + child.setProcessEnvironment(env); + child.start(); + QVERIFY(child.waitForFinished()); + QCOMPARE(child.exitCode(), 0); + QVERIFY(!child.readAllStandardOutput().contains("Checksum mismatch for cached version")); + QVERIFY(!child.readAllStandardError().contains("Checksum mismatch for cached version")); + } +#endif +} + QTEST_MAIN(tst_QQMLTypeLoader) #include "tst_qqmltypeloader.moc" diff --git a/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/tests/auto/qml/qv4mm/tst_qv4mm.cpp index 07f8e9f1d1..d8f4ed12e8 100644 --- a/tests/auto/qml/qv4mm/tst_qv4mm.cpp +++ b/tests/auto/qml/qv4mm/tst_qv4mm.cpp @@ -30,6 +30,7 @@ #include <QQmlEngine> #include <QLoggingCategory> #include <private/qv4mm_p.h> +#include <private/qv4qobjectwrapper_p.h> class tst_qv4mm : public QObject { @@ -37,6 +38,7 @@ class tst_qv4mm : public QObject private slots: void gcStats(); + void multiWrappedQObjects(); }; void tst_qv4mm::gcStats() @@ -46,6 +48,44 @@ void tst_qv4mm::gcStats() engine.collectGarbage(); } +void tst_qv4mm::multiWrappedQObjects() +{ + QV4::ExecutionEngine engine1; + QV4::ExecutionEngine engine2; + { + QObject object; + for (int i = 0; i < 10; ++i) + QV4::QObjectWrapper::wrap(i % 2 ? &engine1 : &engine2, &object); + + QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0); + QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0); + { + QV4::WeakValue value; + value.set(&engine1, QV4::QObjectWrapper::wrap(&engine1, &object)); + } + + QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1); + QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0); + + // Moves the additional WeakValue from m_multiplyWrappedQObjects to + // m_pendingFreedObjectWrapperValue. It's still alive after all. + engine1.memoryManager->runGC(); + QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2); + + // engine2 doesn't own the object as engine1 was the first to wrap it above. + // Therefore, no effect here. + engine2.memoryManager->runGC(); + QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0); + } + + // Clears m_pendingFreedObjectWrapperValue. Now it's really dead. + engine1.memoryManager->runGC(); + QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0); + + engine2.memoryManager->runGC(); + QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0); +} + QTEST_MAIN(tst_qv4mm) #include "tst_qv4mm.moc" diff --git a/tests/auto/qml/v4misc/tst_v4misc.cpp b/tests/auto/qml/v4misc/tst_v4misc.cpp index 5aac91aae9..ecc3a4100c 100644 --- a/tests/auto/qml/v4misc/tst_v4misc.cpp +++ b/tests/auto/qml/v4misc/tst_v4misc.cpp @@ -40,6 +40,9 @@ private slots: void parserMisc_data(); void parserMisc(); + + void subClassing_data(); + void subClassing(); }; void tst_v4misc::tdzOptimizations_data() @@ -130,6 +133,46 @@ void tst_v4misc::parserMisc() QCOMPARE(result.toString(), error); } +void tst_v4misc::subClassing_data() +{ + QTest::addColumn<QString>("script"); + + QString code( + "class Foo extends %1 {" + " constructor() { super(); this.reset(); }" + " reset() { }" + "}" + "new Foo();"); + + + QTest::newRow("Array") << code.arg("Array"); + QTest::newRow("Boolean") << code.arg("Boolean"); + QTest::newRow("Date") << code.arg("Date"); + QTest::newRow("Function") << code.arg("Function"); + QTest::newRow("Number") << code.arg("Number"); + QTest::newRow("Map") << code.arg("Map"); + QTest::newRow("Promise") << QString( + "class Foo extends Promise {" + " constructor() { super(Function()); this.reset(); }" + " reset() { }" + "}" + "new Foo();"); + QTest::newRow("RegExp") << code.arg("RegExp"); + QTest::newRow("Set") << code.arg("Set"); + QTest::newRow("String") << code.arg("String"); + QTest::newRow("WeakMap") << code.arg("WeakMap"); + QTest::newRow("WeakSet") << code.arg("WeakSet"); +} + +void tst_v4misc::subClassing() +{ + QFETCH(QString, script); + + QJSEngine engine; + QJSValue result = engine.evaluate(script); + QVERIFY(!result.isError()); +} + QTEST_MAIN(tst_v4misc); #include "tst_v4misc.moc" |