diff options
author | Liang Qi <liang.qi@qt.io> | 2018-01-19 10:49:56 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2018-01-24 09:34:11 +0100 |
commit | 2570b801c74832a3c83a8b56ad0f76812969e190 (patch) | |
tree | c4bd64d8e6b15b507f51f550ba13a0c062528d65 /tests/auto/qml | |
parent | 1b96186d1418adcba85fdbfd794da2d2f6ea122d (diff) | |
parent | 706a6647db695cdeb854ef1bf956ded56b498f78 (diff) |
Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts:
.qmake.conf
src/qml/compiler/qv4codegen.cpp
src/qml/compiler/qv4compileddata_p.h
src/qml/debugger/qqmlprofiler_p.h
src/qml/jsruntime/qv4engine.cpp
src/qml/memory/qv4mm.cpp
src/qml/qml/qqmlcomponent.cpp
src/qml/qml/qqmlobjectcreator.cpp
src/qml/qml/qqmlobjectcreator_p.h
src/qml/types/qqmldelegatemodel.cpp
src/quick/items/qquickitem_p.h
src/quick/items/qquickwindow.cpp
tests/auto/quick/touchmouse/BLACKLIST
tests/benchmarks/qml/holistic/tst_holistic.cpp
Change-Id: I520f349ab4b048dd337d9647113564fc257865c2
Diffstat (limited to 'tests/auto/qml')
17 files changed, 149 insertions, 5 deletions
diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp index 57e95f7b89..6d31ff9219 100644 --- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp @@ -896,7 +896,8 @@ void tst_QQmlEngineDebugService::queryObjectWithNonStreamableTypes() QmlDebugObjectReference obj = m_dbg->object(); QVERIFY(!obj.className.isEmpty()); - QCOMPARE(findProperty(obj.properties, "modelIndex").value, QVariant()); + QCOMPARE(findProperty(obj.properties, "modelIndex").value, + QVariant(QLatin1String("QModelIndex()"))); } diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro index 69af3cd13b..5073bc703e 100644 --- a/tests/auto/qml/qml.pro +++ b/tests/auto/qml/qml.pro @@ -8,6 +8,7 @@ PUBLICTESTS += \ qjsvalueiterator \ qjsonbinding \ qqmlfile \ + qqmlfileselector !boot2qt { PUBLICTESTS += \ diff --git a/tests/auto/qml/qmlplugindump/qmlplugindump.pro b/tests/auto/qml/qmlplugindump/qmlplugindump.pro index c713edc541..9327beffa6 100644 --- a/tests/auto/qml/qmlplugindump/qmlplugindump.pro +++ b/tests/auto/qml/qmlplugindump/qmlplugindump.pro @@ -3,4 +3,5 @@ TARGET = tst_qmlplugindump QT += testlib gui-private macx:CONFIG -= app_bundle +DEFINES += QT_QMLTEST_DIR=\\\"$${_PRO_FILE_PWD_}\\\" SOURCES += tst_qmlplugindump.cpp diff --git a/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp b/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp index 68e11e3551..7856b1ddc8 100644 --- a/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp +++ b/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp @@ -103,7 +103,7 @@ void tst_qmlplugindump::singleton() QProcess dumper; QStringList args; args << QLatin1String("tests.dumper.CompositeSingleton") << QLatin1String("1.0") - << QLatin1String("."); + << QLatin1String(QT_QMLTEST_DIR); dumper.start(qmlplugindumpPath, args); QVERIFY2(dumper.waitForStarted(), qPrintable(dumper.errorString())); QVERIFY2(dumper.waitForFinished(), qPrintable(dumper.errorString())); diff --git a/tests/auto/qml/qqmlcomponent/data/QtObjectComponent#2.qml b/tests/auto/qml/qqmlcomponent/data/QtObjectComponent#2.qml new file mode 100644 index 0000000000..431c659424 --- /dev/null +++ b/tests/auto/qml/qqmlcomponent/data/QtObjectComponent#2.qml @@ -0,0 +1,3 @@ +import QtQml 2.0 + +QtObject {} diff --git a/tests/auto/qml/qqmlcomponent/data/QtObjectComponent.qml b/tests/auto/qml/qqmlcomponent/data/QtObjectComponent.qml new file mode 100644 index 0000000000..431c659424 --- /dev/null +++ b/tests/auto/qml/qqmlcomponent/data/QtObjectComponent.qml @@ -0,0 +1,3 @@ +import QtQml 2.0 + +QtObject {} diff --git a/tests/auto/qml/qqmlcomponent/qqmlcomponent.pro b/tests/auto/qml/qqmlcomponent/qqmlcomponent.pro index a74334ef63..54012e050c 100644 --- a/tests/auto/qml/qqmlcomponent/qqmlcomponent.pro +++ b/tests/auto/qml/qqmlcomponent/qqmlcomponent.pro @@ -7,6 +7,8 @@ SOURCES += tst_qqmlcomponent.cpp \ HEADERS += ../../shared/testhttpserver.h +RESOURCES += data/QtObjectComponent.qml + include (../../shared/util.pri) TESTDATA = data/* diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp index f2b0b9973e..3c78f6601e 100644 --- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp +++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp @@ -117,6 +117,8 @@ private slots: void recursion(); void recursionContinuation(); void callingContextForInitialProperties(); + void relativeUrl_data(); + void relativeUrl(); private: QQmlEngine engine; @@ -581,6 +583,28 @@ void tst_qqmlcomponent::callingContextForInitialProperties() QVERIFY(checker->scopeObject->metaObject()->indexOfProperty("incubatedObject") != -1); } +void tst_qqmlcomponent::relativeUrl_data() +{ + QTest::addColumn<QUrl>("url"); + + QTest::addRow("fromLocalFile") << QUrl::fromLocalFile("data/QtObjectComponent.qml"); + QTest::addRow("fromLocalFileHash") << QUrl::fromLocalFile("data/QtObjectComponent#2.qml"); + QTest::addRow("constructor") << QUrl("data/QtObjectComponent.qml"); + QTest::addRow("absolute") << QUrl::fromLocalFile(QFINDTESTDATA("data/QtObjectComponent.qml")); + QTest::addRow("qrc") << QUrl("qrc:/data/QtObjectComponent.qml"); +} + +void tst_qqmlcomponent::relativeUrl() +{ + QFETCH(QUrl, url); + + QQmlComponent component(&engine); + // Shouldn't assert in QQmlTypeLoader; we want QQmlComponent to assume that + // data/QtObjectComponent.qml refers to the data/QtObjectComponent.qml in the current working directory. + component.loadUrl(url); + QVERIFY2(!component.isError(), qPrintable(component.errorString())); +} + QTEST_MAIN(tst_qqmlcomponent) #include "tst_qqmlcomponent.moc" diff --git a/tests/auto/qml/qqmlfileselector/tst_qqmlfileselector.cpp b/tests/auto/qml/qqmlfileselector/tst_qqmlfileselector.cpp index 648e4490ee..2c62353630 100644 --- a/tests/auto/qml/qqmlfileselector/tst_qqmlfileselector.cpp +++ b/tests/auto/qml/qqmlfileselector/tst_qqmlfileselector.cpp @@ -33,6 +33,7 @@ #include <QQmlApplicationEngine> #include <QFileSelector> #include <QQmlContext> +#include <QLoggingCategory> #include <qqmlinfo.h> #include "../../shared/util.h" @@ -44,6 +45,7 @@ public: private slots: void basicTest(); + void basicTestCached(); void applicationEngineTest(); }; @@ -62,6 +64,25 @@ void tst_qqmlfileselector::basicTest() delete object; } +void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &message) +{ + if (type == QtDebugMsg + && QByteArray(context.category) == QByteArray("qt.qml.diskcache") + && message.contains("QML source file has moved to a different location.")) { + QFAIL(message.toUtf8()); + } +} + +void tst_qqmlfileselector::basicTestCached() +{ + basicTest(); // Seed the cache, in case basicTestCached() is run on its own + QtMessageHandler defaultHandler = qInstallMessageHandler(&messageHandler); + QLoggingCategory::setFilterRules("qt.qml.diskcache.debug=true"); + basicTest(); // Run again and check that the file is in the cache now + QLoggingCategory::setFilterRules(QString()); + qInstallMessageHandler(defaultHandler); +} + void tst_qqmlfileselector::applicationEngineTest() { QQmlApplicationEngine engine; diff --git a/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp b/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp index 68739886c4..70aaa9678e 100644 --- a/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp +++ b/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp @@ -54,7 +54,7 @@ void tst_QQmlImport::cleanup() void tst_QQmlImport::testDesignerSupported() { QQuickView *window = new QQuickView(); - window->engine()->addImportPath(QT_TESTCASE_BUILDDIR); + window->engine()->addImportPath(directory()); window->setSource(testFileUrl("testfile_supported.qml")); QVERIFY(window->errors().isEmpty()); @@ -68,7 +68,7 @@ void tst_QQmlImport::testDesignerSupported() delete window; window = new QQuickView(); - window->engine()->addImportPath(QT_TESTCASE_BUILDDIR); + window->engine()->addImportPath(directory()); window->engine()->clearComponentCache(); window->setSource(testFileUrl("testfile_supported.qml")); @@ -91,7 +91,7 @@ void tst_QQmlImport::uiFormatLoading() int size = 0; QQmlApplicationEngine *test = new QQmlApplicationEngine(testFileUrl("TestForm.ui.qml")); - test->addImportPath(QT_TESTCASE_BUILDDIR); + test->addImportPath(directory()); QCOMPARE(test->rootObjects().size(), ++size); QVERIFY(test->rootObjects()[size -1]); QVERIFY(test->rootObjects()[size -1]->property("success").toBool()); diff --git a/tests/auto/qml/qqmllanguage/data/accessDeletedObject.qml b/tests/auto/qml/qqmllanguage/data/accessDeletedObject.qml new file mode 100644 index 0000000000..e5151096e5 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/accessDeletedObject.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Item { + id: root + + Component.onCompleted: { + var createdObject = objectCreator.create() + createdObject.del() + // Shouldn't crash. + var test = "index" in createdObject + } +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidAlias.12.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.12.errors.txt new file mode 100644 index 0000000000..8b94763860 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.12.errors.txt @@ -0,0 +1 @@ +4:28:Invalid alias target location: source diff --git a/tests/auto/qml/qqmllanguage/data/invalidAlias.12.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.12.qml new file mode 100644 index 0000000000..71063ae320 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.12.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + property alias source: previewImage.source + previewImage { id: previewImage } +} diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index a56318f80c..dfc6509732 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -277,6 +277,8 @@ private slots: void concurrentLoadQmlDir(); + void accessDeletedObject(); + private: QQmlEngine engine; QStringList defaultImportPathList; @@ -518,6 +520,7 @@ void tst_qqmllanguage::errors_data() QTest::newRow("invalidAlias.9") << "invalidAlias.9.qml" << "invalidAlias.9.errors.txt" << false; QTest::newRow("invalidAlias.10") << "invalidAlias.10.qml" << "invalidAlias.10.errors.txt" << false; QTest::newRow("invalidAlias.11") << "invalidAlias.11.qml" << "invalidAlias.11.errors.txt" << false; + QTest::newRow("invalidAlias.12") << "invalidAlias.12.qml" << "invalidAlias.12.errors.txt" << false; QTest::newRow("invalidAttachedProperty.1") << "invalidAttachedProperty.1.qml" << "invalidAttachedProperty.1.errors.txt" << false; QTest::newRow("invalidAttachedProperty.2") << "invalidAttachedProperty.2.qml" << "invalidAttachedProperty.2.errors.txt" << false; @@ -4877,6 +4880,28 @@ void tst_qqmllanguage::concurrentLoadQmlDir() engine.setImportPathList(defaultImportPathList); } +// Test that deleting an object and then accessing it doesn't crash. +// QTBUG-44153 +class ObjectCreator : public QObject +{ + Q_OBJECT +public slots: + QObject *create() { return (new ObjectCreator); } + void del() { delete this; } +}; + +void tst_qqmllanguage::accessDeletedObject() +{ + QQmlEngine engine; + + engine.rootContext()->setContextProperty("objectCreator", new ObjectCreator); + QQmlComponent component(&engine, testFileUrl("accessDeletedObject.qml")); + VERIFY_ERRORS(0); + + QScopedPointer<QObject> o(component.create()); + QVERIFY(!o.isNull()); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" diff --git a/tests/auto/qml/qqmltypeloader/data/ComponentWithIncubator.qml b/tests/auto/qml/qqmltypeloader/data/ComponentWithIncubator.qml new file mode 100644 index 0000000000..b3610831df --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/ComponentWithIncubator.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Item { + Repeater { + model: 3 + Item {} + } +} + diff --git a/tests/auto/qml/qqmltypeloader/data/trim_cache3.qml b/tests/auto/qml/qqmltypeloader/data/trim_cache3.qml new file mode 100644 index 0000000000..219c7d3bcb --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/trim_cache3.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Item { + width: 400 + height: 400 + + property alias source: loader.source + + Loader { + id: loader + source: "ComponentWithIncubator.qml" + } +} + diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp index 5ab729042f..5a3d76e903 100644 --- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp +++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp @@ -44,6 +44,7 @@ private slots: void loadComponentSynchronously(); void trimCache(); void trimCache2(); + void trimCache3(); void keepSingleton(); void keepRegistrations(); void intercept(); @@ -124,6 +125,26 @@ void tst_QQMLTypeLoader::trimCache2() QCOMPARE(loader.isTypeLoaded(testFileUrl("MyComponent2.qml")), false); } +// test trimming the cache of an item that contains sub-items created via incubation +void tst_QQMLTypeLoader::trimCache3() +{ + QScopedPointer<QQuickView> window(new QQuickView()); + window->setSource(testFileUrl("trim_cache3.qml")); + QQmlTypeLoader &loader = QQmlEnginePrivate::get(window->engine())->typeLoader; + QCOMPARE(loader.isTypeLoaded(testFileUrl("ComponentWithIncubator.qml")), true); + + QQmlProperty::write(window->rootObject(), "source", QString()); + + // handle our deleteLater and cleanup + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + window->engine()->collectGarbage(); + + window->engine()->trimComponentCache(); + + QCOMPARE(loader.isTypeLoaded(testFileUrl("ComponentWithIncubator.qml")), false); +} + static void checkSingleton(const QString &dataDirectory) { QQmlEngine engine; |