diff options
Diffstat (limited to 'tests')
15 files changed, 417 insertions, 9 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/getThis.qml b/tests/auto/qml/qqmlecmascript/data/getThis.qml new file mode 100644 index 0000000000..cd617ee3c0 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/getThis.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQml 2.12 + +QtObject { + id: root + property QtObject self; + + property Timer timer: Timer { + running: true + interval: 1 + onTriggered: { + root.assignThis(); + root.self = null; + root.assignThis(); + } + } + + function getThis() { + return this; + } + + function assignThis() { + self = getThis(); + } +} diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 43cf8192a5..59dc5debb9 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -370,6 +370,7 @@ private slots: void undefinedPropertiesInObjectWrapper(); void hugeRegexpQuantifiers(); void singletonTypeWrapperLookup(); + void getThisObject(); private: // static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); @@ -9036,6 +9037,17 @@ void tst_qqmlecmascript::singletonTypeWrapperLookup() QCOMPARE(test->property("secondLookup").toInt(), singleton2->testVar); } +void tst_qqmlecmascript::getThisObject() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("getThis.qml")); + QVERIFY(component.isReady()); + QScopedPointer<QObject> test(component.create()); + QVERIFY(!test.isNull()); + + QTRY_COMPARE(qvariant_cast<QObject *>(test->property("self")), test.data()); +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" diff --git a/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/CustomModule.pro b/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/CustomModule.pro new file mode 100644 index 0000000000..3366ddc165 --- /dev/null +++ b/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/CustomModule.pro @@ -0,0 +1,13 @@ +TEMPLATE = lib +TARGET = CustomModule +QT += quick qml + +CONFIG += qtquickcompiler +SOURCES += moduleplugin.cpp +RESOURCES += moduleplugin.qrc + +DESTDIR = ../CustomModule + +IMPORT_FILES = qmldir + +include (../../../shared/imports.pri) diff --git a/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/ModuleType.qml b/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/ModuleType.qml new file mode 100644 index 0000000000..ed154e3aa9 --- /dev/null +++ b/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/ModuleType.qml @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQml 2.12 + +QtObject { + objectName: "moduleType" +} diff --git a/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/moduleplugin.cpp b/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/moduleplugin.cpp new file mode 100644 index 0000000000..048250c730 --- /dev/null +++ b/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/moduleplugin.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtQml/qqmlextensionplugin.h> +#include <QtQml/qqmlengine.h> + +QT_BEGIN_NAMESPACE + +class ModulePlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) + +public: + ModulePlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) {} + void registerTypes(const char *uri) override; +}; + +void ModulePlugin::registerTypes(const char *uri) +{ + qmlRegisterModule(uri, 1, 0); + qmlRegisterType(QUrl("qrc:/ModuleType.qml"), uri, 1, 0, "ModuleType"); +} + +QT_END_NAMESPACE + +#include "moduleplugin.moc" diff --git a/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/moduleplugin.qrc b/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/moduleplugin.qrc new file mode 100644 index 0000000000..c8f7dea691 --- /dev/null +++ b/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/moduleplugin.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>ModuleType.qml</file> + </qresource> +</RCC> diff --git a/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/qmldir b/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/qmldir new file mode 100644 index 0000000000..f421ba44dc --- /dev/null +++ b/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/qmldir @@ -0,0 +1,3 @@ +module CustomModule +plugin CustomModule +classname ModulePlugin diff --git a/tests/auto/qml/qqmlenginecleanup/qqmlenginecleanup.pro b/tests/auto/qml/qqmlenginecleanup/qqmlenginecleanup.pro index 90508609a8..34c49a5c0e 100644 --- a/tests/auto/qml/qqmlenginecleanup/qqmlenginecleanup.pro +++ b/tests/auto/qml/qqmlenginecleanup/qqmlenginecleanup.pro @@ -1,9 +1,2 @@ -CONFIG += testcase -TARGET = tst_qqmlenginecleanup -macx:CONFIG -= app_bundle - -include (../../shared/util.pri) - -SOURCES += tst_qqmlenginecleanup.cpp - -QT += testlib qml qml-private +TEMPLATE = subdirs +SUBDIRS += tst_qqmlenginecleanup.pro CustomModuleImport/CustomModule.pro diff --git a/tests/auto/qml/qqmlenginecleanup/tst_qqmlenginecleanup.cpp b/tests/auto/qml/qqmlenginecleanup/tst_qqmlenginecleanup.cpp index b9cede6d13..690db30838 100644 --- a/tests/auto/qml/qqmlenginecleanup/tst_qqmlenginecleanup.cpp +++ b/tests/auto/qml/qqmlenginecleanup/tst_qqmlenginecleanup.cpp @@ -44,6 +44,7 @@ public: private slots: void test_qmlClearTypeRegistrations(); void test_valueTypeProviderModule(); // QTBUG-43004 + void test_customModuleCleanup(); }; // A wrapper around QQmlComponent to ensure the temporary reference counts @@ -168,6 +169,23 @@ void tst_qqmlenginecleanup::test_valueTypeProviderModule() QVERIFY(noDangling); } +void tst_qqmlenginecleanup::test_customModuleCleanup() +{ + for (int i = 0; i < 5; ++i) { + qmlClearTypeRegistrations(); + + QQmlEngine engine; + engine.addImportPath(QT_TESTCASE_BUILDDIR); + + QQmlComponent component(&engine); + component.setData("import CustomModule 1.0\nModuleType {}", QUrl()); + QCOMPARE(component.status(), QQmlComponent::Ready); + + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); + } +} + QTEST_MAIN(tst_qqmlenginecleanup) #include "tst_qqmlenginecleanup.moc" diff --git a/tests/auto/qml/qqmlenginecleanup/tst_qqmlenginecleanup.pro b/tests/auto/qml/qqmlenginecleanup/tst_qqmlenginecleanup.pro new file mode 100644 index 0000000000..90508609a8 --- /dev/null +++ b/tests/auto/qml/qqmlenginecleanup/tst_qqmlenginecleanup.pro @@ -0,0 +1,9 @@ +CONFIG += testcase +TARGET = tst_qqmlenginecleanup +macx:CONFIG -= app_bundle + +include (../../shared/util.pri) + +SOURCES += tst_qqmlenginecleanup.cpp + +QT += testlib qml qml-private diff --git a/tests/auto/quick/qquickanimations/data/fastFlickingBug.qml b/tests/auto/quick/qquickanimations/data/fastFlickingBug.qml new file mode 100644 index 0000000000..b2649a801b --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/fastFlickingBug.qml @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** 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-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.11 +import QtQuick.Window 2.11 + +Window { + id: root + property alias timer : timer + property alias listView : listView + property alias theModel: theModel + property variant ops: [{'op': 'add', 'count': 30}, {'op': 'add', 'count': 60}, {'op': 'rem', 'count': 40}, {'op': 'rem', 'count': 10}, {'op': 'rem', 'count': 39}, + {'op': 'add', 'count': 30}, {'op': 'add', 'count': 60}, {'op': 'rem', 'count': 40}, {'op': 'rem', 'count': 10}, {'op': 'rem', 'count': 39}, + {'op': 'add', 'count': 30}, {'op': 'add', 'count': 60}, {'op': 'rem', 'count': 40}, {'op': 'rem', 'count': 10}, {'op': 'rem', 'count': 39}, + {'op': 'add', 'count': 30}, {'op': 'add', 'count': 60}, {'op': 'rem', 'count': 40}, {'op': 'rem', 'count': 10}, {'op': 'rem', 'count': 39}, + {'op': 'add', 'count': 30}, {'op': 'add', 'count': 60}, {'op': 'rem', 'count': 40}, {'op': 'rem', 'count': 10}, {'op': 'rem', 'count': 39}, + {'op': 'add', 'count': 30}, {'op': 'add', 'count': 60}, {'op': 'rem', 'count': 40}, {'op': 'rem', 'count': 10}, {'op': 'rem', 'count': 39}, + {'op': 'add', 'count': 30}, {'op': 'add', 'count': 60}, {'op': 'rem', 'count': 40}, {'op': 'rem', 'count': 10}, {'op': 'rem', 'count': 39}] + property int opIndex : 0 + width: 400 + height: 600 + + ListModel { + id: theModel + } + + Timer { + id: timer + interval: 100 + running: false + repeat: true + onTriggered: { + if (opIndex >= ops.length) { + timer.stop() + return + } + let op = ops[opIndex] + for (var i = 0; i < op.count; ++i) { + if (op.op === "add") + theModel.append({"name": "opIndex " + opIndex}) + else + theModel.remove(0, 1); + } + opIndex = opIndex + 1 + } + } + + ListView { + id: listView + anchors.fill: parent + spacing: 4 + model: theModel + header: Text { + text: "YAnimator" + } + add: Transition { + NumberAnimation { property: "scale"; from: 0; to: 1; duration: 200 } + NumberAnimation { property: "opacity"; from: 0; to: 1; duration: 200 } + } + displaced: Transition { + YAnimator { duration: 500 } + NumberAnimation { property: "opacity"; to: 1.0; duration: 1000 } + NumberAnimation { property: "scale"; to: 1.0; duration: 1000 } + } + remove: Transition { + NumberAnimation { property: "opacity"; to: 0; duration: 200 } + NumberAnimation { property: "scale"; to: 0; duration: 200 } + } + delegate: Rectangle { + width: 200 + height: 20 + color:"red" + Text { + anchors.centerIn: parent + text: name + } + } + } +} diff --git a/tests/auto/quick/qquickanimations/qquickanimations.pro b/tests/auto/quick/qquickanimations/qquickanimations.pro index cf9c87a305..1c5494a24a 100644 --- a/tests/auto/quick/qquickanimations/qquickanimations.pro +++ b/tests/auto/quick/qquickanimations/qquickanimations.pro @@ -27,6 +27,7 @@ OTHER_FILES += \ data/dotproperty.qml \ data/Double.qml \ data/doubleRegistrationBug.qml \ + data/fastFlickingBug.qml \ data/looping.qml \ data/mixedtype1.qml \ data/mixedtype2.qml \ diff --git a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp index 181d40e9ce..17dfa4a3d7 100644 --- a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp +++ b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp @@ -40,6 +40,7 @@ #include <QtQuick/private/qquickanimatorjob_p.h> #include <QtQuick/private/qquickpathinterpolator_p.h> #include <QtQuick/private/qquickitem_p.h> +#include <QtQuick/private/qquicklistview_p.h> #include <QEasingCurve> #include <limits.h> @@ -110,6 +111,7 @@ private slots: void finished(); void replacingTransitions(); void animationJobSelfDestruction(); + void fastFlickingBug(); }; #define QTIMED_COMPARE(lhs, rhs) do { \ @@ -1744,6 +1746,34 @@ void tst_qquickanimations::animationJobSelfDestruction() QTest::qWait(1000); } +void tst_qquickanimations::fastFlickingBug() +{ + // Don't crash + QQmlEngine engine; + engine.clearComponentCache(); + QQmlComponent c(&engine, testFileUrl("fastFlickingBug.qml")); + QScopedPointer<QQuickWindow> win(qobject_cast<QQuickWindow*>(c.create())); + if (!c.errors().isEmpty()) + qDebug() << c.errorString(); + QVERIFY(win); + win->setTitle(QTest::currentTestFunction()); + win->show(); + QVERIFY(QTest::qWaitForWindowExposed(win.data())); + auto timer = win->property("timer").value<QQmlTimer*>(); + QVERIFY(timer); + QCOMPARE(timer->isRunning(), false); + auto listView = win->property("listView").value<QQuickFlickable*>(); + QVERIFY(listView); + timer->start(); + // flick listView up and down quickly in the middle of a slow transition + for (int sign = 1; timer->isRunning(); sign *= -1) { + listView->flick(0, sign * 4000); + qApp->processEvents(); + QTest::qWait(53); + qApp->processEvents(); + } +} + QTEST_MAIN(tst_qquickanimations) #include "tst_qquickanimations.moc" diff --git a/tests/auto/quick/qquicklistview/data/footer2.qml b/tests/auto/quick/qquicklistview/data/footer2.qml new file mode 100644 index 0000000000..bba74d89f7 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/footer2.qml @@ -0,0 +1,33 @@ +import QtQuick 2.0 + +Rectangle { + width: 240 + height: 320 + + Timer { + running: true + repeat: false + interval: 100 + onTriggered: { + list.model -= 3; + } + } + + ListView { + id: list + objectName: "list" + anchors.fill: parent + model: 3 + delegate: Rectangle { + color: "red" + width: 240 + height: 10 + } + footer: Rectangle { + color: "blue" + width: 240 + height: 10 + } + } +} + diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 2ea8a477a8..39df10b9d9 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -153,6 +153,7 @@ private slots: void headerChangesViewport(); void footer(); void footer_data(); + void footer2(); void extents(); void extents_data(); void resetModel_headerFooter(); @@ -4139,6 +4140,21 @@ void tst_QQuickListView::footer_data() << QPointF(0, -(30 * 20) - 10); } +void tst_QQuickListView::footer2() // QTBUG-31677 +{ + QQuickView *window = getView(); + window->setSource(testFileUrl("footer2.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "list"); + QTRY_VERIFY(listview != nullptr); + + QQuickItem *footer = listview->footerItem(); + QVERIFY(footer != nullptr); + QTRY_COMPARE(footer->y(), 0.0); +} + class LVAccessor : public QQuickListView { public: |