diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-01-04 16:04:38 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2018-01-04 16:04:38 +0000 |
commit | f6fbf988ef8802010a79ad7456b922f5ff3ee63e (patch) | |
tree | 2d8bd45318d866e737c1a8bcc0f5e0c0a280a058 /tests | |
parent | a9a36985e8e77577ba8bd6a840d280389cc544b6 (diff) | |
parent | 2bee46e3f10e2c44d185d7a51a06830b68529676 (diff) |
Merge "Merge remote-tracking branch 'origin/5.9' into 5.10" into refs/staging/5.10
Diffstat (limited to 'tests')
17 files changed, 1037 insertions, 13 deletions
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/data/memory.qml b/tests/auto/qml/debugger/qqmlprofilerservice/data/memory.qml new file mode 100644 index 0000000000..f39dcdf16a --- /dev/null +++ b/tests/auto/qml/debugger/qqmlprofilerservice/data/memory.qml @@ -0,0 +1,17 @@ +import QtQml 2.0 + +Timer { + interval: 1 + running: true + + function recurse(i) { + var x = { t: [1, 2, 3, 4] } + console.log(x.t[i]); + if (i < 3) + recurse(i + 1); + else + Qt.quit(); + } + + onTriggered: recurse(0) +} diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro index a26f48e6c7..7c78b5fcb3 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro +++ b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro @@ -8,7 +8,7 @@ include(../shared/debugutil.pri) TESTDATA = data/* -QT += core qml testlib gui-private core-private +QT += core qml testlib testlib-private gui-private core-private OTHER_FILES += \ data/pixmapCacheTest.qml \ @@ -20,4 +20,5 @@ OTHER_FILES += \ data/signalSourceLocation.qml \ data/javascript.qml \ data/timer.qml \ - data/qstr.qml + data/qstr.qml \ + data/memory.qml diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp index 4d37f16e41..f60e821071 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp +++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp @@ -33,6 +33,7 @@ #include <private/qqmldebugconnection_p.h> #include <QtTest/qtest.h> +#include <private/qtestresult_p.h> #include <QtCore/qlibraryinfo.h> struct QQmlProfilerData @@ -299,6 +300,7 @@ private slots: void javascript(); void flushInterval(); void translationBinding(); + void memory(); }; #define VERIFY(type, position, expected, checks) QVERIFY(verify(type, position, expected, checks)) @@ -725,6 +727,26 @@ void tst_QQmlProfilerService::translationBinding() CheckDetailType | CheckMessageType); } +void tst_QQmlProfilerService::memory() +{ + connect(true, "memory.qml"); + if (QTest::currentTestFailed() || QTestResult::skipCurrentTest()) + return; + + m_client->sendRecordingStatus(true); + + checkTraceReceived(); + checkJsHeap(); + + int smallItems = 0; + for (auto message : m_client->jsHeapMessages) { + if (message.detailType == QV4::Profiling::SmallItem) + ++smallItems; + } + + QVERIFY(smallItems > 5); +} + QTEST_MAIN(tst_QQmlProfilerService) #include "tst_qqmlprofilerservice.moc" diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 7fb4c809f7..a56318f80c 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -44,6 +44,7 @@ #include <private/qqmlglobal_p.h> #include <private/qqmlscriptstring_p.h> #include <private/qqmlvmemetaobject_p.h> +#include <private/qqmlcomponent_p.h> #include "testtypes.h" #include "testhttpserver.h" @@ -254,6 +255,7 @@ private slots: void rootObjectInCreationNotForSubObjects(); void lazyDeferredSubObject(); void deferredProperties(); + void executeDeferredPropertiesOnce(); void noChildEvents(); @@ -4392,8 +4394,17 @@ void tst_qqmllanguage::deferredProperties() QQmlListProperty<QObject> listProperty = object->property("listProperty").value<QQmlListProperty<QObject>>(); QCOMPARE(listProperty.count(&listProperty), 0); + QQmlData *qmlData = QQmlData::get(object.data()); + QVERIFY(qmlData); + + QCOMPARE(qmlData->deferredData.count(), 2); // MyDeferredListProperty.qml + deferredListProperty.qml + QCOMPARE(qmlData->deferredData.first()->bindings.count(), 3); // "innerobj", "innerlist1", "innerlist2" + QCOMPARE(qmlData->deferredData.last()->bindings.count(), 3); // "outerobj", "outerlist1", "outerlist2" + qmlExecuteDeferred(object.data()); + QCOMPARE(qmlData->deferredData.count(), 0); + innerObj = object->findChild<QObject *>(QStringLiteral("innerobj")); // MyDeferredListProperty.qml QVERIFY(innerObj); QCOMPARE(innerObj->property("wasCompleted"), QVariant(true)); @@ -4419,6 +4430,147 @@ void tst_qqmllanguage::deferredProperties() QCOMPARE(listProperty.at(&listProperty, 3)->property("wasCompleted"), QVariant(true)); } +static void beginDeferredOnce(QQmlEnginePrivate *enginePriv, + const QQmlProperty &property, QQmlComponentPrivate::DeferredState *deferredState) +{ + QObject *object = property.object(); + QQmlData *ddata = QQmlData::get(object); + Q_ASSERT(!ddata->deferredData.isEmpty()); + + int propertyIndex = property.index(); + + for (auto dit = ddata->deferredData.rbegin(); dit != ddata->deferredData.rend(); ++dit) { + QQmlData::DeferredData *deferData = *dit; + + auto range = deferData->bindings.equal_range(propertyIndex); + if (range.first == deferData->bindings.end()) + continue; + + QQmlComponentPrivate::ConstructionState *state = new QQmlComponentPrivate::ConstructionState; + state->completePending = true; + + QQmlContextData *creationContext = nullptr; + state->creator.reset(new QQmlObjectCreator(deferData->context->parent, deferData->compilationUnit, creationContext)); + + enginePriv->inProgressCreations++; + + 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); + while (it != last) { + if (!state->creator->populateDeferredBinding(property, deferData, *it)) + state->errors << state->creator->errors; + ++it; + } + + deferredState->constructionStates += state; + + // Cleanup any remaining deferred bindings for this property, also in inner contexts, + // to avoid executing them later and overriding the property that was just populated. + while (dit != ddata->deferredData.rend()) { + (*dit)->bindings.remove(propertyIndex); + ++dit; + } + break; + } +} + +static void testExecuteDeferredOnce(const QQmlProperty &property) +{ + QObject *object = property.object(); + QQmlData *data = QQmlData::get(object); + if (data && !data->deferredData.isEmpty() && !data->wasDeleted(object)) { + QQmlEnginePrivate *ep = QQmlEnginePrivate::get(data->context->engine); + + QQmlComponentPrivate::DeferredState state; + beginDeferredOnce(ep, property, &state); + + // Release deferred data for those compilation units that no longer have deferred bindings + data->releaseDeferredData(); + + QQmlComponentPrivate::completeDeferred(ep, &state); + } +} + +void tst_qqmllanguage::executeDeferredPropertiesOnce() +{ + QQmlComponent component(&engine, testFile("deferredProperties.qml")); + VERIFY_ERRORS(0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); + + QObjectList innerObjsAtCreation = object->findChildren<QObject *>(QStringLiteral("innerobj")); + QVERIFY(innerObjsAtCreation.isEmpty()); + + QObjectList outerObjsAtCreation = object->findChildren<QObject *>(QStringLiteral("outerobj")); + QVERIFY(outerObjsAtCreation.isEmpty()); + + QObject *groupProperty = object->property("groupProperty").value<QObject *>(); + QVERIFY(!groupProperty); + + QQmlListProperty<QObject> listProperty = object->property("listProperty").value<QQmlListProperty<QObject>>(); + QCOMPARE(listProperty.count(&listProperty), 0); + + QQmlData *qmlData = QQmlData::get(object.data()); + QVERIFY(qmlData); + + QCOMPARE(qmlData->deferredData.count(), 2); // MyDeferredListProperty.qml + deferredListProperty.qml + QCOMPARE(qmlData->deferredData.first()->bindings.count(), 3); // "innerobj", "innerlist1", "innerlist2" + QCOMPARE(qmlData->deferredData.last()->bindings.count(), 3); // "outerobj", "outerlist1", "outerlist2" + + // first execution creates the outer object + testExecuteDeferredOnce(QQmlProperty(object.data(), "groupProperty")); + + QCOMPARE(qmlData->deferredData.count(), 2); // MyDeferredListProperty.qml + deferredListProperty.qml + QCOMPARE(qmlData->deferredData.first()->bindings.count(), 2); // "innerlist1", "innerlist2" + QCOMPARE(qmlData->deferredData.last()->bindings.count(), 2); // "outerlist1", "outerlist2" + + QObjectList innerObjsAfterFirstExecute = object->findChildren<QObject *>(QStringLiteral("innerobj")); // MyDeferredListProperty.qml + QVERIFY(innerObjsAfterFirstExecute.isEmpty()); + + QObjectList outerObjsAfterFirstExecute = object->findChildren<QObject *>(QStringLiteral("outerobj")); // deferredListProperty.qml + QCOMPARE(outerObjsAfterFirstExecute.count(), 1); + QCOMPARE(outerObjsAfterFirstExecute.first()->property("wasCompleted"), QVariant(true)); + + groupProperty = object->property("groupProperty").value<QObject *>(); + QCOMPARE(groupProperty, outerObjsAfterFirstExecute.first()); + + listProperty = object->property("listProperty").value<QQmlListProperty<QObject>>(); + QCOMPARE(listProperty.count(&listProperty), 0); + + // re-execution does nothing (to avoid overriding the property) + testExecuteDeferredOnce(QQmlProperty(object.data(), "groupProperty")); + + QCOMPARE(qmlData->deferredData.count(), 2); // MyDeferredListProperty.qml + deferredListProperty.qml + QCOMPARE(qmlData->deferredData.first()->bindings.count(), 2); // "innerlist1", "innerlist2" + QCOMPARE(qmlData->deferredData.last()->bindings.count(), 2); // "outerlist1", "outerlist2" + + QObjectList innerObjsAfterSecondExecute = object->findChildren<QObject *>(QStringLiteral("innerobj")); // MyDeferredListProperty.qml + QVERIFY(innerObjsAfterSecondExecute.isEmpty()); + + QObjectList outerObjsAfterSecondExecute = object->findChildren<QObject *>(QStringLiteral("outerobj")); // deferredListProperty.qml + QCOMPARE(outerObjsAfterFirstExecute, outerObjsAfterSecondExecute); + + groupProperty = object->property("groupProperty").value<QObject *>(); + QCOMPARE(groupProperty, outerObjsAfterFirstExecute.first()); + + listProperty = object->property("listProperty").value<QQmlListProperty<QObject>>(); + QCOMPARE(listProperty.count(&listProperty), 0); + + // execution of a list property should execute all outer list bindings + testExecuteDeferredOnce(QQmlProperty(object.data(), "listProperty")); + + QCOMPARE(qmlData->deferredData.count(), 0); + + listProperty = object->property("listProperty").value<QQmlListProperty<QObject>>(); + QCOMPARE(listProperty.count(&listProperty), 2); + + QCOMPARE(listProperty.at(&listProperty, 0)->objectName(), QStringLiteral("outerlist1")); // deferredListProperty.qml + QCOMPARE(listProperty.at(&listProperty, 0)->property("wasCompleted"), QVariant(true)); + QCOMPARE(listProperty.at(&listProperty, 1)->objectName(), QStringLiteral("outerlist2")); // deferredListProperty.qml + QCOMPARE(listProperty.at(&listProperty, 1)->property("wasCompleted"), QVariant(true)); +} + void tst_qqmllanguage::noChildEvents() { QQmlComponent component(&engine); diff --git a/tests/auto/qml/qqmlmetatype/data/testUnregisterCustomSingletonType.qml b/tests/auto/qml/qqmlmetatype/data/testUnregisterCustomSingletonType.qml new file mode 100644 index 0000000000..85b8f5ac8b --- /dev/null +++ b/tests/auto/qml/qqmlmetatype/data/testUnregisterCustomSingletonType.qml @@ -0,0 +1,8 @@ +import QtQuick 2.7 +import mytypes 1.0 + +Item { + id: root + property string text: StaticProvider.singletonGetString() +} + diff --git a/tests/auto/qml/qqmlmetatype/data/testUnregisterCustomType.qml b/tests/auto/qml/qqmlmetatype/data/testUnregisterCustomType.qml new file mode 100644 index 0000000000..f6ee4e9b77 --- /dev/null +++ b/tests/auto/qml/qqmlmetatype/data/testUnregisterCustomType.qml @@ -0,0 +1,8 @@ +import QtQuick 2.7 +import mytypes 1.0 + +Item { + id: root + Controller { id: controller; objectName: "controller" } +} + diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp index 798e3fd386..58361b4b12 100644 --- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp +++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp @@ -60,6 +60,8 @@ private slots: void isList(); void defaultObject(); + void unregisterCustomType(); + void unregisterCustomSingletonType(); }; class TestType : public QObject @@ -330,6 +332,197 @@ void tst_qqmlmetatype::externalEnums() } +class Controller1 : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString string MEMBER m_string) + Q_PROPERTY(Controller1Enum enumVal MEMBER m_enumVal) +public: + enum Controller1Enum { + ENUM_VALUE_1 = 1, + ENUM_VALUE_2 = 2 + }; + Q_ENUMS(Controller1Enum) + + Controller1(QObject *parent = nullptr) : QObject(parent), m_string("Controller #1"), + m_enumVal(ENUM_VALUE_1) + {} +private: + QString m_string; + Controller1Enum m_enumVal; +}; + +class Controller2 : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString string MEMBER m_string) + Q_PROPERTY(Controller2Enum enumVal MEMBER m_enumVal) +public: + enum Controller2Enum { + ENUM_VALUE_1 = 111, + ENUM_VALUE_2 = 222 + }; + Q_ENUMS(Controller2Enum) + + Controller2(QObject *parent = nullptr) : QObject(parent), m_string("Controller #2"), + m_enumVal(ENUM_VALUE_1) + {} +private: + QString m_string; + Controller2Enum m_enumVal; +}; + +void tst_qqmlmetatype::unregisterCustomType() +{ + int controllerId = 0; + { + QQmlEngine engine; + QQmlType type = QQmlMetaType::qmlType(QString("Controller"), QString("mytypes"), 1, 0); + QVERIFY(!type.isValid()); + controllerId = qmlRegisterType<Controller1>("mytypes", 1, 0, "Controller"); + type = QQmlMetaType::qmlType(QString("Controller"), QString("mytypes"), 1, 0); + QVERIFY(type.isValid()); + QVERIFY(!type.isInterface()); + QVERIFY(!type.isSingleton()); + QVERIFY(!type.isComposite()); + QQmlComponent c(&engine, testFileUrl("testUnregisterCustomType.qml")); + QScopedPointer<QObject> obj(c.create()); + QVERIFY(obj); + QObject *controller = obj->findChild<QObject *>("controller"); + QVERIFY(qobject_cast<Controller1 *>(controller)); + QVariant stringVal = controller->property("string"); + QCOMPARE(stringVal.type(), QVariant::String); + QCOMPARE(stringVal.toString(), QStringLiteral("Controller #1")); + QVariant enumVal = controller->property("enumVal"); + QCOMPARE(enumVal.type(), QVariant::Int); + QCOMPARE(enumVal.toInt(), 1); + } + qmlUnregisterType(controllerId); + { + QQmlEngine engine; + QQmlType type = QQmlMetaType::qmlType(QString("Controller"), QString("mytypes"), 1, 0); + QVERIFY(!type.isValid()); + controllerId = qmlRegisterType<Controller2>("mytypes", 1, 0, "Controller"); + type = QQmlMetaType::qmlType(QString("Controller"), QString("mytypes"), 1, 0); + QVERIFY(type.isValid()); + QVERIFY(!type.isInterface()); + QVERIFY(!type.isSingleton()); + QVERIFY(!type.isComposite()); + QQmlComponent c(&engine, testFileUrl("testUnregisterCustomType.qml")); + QScopedPointer<QObject> obj(c.create()); + QVERIFY(obj); + QObject *controller = obj->findChild<QObject *>("controller"); + QVERIFY(qobject_cast<Controller2 *>(controller)); + QVariant stringVal = controller->property("string"); + QCOMPARE(stringVal.type(), QVariant::String); + QCOMPARE(stringVal.toString(), QStringLiteral("Controller #2")); + QVariant enumVal = controller->property("enumVal"); + QCOMPARE(enumVal.type(), QVariant::Int); + QCOMPARE(enumVal.toInt(), 111); + } + qmlUnregisterType(controllerId); + { + QQmlEngine engine; + QQmlType type = QQmlMetaType::qmlType(QString("Controller"), QString("mytypes"), 1, 0); + QVERIFY(!type.isValid()); + controllerId = qmlRegisterType<Controller1>("mytypes", 1, 0, "Controller"); + type = QQmlMetaType::qmlType(QString("Controller"), QString("mytypes"), 1, 0); + QVERIFY(type.isValid()); + QVERIFY(!type.isInterface()); + QVERIFY(!type.isSingleton()); + QVERIFY(!type.isComposite()); + QQmlComponent c(&engine, testFileUrl("testUnregisterCustomType.qml")); + QScopedPointer<QObject> obj(c.create()); + QVERIFY(obj); + QObject *controller = obj->findChild<QObject *>("controller"); + QVERIFY(qobject_cast<Controller1 *>(controller)); + QVariant stringVal = controller->property("string"); + QCOMPARE(stringVal.type(), QVariant::String); + QCOMPARE(stringVal.toString(), QStringLiteral("Controller #1")); + QVariant enumVal = controller->property("enumVal"); + QCOMPARE(enumVal.type(), QVariant::Int); + QCOMPARE(enumVal.toInt(), 1); + } +} + +class StaticProvider1 : public QObject +{ + Q_OBJECT +public: + StaticProvider1(QObject *parent = nullptr) : QObject(parent) {} + Q_INVOKABLE QString singletonGetString() { return "StaticProvider #1"; } +}; + +static QObject* createStaticProvider1(QQmlEngine *, QJSEngine *) +{ + return new StaticProvider1; +} + +class StaticProvider2 : public QObject +{ + Q_OBJECT +public: + StaticProvider2(QObject *parent = nullptr) : QObject(parent) {} + Q_INVOKABLE QString singletonGetString() { return "StaticProvider #2"; } +}; + +static QObject* createStaticProvider2(QQmlEngine *, QJSEngine *) +{ + return new StaticProvider2; +} + +void tst_qqmlmetatype::unregisterCustomSingletonType() +{ + int staticProviderId = 0; + { + QQmlEngine engine; + staticProviderId = qmlRegisterSingletonType<StaticProvider1>("mytypes", 1, 0, "StaticProvider", createStaticProvider1); + QQmlType type = QQmlMetaType::qmlType(QString("StaticProvider"), QString("mytypes"), 1, 0); + QVERIFY(type.isValid()); + QVERIFY(!type.isInterface()); + QVERIFY(type.isSingleton()); + QVERIFY(!type.isComposite()); + QQmlComponent c(&engine, testFileUrl("testUnregisterCustomSingletonType.qml")); + QScopedPointer<QObject> obj(c.create()); + QVERIFY(obj.data()); + QVariant stringVal = obj->property("text"); + QCOMPARE(stringVal.type(), QVariant::String); + QCOMPARE(stringVal.toString(), QStringLiteral("StaticProvider #1")); + } + qmlUnregisterType(staticProviderId); + { + QQmlEngine engine; + staticProviderId = qmlRegisterSingletonType<StaticProvider2>("mytypes", 1, 0, "StaticProvider", createStaticProvider2); + QQmlType type = QQmlMetaType::qmlType(QString("StaticProvider"), QString("mytypes"), 1, 0); + QVERIFY(type.isValid()); + QVERIFY(!type.isInterface()); + QVERIFY(type.isSingleton()); + QVERIFY(!type.isComposite()); + QQmlComponent c(&engine, testFileUrl("testUnregisterCustomSingletonType.qml")); + QScopedPointer<QObject> obj(c.create()); + QVERIFY(obj.data()); + QVariant stringVal = obj->property("text"); + QCOMPARE(stringVal.type(), QVariant::String); + QCOMPARE(stringVal.toString(), QStringLiteral("StaticProvider #2")); + } + qmlUnregisterType(staticProviderId); + { + QQmlEngine engine; + staticProviderId = qmlRegisterSingletonType<StaticProvider1>("mytypes", 1, 0, "StaticProvider", createStaticProvider1); + QQmlType type = QQmlMetaType::qmlType(QString("StaticProvider"), QString("mytypes"), 1, 0); + QVERIFY(type.isValid()); + QVERIFY(!type.isInterface()); + QVERIFY(type.isSingleton()); + QVERIFY(!type.isComposite()); + QQmlComponent c(&engine, testFileUrl("testUnregisterCustomSingletonType.qml")); + QScopedPointer<QObject> obj(c.create()); + QVERIFY(obj.data()); + QVariant stringVal = obj->property("text"); + QCOMPARE(stringVal.type(), QVariant::String); + QCOMPARE(stringVal.toString(), QStringLiteral("StaticProvider #1")); + } +} + QTEST_MAIN(tst_qqmlmetatype) #include "tst_qqmlmetatype.moc" diff --git a/tests/auto/qml/qqmltypeloader/data/Intercept.qml b/tests/auto/qml/qqmltypeloader/data/Intercept.qml new file mode 100644 index 0000000000..b557b4b941 --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/Intercept.qml @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Fast 1.0 + +Item { + Rectangle { + color: "red" + width: 100 + height: 100 + } + Fast { + + } +} diff --git a/tests/auto/qml/qqmltypeloader/data/test_intercept.qml b/tests/auto/qml/qqmltypeloader/data/test_intercept.qml new file mode 100644 index 0000000000..0d64cb7e28 --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/test_intercept.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListView { + width: 400 + height: 500 + model: 2 + + id: test + property int created: 0 + property int loaded: 0 + + delegate: Loader { + width: ListView.view.width + height: 100 + asynchronous: true + source: index == 0 ? "Intercept.qml" : "GenericView.qml" + + onLoaded: { + test.loaded++ + } + Component.onCompleted: { + test.created++ + } + } +} diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp index 68b450ab26..5ab729042f 100644 --- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp +++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp @@ -28,6 +28,7 @@ #include <QtTest/QtTest> #include <QtQml/qqmlengine.h> +#include <QtQml/qqmlnetworkaccessmanagerfactory.h> #include <QtQuick/qquickview.h> #include <QtQuick/qquickitem.h> #include <QtQml/private/qqmlengine_p.h> @@ -45,6 +46,7 @@ private slots: void trimCache2(); void keepSingleton(); void keepRegistrations(); + void intercept(); }; void tst_QQMLTypeLoader::testLoadComplete() @@ -70,7 +72,7 @@ void tst_QQMLTypeLoader::loadComponentSynchronously() QTest::ignoreMessage(QtWarningMsg, QRegularExpression( QLatin1String(".*nonprotocol::1:1: QtObject is not a type.*"))); QQmlComponent component(&engine, testFileUrl("load_synchronous.qml")); - QObject *o = component.create(); + QScopedPointer<QObject> o(component.create()); QVERIFY(o); } @@ -111,7 +113,7 @@ void tst_QQMLTypeLoader::trimCache() void tst_QQMLTypeLoader::trimCache2() { - QQuickView *window = new QQuickView(); + QScopedPointer<QQuickView> window(new QQuickView()); window->setSource(testFileUrl("trim_cache2.qml")); QQmlTypeLoader &loader = QQmlEnginePrivate::get(window->engine())->typeLoader; // in theory if gc has already run this could be false @@ -192,6 +194,201 @@ void tst_QQMLTypeLoader::keepRegistrations() verifyTypes(true, false); // qmlRegisterType creates an undeletable type. } +class NetworkReply : public QNetworkReply +{ +public: + NetworkReply() + { + open(QIODevice::ReadOnly); + } + + void setData(const QByteArray &data) + { + if (isFinished()) + return; + m_buffer = data; + emit readyRead(); + setFinished(true); + emit finished(); + } + + void fail() + { + if (isFinished()) + return; + m_buffer.clear(); + setError(ContentNotFoundError, "content not found"); + emit error(ContentNotFoundError); + setFinished(true); + emit finished(); + } + + qint64 bytesAvailable() const override + { + return m_buffer.size(); + } + + qint64 readData(char *data, qint64 maxlen) override + { + if (m_buffer.length() < maxlen) + maxlen = m_buffer.length(); + std::memcpy(data, m_buffer.data(), maxlen); + m_buffer.remove(0, maxlen); + return maxlen; + } + + void abort() override + { + if (isFinished()) + return; + m_buffer.clear(); + setFinished(true); + emit finished(); + } + +private: + QByteArray m_buffer; +}; + +class NetworkAccessManager : public QNetworkAccessManager +{ + Q_OBJECT +public: + + NetworkAccessManager(QObject *parent) : QNetworkAccessManager(parent) + { + } + + QNetworkReply *createRequest(Operation op, const QNetworkRequest &request, + QIODevice *outgoingData) override + { + QUrl url = request.url(); + QString scheme = url.scheme(); + if (op != GetOperation || !scheme.endsWith("+debug")) + return QNetworkAccessManager::createRequest(op, request, outgoingData); + + scheme.chop(sizeof("+debug") - 1); + url.setScheme(scheme); + + NetworkReply *reply = new NetworkReply; + QString filename = QQmlFile::urlToLocalFileOrQrc(url); + QTimer::singleShot(10, reply, [this, reply, filename]() { + if (filename.isEmpty()) { + reply->fail(); + } else { + QFile file(filename); + if (file.open(QIODevice::ReadOnly)) { + emit loaded(filename); + reply->setData(transformQmldir(filename, file.readAll())); + } else + reply->fail(); + } + }); + return reply; + } + + QByteArray transformQmldir(const QString &filename, const QByteArray &content) + { + if (!filename.endsWith("/qmldir")) + return content; + + // Make qmldir plugin paths absolute, so that we don't try to load them over the network + QByteArray result; + QByteArray path = filename.toUtf8(); + path.chop(sizeof("qmldir") - 1); + for (QByteArray line : content.split('\n')) { + if (line.isEmpty()) + continue; + QList<QByteArray> segments = line.split(' '); + if (segments.startsWith("plugin")) { + if (segments.length() == 2) { + segments.append(path); + } else if (segments.length() == 3) { + if (!segments[2].startsWith('/')) + segments[2] = path + segments[2]; + } else { + // Invalid plugin declaration. Ignore + } + result.append(segments.join(' ')); + } else { + result.append(line); + } + result.append('\n'); + } + return result; + } + +signals: + void loaded(const QString &filename); +}; + +class NetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory +{ +public: + QStringList loadedFiles; + + QNetworkAccessManager *create(QObject *parent) override + { + NetworkAccessManager *manager = new NetworkAccessManager(parent); + QObject::connect(manager, &NetworkAccessManager::loaded, [this](const QString &filename) { + loadedFiles.append(filename); + }); + return manager; + } +}; + +class UrlInterceptor : public QQmlAbstractUrlInterceptor +{ +public: + QUrl intercept(const QUrl &path, DataType type) override + { + Q_UNUSED(type); + if (!QQmlFile::isLocalFile(path)) + return path; + + QUrl result = path; + QString scheme = result.scheme(); + if (!scheme.endsWith("+debug")) + result.setScheme(scheme + "+debug"); + return result; + } +}; + +void tst_QQMLTypeLoader::intercept() +{ + qmlClearTypeRegistrations(); + + QQmlEngine engine; + engine.addImportPath(dataDirectory()); + engine.addImportPath(QT_TESTCASE_BUILDDIR); + + UrlInterceptor interceptor; + NetworkAccessManagerFactory factory; + + engine.setUrlInterceptor(&interceptor); + engine.setNetworkAccessManagerFactory(&factory); + + QQmlComponent component(&engine, testFileUrl("test_intercept.qml")); + + QVERIFY(component.status() != QQmlComponent::Ready); + QTRY_VERIFY2(component.status() == QQmlComponent::Ready, + component.errorString().toUtf8().constData()); + + QScopedPointer<QObject> o(component.create()); + QVERIFY(o.data()); + + QTRY_COMPARE(o->property("created").toInt(), 2); + QTRY_COMPARE(o->property("loaded").toInt(), 2); + + QVERIFY(factory.loadedFiles.length() >= 6); + QVERIFY(factory.loadedFiles.contains(dataDirectory() + "/test_intercept.qml")); + QVERIFY(factory.loadedFiles.contains(dataDirectory() + "/Intercept.qml")); + QVERIFY(factory.loadedFiles.contains(dataDirectory() + "/Fast/qmldir")); + QVERIFY(factory.loadedFiles.contains(dataDirectory() + "/Fast/Fast.qml")); + QVERIFY(factory.loadedFiles.contains(dataDirectory() + "/GenericView.qml")); + QVERIFY(factory.loadedFiles.contains(QLatin1String(QT_TESTCASE_BUILDDIR) + "/Slow/qmldir")); +} + QTEST_MAIN(tst_QQMLTypeLoader) #include "tst_qqmltypeloader.moc" diff --git a/tests/auto/quick/qquicklistview/data/qtbug61537_modelChangesAsync.qml b/tests/auto/quick/qquicklistview/data/qtbug61537_modelChangesAsync.qml new file mode 100644 index 0000000000..0dc9e6fdb5 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/qtbug61537_modelChangesAsync.qml @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Item { + visible: true + width: 640 + height: 480 + + property ListView listView + + Loader { + id: loader + anchors.fill: parent + asynchronous: true + sourceComponent: comp + + onStatusChanged: { + if (status == Loader.Ready) { + // Assign the listview to the root prop late, so + // that the c++ part doesn't start before everything is ready. + listView = item.listView + } + } + } + + Component { + id: comp + Item { + property alias listView: listView + + ListView { + id: listView + + model: ListModel { + id: listModel + ListElement { title: "one" } + ListElement { title: "two" } + } + + anchors.fill: parent + orientation: ListView.Horizontal + + delegate: Item { + id: delegateRoot + objectName: "delegate" + + width: 200 + height: 200 + + Component.onCompleted: { + if (index === listModel.count - 1) { + // Add a new item while the outer Loader is still incubating async. If the new model item + // incubates using e.g QQmlIncubator::AsynchronousIfNested, it will also be loaded async, which + // is not currently supported (the item will not be added to the listview, or end up the wrong + // position, depending on its index and the current state of the refill/layout logic in + // QQuickListView). + // We add the new item here at the last delegates Component.onCompleted to hit the point in time + // when the listview is not expecting any more async items. In that case, the item will only be + // added to the list of visible items if incubated synchronously, which gives us something we + // can test for in the auto-test. + listModel.insert(0, {title: "zero"}); + } + } + + Rectangle { + anchors.fill: parent + border.width: 1 + Text { + anchors.centerIn: parent + text: index + } + } + } + } + } + } +} diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index f06a118976..223f6004ff 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -261,6 +261,7 @@ private slots: void releaseItems(); void QTBUG_34576_velocityZero(); + void QTBUG_61537_modelChangesAsync(); private: template <class T> void items(const QUrl &source); @@ -8694,6 +8695,33 @@ void tst_QQuickListView::QTBUG_34576_velocityZero() delete window; } +void tst_QQuickListView::QTBUG_61537_modelChangesAsync() +{ + // The purpose of this test if to check that any model changes that happens + // during start-up, while a loader higher up in the chain is still incubating + // async, will not fail. + QQuickView window; + window.setGeometry(0,0,640,480); + + QString filename(testFile("qtbug61537_modelChangesAsync.qml")); + window.setSource(QUrl::fromLocalFile(filename)); + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + + // The qml file will assign the listview to the 'listView' property once the + // loader is ready with async incubation. So we need to wait for it. + QObject *root = window.rootObject(); + QTRY_VERIFY(root->property("listView").value<QQuickListView *>()); + QQuickListView *listView = root->property("listView").value<QQuickListView *>(); + QVERIFY(listView); + + // Check that the number of delegates we expect to be visible in + // the listview matches the number of items we find if we count. + int reportedCount = listView->count(); + int actualCount = findItems<QQuickItem>(listView, "delegate").count(); + QCOMPARE(reportedCount, actualCount); +} + QTEST_MAIN(tst_QQuickListView) #include "tst_qquicklistview.moc" diff --git a/tests/auto/quick/qquickmousearea/data/twoMouseAreas.qml b/tests/auto/quick/qquickmousearea/data/twoMouseAreas.qml new file mode 100644 index 0000000000..28f48c742a --- /dev/null +++ b/tests/auto/quick/qquickmousearea/data/twoMouseAreas.qml @@ -0,0 +1,33 @@ +import QtQuick 2.0 +import QtQuick.Window 2.0 + +Rectangle { + width: 400 + height: 300 + + property bool topPressed: top.pressed + property bool bottomPressed: bottom.pressed + + MouseArea { + id: top + objectName: "top" + width: parent.width + height: parent.height / 2 - 2 + Rectangle { + anchors.fill: parent + color: parent.pressed ? "MediumSeaGreen" : "beige" + } + } + + MouseArea { + id: bottom + objectName: "bottom" + y: parent.height / 2 + width: parent.width + height: parent.height / 2 + Rectangle { + anchors.fill: parent + color: parent.pressed ? "MediumSeaGreen" : "beige" + } + } +} diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index 01bce46ccb..393a57e7e8 100644 --- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -130,6 +130,8 @@ private slots: void notPressedAfterStolenGrab(); void pressAndHold_data(); void pressAndHold(); + void pressOneAndTapAnother_data(); + void pressOneAndTapAnother(); private: int startDragDistance() const { @@ -2173,6 +2175,74 @@ void tst_QQuickMouseArea::pressAndHold() QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, QPoint(50, 50)); } +void tst_QQuickMouseArea::pressOneAndTapAnother_data() +{ + QTest::addColumn<bool>("pressMouseFirst"); + QTest::addColumn<bool>("releaseMouseFirst"); + + QTest::newRow("press mouse, tap touch, release mouse") << true << false; // QTBUG-64249 as written + QTest::newRow("press touch, press mouse, release touch, release mouse") << false << false; + QTest::newRow("press mouse, press touch, release mouse, release touch") << true << true; + // TODO fix in a separate patch after the 5.9->5.10 merge + // QTest::newRow("press touch, click mouse, release touch") << false << true; +} + +void tst_QQuickMouseArea::pressOneAndTapAnother() +{ + QFETCH(bool, pressMouseFirst); + QFETCH(bool, releaseMouseFirst); + + QQuickView window; + QByteArray errorMessage; + QVERIFY2(initView(window, testFileUrl("twoMouseAreas.qml"), true, &errorMessage), errorMessage.constData()); + window.show(); + window.requestActivate(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + QQuickItem *root = window.rootObject(); + QVERIFY(root); + QQuickMouseArea *bottomMA = window.rootObject()->findChild<QQuickMouseArea*>("bottom"); + QVERIFY(bottomMA); + QQuickMouseArea *topMA = window.rootObject()->findChild<QQuickMouseArea*>("top"); + QVERIFY(topMA); + + QPoint upper(32, 32); + QPoint lower(32, window.height() - 32); + + // press them both + if (pressMouseFirst) { + QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, lower); + QTRY_COMPARE(bottomMA->pressed(), true); + + QTest::touchEvent(&window, device).press(0, lower, &window); + QQuickTouchUtils::flush(&window); + QTRY_COMPARE(bottomMA->pressed(), true); + } else { + QTest::touchEvent(&window, device).press(0, lower, &window); + QQuickTouchUtils::flush(&window); + QTRY_COMPARE(bottomMA->pressed(), true); + + QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, lower); + QTRY_COMPARE(bottomMA->pressed(), true); + } + + // release them both and make sure neither one gets stuck + if (releaseMouseFirst) { + QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, lower); + QTRY_COMPARE(bottomMA->pressed(), false); + + QTest::touchEvent(&window, device).release(0, upper, &window); + QQuickTouchUtils::flush(&window); + QTRY_COMPARE(topMA->pressed(), false); + } else { + QTest::touchEvent(&window, device).release(0, upper, &window); + QQuickTouchUtils::flush(&window); + + QTRY_COMPARE(topMA->pressed(), false); + QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, lower); + QTRY_COMPARE(bottomMA->pressed(), false); + } +} + QTEST_MAIN(tst_QQuickMouseArea) #include "tst_qquickmousearea.moc" diff --git a/tests/auto/quick/qquickrepeater/data/asynchronousMove.qml b/tests/auto/quick/qquickrepeater/data/asynchronousMove.qml new file mode 100644 index 0000000000..02499c8531 --- /dev/null +++ b/tests/auto/quick/qquickrepeater/data/asynchronousMove.qml @@ -0,0 +1,51 @@ +import QtQuick 2.3 +import QtQuick.Window 2.2 + +Item { + property bool finished: loader.status === Loader.Ready && loader.progress === 1 + + ListModel { + id: listModel + ListElement { i:0 } + ListElement { i:1 } + ListElement { i:2 } + ListElement { i:3 } + } + + Timer { + running: true + interval: 1 + repeat: count < 5 + property int count : 0 + + onTriggered: { + listModel.move(listModel.count - 1, listModel.count - 2, 1) + ++count + } + } + + Loader { + id: loader + asynchronous: true + sourceComponent: Row { + spacing: 4 + Repeater { + model: listModel + delegate: Column { + spacing: 4 + Repeater { + model: 4 + delegate: Rectangle { + width: 30 + height: 30 + color: "blue" + Component.onCompleted: { + ctrl.wait() + } + } + } + } + } + } + } +} diff --git a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp index f7b04e9a30..3519c53cb7 100644 --- a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp +++ b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp @@ -75,6 +75,7 @@ private slots: void destroyCount(); void stackingOrder(); void objectModel(); + void QTBUG54859_asynchronousMove(); }; class TestObject : public QObject @@ -989,6 +990,30 @@ void tst_QQuickRepeater::objectModel() delete positioner; } +class Ctrl : public QObject +{ + Q_OBJECT +public: + + Q_INVOKABLE void wait() + { + QTest::qWait(200); + } +}; + +void tst_QQuickRepeater::QTBUG54859_asynchronousMove() +{ + Ctrl ctrl; + QQuickView* view = createView(); + view->rootContext()->setContextProperty("ctrl", &ctrl); + view->setSource(testFileUrl("asynchronousMove.qml")); + view->show(); + QQuickItem* item = view->rootObject(); + + + QTRY_COMPARE(item->property("finished"), QVariant(true)); +} + QTEST_MAIN(tst_QQuickRepeater) #include "tst_qquickrepeater.moc" diff --git a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp index cabfb97914..2280f75518 100644 --- a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp +++ b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp @@ -4013,7 +4013,7 @@ void tst_qquickvisualdatamodel::asynchronousInsert() connect(visualModel, SIGNAL(createdItem(int,QObject*)), &requester, SLOT(createdItem(int,QObject*))); connect(visualModel, SIGNAL(destroyingItem(QObject*)), &requester, SLOT(destroyingItem(QObject*))); - QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(requestIndex, true)); + QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(requestIndex, QQmlIncubator::Asynchronous)); QVERIFY(!item); QVERIFY(!requester.itemInitialized); @@ -4025,7 +4025,7 @@ void tst_qquickvisualdatamodel::asynchronousInsert() newItems.append(qMakePair(QLatin1String("New item") + QString::number(i), QString(QLatin1String("")))); model.insertItems(insertIndex, newItems); - item = qobject_cast<QQuickItem*>(visualModel->object(completeIndex, false)); + item = qobject_cast<QQuickItem*>(visualModel->object(completeIndex)); QVERIFY(item); QCOMPARE(requester.itemInitialized, item); @@ -4078,7 +4078,7 @@ void tst_qquickvisualdatamodel::asynchronousRemove() connect(visualModel, SIGNAL(createdItem(int,QObject*)), &requester, SLOT(createdItem(int,QObject*))); connect(visualModel, SIGNAL(destroyingItem(QObject*)), &requester, SLOT(destroyingItem(QObject*))); - QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(requestIndex, true)); + QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(requestIndex, QQmlIncubator::Asynchronous)); QVERIFY(!item); QVERIFY(!requester.itemInitialized); @@ -4099,7 +4099,7 @@ void tst_qquickvisualdatamodel::asynchronousRemove() QVERIFY(!requester.itemCreated); QVERIFY(!requester.itemDestroyed); } else { - item = qobject_cast<QQuickItem*>(visualModel->object(completeIndex, false)); + item = qobject_cast<QQuickItem*>(visualModel->object(completeIndex)); QVERIFY(item); QCOMPARE(requester.itemInitialized, item); @@ -4157,7 +4157,7 @@ void tst_qquickvisualdatamodel::asynchronousMove() connect(visualModel, SIGNAL(createdItem(int,QObject*)), &requester, SLOT(createdItem(int,QObject*))); connect(visualModel, SIGNAL(destroyingItem(QObject*)), &requester, SLOT(destroyingItem(QObject*))); - QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(requestIndex, true)); + QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(requestIndex, QQmlIncubator::Asynchronous)); QVERIFY(!item); QVERIFY(!requester.itemInitialized); @@ -4166,7 +4166,7 @@ void tst_qquickvisualdatamodel::asynchronousMove() model.moveItems(from, to, count); - item = qobject_cast<QQuickItem*>(visualModel->object(completeIndex, false)); + item = qobject_cast<QQuickItem*>(visualModel->object(completeIndex)); QVERIFY(item); @@ -4200,7 +4200,7 @@ void tst_qquickvisualdatamodel::asynchronousCancel() QQmlDelegateModel *visualModel = qobject_cast<QQmlDelegateModel*>(c.create()); QVERIFY(visualModel); - QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(requestIndex, true)); + QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(requestIndex, QQmlIncubator::Asynchronous)); QVERIFY(!item); QCOMPARE(controller.incubatingObjectCount(), 1); @@ -4225,7 +4225,7 @@ void tst_qquickvisualdatamodel::invalidContext() QQmlDelegateModel *visualModel = qobject_cast<QQmlDelegateModel*>(c.create(context.data())); QVERIFY(visualModel); - QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(4, false)); + QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(4)); QVERIFY(item); visualModel->release(item); @@ -4233,7 +4233,7 @@ void tst_qquickvisualdatamodel::invalidContext() model.insertItem(4, "new item", ""); - item = qobject_cast<QQuickItem*>(visualModel->object(4, false)); + item = qobject_cast<QQuickItem*>(visualModel->object(4)); QVERIFY(!item); } |