diff options
Diffstat (limited to 'tests')
33 files changed, 785 insertions, 24 deletions
diff --git a/tests/auto/particles/qquickcustomaffector/BLACKLIST b/tests/auto/particles/qquickcustomaffector/BLACKLIST new file mode 100644 index 0000000000..0757641bcc --- /dev/null +++ b/tests/auto/particles/qquickcustomaffector/BLACKLIST @@ -0,0 +1,2 @@ +[test_move] +windows gcc developer-build diff --git a/tests/auto/particles/qquickcustomaffector/tst_qquickcustomaffector.cpp b/tests/auto/particles/qquickcustomaffector/tst_qquickcustomaffector.cpp index ee05fb29c9..cad3813e92 100644 --- a/tests/auto/particles/qquickcustomaffector/tst_qquickcustomaffector.cpp +++ b/tests/auto/particles/qquickcustomaffector/tst_qquickcustomaffector.cpp @@ -98,16 +98,17 @@ void tst_qquickcustomaffector::test_move() if (!d->stillAlive(system)) continue; //parameters no longer get set once you die - QVERIFY(myFuzzyCompare(d->curX(system), 50.0)); - QVERIFY(myFuzzyCompare(d->curY(system), 50.0)); - QVERIFY(myFuzzyCompare(d->curVX(system), 50.0)); - QVERIFY(myFuzzyCompare(d->curVY(system), 50.0)); - QVERIFY(myFuzzyCompare(d->curAX(), 50.0)); - QVERIFY(myFuzzyCompare(d->curAY(), 50.0)); + QVERIFY2(myFuzzyCompare(d->curX(system), 50.0), QByteArray::number(d->curX(system))); + QVERIFY2(myFuzzyCompare(d->curY(system), 50.0), QByteArray::number(d->curY(system))); + QVERIFY2(myFuzzyCompare(d->curVX(system), 50.0), QByteArray::number(d->curVX(system))); + QVERIFY2(myFuzzyCompare(d->curVY(system), 50.0), QByteArray::number(d->curVY(system))); + QVERIFY2(myFuzzyCompare(d->curAX(), 50.0), QByteArray::number(d->curAX())); + QVERIFY2(myFuzzyCompare(d->curAY(), 50.0), QByteArray::number(d->curAY())); QCOMPARE(d->lifeSpan, 0.5f); QCOMPARE(d->size, 32.f); QCOMPARE(d->endSize, 32.f); - QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0))); + QVERIFY2(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)), + QString::fromLatin1("%1 <= %2 / 1000").arg(d->t).arg(system->timeInt).toUtf8()); } delete view; } 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; diff --git a/tests/auto/quick/qquickgridview/data/qtbug49218.qml b/tests/auto/quick/qquickgridview/data/qtbug49218.qml new file mode 100644 index 0000000000..1a55fe5b3a --- /dev/null +++ b/tests/auto/quick/qquickgridview/data/qtbug49218.qml @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** 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.4 + +Item { + width: 500 + height: 160 + visible: true + + property var model1: ["1","2","3","4","5","6","7","8","9","10", + "11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30", + "31","32","33","34","a"] + property var model2: ["a","b","c","d","e","f","g","h","i","j","k","l","m","1"] + property bool useModel1: true + + function changeModel() { + useModel1 = !useModel1 + grid.loadModel(useModel1 ? model1 : model2) + } + + function scrollToTop() { + grid.contentY = grid.originY; + } + + GridView { + id: grid + anchors.fill: parent + + model: ListModel { + } + + onCurrentIndexChanged: { + positionViewAtIndex(currentIndex, GridView.Contain) + } + + Component.onCompleted: { + loadModel(model1) + grid.currentIndex = 34 + grid.positionViewAtIndex(34, GridView.Contain) + } + + function loadModel(m) { + var remove = {}; + var add = {}; + var i; + for (i=0; i < model.count; ++i) + remove[model.get(i).name] = true; + for (i=0; i < m.length; ++i) + if (remove[m[i]]) + delete remove[m[i]]; + else + add[m[i]] = true; + + for (i=model.count-1; i>= 0; --i) + if (remove[model.get(i).name]) + model.remove(i, 1); + + for (i=0; i<m.length; ++i) + if (add[m[i]]) + model.insert(i, { "name": m[i] }) + } + + delegate: Rectangle { + height: grid.cellHeight + width: grid.cellWidth + color: GridView.isCurrentItem ? "gray" : "white" + Text { + anchors.fill: parent + text: name + } + MouseArea { + anchors.fill: parent + onClicked: { + grid.currentIndex = index + } + } + } + } +} diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp index 388ecc2ab8..e271cc1d7b 100644 --- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp @@ -210,6 +210,7 @@ private slots: void contentHeightWithDelayRemove(); void QTBUG_45640(); + void QTBUG_49218(); void QTBUG_48870_fastModelUpdates(); void keyNavigationEnabled(); @@ -6629,6 +6630,36 @@ void tst_QQuickGridView::QTBUG_45640() delete window; } +void tst_QQuickGridView::QTBUG_49218() +{ + QQuickView *window = createView(); + window->setSource(testFileUrl("qtbug49218.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickItem *rootItem = qobject_cast<QQuickItem*>(window->rootObject()); + QQuickGridView *gridview = qobject_cast<QQuickGridView *>(rootItem->childItems().first()); + QVERIFY(gridview != 0); + + auto processEventsAndForceLayout = [&gridview] () { + for (int pass = 0; pass < 2; ++pass) { + QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); + gridview->forceLayout(); + } + }; + QMetaObject::invokeMethod(rootItem, "scrollToTop"); + processEventsAndForceLayout(); + QMetaObject::invokeMethod(rootItem, "changeModel"); + processEventsAndForceLayout(); + QMetaObject::invokeMethod(rootItem, "changeModel"); + processEventsAndForceLayout(); + QMetaObject::invokeMethod(rootItem, "scrollToTop"); + processEventsAndForceLayout(); + + QCOMPARE(gridview->indexAt(gridview->cellWidth() - 10, gridview->cellHeight() - 10), 0); + delete window; +} + void tst_QQuickGridView::keyNavigationEnabled() { QScopedPointer<QQuickView> window(createView()); diff --git a/tests/auto/quick/qquicklistview/data/addoncompleted.qml b/tests/auto/quick/qquicklistview/data/addoncompleted.qml new file mode 100644 index 0000000000..57265cb2c0 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/addoncompleted.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** 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.9 + +Rectangle { + width: 640 + height: 480 + color: "green" + + ListModel { + id: listModel + ListElement { name: "a" } + ListElement { name: "b" } + ListElement { name: "c" } + ListElement { name: "d" } + ListElement { name: "e" } + ListElement { name: "f" } + ListElement { name: "g" } + ListElement { name: "h" } + ListElement { name: "i" } + ListElement { name: "j" } + } + + ListView { + anchors.fill: parent + model: listModel + objectName: "view" + + delegate: Rectangle { + height: 15 + width: 15 + color: "blue" + objectName: name + Component.onCompleted: { + if (name.length === 1 && listModel.get(index + 1).name.length === 1) { + for (var i = 0; i < 10; ++i) + listModel.insert(index + 1, {name: name + i}); + } + } + } + } +} diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 223f6004ff..a7583129f9 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -255,6 +255,7 @@ private slots: void QTBUG_50105(); void keyNavigationEnabled(); void QTBUG_61269_appendDuringScrollDown(); + void QTBUG_61269_appendDuringScrollDown_data(); void QTBUG_50097_stickyHeader_positionViewAtIndex(); void QTBUG_63974_stickyHeader_positionViewAtIndex_Contain(); void itemFiltered(); @@ -263,6 +264,8 @@ private slots: void QTBUG_34576_velocityZero(); void QTBUG_61537_modelChangesAsync(); + void addOnCompleted(); + private: template <class T> void items(const QUrl &source); template <class T> void changed(const QUrl &source); @@ -8468,8 +8471,19 @@ void tst_QQuickListView::keyNavigationEnabled() QCOMPARE(listView->currentIndex(), 1); } -void tst_QQuickListView::QTBUG_61269_appendDuringScrollDown() +void tst_QQuickListView::QTBUG_61269_appendDuringScrollDown_data() +{ + QTest::addColumn<QQuickListView::SnapMode>("snapMode"); + + QTest::newRow("NoSnap") << QQuickListView::NoSnap; + QTest::newRow("SnapToItem") << QQuickListView::SnapToItem; + QTest::newRow("SnapOneItem") << QQuickListView::SnapOneItem; +} + +void tst_QQuickListView::QTBUG_61269_appendDuringScrollDown() // AKA QTBUG-62864 { + QFETCH(QQuickListView::SnapMode, snapMode); + QScopedPointer<QQuickView> window(createView()); window->setSource(testFileUrl("appendDuringScrollDown.qml")); window->show(); @@ -8477,6 +8491,7 @@ void tst_QQuickListView::QTBUG_61269_appendDuringScrollDown() QVERIFY(QTest::qWaitForWindowActive(window.data())); QQuickListView *listView = qobject_cast<QQuickListView *>(window->rootObject()); + listView->setSnapMode(snapMode); QQuickItem *highlightItem = listView->highlightItem(); QVERIFY(listView); QCOMPARE(listView->isKeyNavigationEnabled(), true); @@ -8722,6 +8737,36 @@ void tst_QQuickListView::QTBUG_61537_modelChangesAsync() QCOMPARE(reportedCount, actualCount); } +void tst_QQuickListView::addOnCompleted() +{ + QScopedPointer<QQuickView> window(createView()); + window->setSource(testFileUrl("addoncompleted.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + + QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "view"); + QTRY_VERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + qreal y = -1; + for (char name = 'a'; name <= 'j'; ++name) { + for (int num = 9; num >= 0; --num) { + const QString objName = QString::fromLatin1("%1%2").arg(name).arg(num); + QQuickItem *item = findItem<QQuickItem>(contentItem, objName); + if (!item) { + QVERIFY(name >= 'd'); + y = 9999999; + } else { + const qreal newY = item->y(); + QVERIFY2(newY > y, objName.toUtf8().constData()); + y = newY; + } + } + } +} + QTEST_MAIN(tst_QQuickListView) #include "tst_qquicklistview.moc" diff --git a/tests/auto/quick/qquickshortcut/data/shortcutsRect.qml b/tests/auto/quick/qquickshortcut/data/shortcutsRect.qml new file mode 100644 index 0000000000..9aced4e530 --- /dev/null +++ b/tests/auto/quick/qquickshortcut/data/shortcutsRect.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick module 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.5 + +Rectangle { + width: 300 + height: 300 + + property string activatedShortcut + property string ambiguousShortcut + + property alias shortcuts: repeater.model + + Repeater { + id: repeater + + Item { + Shortcut { + sequence: modelData.sequence + enabled: modelData.enabled + autoRepeat: modelData.autoRepeat + context: modelData.context + onActivated: activatedShortcut = sequence + onActivatedAmbiguously: ambiguousShortcut = sequence + } + } + } +} diff --git a/tests/auto/quick/qquickshortcut/qquickshortcut.pro b/tests/auto/quick/qquickshortcut/qquickshortcut.pro index d780d9061a..018bb91594 100644 --- a/tests/auto/quick/qquickshortcut/qquickshortcut.pro +++ b/tests/auto/quick/qquickshortcut/qquickshortcut.pro @@ -8,3 +8,6 @@ include (../../shared/util.pri) TESTDATA = data/* QT += core gui qml quick testlib +qtHaveModule(widgets) { + QT += quickwidgets +} diff --git a/tests/auto/quick/qquickshortcut/tst_qquickshortcut.cpp b/tests/auto/quick/qquickshortcut/tst_qquickshortcut.cpp index 75ccf26af9..4962690796 100644 --- a/tests/auto/quick/qquickshortcut/tst_qquickshortcut.cpp +++ b/tests/auto/quick/qquickshortcut/tst_qquickshortcut.cpp @@ -29,6 +29,11 @@ #include <QtTest/qtest.h> #include <QtQuick/qquickwindow.h> #include <QtQml/qqmlapplicationengine.h> +#include <QtQuick/qquickitem.h> +#include <QtTest/qsignalspy.h> +#ifdef QT_QUICKWIDGETS_LIB +#include <QtQuickWidgets/qquickwidget.h> +#endif #include "../../shared/util.h" @@ -47,6 +52,10 @@ private slots: void matcher(); void multiple_data(); void multiple(); +#ifdef QT_QUICKWIDGETS_LIB + void renderControlShortcuts_data(); + void renderControlShortcuts(); +#endif }; Q_DECLARE_METATYPE(Qt::Key) @@ -453,6 +462,121 @@ void tst_QQuickShortcut::multiple() QCOMPARE(window->property("activated").toBool(), activated); } +#ifdef QT_QUICKWIDGETS_LIB +void tst_QQuickShortcut::renderControlShortcuts_data() +{ + QTest::addColumn<QVariantList>("shortcuts"); + QTest::addColumn<Qt::Key>("key"); + QTest::addColumn<Qt::KeyboardModifiers>("modifiers"); + QTest::addColumn<QString>("activatedShortcut"); + QTest::addColumn<QString>("ambiguousShortcut"); + + QVariantList shortcuts; + shortcuts << shortcutMap("M") + << shortcutMap("Alt+M") + << shortcutMap("Ctrl+M") + << shortcutMap("Shift+M") + << shortcutMap("Ctrl+Alt+M") + << shortcutMap("+") + << shortcutMap("F1") + << shortcutMap("Shift+F1"); + + QTest::newRow("M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::NoModifier) << "M" << ""; + QTest::newRow("Alt+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::AltModifier) << "Alt+M" << ""; + QTest::newRow("Ctrl+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::ControlModifier) << "Ctrl+M" << ""; + QTest::newRow("Shift+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::ShiftModifier) << "Shift+M" << ""; + QTest::newRow("Ctrl+Alt+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::ControlModifier|Qt::AltModifier) << "Ctrl+Alt+M" << ""; + QTest::newRow("+") << shortcuts << Qt::Key_Plus << Qt::KeyboardModifiers(Qt::NoModifier) << "+" << ""; + QTest::newRow("F1") << shortcuts << Qt::Key_F1 << Qt::KeyboardModifiers(Qt::NoModifier) << "F1" << ""; + QTest::newRow("Shift+F1") << shortcuts << Qt::Key_F1 << Qt::KeyboardModifiers(Qt::ShiftModifier) << "Shift+F1" << ""; + + // ambiguous + shortcuts << shortcutMap("M") + << shortcutMap("Alt+M") + << shortcutMap("Ctrl+M") + << shortcutMap("Shift+M") + << shortcutMap("Ctrl+Alt+M") + << shortcutMap("+") + << shortcutMap("F1") + << shortcutMap("Shift+F1"); + + QTest::newRow("?M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::NoModifier) << "" << "M"; + QTest::newRow("?Alt+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::AltModifier) << "" << "Alt+M"; + QTest::newRow("?Ctrl+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::ControlModifier) << "" << "Ctrl+M"; + QTest::newRow("?Shift+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::ShiftModifier) << "" << "Shift+M"; + QTest::newRow("?Ctrl+Alt+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::ControlModifier|Qt::AltModifier) << "" << "Ctrl+Alt+M"; + QTest::newRow("?+") << shortcuts << Qt::Key_Plus << Qt::KeyboardModifiers(Qt::NoModifier) << "" << "+"; + QTest::newRow("?F1") << shortcuts << Qt::Key_F1 << Qt::KeyboardModifiers(Qt::NoModifier) << "" << "F1"; + QTest::newRow("?Shift+F1") << shortcuts << Qt::Key_F1 << Qt::KeyboardModifiers(Qt::ShiftModifier) << "" << "Shift+F1"; + + // disabled + shortcuts.clear(); + shortcuts << shortcutMap("M", DisabledShortcut) + << shortcutMap("Alt+M", DisabledShortcut) + << shortcutMap("Ctrl+M", DisabledShortcut) + << shortcutMap("Shift+M", DisabledShortcut) + << shortcutMap("Ctrl+Alt+M", DisabledShortcut) + << shortcutMap("+", DisabledShortcut) + << shortcutMap("F1", DisabledShortcut) + << shortcutMap("Shift+F1", DisabledShortcut); + + QTest::newRow("!M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::NoModifier) << "" << ""; + QTest::newRow("!Alt+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::AltModifier) << "" << ""; + QTest::newRow("!Ctrl+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::ControlModifier) << "" << ""; + QTest::newRow("!Shift+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::ShiftModifier) << "" << ""; + QTest::newRow("!Ctrl+Alt+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::ControlModifier|Qt::AltModifier) << "" << ""; + QTest::newRow("!+") << shortcuts << Qt::Key_Plus << Qt::KeyboardModifiers(Qt::NoModifier) << "" << ""; + QTest::newRow("!F1") << shortcuts << Qt::Key_F1 << Qt::KeyboardModifiers(Qt::NoModifier) << "" << ""; + QTest::newRow("!Shift+F1") << shortcuts << Qt::Key_F1 << Qt::KeyboardModifiers(Qt::ShiftModifier) << "" << ""; + + // unambigous because others disabled + shortcuts << shortcutMap("M") + << shortcutMap("Alt+M") + << shortcutMap("Ctrl+M") + << shortcutMap("Shift+M") + << shortcutMap("Ctrl+Alt+M") + << shortcutMap("+") + << shortcutMap("F1") + << shortcutMap("Shift+F1"); + + QTest::newRow("/M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::NoModifier) << "M" << ""; + QTest::newRow("/Alt+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::AltModifier) << "Alt+M" << ""; + QTest::newRow("/Ctrl+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::ControlModifier) << "Ctrl+M" << ""; + QTest::newRow("/Shift+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::ShiftModifier) << "Shift+M" << ""; + QTest::newRow("/Ctrl+Alt+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::ControlModifier|Qt::AltModifier) << "Ctrl+Alt+M" << ""; + QTest::newRow("/+") << shortcuts << Qt::Key_Plus << Qt::KeyboardModifiers(Qt::NoModifier) << "+" << ""; + QTest::newRow("/F1") << shortcuts << Qt::Key_F1 << Qt::KeyboardModifiers(Qt::NoModifier) << "F1" << ""; + QTest::newRow("/Shift+F1") << shortcuts << Qt::Key_F1 << Qt::KeyboardModifiers(Qt::ShiftModifier) << "Shift+F1" << ""; +} + +void tst_QQuickShortcut::renderControlShortcuts() +{ + QFETCH(QVariantList, shortcuts); + QFETCH(Qt::Key, key); + QFETCH(Qt::KeyboardModifiers, modifiers); + QFETCH(QString, activatedShortcut); + QFETCH(QString, ambiguousShortcut); + + QScopedPointer<QQuickWidget> quickWidget(new QQuickWidget); + quickWidget->resize(300,300); + + QSignalSpy spy(qApp, &QGuiApplication::focusObjectChanged); + + quickWidget->setSource(testFileUrl("shortcutsRect.qml")); + quickWidget->show(); + + spy.wait(); + + QVERIFY(qobject_cast<QQuickWidget*>(qApp->focusObject()) == quickWidget.data()); + + QQuickItem* item = quickWidget->rootObject(); + item->setProperty("shortcuts", shortcuts); + QTest::keyPress(quickWidget->quickWindow(), key, modifiers, 1500); + QCOMPARE(item->property("activatedShortcut").toString(), activatedShortcut); + QCOMPARE(item->property("ambiguousShortcut").toString(), ambiguousShortcut); +} +#endif // QT_QUICKWIDGETS_LIB + QTEST_MAIN(tst_QQuickShortcut) #include "tst_qquickshortcut.moc" diff --git a/tests/auto/quick/touchmouse/BLACKLIST b/tests/auto/quick/touchmouse/BLACKLIST index ac0352d10b..e0d4bff131 100644 --- a/tests/auto/quick/touchmouse/BLACKLIST +++ b/tests/auto/quick/touchmouse/BLACKLIST @@ -1,3 +1,5 @@ # QTBUG-40856 hover regression on pointerhandler branch: TODO fix before merging to dev [hoverEnabled] * +[buttonOnDelayedPressFlickable] +windows gcc developer-build diff --git a/tests/auto/quickwidgets/qquickwidget/data/mouse.qml b/tests/auto/quickwidgets/qquickwidget/data/mouse.qml new file mode 100644 index 0000000000..5d1c6e8443 --- /dev/null +++ b/tests/auto/quickwidgets/qquickwidget/data/mouse.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Rectangle { + width: 50 + height: 50 + + property bool wasClicked: false + property bool wasDoubleClicked: false + property bool wasMoved: false + + MouseArea { + anchors.fill: parent + hoverEnabled: true + onClicked: wasClicked = true + onDoubleClicked: wasDoubleClicked = true + onMouseXChanged: wasMoved = true + } +} diff --git a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp index 0bf2f8d7d8..61673996aa 100644 --- a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp +++ b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp @@ -66,6 +66,7 @@ private slots: void keyEvents(); void shortcuts(); void enterLeave(); + void mouseEventWindowPos(); }; @@ -470,6 +471,34 @@ void tst_qquickwidget::enterLeave() QTRY_VERIFY(!rootItem->property("hasMouse").toBool()); } +void tst_qquickwidget::mouseEventWindowPos() +{ + QWidget widget; + widget.resize(100, 100); + QQuickWidget *quick = new QQuickWidget(&widget); + quick->setSource(testFileUrl("mouse.qml")); + quick->move(50, 50); + widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget, 5000)); + QQuickItem *rootItem = quick->rootObject(); + QVERIFY(rootItem); + + QVERIFY(!rootItem->property("wasClicked").toBool()); + QVERIFY(!rootItem->property("wasDoubleClicked").toBool()); + QVERIFY(!rootItem->property("wasMoved").toBool()); + + QWindow *window = widget.windowHandle(); + QVERIFY(window); + + QTest::mouseMove(window, QPoint(60, 60)); + QTest::mouseClick(window, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(60, 60)); + QTRY_VERIFY(rootItem->property("wasClicked").toBool()); + QTest::mouseDClick(window, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(60, 60)); + QTRY_VERIFY(rootItem->property("wasDoubleClicked").toBool()); + QTest::mouseMove(window, QPoint(70, 70)); + QTRY_VERIFY(rootItem->property("wasMoved").toBool()); +} + QTEST_MAIN(tst_qquickwidget) #include "tst_qquickwidget.moc" diff --git a/tests/benchmarks/qml/animation/tst_animation.cpp b/tests/benchmarks/qml/animation/tst_animation.cpp index 27622ed013..f377c94f72 100644 --- a/tests/benchmarks/qml/animation/tst_animation.cpp +++ b/tests/benchmarks/qml/animation/tst_animation.cpp @@ -125,12 +125,12 @@ void tst_animation::animationelements_data() void tst_animation::animationelements() { QFETCH(QString, type); - QQmlType *t = QQmlMetaType::qmlType(type, 2, 0); - if (!t || !t->isCreatable()) + QQmlType t = QQmlMetaType::qmlType(type, 2, 0); + if (!t.isValid() || !t.isCreatable()) QSKIP("Non-creatable type"); QBENCHMARK { - QObject *obj = t->create(); + QObject *obj = t.create(); delete obj; } } diff --git a/tests/benchmarks/qml/holistic/tst_holistic.cpp b/tests/benchmarks/qml/holistic/tst_holistic.cpp index d7e71297f2..9186816a16 100644 --- a/tests/benchmarks/qml/holistic/tst_holistic.cpp +++ b/tests/benchmarks/qml/holistic/tst_holistic.cpp @@ -107,7 +107,6 @@ private slots: void typeResolution_data(); void typeResolution(); - }; tst_holistic::tst_holistic() @@ -240,7 +239,6 @@ void tst_holistic::compilation_data() void tst_holistic::compilation() { - QQmlEngine engine; // This function benchmarks the cost of loading and compiling specified QML files. // If "repetitions" is non-zero, each file from "files" will be compiled "repetitions" // times, without clearing the engine's component cache between compilations. @@ -250,6 +248,8 @@ void tst_holistic::compilation() Q_ASSERT(files.size() > 0); Q_ASSERT(repetitions > 0); + QQmlEngine engine; + QBENCHMARK { engine.clearComponentCache(); for (int i = 0; i < repetitions; ++i) { @@ -262,7 +262,6 @@ void tst_holistic::compilation() void tst_holistic::instantiation() { - QQmlEngine engine; // This function benchmarks the cost of instantiating components compiled from specified QML files. // If "repetitions" is non-zero, each component compiled from "files" will be instantiated "repetitions" // times, without clearing the component's instantiation cache between instantiations. @@ -272,6 +271,8 @@ void tst_holistic::instantiation() Q_ASSERT(files.size() > 0); Q_ASSERT(repetitions > 0); + QQmlEngine engine; + QList<QQmlComponent*> components; for (int i = 0; i < files.size(); ++i) { QQmlComponent *c = new QQmlComponent(&engine, QUrl::fromLocalFile(files.at(i))); @@ -297,7 +298,6 @@ void tst_holistic::instantiation() void tst_holistic::creation() { - QQmlEngine engine; // This function benchmarks the cost of loading, compiling and instantiating specified QML files. // If "repetitions" is non-zero, each file from "files" will be created "repetitions" // times, without clearing the engine's component cache between component creation. @@ -307,6 +307,8 @@ void tst_holistic::creation() Q_ASSERT(files.size() > 0); Q_ASSERT(repetitions > 0); + QQmlEngine engine; + QBENCHMARK { engine.clearComponentCache(); for (int i = 0; i < repetitions; ++i) { @@ -360,7 +362,6 @@ void tst_holistic::dynamicity_data() void tst_holistic::dynamicity() { - QQmlEngine engine; // This function benchmarks the cost of "continued operation" - signal invocation, // updating bindings, etc. Note that we take two different writeValues in order // to force updates to occur, and we read to force lazy evaluation to occur. @@ -371,6 +372,7 @@ void tst_holistic::dynamicity() QFETCH(QVariant, writeValueTwo); QFETCH(QString, readProperty); + QQmlEngine engine; QQmlComponent c(&engine, file); QObject *obj = c.create(); @@ -474,13 +476,13 @@ void tst_holistic::cppToJsDirect_data() void tst_holistic::cppToJsDirect() { - QQmlEngine engine; // This function benchmarks the cost of calling from CPP scope to JS scope // (and possibly vice versa, if the invoked js method then calls to cpp). QFETCH(QString, file); QFETCH(QString, methodName); + QQmlEngine engine; QQmlComponent c(&engine, file); QObject *obj = c.create(); @@ -494,13 +496,13 @@ void tst_holistic::cppToJsDirect() void tst_holistic::cppToJsIndirect() { - QQmlEngine engine; // This function benchmarks the cost of binding scarce resources // to properties of a QML component. The engine should automatically release such // resources when they are no longer used. // The benchmark deliberately causes change signals to be emitted (and // modifies the scarce resources) so that the properties are updated. + QQmlEngine engine; QQmlComponent c(&engine, QString(SRCDIR + QLatin1String("/data/scopeSwitching/ScarceTwo.qml"))); QObject *obj = c.create(); @@ -548,7 +550,6 @@ void tst_holistic::typeResolution_data() void tst_holistic::typeResolution() { - QQmlEngine engine; // This function benchmarks the cost of "continued operation" (signal invocation, // updating bindings, etc) where the component has lots of nested items with // lots of resolving required. Note that we take two different writeValues in order @@ -565,6 +566,7 @@ void tst_holistic::typeResolution() Q_ASSERT(propertyNameTwo.size() == propertyValueTwo.size()); Q_ASSERT(repetitions > 0); + QQmlEngine engine; QQmlComponent c(&engine, file); QObject *obj = c.create(); diff --git a/tests/manual/scenegraph_lancelot/data/text/text_emoji_hebrew.qml b/tests/manual/scenegraph_lancelot/data/text/text_emoji_hebrew.qml new file mode 100644 index 0000000000..b67d584a12 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/text/text_emoji_hebrew.qml @@ -0,0 +1,45 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Component { + id: component + Column { + property variant listModel: model + Repeater { + model: [Text.NativeRendering, Text.QtRendering] + Rectangle { + width: text.implicitWidth + height: text.implicitHeight + color: listModel.backGroundColor ? listModel.backGroundColor : "white" + + Text { + id: text + font.pixelSize: 32 + renderType: modelData + text: "ื๐ื๐ื๐ื๐ื๐ธ!" + + color: listModel.color ? listModel.color : "black" + opacity: listModel.opacity ? listModel.opacity : 1.0 + } + } + } + } + } + + Column { + anchors.centerIn: parent + Repeater { + model: ListModel { + ListElement { color: "black" } + ListElement { color: "blue" } + ListElement { color: "#990000ff" } + ListElement { opacity: 0.5 } + ListElement { backGroundColor: "green" } + } + delegate: component + } + } +} diff --git a/tests/manual/scenegraph_lancelot/data/text/text_emoji_zwj.qml b/tests/manual/scenegraph_lancelot/data/text/text_emoji_zwj.qml new file mode 100644 index 0000000000..4691ff7efd --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/text/text_emoji_zwj.qml @@ -0,0 +1,45 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Component { + id: component + Column { + property variant listModel: model + Repeater { + model: [Text.NativeRendering, Text.QtRendering] + Rectangle { + width: text.implicitWidth + height: text.implicitHeight + color: listModel.backGroundColor ? listModel.backGroundColor : "white" + + Text { + id: text + font.pixelSize: 32 + renderType: modelData + text: "๐จโ๐ฉโ๐งโ๐ฆ" + + color: listModel.color ? listModel.color : "black" + opacity: listModel.opacity ? listModel.opacity : 1.0 + } + } + } + } + } + + Column { + anchors.centerIn: parent + Repeater { + model: ListModel { + ListElement { color: "black" } + ListElement { color: "blue" } + ListElement { color: "#990000ff" } + ListElement { opacity: 0.5 } + ListElement { backGroundColor: "green" } + } + delegate: component + } + } +} |