aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-03-29 01:00:40 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-03-29 01:00:40 +0100
commitf385f6b39f2b60f1f6c59973a030b03437abbef2 (patch)
treec0ec45ee3f20b82b7f42e784fb10616edb8a2c75 /tests/auto/qml
parentd9f849b33591458fbb66724e4e6d59a1b87678f2 (diff)
parent4407f1f81813216bf64021eab7dcecc88d3056fe (diff)
Merge remote-tracking branch 'origin/5.13' into dev
Diffstat (limited to 'tests/auto/qml')
-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/qquickfolderlistmodel/BLACKLIST3
-rw-r--r--tests/auto/qml/qv4mm/tst_qv4mm.cpp54
4 files changed, 63 insertions, 20 deletions
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index 4af5e1d850..4cc37f0380 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -243,6 +243,7 @@ private slots:
void importExportErrors();
void equality();
+ void aggressiveGc();
public:
Q_INVOKABLE QJSValue throwingCppMethod1();
@@ -4798,6 +4799,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/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)