aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp13
-rw-r--r--tests/auto/qml/qqmlengine/tst_qqmlengine.cpp13
-rw-r--r--tests/auto/qml/qqmlmetatype/data/Components/App.qml57
-rw-r--r--tests/auto/qml/qqmlmetatype/data/Components/qmldir3
-rw-r--r--tests/auto/qml/qqmlmetatype/data/enumsInRecursiveImport.qml11
-rw-r--r--tests/auto/qml/qqmlmetatype/qqmlmetatype.pro7
-rw-r--r--tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp32
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/BLACKLIST3
-rw-r--r--tests/auto/qml/qv4mm/tst_qv4mm.cpp54
-rw-r--r--tests/auto/quick/qquickpathview/data/pathview5.qml65
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp23
11 files changed, 261 insertions, 20 deletions
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index 0491ccd473..0b1f1e0bca 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -236,6 +236,7 @@ private slots:
void importExportErrors();
void equality();
+ void aggressiveGc();
public:
Q_INVOKABLE QJSValue throwingCppMethod1();
@@ -4632,6 +4633,18 @@ void tst_QJSEngine::equality()
QCOMPARE(ok.toString(), QString("ok"));
}
+void tst_QJSEngine::aggressiveGc()
+{
+ const QByteArray origAggressiveGc = qgetenv("QV4_MM_AGGRESSIVE_GC");
+ qputenv("QV4_MM_AGGRESSIVE_GC", "true");
+ {
+ QJSEngine engine; // ctor crashes if core allocation methods don't properly scope things.
+ QJSValue obj = engine.newObject();
+ QVERIFY(obj.isObject());
+ }
+ qputenv("QV4_MM_AGGRESSIVE_GC", origAggressiveGc);
+}
+
QTEST_MAIN(tst_QJSEngine)
#include "tst_qjsengine.moc"
diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
index f58ae38264..b9cb6b70d2 100644
--- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
+++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
@@ -80,6 +80,7 @@ private slots:
void qrcUrls();
void cppSignalAndEval();
void singletonInstance();
+ void aggressiveGc();
public slots:
QObject *createAQObjectForOwnershipTest ()
@@ -1043,6 +1044,18 @@ void tst_qqmlengine::singletonInstance()
}
}
+void tst_qqmlengine::aggressiveGc()
+{
+ const QByteArray origAggressiveGc = qgetenv("QV4_MM_AGGRESSIVE_GC");
+ qputenv("QV4_MM_AGGRESSIVE_GC", "true");
+ {
+ QQmlEngine engine; // freezing should not run into infinite recursion
+ QJSValue obj = engine.newObject();
+ QVERIFY(obj.isObject());
+ }
+ qputenv("QV4_MM_AGGRESSIVE_GC", origAggressiveGc);
+}
+
QTEST_MAIN(tst_qqmlengine)
#include "tst_qqmlengine.moc"
diff --git a/tests/auto/qml/qqmlmetatype/data/Components/App.qml b/tests/auto/qml/qqmlmetatype/data/Components/App.qml
new file mode 100644
index 0000000000..3792ca665e
--- /dev/null
+++ b/tests/auto/qml/qqmlmetatype/data/Components/App.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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 QtQml 2.0
+
+import Components 1.0
+
+QtObject {
+ id: mainRect
+
+ property int appState: App.AppState.Blue
+ property string color: "blue"
+
+ enum AppState {
+ Red,
+ Green,
+ Blue
+ }
+
+ onAppStateChanged: {
+ if (appState === App.AppState.Green)
+ mainRect.color = "green"
+ else if (appState === App.AppState.Red)
+ mainRect.color = "red"
+ }
+
+ property Timer timer: Timer {
+ onTriggered: appState = App.AppState.Green
+ running: true
+ interval: 100
+ }
+}
diff --git a/tests/auto/qml/qqmlmetatype/data/Components/qmldir b/tests/auto/qml/qqmlmetatype/data/Components/qmldir
new file mode 100644
index 0000000000..3f6db4ed2d
--- /dev/null
+++ b/tests/auto/qml/qqmlmetatype/data/Components/qmldir
@@ -0,0 +1,3 @@
+module Components
+
+App 1.0 App.qml
diff --git a/tests/auto/qml/qqmlmetatype/data/enumsInRecursiveImport.qml b/tests/auto/qml/qqmlmetatype/data/enumsInRecursiveImport.qml
new file mode 100644
index 0000000000..eef6abc6e5
--- /dev/null
+++ b/tests/auto/qml/qqmlmetatype/data/enumsInRecursiveImport.qml
@@ -0,0 +1,11 @@
+import QtQml 2.0
+
+import Components 1.0
+
+QtObject {
+ property App app: App {
+ appState: 0
+ }
+
+ property string color: app.color
+}
diff --git a/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro b/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro
index 345bc59615..109de7d212 100644
--- a/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro
+++ b/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro
@@ -10,4 +10,11 @@ qmlfiles.files = data/CompositeType.qml
qmlfiles.prefix = /tstqqmlmetatype
RESOURCES += qmlfiles
+qmldirresource.files = \
+ data/Components/App.qml \
+ data/Components/qmldir \
+ data/enumsInRecursiveImport.qml
+qmldirresource.prefix = /
+RESOURCES += qmldirresource
+
QT += core-private gui-private qml-private testlib
diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
index ce72f40dcc..7f103dc5ed 100644
--- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
+++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
@@ -67,6 +67,9 @@ private slots:
void normalizeUrls();
void unregisterAttachedProperties();
void revisionedGroupedProperties();
+
+ void enumsInRecursiveImport_data();
+ void enumsInRecursiveImport();
};
class TestType : public QObject
@@ -629,6 +632,35 @@ void tst_qqmlmetatype::revisionedGroupedProperties()
}
}
+void tst_qqmlmetatype::enumsInRecursiveImport_data()
+{
+ QTest::addColumn<QString>("importPath");
+ QTest::addColumn<QUrl>("componentUrl");
+
+ QTest::addRow("data directory") << dataDirectory()
+ << testFileUrl("enumsInRecursiveImport.qml");
+
+ // The qrc case behaves differently because we failed to detect the recursion in type loading
+ // due to varying numbers of slashes after the "qrc:" in the URLs.
+ QTest::addRow("resources") << QStringLiteral("qrc:/data")
+ << QUrl("qrc:/data/enumsInRecursiveImport.qml");
+}
+
+void tst_qqmlmetatype::enumsInRecursiveImport()
+{
+ QFETCH(QString, importPath);
+ QFETCH(QUrl, componentUrl);
+
+ qmlClearTypeRegistrations();
+ QQmlEngine engine;
+ engine.addImportPath(importPath);
+ QQmlComponent c(&engine, componentUrl);
+ QVERIFY(c.isReady());
+ QScopedPointer<QObject> obj(c.create());
+ QVERIFY(!obj.isNull());
+ QTRY_COMPARE(obj->property("color").toString(), QString("green"));
+}
+
QTEST_MAIN(tst_qqmlmetatype)
#include "tst_qqmlmetatype.moc"
diff --git a/tests/auto/qml/qquickfolderlistmodel/BLACKLIST b/tests/auto/qml/qquickfolderlistmodel/BLACKLIST
new file mode 100644
index 0000000000..642fdea741
--- /dev/null
+++ b/tests/auto/qml/qquickfolderlistmodel/BLACKLIST
@@ -0,0 +1,3 @@
+[nameFilters]
+msvc-2015
+msvc-2017
diff --git a/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/tests/auto/qml/qv4mm/tst_qv4mm.cpp
index b57b716ed6..1e34b79954 100644
--- a/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+++ b/tests/auto/qml/qv4mm/tst_qv4mm.cpp
@@ -112,26 +112,40 @@ void tst_qv4mm::accessParentOnDestruction()
void tst_qv4mm::clearICParent()
{
- QJSEngine engine;
- QJSValue value = engine.evaluate(
- "(function() {\n"
- " var test = Object.create(null);\n"
- " for (var i = 0; i < 100; i++)\n"
- " test[(\"key_\"+i)] = true;\n"
- " for (var i = 0; i < 100; i++)\n"
- " delete test[\"key_\" + i];\n"
- " return test;\n"
- "})();"
- );
- engine.collectGarbage();
- QV4::Value *v4Value = QJSValuePrivate::getValue(&value);
- QVERIFY(v4Value);
- QV4::Heap::Object *v4Object = v4Value->toObject(engine.handle());
- QVERIFY(v4Object);
-
- // It should garbage collect the parents of the internalClass,
- // as those aren't used anywhere else.
- QCOMPARE(v4Object->internalClass->parent, nullptr);
+ QV4::ExecutionEngine engine;
+ QV4::Scope scope(engine.rootContext());
+ QV4::ScopedObject object(scope, engine.newObject());
+
+ // Keep identifiers in a separate array so that we don't have to allocate them in the loop that
+ // should test the GC on InternalClass allocations.
+ QV4::ScopedArrayObject identifiers(scope, engine.newArrayObject());
+ for (uint i = 0; i < 16 * 1024; ++i) {
+ QV4::Scope scope(&engine);
+ QV4::ScopedString s(scope);
+ s = engine.newIdentifier(QString::fromLatin1("key%1").arg(i));
+ identifiers->push_back(s);
+
+ QV4::ScopedValue v(scope);
+ v->setDouble(i);
+ object->insertMember(s, v);
+ }
+
+ // When allocating the InternalClass objects required for deleting properties, the GC should
+ // eventually run and remove all but the last two.
+ // If we ever manage to avoid allocating the InternalClasses in the first place we will need
+ // to change this test.
+ for (uint i = 0; i < 16 * 1024; ++i) {
+ QV4::Scope scope(&engine);
+ QV4::ScopedString s(scope, identifiers->getIndexed(i));
+ QV4::Scoped<QV4::InternalClass> ic(scope, object->internalClass());
+ QVERIFY(ic->d()->parent != nullptr);
+ object->deleteProperty(s->toPropertyKey());
+ QVERIFY(object->internalClass() != ic->d());
+ QCOMPARE(object->internalClass()->parent, ic->d());
+ if (ic->d()->parent == nullptr)
+ return;
+ }
+ QFAIL("Garbage collector was not triggered by large amount of InternalClasses");
}
QTEST_MAIN(tst_qv4mm)
diff --git a/tests/auto/quick/qquickpathview/data/pathview5.qml b/tests/auto/quick/qquickpathview/data/pathview5.qml
new file mode 100644
index 0000000000..479c5dc500
--- /dev/null
+++ b/tests/auto/quick/qquickpathview/data/pathview5.qml
@@ -0,0 +1,65 @@
+import QtQuick 2.0
+
+PathView {
+ property int countclick: 0
+ id: pathview
+ y: 0
+ width: 348
+ height: 480
+
+ interactive: false
+
+ cacheItemCount: 10
+ currentIndex: 2
+ pathItemCount: 4
+ highlightMoveDuration: 1000
+ highlightRangeMode : PathView.StrictlyEnforceRange
+ preferredHighlightBegin: 0.5
+ preferredHighlightEnd: 0.5
+ snapMode : PathView.SnapOneItem
+
+ path: Path {
+ id: leftPath
+ startX: pathview.width / 2 - 800
+ startY: pathview.height / 2 - 800
+
+ PathArc {
+ x: pathview.width / 2 - 800
+ y: pathview.height / 2 + 800
+ radiusX: 800
+ radiusY: 800
+ direction: PathArc.Clockwise
+ }
+ }
+
+ model: ListModel {
+ id: model
+ ListElement { objectName:"aqua"; name: "aqua" ;mycolor:"aqua"}
+ ListElement { objectName:"blue"; name: "blue" ;mycolor:"blue"}
+ ListElement { objectName:"blueviolet"; name: "blueviolet" ;mycolor:"blueviolet"}
+ ListElement { objectName:"brown"; name: "brown" ;mycolor:"brown"}
+ ListElement { objectName:"chartreuse"; name: "chartreuse" ;mycolor:"chartreuse"}
+ }
+
+ delegate: Item {
+ id: revolveritem
+ objectName: model.objectName
+
+ width: pathview.width
+ height: pathview.height
+
+ Rectangle
+ {
+ id:myRectangle
+ color: mycolor
+ width: pathview.width -20
+ height: pathview.height -20
+
+ Text {
+ anchors.centerIn: parent
+ text: "index:"+index
+ color: "white"
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
index 6267a3771e..7491df5087 100644
--- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
+++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
@@ -103,6 +103,7 @@ private slots:
void offset_data();
void offset();
void setCurrentIndex();
+ void setCurrentIndexWrap();
void resetModel();
void propertyChanges();
void pathChanges();
@@ -1137,6 +1138,28 @@ void tst_QQuickPathView::setCurrentIndex()
QCOMPARE(currentIndexSpy.count(), 1);
}
+void tst_QQuickPathView::setCurrentIndexWrap()
+{
+ QScopedPointer<QQuickView> window(createView());
+ window->setSource(testFileUrl("pathview5.qml"));
+ window->show();
+ qApp->processEvents();
+
+ QQuickPathView *pathview = qobject_cast<QQuickPathView*>(window->rootObject());
+ QVERIFY(pathview);
+
+ // set current index to last item
+ pathview->setCurrentIndex(4);
+ // set currentIndex to first item, then quickly set it back (QTBUG-74508)
+ QSignalSpy currentIndexSpy(pathview, SIGNAL(currentIndexChanged()));
+ QSignalSpy movementStartedSpy(pathview, SIGNAL(movementStarted()));
+ pathview->setCurrentIndex(0);
+ pathview->setCurrentIndex(4);
+ QCOMPARE(pathview->currentIndex(), 4);
+ QCOMPARE(currentIndexSpy.count(), 2);
+ QCOMPARE(movementStartedSpy.count(), 0);
+}
+
void tst_QQuickPathView::resetModel()
{
QScopedPointer<QQuickView> window(createView());